2017-03-29 13:28:32 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl\Callbacks\Structures\TrackMania;
|
|
|
|
|
|
|
|
|
2017-04-13 19:14:23 +02:00
|
|
|
use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure;
|
2017-03-29 13:28:32 +02:00
|
|
|
use ManiaControl\ManiaControl;
|
|
|
|
use ManiaControl\Utils\Formatter;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Structure Class for the Default Event Structure Callback
|
|
|
|
*
|
2017-04-07 23:26:35 +02:00
|
|
|
* @api
|
2017-03-29 13:28:32 +02:00
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
2018-03-27 20:11:40 +02:00
|
|
|
* @copyright 2014-2018 ManiaControl Team
|
2017-03-29 13:28:32 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
|
|
|
*/
|
2017-04-14 17:02:00 +02:00
|
|
|
class OnWayPointEventStructure extends BasePlayerTimeStructure {
|
2017-04-14 16:30:33 +02:00
|
|
|
private $raceTime;
|
|
|
|
private $lapTime;
|
|
|
|
private $stuntsScore;
|
|
|
|
private $checkPointInRace;
|
|
|
|
private $checkPointInLap;
|
|
|
|
private $isEndRace;
|
|
|
|
private $isEndLap;
|
|
|
|
private $blockId;
|
2017-03-29 13:28:32 +02:00
|
|
|
private $speed;
|
|
|
|
private $distance;
|
2017-05-08 19:55:07 +02:00
|
|
|
private $lapNumber;
|
2017-03-29 13:28:32 +02:00
|
|
|
|
2017-04-07 23:26:35 +02:00
|
|
|
/**
|
2017-04-14 17:02:00 +02:00
|
|
|
* OnWayPointEventStructure constructor.
|
2017-04-07 23:26:35 +02:00
|
|
|
*
|
|
|
|
* @param \ManiaControl\ManiaControl $maniaControl
|
|
|
|
* @param $data
|
|
|
|
*/
|
2017-03-29 13:28:32 +02:00
|
|
|
public function __construct(ManiaControl $maniaControl, $data) {
|
|
|
|
parent::__construct($maniaControl, $data);
|
|
|
|
|
2017-04-14 16:30:33 +02:00
|
|
|
$this->raceTime = (int) $this->getPlainJsonObject()->racetime;
|
|
|
|
$this->lapTime = (int) $this->getPlainJsonObject()->laptime;
|
|
|
|
$this->stuntsScore = $this->getPlainJsonObject()->stuntsscore;
|
|
|
|
$this->checkPointInRace = (int) $this->getPlainJsonObject()->checkpointinrace;
|
|
|
|
$this->checkPointInLap = (int) $this->getPlainJsonObject()->checkpointinlap;
|
2017-05-08 19:55:07 +02:00
|
|
|
$this->isEndRace = Formatter::parseBoolean($this->getPlainJsonObject()->isendrace);
|
|
|
|
$this->isEndLap = Formatter::parseBoolean($this->getPlainJsonObject()->isendlap);
|
2017-04-14 16:30:33 +02:00
|
|
|
$this->blockId = $this->getPlainJsonObject()->blockid;
|
2017-04-07 23:26:35 +02:00
|
|
|
$this->speed = $this->getPlainJsonObject()->speed;
|
|
|
|
$this->distance = $this->getPlainJsonObject()->distance;
|
|
|
|
|
2017-05-08 19:55:07 +02:00
|
|
|
if ($this->checkPointInRace > 0) {
|
|
|
|
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
|
|
|
|
$this->lapNumber = intval($this->checkPointInRace / $currentMap->nbCheckpoints);
|
2017-03-29 13:28:32 +02:00
|
|
|
}
|
|
|
|
}
|
2017-04-14 16:30:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @api
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getRaceTime() {
|
|
|
|
return $this->raceTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @api
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getLapTime() {
|
|
|
|
return $this->lapTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @api
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getStuntsScore() {
|
|
|
|
return $this->stuntsScore;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @api
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getCheckPointInRace() {
|
|
|
|
return $this->checkPointInRace;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @api
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getCheckPointInLap() {
|
|
|
|
return $this->checkPointInLap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @api
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getIsEndRace() {
|
|
|
|
return $this->isEndRace;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @api
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getIsEndLap() {
|
|
|
|
return $this->isEndLap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @api
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getBlockId() {
|
|
|
|
return $this->blockId;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @api
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getSpeed() {
|
|
|
|
return $this->speed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @api
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getDistance() {
|
|
|
|
return $this->distance;
|
|
|
|
}
|
|
|
|
|
2017-05-08 19:55:07 +02:00
|
|
|
/**
|
|
|
|
* Gets the Current Lap Number
|
|
|
|
*
|
|
|
|
* @return float|int
|
|
|
|
*/
|
|
|
|
public function getLapNumber() {
|
|
|
|
return $this->lapNumber;
|
|
|
|
}
|
|
|
|
|
2017-03-29 13:28:32 +02:00
|
|
|
}
|