implemented all trackmania callbacks

This commit is contained in:
kremsy
2017-04-14 17:02:00 +02:00
parent 91d09ec8dc
commit 3aab01b98b
16 changed files with 458 additions and 431 deletions

View File

@ -1,88 +0,0 @@
<?php
namespace ManiaControl\Callbacks\Structures;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
/**
* Structure Class for the ArmorEmpty Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*
* @deprecated see OnArmorEmptyStructure
*/
class ArmorEmptyStructure {
/*
* Private properties
*/
private $shooter;
private $victim;
private $damage;
private $shooterPoints;
private $weapon;
/** @var ManiaControl $maniaControl */
private $maniaControl;
/**
* Construct a new Armor Empty Structure
*
* @param ManiaControl $maniaControl
* @param array $data
*/
public function __construct(ManiaControl $maniaControl, array $data) {
$this->maniaControl = $maniaControl;
$this->shooter = $data[0];
$this->victim = $data[1];
$this->damage = $data[2];
$this->weapon = $data[3];
$this->shooterPoints = $data[4];
}
/**
* Get the shooter
*
* @return Player
*/
public function getShooter() {
return $this->maniaControl->getPlayerManager()->getPlayer($this->shooter);
}
/**
* Get the victim
*
* @return Player
*/
public function getVictim() {
return $this->maniaControl->getPlayerManager()->getPlayer($this->victim);
}
/**
* Get the damage
*
* @return int
*/
public function getDamage() {
return $this->damage;
}
/**
* Get the shooter points
*
* @return int
*/
public function getShooterPoints() {
return $this->shooterPoints;
}
/**
* Get the weapon
*
* @return int
*/
public function getWeapon() {
// TODO: any way of returning type "Weapon?"
return $this->weapon;
}
}

View File

@ -1,60 +0,0 @@
<?php
namespace ManiaControl\Callbacks\Structures;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
/**
* Structure Class for the Capture Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*
* @deprecated see Capture Structure
*/
class CaptureStructure {
/*
* Private properties
*/
private $playerArray;
/** @var ManiaControl $maniaControl */
private $maniaControl;
/**
* Construct a new Capture Structure
*
* @param ManiaControl $maniaControl
* @param array $data
*/
public function __construct(ManiaControl $maniaControl, array $data) {
$this->maniaControl = $maniaControl;
$this->playerArray = $data;
}
/**
* Get the logins
*
* @return array
*/
public function getLoginArray() {
return $this->playerArray;
}
/**
* Get the players
*
* @return Player[]
*/
public function getPlayerArray() {
$playerArray = array();
foreach ($this->playerArray as $login) {
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
if ($player) {
$playerArray[$login] = $player;
}
}
return $playerArray;
}
}

View File

@ -0,0 +1,59 @@
<?php
namespace ManiaControl\Callbacks\Structures\Common;
use ManiaControl\ManiaControl;
/**
* Base Structure Class for all Callbacks using a Timestamp
*
* @api
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class UIPropertiesBaseStructure extends BaseResponseStructure {
private $uiPropertiesXML;
private $uiPropertiesJson;
/**
* BaseResponseStructure constructor.
*
* @param \ManiaControl\ManiaControl $maniaControl
* @param $data
*/
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->uiPropertiesXML = $data[1];
$this->uiPropertiesJson = $data[2];
}
/**
* Gets the UI Properties as XML
*
* @return mixed
*/
public function getUiPropertiesXML() {
return $this->uiPropertiesXML;
}
/**
* Gets the UI Properties as Json
*
* @return mixed
*/
public function getUiPropertiesJson() {
return $this->uiPropertiesJson;
}
/**
* Gets the UI Properties as JSON Decoded Object
*
* @return mixed
*/
public function getUiPropertiesObject() {
return json_decode($this->uiPropertiesJson);
}
}

View File

