TrackManiaControl/application/core/Libs/Maniaplanet/DedicatedServer/Structures/VoteRatio.php

61 lines
1.4 KiB
PHP
Raw Normal View History

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_DEFAULT = '*';
2014-01-16 16:56:24 +01:00
const COMMAND_SCRIPT_SETTINGS = 'SetModeScriptSettingsAndCommands';
2014-06-12 15:39:50 +02:00
const COMMAND_NEXT_MAP = 'NextMap';
const COMMAND_JUMP_MAP = 'JumpToMapIdent';
const COMMAND_SET_NEXT_MAP = 'SetNextMapIdent';
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 = '';
}
/**
2014-05-20 15:20:16 +02:00
* @internal
2014-05-08 19:38:15 +02:00
* @return bool
*/
function isValid()
{
return is_string($this->command)
2014-05-13 17:37:35 +02:00
&& is_string($this->param)
&& self::isRatio($this->ratio);
2014-05-08 19:38:15 +02:00
}
/**
2014-05-20 15:20:16 +02:00
* @internal
2014-05-08 19:38:15 +02:00
* @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
}
}