TrackManiaControl/core/Callbacks/Structures/TrackMania/OnWayPointEventStructure.php

186 lines
4.4 KiB
PHP
Raw Permalink Normal View History

<?php
namespace ManiaControl\Callbacks\Structures\TrackMania;
2017-04-13 19:14:23 +02:00
use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure;
use ManiaControl\ManiaControl;
use ManiaControl\Utils\Formatter;
/**
* Structure Class for the Default Event Structure Callback
*
2017-04-07 23:26:35 +02:00
* @api
* @author ManiaControl Team <mail@maniacontrol.com>
2020-01-22 10:39:35 +01:00
* @copyright 2014-2020 ManiaControl Team
* @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;
2023-06-30 18:22:20 +02:00
private $curRaceCheckpoints;
private $curLapCheckpoints;
private $isInfiniteLaps;
private $isIndependentLaps;
2017-04-14 16:30:33 +02:00
private $isEndRace;
private $isEndLap;
private $blockId;
private $speed;
private $distance;
private $lapNumber;
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
*/
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
2023-06-30 18:22:20 +02:00
$this->raceTime = (int) $this->getPlainJsonObject()->racetime;
$this->lapTime = (int) $this->getPlainJsonObject()->laptime;
$this->stuntsScore = isset($this->getPlainJsonObject()->stuntsscore) ? $this->getPlainJsonObject()->stuntsscore : null;
$this->checkPointInRace = (int) $this->getPlainJsonObject()->checkpointinrace;
$this->checkPointInLap = (int) $this->getPlainJsonObject()->checkpointinlap;
$this->curRaceCheckpoints = isset($this->getPlainJsonObject()->curracecheckpoints) ? $this->getPlainJsonObject()->curracecheckpoints : null;
$this->curLapCheckpoints = isset($this->getPlainJsonObject()->curlapcheckpoints) ? $this->getPlainJsonObject()->curlapcheckpoints : null;
$this->isInfiniteLaps = isset($this->getPlainJsonObject()->isinfinitelaps) ? Formatter::parseBoolean($this->getPlainJsonObject()->isinfinitelaps) : null;
$this->isIndependentLaps = isset($this->getPlainJsonObject()->isindependentlaps) ? Formatter::parseBoolean($this->getPlainJsonObject()->isindependentlaps) : null;
$this->isEndRace = Formatter::parseBoolean($this->getPlainJsonObject()->isendrace);
$this->isEndLap = Formatter::parseBoolean($this->getPlainJsonObject()->isendlap);
$this->blockId = $this->getPlainJsonObject()->blockid;
$this->speed = $this->getPlainJsonObject()->speed;
$this->distance = isset($this->getPlainJsonObject()->distance) ? $this->getPlainJsonObject()->distance : null;
2017-04-07 23:26:35 +02:00
if ($this->checkPointInRace > 0) {
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
$this->lapNumber = intval($this->checkPointInRace / $currentMap->nbCheckpoints);
}
}
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;
}
2023-06-30 18:22:20 +02:00
/**
* @api
* @return array|null
*/
public function getCurRaceCheckpoints() {
return $this->curRaceCheckpoints;
}
/**
* @api
* @return array|null
*/
public function getCurLapCheckpoints() {
return $this->curLapCheckpoints;
}
/**
* @api
* @return bool|null
*/
public function getIsInfiniteLaps() {
return $this->isInfiniteLaps;
}
/**
* @api
* @return bool|null
*/
public function getIsIndependentLaps() {
return $this->isIndependentLaps;
}
2017-04-14 16:30:33 +02:00
/**
* @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;
}
/**
* Gets the Current Lap Number
*
* @return float|int
*/
public function getLapNumber() {
return $this->lapNumber;
}
}