@ -1,78 +0,0 @@
<?php
namespace ManiaControl\Callbacks\Structures;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
/**
* Structure Class for the NearMiss Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*
* @deprecated see OnNearMissStructure
*/
class NearMissStructure {
/*
* Private properties
*/
private $shooter;
private $victim;
private $distance;
private $weapon;
/** @var ManiaControl $maniaControl */
private $maniaControl;
/**
* Construct a new Near Miss Structure
*
* @param ManiaControl $maniaControl
* @param array $data
*/
public function __construct(ManiaControl $maniaControl, array $data) {
$this->maniaControl = $maniaControl;
$this->shooter = $data[0];
$this->victim = $data[1];
$this->weapon = $data[2];
$this->distance = $data[3];
}
/**
* Get the shooter
*
* @return Player
*/
public function getShooter() {
return $this->maniaControl->getPlayerManager()->getPlayer($this->shooter);
}
/**
* Get the victim
*
* @return Player
*/
public function getVictim() {
return $this->maniaControl->getPlayerManager()->getPlayer($this->victim);
}
/**
* Get the distance
*
* @return double
*/
public function getDistance() {
return doubleval($this->distance);
}
/**
* Get the weapon
*
* @return int
*/
public function getWeapon() {
return $this->weapon;
}
}

View File

@ -1,122 +0,0 @@
<?php
namespace ManiaControl\Callbacks\Structures;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
/**
* Structure Class for the Player Hit Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*
* @deprecated see OnPlayerHitStructure
*/
class PlayerHitStructure {
/*
* Private properties
*/
private $shooter;
private $victim;
private $damage;
private $shooterPoints;
private $weapon;
private $hitDistance;
private $shooterPosition = 0;
private $victimPosition = 0;
private $shooterAimDirection = 0;
private $victimAimDirection = 0;
/** @var ManiaControl $maniaControl */
private $maniaControl;
/**
* Construct new Player Hit Structure
*
* @param ManiaControl $maniaControl
* @param array $data
*/
public function __construct(ManiaControl $maniaControl, array $data) {
$this->maniaControl = $maniaControl;
$this->shooter = $data[0];
$this->victim = $data[1];
$this->damage = $data[2];
$this->weapon = $data[3];
$this->shooterPoints = $data[4];
$this->hitDistance = $data[5];
//TODO remove key check in some months (got implemented 2015-05-03)
if (array_key_exists(6, $data)) {
$this->shooterPosition = $data[6];
}
if (array_key_exists(7, $data)) {
$this->victimPosition = $data[7];
}
if (array_key_exists(8, $data)) {
$this->shooterAimDirection = $data[8];
}
if (array_key_exists(9, $data)) {
$this->victimAimDirection = $data[9];
}
}
/**
* Get the shooter
*
* @return Player
*/
public function getShooter() {
return $this->maniaControl->getPlayerManager()->getPlayer($this->shooter);
}
/**
* Get the victim
*
* @return Player
*/
public function getVictim() {
return $this->maniaControl->getPlayerManager()->getPlayer($this->victim);
}
/**
* Get the damage
*
* @return int
*/
public function getDamage() {
return intval($this->damage);
}
/**
* Get the shooter points
*
* @return int
*/
public function getShooterPoints() {
return intval($this->shooterPoints);
}
/**
* Get the weapon
*
* @return int
*/
public function getWeapon() {
// TODO: any way of returning type "Weapon?"
return $this->weapon;
}
/**
* Get The Hit Distance
*
* @return double
*/
public function getHitDistance() {
return doubleval($this->hitDistance);
}
}

View File

@ -0,0 +1,41 @@
<?php
namespace ManiaControl\Callbacks\Structures\TrackMania;
use ManiaControl\Callbacks\Structures\Common\BaseResponseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the On Points Repartition Structure Callback
*
* @api
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnPointsRepartitionStructure extends BaseResponseStructure {
private $pointsRepartition = array();
/**
* OnWayPointEventStructure constructor.
*
* @param \ManiaControl\ManiaControl $maniaControl
* @param $data
*/
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->pointsRepartition = $this->getPlainJsonObject()->pointsrepartition;
}
/**
* @api
* @return array
*/
public function getPointsRepartition() {
return $this->pointsRepartition;
}
}

View File

@ -0,0 +1,114 @@
<?php
namespace ManiaControl\Callbacks\Structures\TrackMania;
use ManiaControl\Callbacks\Models\RecordCallback;
use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure;
use ManiaControl\ManiaControl;
use ManiaControl\Utils\Formatter;
/**
* Structure Class for the On Respawn Structure Callback
*
* @api
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnRespawnStructure extends BasePlayerTimeStructure {
private $numberOfRespawns;
private $raceTime;
private $lapTime;
private $stuntsScore;
private $checkPointInRace;
private $checkPointInLap;
private $speed;
private $distance;
/**
* OnWayPointEventStructure constructor.
*
* @param \ManiaControl\ManiaControl $maniaControl
* @param $data
*/
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$jsonObj = $this->getPlainJsonObject();
$this->numberOfRespawns = (int) $jsonObj->numberOfRespawns;
$this->raceTime = (int) $jsonObj->racetime;
$this->lapTime = (int) $jsonObj->laptime;
$this->stuntsScore = $jsonObj->stuntsscore;
$this->checkPointInRace = (int) $jsonObj->checkpointinrace;
$this->checkPointInLap = (int) $jsonObj->checkpointinlap;
$this->speed = $jsonObj->speed;
$this->distance = $jsonObj->distance;
}
/**
* @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 getSpeed() {
return $this->speed;
}
/**
* @api
* @return mixed
*/
public function getDistance() {
return $this->distance;
}
/**
* @api
* @return int
*/
public function getNumberOfRespawns() {
return $this->numberOfRespawns;
}
}

