TrackManiaControl/application/core/Maps/Map.php

78 lines
1.7 KiB
PHP
Raw Normal View History

<?php
namespace ManiaControl\Maps;
2013-12-30 23:53:42 +01:00
use ManiaControl\Formatter;
/**
2014-01-06 15:54:22 +01:00
* Map Class
*
* @author kremsy & steeffeen
*/
class Map {
/**
2014-01-06 15:54:22 +01:00
* Public Properties
*/
public $index = -1;
public $name = 'undefined';
public $uid = '';
public $fileName = '';
public $environment = '';
2014-01-05 13:56:05 +01:00
public $goldTime = -1;
public $copperPrice = -1;
public $mapType = '';
public $mapStyle = '';
public $nbCheckpoints = -1;
2014-01-09 23:21:44 +01:00
/** @var MXMapInfo $mx */
public $mx = null;
public $authorLogin = '';
public $authorNick = '';
public $authorZone = '';
public $authorEInfo = '';
public $comment = '';
public $titleUid = '';
2014-01-05 13:56:05 +01:00
public $startTime = -1;
2014-01-09 23:21:44 +01:00
public $lastUpdate = 0;
2014-01-08 21:52:42 +01:00
/**
2014-01-06 15:54:22 +01:00
* Create a new Map Object from Rpc Data
*
2014-01-12 20:56:25 +01:00
* @param array $rpc_infos
* @internal param \ManiaControl\ManiaControl $maniaControl
*/
2014-01-12 20:56:25 +01:00
public function __construct($rpc_infos = null) {
$this->startTime = time();
2014-01-08 21:52:42 +01:00
if(!$rpc_infos) {
return;
}
2014-01-11 10:57:07 +01:00
$this->name = FORMATTER::stripDirtyCodes($rpc_infos['Name']);
2014-01-08 21:52:42 +01:00
$this->uid = $rpc_infos['UId'];
$this->fileName = $rpc_infos['FileName'];
$this->authorLogin = $rpc_infos['Author'];
$this->environment = $rpc_infos['Environnement'];
2014-01-08 21:52:42 +01:00
$this->goldTime = $rpc_infos['GoldTime'];
$this->copperPrice = $rpc_infos['CopperPrice'];
2014-01-08 21:52:42 +01:00
$this->mapType = $rpc_infos['MapType'];
$this->mapStyle = $rpc_infos['MapStyle'];
2014-01-09 23:21:44 +01:00
2014-01-08 21:52:42 +01:00
if(isset($rpc_infos['NbCheckpoints'])) {
2013-12-16 08:38:35 +01:00
$this->nbCheckpoints = $rpc_infos['NbCheckpoints'];
}
2014-01-08 21:52:42 +01:00
2013-12-16 08:38:35 +01:00
$this->authorNick = $this->authorLogin;
2014-01-09 23:21:44 +01:00
}
2014-01-08 21:52:42 +01:00
2014-01-09 23:21:44 +01:00
/**
* Checks if a map Update is available
*
* @return bool
*/
public function updateAvailable() {
2014-01-12 00:02:17 +01:00
if($this->mx != null && ($this->lastUpdate < $this->mx->updated || $this->uid != $this->mx->uid)) {
2014-01-09 23:21:44 +01:00
return true;
} else {
return false;
}
}
}