1
This commit is contained in:
parent
96841a0deb
commit
05b70acfa0
@ -1,6 +1,9 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include "custom_battle.h"
|
||||
#include "custom_team.h"
|
||||
#include "custom_member.h"
|
||||
#include "netdata.h"
|
||||
|
||||
void CustomBattle::Init()
|
||||
{
|
||||
@ -25,6 +28,45 @@ void CustomBattle::ParseResult(a8::XObject& obj)
|
||||
start_time_ = obj.Get("start_time");
|
||||
sign_ = obj.Get("sign").GetString();
|
||||
|
||||
auto team_list = obj.At("team_list");
|
||||
if (!team_list || team_list->IsArray()) {
|
||||
parse_ok_ = false;
|
||||
return;
|
||||
}
|
||||
for (int i = 0;i < team_list->Size(); ++i) {
|
||||
auto team_obj = team_list->At(i);
|
||||
if (!team_obj || !team_obj->IsObject()) {
|
||||
parse_ok_ = false;
|
||||
return;
|
||||
}
|
||||
std::string team_uuid = team_obj->Get("team_uuid").GetString();
|
||||
auto member_list = team_obj->At("members");
|
||||
if (!member_list ||
|
||||
member_list->IsArray()) {
|
||||
parse_ok_ = false;
|
||||
return;
|
||||
}
|
||||
auto team = GetTeamByTeamUuid(team_uuid);
|
||||
if (!team) {
|
||||
team = std::make_shared<CustomTeam>();
|
||||
team->team_uuid_ = team_uuid;
|
||||
uuid_hash_[team->team_uuid_] = team;
|
||||
}
|
||||
for (int ii = 0; ii < member_list->Size(); ++ii) {
|
||||
auto member_obj = member_list->At(i);
|
||||
if (!member_obj || !member_obj->IsObject()) {
|
||||
parse_ok_ = false;
|
||||
return;
|
||||
}
|
||||
auto member = std::make_shared<CustomMember>();
|
||||
member->account_id_ = member_obj->Get("account_id").GetString();
|
||||
member->session_id_ = member_obj->Get("session_id").GetString();
|
||||
member->battle_context_ = std::make_shared<BattleDataContext>();
|
||||
team->member_hash_[member->account_id_] = member;
|
||||
account_hash_[member->account_id_] = team;
|
||||
}
|
||||
}
|
||||
|
||||
raw_data_ = std::make_shared<a8::XObject>();
|
||||
obj.DeepCopy(*raw_data_);
|
||||
parse_ok_ = true;
|
||||
|
@ -10,5 +10,7 @@ class CustomMember
|
||||
|
||||
private:
|
||||
std::string account_id_;
|
||||
std::string session_id_;
|
||||
std::shared_ptr<BattleDataContext> battle_context_;
|
||||
friend class CustomBattle;
|
||||
};
|
||||
|
@ -11,4 +11,5 @@ class CustomTeam
|
||||
private:
|
||||
std::string team_uuid_;
|
||||
std::map<std::string, std::shared_ptr<CustomMember>> member_hash_;
|
||||
friend class CustomBattle;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user