function onPlayerUnsetLocalAlly($login, array $params = array()) { $this->allyService->remove($login, $params['allyLogin']); }
function onModeScriptCallback($param1, $param2) { switch ($param1) { case 'Master': $login = $param2[0]; $player = $this->storage->getPlayerObject($login); if ($player !== null) { $service = new Services\MatchMakingService(); $service->addMaster($login, $player->nickName, $player->ladderStats['PlayerRankings'][0]['Score'], $this->lobby->login, $this->scriptName, $this->titleIdString); } break; case 'MatchmakingGetOrder': if ($this->match) { $allyService = Services\AllyService::getInstance($this->lobby->login, $this->scriptName, $this->titleIdString); $alliesList = array(); foreach ($this->match->players as $login) { $alliesList = array_merge($alliesList, $allyService->get($login)); } $alliesList = array_unique($alliesList); $this->connection->triggerModeScriptEvent('MatchmakingSetTempAllies', implode(',', $alliesList)); } break; case 'LibXmlRpc_Scores': if ($this->matchId) { $this->scores['match'][0] = $param2[0]; $this->scores['match'][1] = $param2[1]; $this->scores['map'][0] = $param2[2]; $this->scores['map'][1] = $param2[3]; $this->matchMakingService->updateMatchScores($this->matchId, $this->scores['match'][0], $this->scores['match'][1], $this->scores['map'][0], $this->scores['map'][1]); } break; case 'LibXmlRpc_EndRound': $this->connection->triggerModeScriptEvent('LibXmlRpc_GetScores', ''); break; case 'LibXmlRpc_EndTurn': $this->connection->triggerModeScriptEvent('LibXmlRpc_GetScores', ''); break; case 'LibXmlRpc_EndMap': $this->connection->triggerModeScriptEvent('LibXmlRpc_GetScores', ''); break; case 'LibXmlRpc_EndMatch': $this->connection->triggerModeScriptEvent('LibXmlRpc_GetScores', ''); break; } }
/** * update the Player list * @param string $login * @param string[] $blockedPlayerList */ final function updatePlayerList(array $blockedPlayerList, $setLocalAllyAction, $unsetLocalAllyAction, $maxAllyCount, $player = '') { if ($player) { $playerLists = Windows\PlayerList::Get($player); } else { $playerLists = Windows\PlayerList::GetAll(); } foreach ($playerLists as $playerList) { $recipient = $playerList->getRecipient(); $allies = \ManiaLivePlugins\MatchMakingLobby\Services\AllyService::getInstance()->getAll($recipient); $loginsWithUnsetAction = array_map(function (\ManiaLivePlugins\MatchMakingLobby\Services\Ally $a) { if ($a->type == \ManiaLivePlugins\MatchMakingLobby\Services\Ally::TYPE_LOCAL) { return $a->login; } }, $allies); $loginsWithNoAction = array_map(function (\ManiaLivePlugins\MatchMakingLobby\Services\Ally $a) { if ($a->type == \ManiaLivePlugins\MatchMakingLobby\Services\Ally::TYPE_GENERAL) { return $a->login; } }, $allies); $bilateralAllies = array_map(function (\ManiaLivePlugins\MatchMakingLobby\Services\Ally $a) { if ($a->isBilateral) { return $a->login; } }, $allies); $storage = Storage::getInstance(); foreach (array_merge($storage->players, $storage->spectators) as $player) { if (PlayerInfo::Get($player->login)->isAway()) { continue; } $ladderPoints = $player->ladderStats['PlayerRankings'][0]['Score']; $playerInfo = PlayerInfo::Get($player->login); $state = Player::STATE_NOT_READY; if ($playerInfo->isReady()) { $state = Player::STATE_READY; } if ($playerInfo->isInMatch) { $state = Player::STATE_IN_MATCH; } if (array_key_exists($player->login, $blockedPlayerList)) { $state = Player::STATE_BLOCKED; } if ($player->login == $recipient) { $action = null; $isAlly = false; } elseif (in_array($player->login, $loginsWithNoAction)) { $action = null; $isAlly = true; } elseif (in_array($player->login, $loginsWithUnsetAction)) { $action = $unsetLocalAllyAction; $isAlly = true; } else { $action = count($allies) >= $maxAllyCount ? null : $setLocalAllyAction; $isAlly = false; } $isBilateral = in_array($player->login, $bilateralAllies); $playerList->setPlayer($player->login, $player->nickName, $ladderPoints, $state, $action, $isAlly, $isBilateral); } } Windows\PlayerList::RedrawAll(); }