This commit is contained in:
aozhiwei 2022-09-07 17:40:04 +08:00
parent 17ac29d47f
commit 774ab0e2dd

View File

@ -16,6 +16,7 @@ class HeroAbility
public:
long long hero_uniid_ = 0;
MetaData::Player* hero_meta = nullptr;
std::shared_ptr<a8::XObject> hero_dto;
float GetHP()
{
@ -52,6 +53,11 @@ public:
return hero_meta->i->miss_damage_ruduce();
}
void Init()
{
}
private:
float hp_ = 0.0f;
@ -69,6 +75,7 @@ class WeaponAbility
public:
long long weapon_uniid = 0;
MetaData::Equip* weapon_meta = nullptr;
std::shared_ptr<a8::XObject> weapon_dto;
float GetAtk()
{
@ -85,6 +92,17 @@ public:
return weapon_meta->i->cri_damage();
}
void Init()
{
}
private:
float atk_ = 0.0f;
float crit_atk_ = 0.0f;
float crit_atk_ratio_ = 0.0f;
};
BattleDataContext::BattleDataContext()
@ -106,6 +124,7 @@ void BattleDataContext::ParseResult(a8::XObject& obj)
if (obj.HasKey("hero_dto") && obj.At("hero_dto")->IsObject()) {
hero_dto = obj.At("hero_dto");
hero_ability_->hero_uniid_ = hero_dto->Get("hero_uniid", "");
hero_ability_->hero_dto = hero_dto;;
MetaData::Player* meta = MetaMgr::Instance()->GetPlayer(hero_dto->Get("hero_id", ""));
if (meta) {
hero_ability_->hero_meta = meta;
@ -118,6 +137,7 @@ void BattleDataContext::ParseResult(a8::XObject& obj)
weapon1_ability_ = std::make_shared<WeaponAbility>();
weapon1_ability_->weapon_uniid = weapon_dto1->Get("gun_uniid", 0);
weapon1_ability_->weapon_meta = meta;
weapon1_ability_->weapon_dto = weapon_dto1;
}
}
if (obj.HasKey("weapon_dto2") && obj.At("weapon_dto2")->IsObject()) {
@ -126,7 +146,8 @@ void BattleDataContext::ParseResult(a8::XObject& obj)
if (meta) {
weapon2_ability_ = std::make_shared<WeaponAbility>();
weapon2_ability_->weapon_uniid = weapon_dto2->Get("gun_uniid", 0);
weapon1_ability_->weapon_meta = meta;
weapon2_ability_->weapon_meta = meta;
weapon2_ability_->weapon_dto = weapon_dto2;
}
}
}
@ -422,6 +443,13 @@ void BattleDataContext::Init(Creature* c)
if (!hero_ability_->hero_uniid_) {
hero_ability_->hero_uniid_ = App::Instance()->AllocTempHeroUniId();
}
hero_ability_->Init();
if (weapon1_ability_) {
weapon1_ability_->Init();
}
if (weapon2_ability_) {
weapon2_ability_->Init();
}
atk_ = hero_ability_->GetAtk();
def_ = hero_ability_->GetDef();
crit_ = hero_ability_->GetCritAtk();