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;
|
||||
create_tick_ = a8::XGetTickCount();
|
||||
timer_ = a8::Timer::Instance()->AddRepeatTimerAndAttach
|
||||
a8::Timer::Instance()->AddRepeatTimerAndAttach
|
||||
(1000,
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
@ -222,8 +222,6 @@ void MatchTeam::Update()
|
||||
master_team_->SyncMatchInfo();
|
||||
if (phase_ == kMatchStartGame && IsMasterTeam()) {
|
||||
StartGame();
|
||||
a8::Timer::Instance()->DeleteTimer(timer_);
|
||||
timer_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -290,17 +288,9 @@ void MatchTeam::UpdateMaster()
|
||||
break;
|
||||
case kMatchChoose:
|
||||
{
|
||||
if (phase_left_time_ <= 10) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
UpdateTeamState();
|
||||
CheckChoose();
|
||||
CheckPrepare();
|
||||
if ((phase_left_time_ <= MetaMgr::Instance()->match_lock_time) || IsAllPrepare()) {
|
||||
for (int i = 0; i < MAX_TEAM_NUM; ++i) {
|
||||
AutoChoose(true);
|
||||
@ -575,3 +565,34 @@ bool MatchTeam::IsAllPrepare()
|
||||
}
|
||||
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();
|
||||
};
|
||||
|
||||
struct timer_list;
|
||||
class MatchTeam
|
||||
{
|
||||
public:
|
||||
@ -85,6 +84,9 @@ class MatchTeam
|
||||
void ChooseLeader();
|
||||
void AutoChoose(bool force = false);
|
||||
bool IsAllPrepare();
|
||||
void UpdateTeamState();
|
||||
void CheckChoose();
|
||||
void CheckPrepare();
|
||||
|
||||
private:
|
||||
long long phase_start_tick_ = 0;
|
||||
@ -95,7 +97,8 @@ class MatchTeam
|
||||
std::map<std::string, std::shared_ptr<RawTeamMember>> raw_member_hash_;
|
||||
std::shared_ptr<RawTeamMember> first_member_;
|
||||
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_;
|
||||
MatchTeam* master_team_ = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user