2014-01-16 16:56:24 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* ManiaPlanet dedicated server Xml-RPC client
|
|
|
|
*
|
|
|
|
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
|
|
|
*/
|
2014-05-08 19:38:15 +02:00
|
|
|
|
2014-01-16 16:56:24 +01:00
|
|
|
namespace Maniaplanet\DedicatedServer\Structures;
|
|
|
|
|
|
|
|
class VoteRatio extends AbstractStructure
|
|
|
|
{
|
|
|
|
const COMMAND_SCRIPT_SETTINGS = 'SetModeScriptSettingsAndCommands';
|
|
|
|
const COMMAND_NEXT_MAP = 'NextMap';
|
|
|
|
const COMMAND_JUMP_MAP = 'JumpToMapIndex';
|
|
|
|
const COMMAND_SET_NEXT_MAP = 'SetNextMapIndex';
|
|
|
|
const COMMAND_RESTART_MAP = 'RestartMap';
|
|
|
|
const COMMAND_TEAM_BALANCE = 'AutoTeamBalance';
|
|
|
|
const COMMAND_KICK = 'Kick';
|
|
|
|
const COMMAND_BAN = 'Ban';
|
2014-05-08 19:38:15 +02:00
|
|
|
|
|
|
|
/** @var string '*' for default */
|
2014-01-16 16:56:24 +01:00
|
|
|
public $command;
|
2014-05-08 19:38:15 +02:00
|
|
|
/** @var string Empty to match all votes for the command */
|
2014-01-16 16:56:24 +01:00
|
|
|
public $param;
|
2014-05-08 19:38:15 +02:00
|
|
|
/** @var float Must be in range [0,1] or -1 to disable */
|
2014-01-16 16:56:24 +01:00
|
|
|
public $ratio;
|
|
|
|
|
2014-05-08 19:38:15 +02:00
|
|
|
/**
|
|
|
|
* @param string $command
|
|
|
|
* @param float $ratio
|
|
|
|
*/
|
|
|
|
public function __construct($command = '', $ratio = 0.)
|
2014-01-16 16:56:24 +01:00
|
|
|
{
|
|
|
|
$this->command = $command;
|
|
|
|
$this->ratio = $ratio;
|
2014-05-08 19:38:15 +02:00
|
|
|
$this->param = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
function isValid()
|
|
|
|
{
|
|
|
|
return is_string($this->command)
|
|
|
|
&& is_string($this->param)
|
|
|
|
&& self::isRatio($this->ratio);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param float $ratio
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
static function isRatio($ratio)
|
|
|
|
{
|
|
|
|
return is_float($ratio) && ($ratio === -1. || ($ratio >= 0. && $ratio <= 1.));
|
2014-01-16 16:56:24 +01:00
|
|
|
}
|
|
|
|
}
|