View File

@ -13,5 +13,5 @@ use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnEventStartLineStructure extends BasePlayerTimeStructure {
class OnStartLineEventStructure extends BasePlayerTimeStructure {
}

View File

@ -0,0 +1,152 @@
<?php
namespace ManiaControl\Callbacks\Structures\TrackMania;
use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the Stunt Event Structure Callback
*
* @api
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnStuntEventStructure extends BasePlayerTimeStructure {
private $numberOfRespawns;
private $raceTime;
private $lapTime;
private $stuntsScore;
private $figureName;
private $angle;
private $points;
private $combo;
private $isStraight;
private $isReverse;
private $isMasterJump;
private $factor;
/**
* OnWayPointEventStructure constructor.
*
* @param \ManiaControl\ManiaControl $maniaControl
* @param $data
*/
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$jsonObj = $this->getPlainJsonObject();
$this->numberOfRespawns = (int) $jsonObj->numberOfRespawns;
$this->raceTime = (int) $jsonObj->racetime;
$this->lapTime = (int) $jsonObj->laptime;
$this->stuntsScore = $jsonObj->stuntsscore;
$this->figureName = $jsonObj->figure;
$this->angle = $jsonObj->angle;
$this->points = $jsonObj->points;
$this->combo = $jsonObj->combo;
$this->isStraight = $jsonObj->isstraight;
$this->isReverse = $jsonObj->isreverse;
$this->isMasterJump = $jsonObj->ismasterjump;
$this->factor = $jsonObj->factor;
}
/**
* @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 getNumberOfRespawns() {
return $this->numberOfRespawns;
}
/**
* @api
* @return mixed
*/
public function getFigureName() {
return $this->figureName;
}
/**
* @api
* @return mixed
*/
public function getAngle() {
return $this->angle;
}
/**
* @api
* @return mixed
*/
public function getPoints() {
return $this->points;
}
/**
* @api
* @return mixed
*/
public function getCombo() {
return $this->combo;
}
/**
* @api
* @return mixed
*/
public function getIsStraight() {
return $this->isStraight;
}
/**
* @api
* @return mixed
*/
public function getIsReverse() {
return $this->isReverse;
}
/**
* @api
* @return mixed
*/
public function getIsMasterJump() {
return $this->isMasterJump;
}
/**
* @api
* @return mixed Points multiplier
*/
public function getFactor() {
return $this->factor;
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace ManiaControl\Callbacks\Structures\TrackMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the On Warmup Start and End Round Callback Structure
*
* @api
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnWarmupStartEndRoundStructure extends BaseStructure {
private $current;
private $total;
/**
* OnWayPointEventStructure constructor.
*
* @param \ManiaControl\ManiaControl $maniaControl
* @param $data
*/
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->current = (int) $this->getPlainJsonObject()->current;
$this->total = (int) $this->getPlainJsonObject()->total;
}
/**
* Gets the number of the current round
*
* @api
* @return int
*/
public function getCurrent() {
return $this->current;
}
/**
* Gets the number of the warmup rounds
*
* @api
* @return int
*/
public function getTotal() {
return $this->total;
}
}

View File

@ -16,7 +16,7 @@ use ManiaControl\Utils\Formatter;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnEventWayPointStructure extends BasePlayerTimeStructure {
class OnWayPointEventStructure extends BasePlayerTimeStructure {
private $raceTime;
private $lapTime;
private $stuntsScore;
@ -29,7 +29,7 @@ class OnEventWayPointStructure extends BasePlayerTimeStructure {
private $distance;
/**
* OnEventWayPointStructure constructor.
* OnWayPointEventStructure constructor.
*
* @param \ManiaControl\ManiaControl $maniaControl
* @param $data