shufflemap list
This commit is contained in:
parent
7bc09fca3b
commit
8afdfeb450
@ -46,7 +46,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
$this->maniaControl->commandManager->registerCommandListener('restartmap', $this, 'command_RestartMap', true);
|
$this->maniaControl->commandManager->registerCommandListener('restartmap', $this, 'command_RestartMap', true);
|
||||||
$this->maniaControl->commandManager->registerCommandListener('addmap', $this, 'command_AddMap', true);
|
$this->maniaControl->commandManager->registerCommandListener('addmap', $this, 'command_AddMap', true);
|
||||||
$this->maniaControl->commandManager->registerCommandListener(array('removemap', 'removethis', 'erasemap', 'erasethis'), $this, 'command_RemoveMap', true);
|
$this->maniaControl->commandManager->registerCommandListener(array('removemap', 'removethis', 'erasemap', 'erasethis'), $this, 'command_RemoveMap', true);
|
||||||
$this->maniaControl->commandManager->registerCommandListener(array('shufflemaps', 'shuffle'), $this, 'command_ShuffleMap', true);
|
$this->maniaControl->commandManager->registerCommandListener(array('shufflemaps', 'shuffle'), $this, 'command_ShuffleMaps', true);
|
||||||
|
|
||||||
// Register for player chat commands
|
// Register for player chat commands
|
||||||
$this->maniaControl->commandManager->registerCommandListener(array('maps', 'list'), $this, 'command_List');
|
$this->maniaControl->commandManager->registerCommandListener(array('maps', 'list'), $this, 'command_List');
|
||||||
|
@ -164,18 +164,22 @@ class MapManager implements CallbackListener {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function shuffleMapList() {
|
public function shuffleMapList() {
|
||||||
if(!$this->maniaControl->client->query('GetMapList', 100, 0)) {
|
shuffle($this->maps);
|
||||||
trigger_error("Couldn't fetch mapList. " . $this->maniaControl->getClientErrorText());
|
|
||||||
return false;
|
$mapArray = array();
|
||||||
|
|
||||||
|
foreach($this->maps as $map) {
|
||||||
|
/** @var Map $map */
|
||||||
|
$mapArray[] = $map->fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mapList = $this->maniaControl->client->getResponse();
|
if(!$this->maniaControl->client->query('ChooseNextMapList', $mapArray)) {
|
||||||
shuffle($mapList);
|
|
||||||
|
|
||||||
if(!$this->maniaControl->client->query('ChooseNextChallengeList', $mapList)) {
|
|
||||||
trigger_error("Couldn't shuffle mapList. " . $this->maniaControl->getClientErrorText());
|
trigger_error("Couldn't shuffle mapList. " . $this->maniaControl->getClientErrorText());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->fetchCurrentMap();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user