添加组队合并队伍功能
This commit is contained in:
parent
e6ab525906
commit
efe64536c6
@ -42,6 +42,7 @@ class Human : public Entity
|
|||||||
std::string session_id;
|
std::string session_id;
|
||||||
std::string from_appid;
|
std::string from_appid;
|
||||||
std::string team_uuid;
|
std::string team_uuid;
|
||||||
|
bool auto_fill = false;
|
||||||
int account_registertime = 0;
|
int account_registertime = 0;
|
||||||
MetaData::Player* meta = nullptr;
|
MetaData::Player* meta = nullptr;
|
||||||
MetaData::Equip* helmet_meta = nullptr;
|
MetaData::Equip* helmet_meta = nullptr;
|
||||||
|
@ -22,7 +22,6 @@ class Player : public Human
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
int team_mode = 0;
|
int team_mode = 0;
|
||||||
bool auto_fill = false;
|
|
||||||
bool use_touch = false;
|
bool use_touch = false;
|
||||||
long long create_tick = 0;
|
long long create_tick = 0;
|
||||||
|
|
||||||
|
@ -880,6 +880,7 @@ void Room::UpdateGas()
|
|||||||
CreateAndroid(ROOM_MAX_PLAYER_NUM - human_hash_.size());
|
CreateAndroid(ROOM_MAX_PLAYER_NUM - human_hash_.size());
|
||||||
NotifyUiUpdate();
|
NotifyUiUpdate();
|
||||||
}
|
}
|
||||||
|
CombineTeam();
|
||||||
ShuaPlane();
|
ShuaPlane();
|
||||||
NotifyWxVoip();
|
NotifyWxVoip();
|
||||||
RoomMgr::Instance()->ActiveRoom(room_uuid);
|
RoomMgr::Instance()->ActiveRoom(room_uuid);
|
||||||
@ -1115,6 +1116,63 @@ void Room::MatchTeam(Human* hum)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Room::CombineTeam()
|
||||||
|
{
|
||||||
|
std::map<int, size_t> need_combine_teams;
|
||||||
|
std::map<int, size_t> need_combine_teams_copy;
|
||||||
|
|
||||||
|
for (auto& pair : team_hash_) {
|
||||||
|
for (Human* hum : pair.second) {
|
||||||
|
if (hum->auto_fill) {
|
||||||
|
need_combine_teams[pair.first] = pair.second.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
need_combine_teams_copy = need_combine_teams;
|
||||||
|
bool combine_ok = false;
|
||||||
|
do {
|
||||||
|
combine_ok = false;
|
||||||
|
for (auto& pair1 : need_combine_teams) {
|
||||||
|
for (auto& pair2 : need_combine_teams_copy) {
|
||||||
|
if (pair1.first != pair2.first) {
|
||||||
|
if (pair1.second + pair2.second <= MAX_TEAM_NUM) {
|
||||||
|
int team_id1 = pair1.first;
|
||||||
|
int team_id2 = pair2.first;
|
||||||
|
|
||||||
|
{
|
||||||
|
std::set<Human*>& team1_members = team_hash_[team_id1];
|
||||||
|
std::set<Human*>& team2_members = team_hash_[team_id2];
|
||||||
|
if (pair1.second > pair2.second) {
|
||||||
|
for (Human* hum : team2_members) {
|
||||||
|
hum->team_id = team_id1;
|
||||||
|
hum->team_members = &team1_members;
|
||||||
|
team1_members.insert(hum);
|
||||||
|
}
|
||||||
|
team_hash_.erase(pair2.first);
|
||||||
|
} else {
|
||||||
|
for (Human* hum : team1_members) {
|
||||||
|
hum->team_id = team_id2;
|
||||||
|
hum->team_members = &team2_members;
|
||||||
|
team2_members.insert(hum);
|
||||||
|
}
|
||||||
|
team_hash_.erase(pair1.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
need_combine_teams.erase(team_id1);
|
||||||
|
need_combine_teams.erase(team_id2);
|
||||||
|
need_combine_teams_copy.erase(team_id1);
|
||||||
|
need_combine_teams_copy.erase(team_id2);
|
||||||
|
combine_ok = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (combine_ok);
|
||||||
|
}
|
||||||
|
|
||||||
void Room::InitAirDrop()
|
void Room::InitAirDrop()
|
||||||
{
|
{
|
||||||
std::list<MetaData::AirDrop>& air_drops = MetaMgr::Instance()->GetAirDrops();
|
std::list<MetaData::AirDrop>& air_drops = MetaMgr::Instance()->GetAirDrops();
|
||||||
|
@ -101,6 +101,7 @@ private:
|
|||||||
a8::Vec2& out_pos);
|
a8::Vec2& out_pos);
|
||||||
void AutoMatchTeam();
|
void AutoMatchTeam();
|
||||||
void MatchTeam(Human* hum);
|
void MatchTeam(Human* hum);
|
||||||
|
void CombineTeam();
|
||||||
void InitAirDrop();
|
void InitAirDrop();
|
||||||
void AirDrop(int appear_time, int box_id);
|
void AirDrop(int appear_time, int box_id);
|
||||||
void ShuaPlane();
|
void ShuaPlane();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user