1
This commit is contained in:
parent
644c1a5c45
commit
d3812d7ed7
@ -4,11 +4,13 @@
|
||||
#include "human.h"
|
||||
#include "room.h"
|
||||
#include "player.h"
|
||||
|
||||
#include "mt/Param.h"
|
||||
#include "mt/Text.h"
|
||||
#include "mt/Equip.h"
|
||||
#include "mt/Hero.h"
|
||||
|
||||
bool RollMsgHintInfo::Replace(int idx, std::string& text)
|
||||
bool RollMsgHintInfo::Replace(Room* room, int idx, std::string& text)
|
||||
{
|
||||
switch (idx) {
|
||||
case kFieldIdxMasterName:
|
||||
@ -23,7 +25,10 @@ bool RollMsgHintInfo::Replace(int idx, std::string& text)
|
||||
break;
|
||||
case kFieldIdxKillerHeroId:
|
||||
{
|
||||
text = killer_name;
|
||||
Human* hum = room->GetHumanByUniId(killer_id);
|
||||
if (hum) {
|
||||
text = a8::XValue(hum->meta->id()).GetString();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case kFieldIdxDeadName:
|
||||
@ -33,7 +38,10 @@ bool RollMsgHintInfo::Replace(int idx, std::string& text)
|
||||
break;
|
||||
case kFieldIdxDeadHeroId:
|
||||
{
|
||||
text = dead_name;
|
||||
Human* hum = room->GetHumanByUniId(dead_id);
|
||||
if (hum) {
|
||||
text = a8::XValue(hum->meta->id()).GetString();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case kFieldIdxWeaponTextIcon:
|
||||
@ -109,6 +117,8 @@ void KillMgr::FillHintInfo(Human* dead_hum, KillInfo* info, RollMsgHintInfo& hin
|
||||
if (equip_meta) {
|
||||
hint_info.weapon_text_icon = equip_meta->text_icon();
|
||||
}
|
||||
hint_info.dead_id = dead_hum->GetUniId();
|
||||
hint_info.killer_id = info->killer_id;
|
||||
hint_info.killer_name = killer->GetName();
|
||||
if (info->killer_id == dead_hum->GetUniId()) {
|
||||
//${dead.name} 自杀
|
||||
|
@ -7,6 +7,8 @@ namespace cs
|
||||
class SMRollMsg;
|
||||
}
|
||||
|
||||
class Room;
|
||||
|
||||
struct KillInfo
|
||||
{
|
||||
int root_master_id = 0;
|
||||
@ -19,13 +21,15 @@ struct KillInfo
|
||||
|
||||
struct RollMsgHintInfo
|
||||
{
|
||||
int killer_id = 0;
|
||||
int dead_id = 0;
|
||||
std::string master_name;
|
||||
std::string killer_name;
|
||||
std::string dead_name;
|
||||
std::string weapon_text_icon;
|
||||
|
||||
std::vector<std::tuple<int, std::string>>* hint_template = nullptr;
|
||||
bool Replace(int idx, std::string& text);
|
||||
bool Replace(Room* room, int idx, std::string& text);
|
||||
};
|
||||
|
||||
class Human;
|
||||
@ -44,7 +48,8 @@ class KillMgr : public a8::Singleton<KillMgr>
|
||||
|
||||
private:
|
||||
void FillHintInfo(Human* dead_hum, KillInfo* info, RollMsgHintInfo& hint_info);
|
||||
void PreprocessRollMsg(std::shared_ptr<cs::SMRollMsg> pb_msg,
|
||||
void PreprocessRollMsg(Human* dead_hum,
|
||||
std::shared_ptr<cs::SMRollMsg> pb_msg,
|
||||
RollMsgHintInfo& hint_info);
|
||||
void BoradcastRollMsg(Human* dead_hum,
|
||||
KillInfo* info,
|
||||
|
@ -178,12 +178,13 @@ void KillMgr::OnHumanDead(Human* dead_hum, KillInfo* info)
|
||||
RollMsgHintInfo hint_info;
|
||||
std::shared_ptr<cs::SMRollMsg> pb_msg = std::make_shared<cs::SMRollMsg>();
|
||||
FillHintInfo(dead_hum, info, hint_info);
|
||||
PreprocessRollMsg(pb_msg, hint_info);
|
||||
PreprocessRollMsg(dead_hum, pb_msg, hint_info);
|
||||
BoradcastRollMsg(dead_hum, info, 0, pb_msg);
|
||||
}
|
||||
|
||||
void KillMgr::PreprocessRollMsg(std::shared_ptr<cs::SMRollMsg> pb_msg,
|
||||
RollMsgHintInfo& hint_info)
|
||||
void KillMgr::PreprocessRollMsg(Human* dead_hum,
|
||||
std::shared_ptr<cs::SMRollMsg> pb_msg,
|
||||
RollMsgHintInfo& hint_info)
|
||||
{
|
||||
if (hint_info.hint_template) {
|
||||
for (auto& tuple : *hint_info.hint_template) {
|
||||
@ -214,7 +215,7 @@ void KillMgr::PreprocessRollMsg(std::shared_ptr<cs::SMRollMsg> pb_msg,
|
||||
default:
|
||||
{
|
||||
std::string text;
|
||||
if (hint_info.Replace(el_type, text)) {
|
||||
if (hint_info.Replace(dead_hum->room, el_type, text)) {
|
||||
if (el_type == kFieldIdxWeaponTextIcon) {
|
||||
auto e = pb_msg->add_elements();
|
||||
e->set_element_type(kImageElement);
|
||||
|
Loading…
x
Reference in New Issue
Block a user