1
This commit is contained in:
parent
0e09610af6
commit
8424bd57a7
@ -67,6 +67,7 @@ void CustomBattle::ParseResult(a8::XObject& obj)
|
|||||||
team->team_uuid_ = team_uuid;
|
team->team_uuid_ = team_uuid;
|
||||||
team->is_view_ = false;
|
team->is_view_ = false;
|
||||||
uuid_hash_[team->team_uuid_] = team;
|
uuid_hash_[team->team_uuid_] = team;
|
||||||
|
team_list_.push_back(team);
|
||||||
}
|
}
|
||||||
for (int ii = 0; ii < member_list->Size(); ++ii) {
|
for (int ii = 0; ii < member_list->Size(); ++ii) {
|
||||||
auto member_obj = member_list->At(ii);
|
auto member_obj = member_list->At(ii);
|
||||||
@ -144,6 +145,7 @@ void CustomBattle::ParseResult(a8::XObject& obj)
|
|||||||
|
|
||||||
raw_data_ = std::make_shared<a8::XObject>();
|
raw_data_ = std::make_shared<a8::XObject>();
|
||||||
obj.DeepCopy(*raw_data_);
|
obj.DeepCopy(*raw_data_);
|
||||||
|
CalcTeam1AverageHeroLv();
|
||||||
parse_ok_ = true;
|
parse_ok_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,6 +231,13 @@ RoomMode_e CustomBattle::GetRoomMode()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CustomBattle::CalcTeam1AverageHeroLv()
|
||||||
|
{
|
||||||
|
if (!team_list_.empty()) {
|
||||||
|
team1_average_hero_lv_ = team_list_.at(0)->GetAverageHeroLv();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RoomType_e CustomBattle::GetRoomType()
|
RoomType_e CustomBattle::GetRoomType()
|
||||||
{
|
{
|
||||||
if (IsMoba()) {
|
if (IsMoba()) {
|
||||||
@ -253,3 +262,14 @@ RoomType_e CustomBattle::GetRoomType()
|
|||||||
return RoomType_OldBrid3;
|
return RoomType_OldBrid3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<CustomTeam> CustomBattle::GetTeamByIdx(int idx)
|
||||||
|
{
|
||||||
|
if (GetTeamNum() <= 0) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
if (idx < 0 || idx >= GetTeamNum()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return team_list_.at(idx);
|
||||||
|
}
|
||||||
|
@ -28,6 +28,7 @@ class CustomBattle
|
|||||||
int GetStartTime() { return start_time_; }
|
int GetStartTime() { return start_time_; }
|
||||||
void ParseResult(a8::XObject& obj);
|
void ParseResult(a8::XObject& obj);
|
||||||
std::shared_ptr<CustomTeam> GetTeamByAccountId(const std::string& account_id);
|
std::shared_ptr<CustomTeam> GetTeamByAccountId(const std::string& account_id);
|
||||||
|
std::shared_ptr<CustomTeam> GetTeamByIdx(int idx);
|
||||||
std::shared_ptr<CustomMember> GetMemberByAccountId(const std::string& account_id);
|
std::shared_ptr<CustomMember> GetMemberByAccountId(const std::string& account_id);
|
||||||
std::shared_ptr<CustomTeam> GetTeamByTeamUuid(const std::string& team_uuid);
|
std::shared_ptr<CustomTeam> GetTeamByTeamUuid(const std::string& team_uuid);
|
||||||
std::shared_ptr<CustomMember> GetObByAccountId(const std::string& account_id);
|
std::shared_ptr<CustomMember> GetObByAccountId(const std::string& account_id);
|
||||||
@ -43,6 +44,10 @@ class CustomBattle
|
|||||||
bool IsPvp() { return !is_moba_; }
|
bool IsPvp() { return !is_moba_; }
|
||||||
bool IsMoba() { return is_moba_; }
|
bool IsMoba() { return is_moba_; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void CalcTeam1AverageHeroLv();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool parse_ok_ = false;
|
bool parse_ok_ = false;
|
||||||
Room *room_ = nullptr;
|
Room *room_ = nullptr;
|
||||||
@ -57,6 +62,7 @@ class CustomBattle
|
|||||||
int team1_average_hero_lv_ = 0;
|
int team1_average_hero_lv_ = 0;
|
||||||
std::string sign_;
|
std::string sign_;
|
||||||
std::shared_ptr<a8::XObject> raw_data_;
|
std::shared_ptr<a8::XObject> raw_data_;
|
||||||
|
std::vector<std::shared_ptr<CustomTeam>> team_list_;
|
||||||
std::map<std::string, std::shared_ptr<CustomTeam>> uuid_hash_;
|
std::map<std::string, std::shared_ptr<CustomTeam>> uuid_hash_;
|
||||||
std::shared_ptr<CustomTeam> ob_team_;
|
std::shared_ptr<CustomTeam> ob_team_;
|
||||||
std::map<std::string, std::shared_ptr<CustomTeam>> account_hash_;
|
std::map<std::string, std::shared_ptr<CustomTeam>> account_hash_;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
#include "custom_team.h"
|
#include "custom_team.h"
|
||||||
|
#include "custom_member.h"
|
||||||
|
#include "netdata.h"
|
||||||
|
|
||||||
std::shared_ptr<CustomMember> CustomTeam::GetMember(const std::string& account_id)
|
std::shared_ptr<CustomMember> CustomTeam::GetMember(const std::string& account_id)
|
||||||
{
|
{
|
||||||
@ -21,3 +23,23 @@ int CustomTeam::GetMemberNum()
|
|||||||
{
|
{
|
||||||
return member_hash_.size();
|
return member_hash_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CustomTeam::GetAverageHeroLv()
|
||||||
|
{
|
||||||
|
if (GetMemberNum() <= 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int total_hero_lv = 0;
|
||||||
|
TraverseMember
|
||||||
|
(
|
||||||
|
[&total_hero_lv] (std::shared_ptr<CustomMember> m) -> bool
|
||||||
|
{
|
||||||
|
long long hero_uniid = 0;
|
||||||
|
int hero_lv = 0;
|
||||||
|
int quality = 0;
|
||||||
|
m->GetNetData()->GetHeroLvQuality(hero_uniid, hero_lv, quality);
|
||||||
|
total_hero_lv += hero_lv;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
return total_hero_lv / GetMemberNum();
|
||||||
|
}
|
||||||
|
@ -10,6 +10,7 @@ class CustomTeam
|
|||||||
bool IsView() { return is_view_; }
|
bool IsView() { return is_view_; }
|
||||||
void TraverseMember(std::function<bool (std::shared_ptr<CustomMember>)> cb);
|
void TraverseMember(std::function<bool (std::shared_ptr<CustomMember>)> cb);
|
||||||
int GetMemberNum();
|
int GetMemberNum();
|
||||||
|
int GetAverageHeroLv();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string team_uuid_;
|
std::string team_uuid_;
|
||||||
|
@ -3603,5 +3603,47 @@ void Room::DecAliveCount()
|
|||||||
|
|
||||||
bool Room::CanJoin(std::shared_ptr<CustomBattle> p)
|
bool Room::CanJoin(std::shared_ptr<CustomBattle> p)
|
||||||
{
|
{
|
||||||
return false;
|
if (p->IsMoba()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!p->IsNormalMode()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (p->GetTeamNum() > 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (p->GetTeamNum() < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lock_room_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (IsCustomBattle()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (IsMobaModeRoom()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (room_mode_ != p->GetRoomMode()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (GetGasData().GetGasMode() != GasInactive) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (map_meta_->map_id() != p->GetMapId()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto p_team = p->GetTeamByIdx(0);
|
||||||
|
if (GetPlayerNum() + p_team->GetMemberNum() > GetRoomMaxPlayerNum()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int try_count = 0;
|
||||||
|
while (GetHumanNum() + p_team->GetMemberNum() > GetRoomMaxPlayerNum() &&
|
||||||
|
try_count < 100) {
|
||||||
|
++try_count;
|
||||||
|
RandRemoveAndroid();
|
||||||
|
}
|
||||||
|
return GetHumanNum() + p_team->GetMemberNum() <= GetRoomMaxPlayerNum();
|
||||||
}
|
}
|
||||||
|
@ -373,6 +373,7 @@ void Team::GenBattleReportData(Human* player, a8::MutableXObject* params)
|
|||||||
}
|
}
|
||||||
member_pb->SetVal("move_distance", hum->stats->move_distance);
|
member_pb->SetVal("move_distance", hum->stats->move_distance);
|
||||||
member_pb->SetVal("full_level_idx", hum->stats->full_level_idx);
|
member_pb->SetVal("full_level_idx", hum->stats->full_level_idx);
|
||||||
|
member_pb->SetVal("hero_level", hum->GetHeroLevel());
|
||||||
member_pb->SetVal("is_run_away", hum->stats->is_run_away);
|
member_pb->SetVal("is_run_away", hum->stats->is_run_away);
|
||||||
|
|
||||||
member_pb->SetVal("hero_id", hum->meta->id());
|
member_pb->SetVal("hero_id", hum->meta->id());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user