添加技能读取

This commit is contained in:
aozhiwei 2019-07-06 18:15:01 +08:00
parent 42080ff330
commit 6809b5f1d8
5 changed files with 78 additions and 0 deletions

View File

@ -170,6 +170,15 @@ enum BuffTriggerType_e
BTT_UseItem = 6 //使用道具触发 BTT_UseItem = 6 //使用道具触发
}; };
enum SkillFunc_e
{
Skill_FuncNone = 0,
Skill_Jump = 1,
Skill_Shot = 2,
Skill_SummonObject = 3,
Skill_FuncEnd
};
const char* const PROJ_NAME_FMT = "game%d_gameserver"; const char* const PROJ_NAME_FMT = "game%d_gameserver";
const char* const PROJ_ROOT_FMT = "/data/logs/%s"; const char* const PROJ_ROOT_FMT = "/data/logs/%s";

View File

@ -36,3 +36,15 @@ bool IsValidSlotId(int slot_id)
{ {
return slot_id >= 0 && slot_id < IS_END; return slot_id >= 0 && slot_id < IS_END;
} }
SkillFunc_e Str2SkillFunc(const std::string& func_str)
{
if (func_str == "jump") {
return Skill_Jump;
} else if (func_str == "shot") {
return Skill_Shot;
} else if (func_str == "summon_object") {
return Skill_SummonObject;
}
return Skill_FuncNone;
}

View File

@ -22,3 +22,4 @@ class Global : public a8::Singleton<Global>
}; };
bool IsValidSlotId(int slot_id); bool IsValidSlotId(int slot_id);
SkillFunc_e Str2SkillFunc(const std::string& func_str);

View File

@ -355,6 +355,46 @@ namespace MetaData
void Skill::Init() void Skill::Init()
{ {
{
std::vector<std::string> strings;
a8::Split(i->buff_list(), strings, '|');
for (auto& str : strings) {
buff_list.insert(a8::XValue(str));
}
}
{
const google::protobuf::Descriptor* descriptor = i->GetDescriptor();
const google::protobuf::Reflection* reflection = i->GetReflection();
for (int idx = 1; idx <= 100; ++idx) {
MetaData::SkillPhase phase;
{
auto field_desc = descriptor->FindFieldByName(a8::Format("phase%d_time_offset", {idx}));
if (!field_desc) {
break;
}
phase.phase_idx = phases.size() + 1;
phase.time_offset = reflection->GetInt32(*(metatable::Skill*)i, field_desc);
}
{
auto field_desc = descriptor->FindFieldByName(a8::Format("phase%d_func", {idx}));
phase.func = reflection->GetString(*(metatable::Skill*)i, field_desc);
}
{
auto field_desc = descriptor->FindFieldByName(a8::Format("phase%d_param1", {idx}));
phase.param1_str = reflection->GetString(*(metatable::Skill*)i, field_desc);
}
{
auto field_desc = descriptor->FindFieldByName(a8::Format("phase%d_param2", {idx}));
phase.param2_str = reflection->GetString(*(metatable::Skill*)i, field_desc);
}
phase.func_id = Str2SkillFunc(phase.func);
if (phase.func_id != Skill_FuncNone) {
phase.param1 = a8::XValue(phase.param1_str);
phase.param2 = a8::XValue(phase.param2_str);
phases.push_back(phase);
}
}
}
} }
void Buff::Init() void Buff::Init()

View File

@ -126,11 +126,27 @@ namespace MetaData
int rand_space = 0; int rand_space = 0;
}; };
struct SkillPhase
{
int phase_idx = 0;
int time_offset = 0;
SkillFunc_e func_id = Skill_FuncNone;
a8::XValue param1;
a8::XValue param2;
std::string func;
std::string param1_str;
std::string param2_str;
};
struct Skill struct Skill
{ {
const metatable::Skill* i = nullptr; const metatable::Skill* i = nullptr;
void Init(); void Init();
std::set<int> buff_list;
std::vector<MetaData::SkillPhase> phases;
}; };
struct Buff struct Buff