1
This commit is contained in:
parent
ad97ab4c31
commit
c7b3b81ea5
@ -75,7 +75,7 @@ void MatchTeam::Init(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
|||||||
{
|
{
|
||||||
master_team_ = this;
|
master_team_ = this;
|
||||||
create_tick_ = a8::XGetTickCount();
|
create_tick_ = a8::XGetTickCount();
|
||||||
timer_ = a8::Timer::Instance()->AddRepeatTimerAndAttach
|
a8::Timer::Instance()->AddRepeatTimerAndAttach
|
||||||
(1000,
|
(1000,
|
||||||
a8::XParams()
|
a8::XParams()
|
||||||
.SetSender(this),
|
.SetSender(this),
|
||||||
@ -222,8 +222,6 @@ void MatchTeam::Update()
|
|||||||
master_team_->SyncMatchInfo();
|
master_team_->SyncMatchInfo();
|
||||||
if (phase_ == kMatchStartGame && IsMasterTeam()) {
|
if (phase_ == kMatchStartGame && IsMasterTeam()) {
|
||||||
StartGame();
|
StartGame();
|
||||||
a8::Timer::Instance()->DeleteTimer(timer_);
|
|
||||||
timer_ = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,17 +288,9 @@ void MatchTeam::UpdateMaster()
|
|||||||
break;
|
break;
|
||||||
case kMatchChoose:
|
case kMatchChoose:
|
||||||
{
|
{
|
||||||
if (phase_left_time_ <= 10) {
|
UpdateTeamState();
|
||||||
if (last_auto_choose_tick_ <= 0) {
|
CheckChoose();
|
||||||
AutoChoose();
|
CheckPrepare();
|
||||||
last_auto_choose_tick_ = a8::XGetTickCount();
|
|
||||||
} else {
|
|
||||||
if (a8::XGetTickCount() - last_auto_choose_tick_ > (last_auto_choose_tick_ % 3000)) {
|
|
||||||
AutoChoose();
|
|
||||||
last_auto_choose_tick_ = a8::XGetTickCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((phase_left_time_ <= MetaMgr::Instance()->match_lock_time) || IsAllPrepare()) {
|
if ((phase_left_time_ <= MetaMgr::Instance()->match_lock_time) || IsAllPrepare()) {
|
||||||
for (int i = 0; i < MAX_TEAM_NUM; ++i) {
|
for (int i = 0; i < MAX_TEAM_NUM; ++i) {
|
||||||
AutoChoose(true);
|
AutoChoose(true);
|
||||||
@ -575,3 +565,34 @@ bool MatchTeam::IsAllPrepare()
|
|||||||
}
|
}
|
||||||
return num >= MAX_TEAM_NUM;
|
return num >= MAX_TEAM_NUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MatchTeam::UpdateTeamState()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MatchTeam::CheckChoose()
|
||||||
|
{
|
||||||
|
if (phase_ != kMatchChoose) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (phase_left_time_ <= 10 || all_player_choose_times_ > 0) {
|
||||||
|
if (last_auto_choose_tick_ <= 0) {
|
||||||
|
AutoChoose();
|
||||||
|
last_auto_choose_tick_ = a8::XGetTickCount();
|
||||||
|
} else {
|
||||||
|
if (a8::XGetTickCount() - last_auto_choose_tick_ > (last_auto_choose_tick_ % 3000)) {
|
||||||
|
AutoChoose();
|
||||||
|
last_auto_choose_tick_ = a8::XGetTickCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MatchTeam::CheckPrepare()
|
||||||
|
{
|
||||||
|
if (phase_ != kMatchChoose) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -42,7 +42,6 @@ struct RawTeamMember
|
|||||||
void InitRobot();
|
void InitRobot();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct timer_list;
|
|
||||||
class MatchTeam
|
class MatchTeam
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -85,6 +84,9 @@ class MatchTeam
|
|||||||
void ChooseLeader();
|
void ChooseLeader();
|
||||||
void AutoChoose(bool force = false);
|
void AutoChoose(bool force = false);
|
||||||
bool IsAllPrepare();
|
bool IsAllPrepare();
|
||||||
|
void UpdateTeamState();
|
||||||
|
void CheckChoose();
|
||||||
|
void CheckPrepare();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long long phase_start_tick_ = 0;
|
long long phase_start_tick_ = 0;
|
||||||
@ -95,7 +97,8 @@ class MatchTeam
|
|||||||
std::map<std::string, std::shared_ptr<RawTeamMember>> raw_member_hash_;
|
std::map<std::string, std::shared_ptr<RawTeamMember>> raw_member_hash_;
|
||||||
std::shared_ptr<RawTeamMember> first_member_;
|
std::shared_ptr<RawTeamMember> first_member_;
|
||||||
long long last_auto_choose_tick_ = 0;
|
long long last_auto_choose_tick_ = 0;
|
||||||
timer_list* timer_ = nullptr;
|
int all_player_choose_times_ = 0;
|
||||||
|
int all_player_parpre_times_ = 0;
|
||||||
|
|
||||||
std::map<std::string, MatchTeam*> combined_team_hash_;
|
std::map<std::string, MatchTeam*> combined_team_hash_;
|
||||||
MatchTeam* master_team_ = nullptr;
|
MatchTeam* master_team_ = nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user