From ad99f17bb8e7ab6b3f30d118a074da55a48312ca Mon Sep 17 00:00:00 2001 From: Max Klaversma Date: Sun, 9 Feb 2014 14:38:44 +0100 Subject: [PATCH] Added teamcheck for QueuePlugin --- application/plugins/QueuePlugin.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/application/plugins/QueuePlugin.php b/application/plugins/QueuePlugin.php index d268d737..57a3ce0f 100644 --- a/application/plugins/QueuePlugin.php +++ b/application/plugins/QueuePlugin.php @@ -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]); }