Added teamcheck for QueuePlugin

This commit is contained in:
Max Klaversma 2014-02-09 14:38:44 +01:00 committed by Steffen Schröder
parent 1b059f0cff
commit ad99f17bb8

View File

@ -296,10 +296,27 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
try {
$this->maniaControl->client->forceSpectator($player->login, 0);
} catch(\Exception $e) {
//do nothing
} catch(\Exception $e) { }
$teams = array();
/** @var Player $player */
foreach($this->maniaControl->playerManager->players as $player) {
$teams[$player->teamId]++;
}
$smallestTeam = null;
$smallestSize = 999;
foreach($teams as $team => $size) {
if($size < $smallestSize) {
$smallestTeam = $team;
$smallestSize = $size;
}
}
try {
$this->maniaControl->client->forcePlayerTeam($player->login, $smallestTeam);
} catch(\Exception $e) { }
if(isset($this->spectators[$player->login])) {
unset($this->spectators[$player->login]);
}