TrackManiaControl/core/Maps/MapQueue.php

556 lines
17 KiB
PHP
Raw Permalink Normal View History

2013-12-31 12:25:03 +01:00
<?php
namespace ManiaControl\Maps;
2014-01-14 18:27:54 +01:00
2014-01-28 20:09:09 +01:00
use ManiaControl\Admin\AuthenticationManager;
2013-12-31 12:25:03 +01:00
use ManiaControl\Callbacks\CallbackListener;
2014-04-28 20:50:38 +02:00
use ManiaControl\Callbacks\Callbacks;
2013-12-31 12:25:03 +01:00
use ManiaControl\Commands\CommandListener;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Logger;
2013-12-31 12:25:03 +01:00
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
use ManiaControl\Utils\Formatter;
2014-05-09 11:58:33 +02:00
use Maniaplanet\DedicatedServer\Xmlrpc\NextMapException;
2014-08-03 13:06:43 +02:00
use Maniaplanet\DedicatedServer\Xmlrpc\NotInListException;
2013-12-31 12:25:03 +01:00
/**
* ManiaControl Map Queue Class
2013-12-31 12:25:03 +01:00
*
2014-05-02 17:50:30 +02:00
* @author ManiaControl Team <mail@maniacontrol.com>
2020-01-22 10:39:35 +01:00
* @copyright 2014-2020 ManiaControl Team
2014-05-02 17:50:30 +02:00
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
2013-12-31 12:25:03 +01:00
*/
class MapQueue implements CallbackListener, CommandListener, UsageInformationAble {
use UsageInformationTrait;
/*
2013-12-31 12:25:03 +01:00
* Constants
*/
2014-01-14 18:27:54 +01:00
const CB_MAPQUEUE_CHANGED = 'MapQueue.MapQueueBoxChanged';
2013-12-31 12:25:03 +01:00
2014-01-28 20:09:09 +01:00
const SETTING_SKIP_MAP_ON_LEAVE = 'Skip Map when the requester leaves';
const SETTING_SKIP_MAPQUEUE_ADMIN = 'Skip Map when admin leaves';
const SETTING_MAPLIMIT_PLAYER = 'Maximum maps per player in the Map-Queue (-1 = unlimited)';
const SETTING_MAPLIMIT_ADMIN = 'Maximum maps per admin (Admin+) in the Map-Queue (-1 = unlimited)';
const SETTING_MESSAGE_FORMAT = 'Message Format';
const SETTING_BUFFERSIZE = 'Size of the Map-Queue buffer (recently played maps)';
const SETTING_PERMISSION_ADD_TO_QUEUE = 'Add map to queue';
2014-05-18 16:26:52 +02:00
const SETTING_PERMISSION_CLEAR_MAPQUEUE = 'Clear MapQueue';
const SETTING_PERMISSION_QUEUE_BUFFER = 'Queue maps in buffer';
2013-12-31 12:25:03 +01:00
const ADMIN_COMMAND_CLEAR_MAPQUEUE = 'clearmapqueue';
2014-01-14 18:27:54 +01:00
const ADMIN_COMMAND_CLEAR_JUKEBOX = 'clearjukebox';
2014-05-02 17:50:30 +02:00
/*
* Private properties
2013-12-31 12:25:03 +01:00
*/
/** @var ManiaControl $maniaControl */
2013-12-31 12:25:03 +01:00
private $maniaControl = null;
2015-07-11 13:41:46 +02:00
private $queuedMaps = array();
private $nextMap = null;
private $buffer = array();
private $nextNoQueue = false;
2014-05-09 11:58:33 +02:00
2013-12-31 12:25:03 +01:00
/**
* Construct a new map queue instance
2013-12-31 12:25:03 +01:00
*
* @param ManiaControl $maniaControl
*/
public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
// Callbacks
2017-05-14 09:43:54 +02:00
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::MP_PODIUMSTART, $this, 'endMap');
2014-08-13 11:05:52 +02:00
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'beginMap');
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
// Settings
2014-08-13 11:05:52 +02:00
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SKIP_MAP_ON_LEAVE, true);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SKIP_MAPQUEUE_ADMIN, false);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAPLIMIT_PLAYER, 1);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAPLIMIT_ADMIN, -1);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MESSAGE_FORMAT, '$fa0');
2014-08-13 11:05:52 +02:00
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_BUFFERSIZE, 10);
// Permissions
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_ADD_TO_QUEUE, AuthenticationManager::AUTH_LEVEL_PLAYER, AuthenticationManager::AUTH_LEVEL_PLAYER);
2014-08-13 11:05:52 +02:00
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_CLEAR_MAPQUEUE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_QUEUE_BUFFER, AuthenticationManager::AUTH_LEVEL_ADMIN);
// Admin Commands
2014-08-13 11:05:52 +02:00
$this->maniaControl->getCommandManager()->registerCommandListener(self::ADMIN_COMMAND_CLEAR_JUKEBOX, $this, 'command_ClearMapQueue', true, 'Clears the Map-Queue.');
$this->maniaControl->getCommandManager()->registerCommandListener(self::ADMIN_COMMAND_CLEAR_MAPQUEUE, $this, 'command_ClearMapQueue', true, 'Clears the Map-Queue.');
$this->maniaControl->getCommandManager()->registerCommandListener(array('jb', 'jukebox', 'mapqueue'), $this, 'command_MapQueue', false, 'Shows current maps in Map-Queue.');
2013-12-31 12:25:03 +01:00
}
/**
* Don't queue on the next MapChange
*/
public function dontQueueNextMapChange() {
$this->nextNoQueue = true;
}
/**
* Add current map to buffer on startup
*/
public function handleAfterInit() {
2014-08-13 11:05:52 +02:00
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
$this->buffer[] = $currentMap->uid;
}
2013-12-31 12:25:03 +01:00
/**
* Clear the map-queue via admin command clear map queue
2014-01-14 18:27:54 +01:00
*
2014-05-02 18:21:38 +02:00
* @param array $chatCallback
* @param Player $admin
2013-12-31 12:25:03 +01:00
*/
2014-05-02 18:21:38 +02:00
public function command_ClearMapQueue(array $chatCallback, Player $admin) {
2014-01-17 22:35:14 +01:00
$this->clearMapQueue($admin);
}
2014-05-02 17:50:30 +02:00
/**
2014-05-02 18:21:38 +02:00
* Clear the Map Queue
2014-05-02 17:50:30 +02:00
*
2014-08-13 21:33:26 +02:00
* @param Player $admin |null
2014-05-02 17:50:30 +02:00
*/
2014-08-13 21:33:26 +02:00
public function clearMapQueue(Player $admin = null) {
2015-07-11 13:41:46 +02:00
if ($admin && !$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
2014-08-13 11:05:52 +02:00
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
2014-05-02 17:50:30 +02:00
return;
}
$messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT);
2014-08-13 21:33:26 +02:00
if ($admin && empty($this->queuedMaps)) {
$this->maniaControl->getChat()->sendError($messagePrefix . 'There are no maps in the jukebox!', $admin);
2014-05-02 17:50:30 +02:00
return;
}
// Destroy map - queue list
2014-05-02 17:50:30 +02:00
$this->queuedMaps = array();
2014-08-13 21:33:26 +02:00
if ($admin) {
$title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage(
"{$messagePrefix}{$title} %s cleared the Map-Queue!",
$admin
);
2014-08-13 21:33:26 +02:00
$this->maniaControl->getChat()->sendInformation($message);
Logger::logInfo($message, true);
}
2014-05-02 17:50:30 +02:00
// Trigger callback
2014-08-13 11:05:52 +02:00
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('clear'));
2014-05-02 17:50:30 +02:00
}
/**
* Handle the mapqueue/jukebox command
*
2014-05-02 18:21:38 +02:00
* @param array $chatCallback
* @param Player $player
*/
2014-05-02 18:21:38 +02:00
public function command_MapQueue(array $chatCallback, Player $player) {
$chatCommands = explode(' ', $chatCallback[1][2]);
2014-05-02 17:50:30 +02:00
if (isset($chatCommands[1])) {
$listParam = strtolower($chatCommands[1]);
switch ($listParam) {
case 'list':
$this->showMapQueue($player);
break;
case 'display':
$this->showMapQueueManialink($player);
break;
case 'clear':
$this->clearMapQueue($player);
break;
default:
$this->showMapQueue($player);
break;
}
} else {
$this->showMapQueue($player);
}
}
/**
* Show current mapqueue in the chat
*
2014-05-02 18:21:38 +02:00
* @param Player $player
*/
2014-05-02 18:21:38 +02:00
public function showMapQueue(Player $player) {
$messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT);
if (empty($this->queuedMaps)) {
$this->maniaControl->getChat()->sendInformation($messagePrefix . 'There are no maps in the jukebox!', $player);
return;
}
$message = $messagePrefix . 'Upcoming maps in the Map-Queue:';
2014-06-17 23:55:59 +02:00
$index = 1;
2014-05-02 17:50:30 +02:00
foreach ($this->queuedMaps as $queuedMap) {
$message .= $this->maniaControl->getChat()->formatMessage(
' %s. [%s]',
$index,
Formatter::stripCodes($queuedMap[1]->name)
);
2014-06-17 23:55:59 +02:00
$index++;
}
2014-08-13 11:05:52 +02:00
$this->maniaControl->getChat()->sendInformation($message, $player);
}
/**
* Show current mapqueue in a manialink
*
2014-05-02 18:21:38 +02:00
* @param Player $player
*/
2014-05-02 18:21:38 +02:00
public function showMapQueueManialink(Player $player) {
$messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT);
if (empty($this->queuedMaps)) {
$this->maniaControl->getChat()->sendInformation($messagePrefix . 'There are no Maps in the Jukebox!', $player);
return;
}
$maps = array();
2014-05-02 17:50:30 +02:00
foreach ($this->queuedMaps as $queuedMap) {
array_push($maps, $queuedMap[1]);
}
2014-08-13 11:05:52 +02:00
$this->maniaControl->getMapManager()->getMapList()->showMapList($player, $maps);
}
/**
* Return the current queue buffer
*
* @return string[]
*/
public function getQueueBuffer() {
return $this->buffer;
}
/**
* Add map as first map in queue (for /replay)
*
2014-05-02 18:21:38 +02:00
* @param Player $player
* @param Map $map
*/
2014-05-02 18:21:38 +02:00
public function addFirstMapToMapQueue(Player $player, Map $map) {
2014-04-27 00:55:39 +02:00
if ($map) {
if (array_key_exists($map->uid, $this->queuedMaps)) {
unset($this->queuedMaps[$map->uid]);
}
array_unshift($this->queuedMaps, array($player, $map, true));
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $map));
2014-04-27 00:55:39 +02:00
}
}
2014-08-13 21:35:05 +02:00
/**
* Adds a Map to the Map-Queue from Plugins or whatever
*
* @param $uid
* @return bool
*/
2014-08-13 21:33:26 +02:00
public function serverAddMapToMapQueue($uid) {
$map = $this->maniaControl->getMapManager()->getMapByUid($uid);
if (!$map) {
return false;
}
$this->queuedMaps[$uid] = array(null, $map);
$messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT);
$message = $this->maniaControl->getChat()->formatMessage(
$messagePrefix . '%s has been added to the Map-Queue by the Server.',
$map
);
$this->maniaControl->getChat()->sendInformation($message);
2014-08-13 21:33:26 +02:00
// Trigger callback
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $this->queuedMaps[$uid]));
return true;
}
2014-01-28 20:14:21 +01:00
/**
* Add a Map to the map-queue
2014-01-14 18:27:54 +01:00
*
2014-05-02 18:21:38 +02:00
* @param string $login
* @param string $uid
2013-12-31 12:25:03 +01:00
*/
2014-01-14 18:27:54 +01:00
public function addMapToMapQueue($login, $uid) {
2014-08-13 11:05:52 +02:00
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
if (!$player) {
return;
}
2013-12-31 12:25:03 +01:00
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_ADD_TO_QUEUE)) return;
// Check if the Player is muted
if ($player->isMuted()) {
$this->maniaControl->getChat()->sendError('Muted Players are not allowed to queue a map.', $player);
return;
}
//Check if player is allowed to add (another) map
2014-08-13 11:05:52 +02:00
$isModerator = $this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR);
$mapsForPlayer = 0;
2014-05-02 17:50:30 +02:00
foreach ($this->queuedMaps as $queuedMap) {
if ($queuedMap[0]->login == $login) {
$mapsForPlayer++;
}
}
if ($isModerator) {
2014-08-13 11:05:52 +02:00
$maxAdmin = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAPLIMIT_ADMIN);
if ($maxAdmin >= 0 && $mapsForPlayer >= $maxAdmin) {
$message = $this->maniaControl->getChat()->formatMessage(
'You already have %s map(s) in the Map-Queue!',
$maxAdmin
);
$this->maniaControl->getChat()->sendError($message, $player);
return;
}
} else {
2014-08-13 11:05:52 +02:00
$maxPlayer = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAPLIMIT_PLAYER);
if ($maxPlayer >= 0 && $mapsForPlayer >= $maxPlayer) {
$message = $this->maniaControl->getChat()->formatMessage(
'You already have %s map(s) in the Map-Queue!',
$maxPlayer
);
$this->maniaControl->getChat()->sendError($message, $player);
return;
}
}
2014-07-05 13:58:35 +02:00
// Check if the map is already juked
$map = null;
if ($uid instanceof Map) {
$map = $uid;
$uid = $map->uid;
}
2014-01-28 20:09:09 +01:00
if (array_key_exists($uid, $this->queuedMaps)) {
$this->maniaControl->getChat()->sendError('This map is already in the Map-Queue!', $player);
2013-12-31 12:25:03 +01:00
return;
}
//TODO recently maps not able to add to queue-amps setting, and management
// Check if map is in the buffer
$messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT);
2014-05-02 17:50:30 +02:00
if (in_array($uid, $this->buffer)) {
$this->maniaControl->getChat()->sendInformation($messagePrefix . 'This map has recently been played!', $player);
2015-07-11 13:41:46 +02:00
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
return;
}
}
2013-12-31 12:25:03 +01:00
2014-07-05 13:58:35 +02:00
if (!$map) {
2014-08-13 11:05:52 +02:00
$map = $this->maniaControl->getMapManager()->getMapByUid($uid);
2014-07-05 13:58:35 +02:00
}
2013-12-31 12:25:03 +01:00
$this->queuedMaps[$uid] = array($player, $map);
$message = $this->maniaControl->getChat()->formatMessage(
$messagePrefix . '%s has been added to the Map-Queue by %s.',
$map,
$player
);
$this->maniaControl->getChat()->sendInformation($message);
2013-12-31 12:25:03 +01:00
// Trigger callback
2014-08-13 11:05:52 +02:00
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $this->queuedMaps[$uid]));
2013-12-31 12:25:03 +01:00
}
/**
* Remove a Map from the Map queue
2014-01-14 18:27:54 +01:00
*
2015-07-11 13:41:46 +02:00
* @param Player|null $player
* @param string $uid
2013-12-31 12:25:03 +01:00
*/
2015-07-11 13:41:46 +02:00
public function removeFromMapQueue($player, $uid) {
2014-01-28 20:09:09 +01:00
if (!isset($this->queuedMaps[$uid])) {
return;
}
$queuer = $this->maniaControl->getMapManager()->getMapQueue()->getQueuer($uid);
if (($queuer === null || $queuer->login !== $player->login) && !$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)) return;
/** @var Map $map */
2014-01-28 20:09:09 +01:00
$map = $this->queuedMaps[$uid][1];
2013-12-31 12:25:03 +01:00
unset($this->queuedMaps[$uid]);
2014-01-28 20:09:09 +01:00
2015-07-11 13:41:46 +02:00
if ($player) {
$messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT);
$message = $this->maniaControl->getChat()->formatMessage(
$messagePrefix . '%s has been removed from the Map-Queue by %s.',
$map,
$player
);
$this->maniaControl->getChat()->sendInformation($message);
2015-07-11 13:41:46 +02:00
}
2014-01-28 20:09:09 +01:00
// Trigger callback
2014-08-13 11:05:52 +02:00
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('remove', $map));
2013-12-31 12:25:03 +01:00
}
/**
* Called on endmap
2014-01-14 18:27:54 +01:00
*
2017-05-14 09:43:54 +02:00
* @internal
2013-12-31 12:25:03 +01:00
*/
2017-05-14 09:43:54 +02:00
public function endMap() {
// Don't queue next map (for example on skip to map)
if ($this->nextNoQueue) {
2014-05-09 11:58:33 +02:00
$this->nextNoQueue = false;
return;
}
$messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT);
2014-05-09 11:58:33 +02:00
2013-12-31 12:25:03 +01:00
$this->nextMap = null;
2015-07-11 13:41:46 +02:00
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SKIP_MAP_ON_LEAVE)) {
// Skip Map if requester has left
2014-05-02 17:50:30 +02:00
foreach ($this->queuedMaps as $queuedMap) {
/** @var Player $player */
2013-12-31 12:25:03 +01:00
$player = $queuedMap[0];
/** @var Map $map */
$map = $queuedMap[1];
2013-12-31 12:25:03 +01:00
// Check if map is added via replay vote/command
if (isset($queuedMap[2]) && $queuedMap[2] === true) {
break;
}
2014-08-13 21:33:26 +02:00
// Player found, so play this map (or if it got juked by the server)
if ($player == null || $this->maniaControl->getPlayerManager()->getPlayer($player->login)) {
2013-12-31 12:25:03 +01:00
break;
}
2014-08-13 21:33:26 +02:00
if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SKIP_MAPQUEUE_ADMIN)) {
2013-12-31 12:36:49 +01:00
//Check if the queuer is a admin
2014-01-28 20:09:09 +01:00
if ($player->authLevel > 0) {
2013-12-31 12:25:03 +01:00
break;
}
}
// Trigger callback
2014-08-13 11:05:52 +02:00
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('skip', $queuedMap[0]));
2013-12-31 12:25:03 +01:00
2014-08-03 13:06:43 +02:00
// Player not found, so remove the map from the mapqueue
2013-12-31 12:25:03 +01:00
array_shift($this->queuedMaps);
$message = $this->maniaControl->getChat()->formatMessage(
$messagePrefix . '%s will be skipped, because %s left the game!',
$map,
$player
);
$this->maniaControl->getChat()->sendInformation($message);
2013-12-31 12:25:03 +01:00
}
}
$this->nextMap = array_shift($this->queuedMaps);
// Check if Map Queue is empty
2014-03-31 21:54:51 +02:00
if (!$this->nextMap || !isset($this->nextMap[1])) {
2013-12-31 12:25:03 +01:00
return;
2014-01-14 18:27:54 +01:00
}
/** @var Player $player */
$player = $this->nextMap[0];
/** @var Map $map */
2013-12-31 12:25:03 +01:00
$map = $this->nextMap[1];
2014-08-13 21:33:26 +02:00
// Message only if it's juked by a player (not by the server)
if ($player) {
$message = $this->maniaControl->getChat()->formatMessage(
$messagePrefix . 'Next map will be %s as requested by %s.',
$map,
$player
);
$this->maniaControl->getChat()->sendInformation($message);
2014-08-13 21:33:26 +02:00
}
2013-12-31 12:25:03 +01:00
try {
2017-05-14 09:25:52 +02:00
$this->maniaControl->getClient()->setNextMapIdent($map->uid, true);
} catch (NextMapException $e) {
2014-08-03 13:06:43 +02:00
} catch (NotInListException $e) {
2014-05-09 11:58:33 +02:00
}
2013-12-31 12:25:03 +01:00
}
/**
* Called on begin map
*
* @param Map $map
*/
public function beginMap(Map $map) {
2014-05-02 17:50:30 +02:00
if (in_array($map->uid, $this->buffer)) {
return;
}
2015-07-11 13:41:46 +02:00
if (count($this->buffer) >= $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_BUFFERSIZE)) {
array_shift($this->buffer);
}
$this->buffer[] = $map->uid;
}
2013-12-31 12:25:03 +01:00
/**
* Return the next Map if the next map is a queuedmap or null if it's not
2014-01-14 18:27:54 +01:00
*
2014-05-02 18:21:38 +02:00
* @return Map
2013-12-31 12:25:03 +01:00
*/
2014-01-14 18:27:54 +01:00
public function getNextMap() {
2013-12-31 12:25:03 +01:00
return $this->nextMap;
}
2014-01-14 18:27:54 +01:00
2014-01-14 20:35:31 +01:00
/**
* Return the first Queued Map
2014-01-14 20:35:31 +01:00
*
* @return array(Player $player, Map $map)
*/
public function getNextQueuedMap() {
2014-05-02 17:50:30 +02:00
foreach ($this->queuedMaps as $queuedMap) {
2014-01-14 20:35:31 +01:00
//return the first Queued Map
return $queuedMap;
}
return null;
}
2013-12-31 12:25:03 +01:00
/**
* Return a list with the indexes of the queued maps
2014-01-14 18:27:54 +01:00
*
2013-12-31 12:25:03 +01:00
* @return array
*/
2014-01-14 18:27:54 +01:00
public function getQueuedMapsRanking() {
$index = 1;
2013-12-31 12:25:03 +01:00
$queuedMaps = array();
2014-05-02 17:50:30 +02:00
foreach ($this->queuedMaps as $queuedMap) {
$map = $queuedMap[1];
$queuedMaps[$map->uid] = $index;
$index++;
2013-12-31 12:25:03 +01:00
}
return $queuedMaps;
}
2014-01-28 20:09:09 +01:00
/**
* Return the Queuer of a Map
2014-01-28 20:09:09 +01:00
*
* @param string $uid
2014-01-28 20:09:09 +01:00
* @return mixed
*/
public function getQueuer($uid) {
return $this->queuedMaps[$uid][0];
}
2013-12-31 12:25:03 +01:00
/**
* Dummy Function for testing
*/
2014-01-14 18:27:54 +01:00
public function printAllMaps() {
2014-05-02 17:50:30 +02:00
foreach ($this->queuedMaps as $map) {
2013-12-31 12:25:03 +01:00
$map = $map[1];
var_dump($map->name);
}
}
}