TrackManiaControl/application/core/map.php

79 lines
2.1 KiB
PHP
Raw Normal View History

2013-11-10 17:04:57 +01:00
<?php
namespace ManiaControl;
2013-11-10 19:31:17 +01:00
/**
* Map Object
*
* @author kremsy & steeffeen
*/
2013-11-10 17:04:57 +01:00
2013-11-11 18:37:53 +01:00
class Map {
/**
* Private properties
*/
private $maniaControl = 0;
/**
* Public properties
*/
public $mapFetcher = null;
2013-11-10 17:04:57 +01:00
public $id = 0;
public $name = '';
public $uid = 0;
2013-11-11 18:37:53 +01:00
public $fileName = '';
2013-11-10 17:04:57 +01:00
public $environment = '';
2013-11-11 18:37:53 +01:00
public $goldTime; //format?
public $copperPrice = 0;
public $mapType = '';
public $mapStyle = '';
2013-11-10 19:23:22 +01:00
public $mx = null;
2013-11-10 19:31:17 +01:00
public $authorLogin = '';
2013-11-10 19:03:29 +01:00
public $authorNick = '';
public $authorZone = '';
2013-11-11 18:37:53 +01:00
public $authorEInfo = '';
public $comment = '';
public $titleUid = '';
public $starttime = 0;
2013-11-10 17:04:57 +01:00
// instantiates the map with an RPC response
2013-11-11 18:37:53 +01:00
public function __construct(ManiaControl $maniaControl, $rpc_infos = null) {
$this->maniaControl = $maniaControl;
2013-11-10 17:04:57 +01:00
if ($rpc_infos) {
2013-11-11 18:37:53 +01:00
$this->name = $rpc_infos['Name']; //in aseco stripped new lines on name
2013-11-10 17:04:57 +01:00
$this->uid = $rpc_infos['UId'];
2013-11-11 18:37:53 +01:00
$this->fileName = $rpc_infos['FileName'];
2013-11-10 19:31:17 +01:00
$this->authorLogin = $rpc_infos['Author'];
2013-11-10 17:04:57 +01:00
$this->environment = $rpc_infos['Environnement'];
2013-11-11 18:37:53 +01:00
$this->goldTime = $rpc_infos['GoldTime'];
$this->copperPrice = $rpc_infos['CopperPrice'];
$this->mapType = $rpc_infos['MapType'];
$this->mapStyle = $rpc_infos['MapStyle'];
$this->mapFetcher = new \GBXChallMapFetcher(true);
2013-11-10 17:04:57 +01:00
2013-11-11 18:37:53 +01:00
try{
$this->mapFetcher->processFile($this->maniaControl->server->getMapsDirectory() . $this->fileName);
} catch (Exception $e){
trigger_error($e->getMessage(), E_USER_WARNING);
}
$this->authorNick = $this->mapFetcher->authorNick;
$this->authorEInfo = $this->mapFetcher->authorEInfo;
$this->authorZone = $this->mapFetcher->authorZone;
$this->comment = $this->mapFetcher->comment;
//additional properties anyway in the mapfetcher object
//TODO: change to SM to gameerkennung
//TODO: define timeout if mx is down
$this->mx = new \MXInfoFetcher('SM', $this->uid, false); //SM -> change to gameerkennung
2013-11-10 17:04:57 +01:00
} else {
$this->name = 'undefined';
}
2013-11-11 18:37:53 +01:00
$this->starttime = time();
2013-11-10 17:04:57 +01:00
}
}