1
This commit is contained in:
parent
731417119f
commit
c64c00f76b
@ -136,7 +136,7 @@ class Human : public Creature
|
||||
int today_enter_times = 0;
|
||||
int account_registertime = 0;
|
||||
int channel = 0;
|
||||
std::string hero_uniid;
|
||||
long long hero_uniid = 0;
|
||||
long long battle_uuid = 0;
|
||||
int is_valid_battle = 0;
|
||||
std::string payload;
|
||||
|
@ -3985,7 +3985,7 @@ void Room::AddTeam(class MatchTeam* team)
|
||||
} else {
|
||||
Player* hum = NewPlayer();
|
||||
hum->proto_version = msg.proto_version();
|
||||
hum->hero_uniid = msg.hero_uniid();
|
||||
hum->hero_uniid = a8::XValue(msg.hero_uniid());
|
||||
hum->battle_uuid = member->battle_uuid;
|
||||
hum->is_valid_battle = member->is_valid_battle;
|
||||
hum->payload = member->payload;
|
||||
|
@ -185,7 +185,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
}
|
||||
Player* hum = room->NewPlayer();
|
||||
hum->proto_version = msg.proto_version();
|
||||
hum->hero_uniid = msg.hero_uniid();
|
||||
hum->hero_uniid = a8::XValue(msg.hero_uniid());
|
||||
hum->battle_uuid = results.at(0)->battle_uuid;
|
||||
hum->is_valid_battle = results.at(0)->is_valid_battle;
|
||||
hum->payload = results.at(0)->payload;
|
||||
|
@ -35,7 +35,7 @@ void BattleDataContext::ParseResult(a8::XObject& obj)
|
||||
errmsg = obj.Get("errmsg").GetString();
|
||||
if (obj.HasKey("hero_dto") && obj.At("hero_dto")->IsObject()) {
|
||||
hero_dto = obj.At("hero_dto");
|
||||
hero_uniid = hero_dto->Get("hero_uniid", "").GetString();
|
||||
hero_uniid_ = hero_dto->Get("hero_uniid", "");
|
||||
if (hero_dto->HasKey("attr") && hero_dto->IsArray()) {
|
||||
ApplyAttr(hero_attr_abs_,
|
||||
hero_attr_rate_,
|
||||
@ -44,7 +44,7 @@ void BattleDataContext::ParseResult(a8::XObject& obj)
|
||||
}
|
||||
if (obj.HasKey("weapon_dto1") && obj.At("weapon_dto1")->IsObject()) {
|
||||
weapon_dto1 = obj.At("weapon_dto1");
|
||||
weapon_uniid1 = weapon_dto1->Get("gun_uniid", 0);
|
||||
weapon_uniid1_ = weapon_dto1->Get("gun_uniid", 0);
|
||||
if (weapon_dto1->HasKey("attr") && weapon_dto1->IsArray()) {
|
||||
ApplyAttr(weapon1_attr_abs_,
|
||||
weapon1_attr_rate_,
|
||||
@ -53,7 +53,7 @@ void BattleDataContext::ParseResult(a8::XObject& obj)
|
||||
}
|
||||
if (obj.HasKey("weapon_dto2") && obj.At("weapon_dto2")->IsObject()) {
|
||||
weapon_dto2 = obj.At("weapon_dto2");
|
||||
weapon_uniid2 = weapon_dto2->Get("gun_uniid", 0);
|
||||
weapon_uniid2_ = weapon_dto2->Get("gun_uniid", 0);
|
||||
if (weapon_dto2->HasKey("attr") && weapon_dto2->IsArray()) {
|
||||
ApplyAttr(weapon2_attr_abs_,
|
||||
weapon2_attr_rate_,
|
||||
@ -62,18 +62,22 @@ void BattleDataContext::ParseResult(a8::XObject& obj)
|
||||
}
|
||||
}
|
||||
|
||||
float BattleDataContext::GetHeroAttrAbs(int attr_id)
|
||||
float BattleDataContext::GetHeroAttrAbs(long long hero_uniid, int attr_id)
|
||||
{
|
||||
if (IsValidHumanAttr(attr_id)) {
|
||||
return hero_attr_abs_[attr_id];
|
||||
if (hero_uniid && hero_uniid == hero_uniid_) {
|
||||
if (IsValidHumanAttr(attr_id)) {
|
||||
return hero_attr_abs_[attr_id];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
float BattleDataContext::GetHeroAttrRate(int attr_id)
|
||||
float BattleDataContext::GetHeroAttrRate(long long hero_uniid, int attr_id)
|
||||
{
|
||||
if (IsValidHumanAttr(attr_id)) {
|
||||
return hero_attr_rate_[attr_id]/ 100.0f;
|
||||
if (hero_uniid && hero_uniid == hero_uniid_) {
|
||||
if (IsValidHumanAttr(attr_id)) {
|
||||
return hero_attr_rate_[attr_id]/ 100.0f;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -84,9 +88,9 @@ float BattleDataContext::GetWeaponAttrAbs(long long weapon_uniid, int attr_id)
|
||||
return 0;
|
||||
}
|
||||
if (IsValidHumanAttr(attr_id)) {
|
||||
if (weapon_uniid == weapon_uniid1) {
|
||||
if (weapon_uniid == weapon_uniid1_) {
|
||||
return weapon1_attr_abs_[attr_id];
|
||||
} else if (weapon_uniid == weapon_uniid2) {
|
||||
} else if (weapon_uniid == weapon_uniid2_) {
|
||||
return weapon2_attr_abs_[attr_id];
|
||||
}
|
||||
}
|
||||
@ -99,51 +103,15 @@ float BattleDataContext::GetWeaponAttrRate(long long weapon_uniid, int attr_id)
|
||||
return 0;
|
||||
}
|
||||
if (IsValidHumanAttr(attr_id)) {
|
||||
if (weapon_uniid == weapon_uniid1) {
|
||||
if (weapon_uniid == weapon_uniid1_) {
|
||||
return weapon1_attr_rate_[attr_id];
|
||||
} else if (weapon_uniid == weapon_uniid2) {
|
||||
} else if (weapon_uniid == weapon_uniid2_) {
|
||||
return weapon2_attr_rate_[attr_id];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void BattleDataContext::CalcAttr(const std::string& hero_uniid,
|
||||
long long curr_weapon_uniid)
|
||||
{
|
||||
Clear();
|
||||
if (!hero_uniid.empty() &&
|
||||
hero_dto &&
|
||||
hero_dto->IsObject() &&
|
||||
hero_dto->Get("hero_uniid", "").GetString() == hero_uniid
|
||||
) {
|
||||
if (hero_dto->HasKey("attr")) {
|
||||
//ApplyAttr(hero_dto->At("attr"));
|
||||
}
|
||||
}
|
||||
if (!curr_weapon_uniid) {
|
||||
std::shared_ptr<a8::XObject> curr_weapon_dto;
|
||||
if (weapon_dto1 &&
|
||||
weapon_dto1->IsObject() &&
|
||||
weapon_dto1->Get("gun_uniid").GetInt64() == curr_weapon_uniid) {
|
||||
curr_weapon_dto = weapon_dto1;
|
||||
}
|
||||
if (!curr_weapon_dto &&
|
||||
weapon_dto1 &&
|
||||
weapon_dto1->IsObject() &&
|
||||
weapon_dto1->Get("gun_uniid").GetInt64() == curr_weapon_uniid) {
|
||||
curr_weapon_dto = weapon_dto1;
|
||||
}
|
||||
if (curr_weapon_dto) {
|
||||
if (curr_weapon_dto->HasKey("attr")) {
|
||||
ApplyAttr(curr_weapon_dto->At("attr"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void BattleDataContext::ApplyAttr(std::array<float, kHAT_End>& attr_abs,
|
||||
std::array<float, kHAT_End>& attr_rate,
|
||||
std::shared_ptr<a8::XObject> obj)
|
||||
|
@ -33,8 +33,8 @@ struct BattleDataContext
|
||||
std::shared_ptr<a8::XObject> weapon_dto1;
|
||||
std::shared_ptr<a8::XObject> weapon_dto2;
|
||||
|
||||
float GetHeroAttrAbs(int attr_id);
|
||||
float GetHeroAttrRate(int attr_id);
|
||||
float GetHeroAttrAbs(long long hero_uniid, int attr_id);
|
||||
float GetHeroAttrRate(long long hero_uniid, int attr_id);
|
||||
|
||||
float GetWeaponAttrAbs(long long weapon_uniid, int attr_id);
|
||||
float GetWeaponAttrRate(long long weapon_uniid, int attr_id);
|
||||
@ -48,9 +48,9 @@ private:
|
||||
std::shared_ptr<a8::XObject> obj);
|
||||
|
||||
private:
|
||||
std::string hero_uniid;
|
||||
long long weapon_uniid1 = 0;
|
||||
long long weapon_uniid2 = 0;
|
||||
long long hero_uniid_ = 0;
|
||||
long long weapon_uniid1_ = 0;
|
||||
long long weapon_uniid2_ = 0;
|
||||
|
||||
std::array<float, kHAT_End> hero_attr_abs_ = {};
|
||||
std::array<float, kHAT_End> hero_attr_rate_ = {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user