From 3aab01b98b36b23a699d080ce6b8744b64a07bb6 Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 14 Apr 2017 17:02:00 +0200 Subject: [PATCH] implemented all trackmania callbacks --- core/Callbacks/Callbacks.php | 63 ++------ core/Callbacks/LibXmlRpcCallbacks.php | 16 -- core/Callbacks/ShootManiaCallbacks.php | 4 +- .../Structures/ArmorEmptyStructure.php | 88 ---------- .../Callbacks/Structures/CaptureStructure.php | 60 ------- .../Common/UIPropertiesBaseStructure.php | 59 +++++++ .../Structures/NearMissStructure.php | 78 --------- .../Structures/PlayerHitStructure.php | 122 -------------- .../OnPointsRepartitionStructure.php | 41 +++++ .../TrackMania/OnRespawnStructure.php | 114 +++++++++++++ ...ture.php => OnStartLineEventStructure.php} | 2 +- .../TrackMania/OnStuntEventStructure.php | 152 ++++++++++++++++++ .../OnWarmupStartEndRoundStructure.php | 53 ++++++ ...cture.php => OnWayPointEventStructure.php} | 4 +- core/Callbacks/TrackManiaCallbacks.php | 32 ++-- core/Server/RankingManager.php | 1 + 16 files changed, 458 insertions(+), 431 deletions(-) delete mode 100644 core/Callbacks/Structures/ArmorEmptyStructure.php delete mode 100644 core/Callbacks/Structures/CaptureStructure.php create mode 100644 core/Callbacks/Structures/Common/UIPropertiesBaseStructure.php delete mode 100644 core/Callbacks/Structures/NearMissStructure.php delete mode 100644 core/Callbacks/Structures/PlayerHitStructure.php create mode 100644 core/Callbacks/Structures/TrackMania/OnPointsRepartitionStructure.php create mode 100644 core/Callbacks/Structures/TrackMania/OnRespawnStructure.php rename core/Callbacks/Structures/TrackMania/{OnEventStartLineStructure.php => OnStartLineEventStructure.php} (85%) create mode 100644 core/Callbacks/Structures/TrackMania/OnStuntEventStructure.php create mode 100644 core/Callbacks/Structures/TrackMania/OnWarmupStartEndRoundStructure.php rename core/Callbacks/Structures/TrackMania/{OnEventWayPointStructure.php => OnWayPointEventStructure.php} (97%) diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index ab4985c4..73a4abd7 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -73,9 +73,8 @@ interface Callbacks { const MP_USES_TEAMMODE = 'Maniaplanet.Mode.UseTeams'; const MP_PAUSE_STATUS = 'Maniaplanet.Pause.Status'; - const SM_UIPROPERTIES = 'Shootmania.UI.Properties'; - const SM_SCORES = "Shootmania.Scores"; - + const SM_UIPROPERTIES = 'Shootmania.UI.Properties'; + const SM_SCORES = "Shootmania.Scores"; const SM_ONEVENTDEFAULT = "Shootmania.Event.Default"; const SM_ONSHOOT = "Shootmania.Event.OnShoot"; const SM_ONHIT = "Shootmania.Event.OnHit"; @@ -135,21 +134,18 @@ interface Callbacks { * * @see \ManiaControl\Players\PlayerManager::CB_PLAYERDISCONNECT */ - const TM_ONPLAYERREMOVED = "Trackmania.Event.OnPlayerRemoved"; - - const TM_ONWAYPOINT = "Trackmania.Event.WayPoint"; - const TM_ONGIVEUP = "Trackmania.Event.GiveUp"; - const TM_ONRESPAWN = "Trackmania.Event.Respawn"; - const TM_ONSTUNT = "Trackmania.Event.Stunt"; - const TM_ONSTARTCOUNTDOWN = "Trackmania.Event.StartCountdown"; - const TM_SCORES = "Trackmania.Scores"; - const TM_WARMUPSTART = "Trackmania.WarmUp.Start"; - const TM_WARMUPSTARTROUND = "Trackmania.WarmUp.StartRound"; - const TM_WARMUPENDROUND = "Trackmania.WarmUp.EndRound"; - const TM_WARMUPEND = "Trackmania.WarmUp.End"; - - const TM_UIPROPERTIES = 'Trackmania.UI.Properties'; - + const TM_ONPLAYERREMOVED = "Trackmania.Event.OnPlayerRemoved"; + const TM_ONWAYPOINT = "Trackmania.Event.WayPoint"; + const TM_ONGIVEUP = "Trackmania.Event.GiveUp"; + const TM_ONRESPAWN = "Trackmania.Event.Respawn"; + const TM_ONSTUNT = "Trackmania.Event.Stunt"; + const TM_ONSTARTCOUNTDOWN = "Trackmania.Event.StartCountdown"; + const TM_SCORES = "Trackmania.Scores"; + const TM_WARMUPSTART = "Trackmania.WarmUp.Start"; + const TM_WARMUPSTARTROUND = "Trackmania.WarmUp.StartRound"; + const TM_WARMUPENDROUND = "Trackmania.WarmUp.EndRound"; + const TM_WARMUPEND = "Trackmania.WarmUp.End"; + const TM_UIPROPERTIES = 'Trackmania.UI.Properties'; const TM_POINTSREPARTITION = 'Trackmania.PointsRepartition'; //ManiaControl Callbacks @@ -301,38 +297,7 @@ interface Callbacks { * @deprecated */ const AFKSTATUS = 'Callbacks.AfkStatus'; - /** Returns if the GameMode has Warmup activated, returned after param1 Scores - * - * @deprecated - */ - const WARMUPSTATUS = 'Callbacks.WarmupStatus'; - /** OnShoot Callback: Player, WeaponNumber (see Weapons Structure) - * - * @deprecated - */ - const ONSHOOT = 'Callbacks.OnShoot'; - - /** OnHit Callback: PlayerHitStructure - * - * @deprecated - */ - const ONHIT = 'Callbacks.OnHit'; - /** OnNearMiss Callback: NearMissStructure - * - * @deprecated - */ - const ONNEARMISS = 'Callbacks.OnNearMiss'; - /** OnArmorEmpty Callback: ArmorEmptyStructure - * - * @deprecated - */ - const ONARMOREMPTY = 'Callbacks.OnArmorEmpty'; - /** OnCapture Callback: CaptureStructure - * - * @deprecated - */ - const ONCAPTURE = 'Callbacks.OnCapture'; /** OnPlayerRequestRespawn Callback: Player * * @deprecated diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index 48367551..90ab58d9 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -231,22 +231,6 @@ class LibXmlRpcCallbacks implements CallbackListener { case 'LibXmlRpc_OnStunt': $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONSTUNT, $data); break; - case 'LibXmlRpc_OnShoot': - $player = $this->maniaControl->getPlayerManager()->getPlayer($data[0]); - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONSHOOT, $player, $data[1]); - break; - case 'LibXmlRpc_OnHit': - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONHIT, new PlayerHitStructure($this->maniaControl, $data)); - break; - case 'LibXmlRpc_OnNearMiss': - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONNEARMISS, new NearMissStructure($this->maniaControl, $data)); - break; - case 'LibXmlRpc_OnArmorEmpty': - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONARMOREMPTY, new ArmorEmptyStructure($this->maniaControl, $data)); - break; - case 'LibXmlRpc_OnCapture': - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONCAPTURE, new CaptureStructure($this->maniaControl, $data)); - break; case 'LibXmlRpc_OnPlayerRequestRespawn': $player = $this->maniaControl->getPlayerManager()->getPlayer($data[0]); $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONPLAYERREQUESTRESPAWN, $player); diff --git a/core/Callbacks/ShootManiaCallbacks.php b/core/Callbacks/ShootManiaCallbacks.php index f80f3223..028bd91d 100644 --- a/core/Callbacks/ShootManiaCallbacks.php +++ b/core/Callbacks/ShootManiaCallbacks.php @@ -4,6 +4,7 @@ namespace ManiaControl\Callbacks; use ManiaControl\Callbacks\Models\RecordCallback; use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure; +use ManiaControl\Callbacks\Structures\Common\UIPropertiesBaseStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnActionCustomEventStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnActionEvent; use ManiaControl\Callbacks\Structures\ShootMania\OnArmorEmptyStructure; @@ -81,8 +82,7 @@ class ShootManiaCallbacks implements CallbackListener { $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnScoresStructure($this->maniaControl, $data)); break; case Callbacks::SM_UIPROPERTIES: - //TODO structure, but wait for further update - $this->maniaControl->getCallbackManager()->triggerCallback($name, $data); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new UIPropertiesBaseStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONEVENTDEFAULT: $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnDefaultEventStructure($this->maniaControl, $data)); diff --git a/core/Callbacks/Structures/ArmorEmptyStructure.php b/core/Callbacks/Structures/ArmorEmptyStructure.php deleted file mode 100644 index bf53c1ea..00000000 --- a/core/Callbacks/Structures/ArmorEmptyStructure.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @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; - } -} diff --git a/core/Callbacks/Structures/CaptureStructure.php b/core/Callbacks/Structures/CaptureStructure.php deleted file mode 100644 index f1f524cb..00000000 --- a/core/Callbacks/Structures/CaptureStructure.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @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; - } -} diff --git a/core/Callbacks/Structures/Common/UIPropertiesBaseStructure.php b/core/Callbacks/Structures/Common/UIPropertiesBaseStructure.php new file mode 100644 index 00000000..a47716d2 --- /dev/null +++ b/core/Callbacks/Structures/Common/UIPropertiesBaseStructure.php @@ -0,0 +1,59 @@ + + * @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); + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/NearMissStructure.php b/core/Callbacks/Structures/NearMissStructure.php deleted file mode 100644 index a0cd687f..00000000 --- a/core/Callbacks/Structures/NearMissStructure.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @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; - } - -} diff --git a/core/Callbacks/Structures/PlayerHitStructure.php b/core/Callbacks/Structures/PlayerHitStructure.php deleted file mode 100644 index bef91a03..00000000 --- a/core/Callbacks/Structures/PlayerHitStructure.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @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); - } -} diff --git a/core/Callbacks/Structures/TrackMania/OnPointsRepartitionStructure.php b/core/Callbacks/Structures/TrackMania/OnPointsRepartitionStructure.php new file mode 100644 index 00000000..ee944347 --- /dev/null +++ b/core/Callbacks/Structures/TrackMania/OnPointsRepartitionStructure.php @@ -0,0 +1,41 @@ + + * @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; + } + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/TrackMania/OnRespawnStructure.php b/core/Callbacks/Structures/TrackMania/OnRespawnStructure.php new file mode 100644 index 00000000..f3368c53 --- /dev/null +++ b/core/Callbacks/Structures/TrackMania/OnRespawnStructure.php @@ -0,0 +1,114 @@ + + * @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; + } + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/TrackMania/OnEventStartLineStructure.php b/core/Callbacks/Structures/TrackMania/OnStartLineEventStructure.php similarity index 85% rename from core/Callbacks/Structures/TrackMania/OnEventStartLineStructure.php rename to core/Callbacks/Structures/TrackMania/OnStartLineEventStructure.php index 7604b48b..990de29b 100644 --- a/core/Callbacks/Structures/TrackMania/OnEventStartLineStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnStartLineEventStructure.php @@ -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 { } \ No newline at end of file diff --git a/core/Callbacks/Structures/TrackMania/OnStuntEventStructure.php b/core/Callbacks/Structures/TrackMania/OnStuntEventStructure.php new file mode 100644 index 00000000..2aff23ed --- /dev/null +++ b/core/Callbacks/Structures/TrackMania/OnStuntEventStructure.php @@ -0,0 +1,152 @@ + + * @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; + } + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/TrackMania/OnWarmupStartEndRoundStructure.php b/core/Callbacks/Structures/TrackMania/OnWarmupStartEndRoundStructure.php new file mode 100644 index 00000000..3e4c48d3 --- /dev/null +++ b/core/Callbacks/Structures/TrackMania/OnWarmupStartEndRoundStructure.php @@ -0,0 +1,53 @@ + + * @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; + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/TrackMania/OnEventWayPointStructure.php b/core/Callbacks/Structures/TrackMania/OnWayPointEventStructure.php similarity index 97% rename from core/Callbacks/Structures/TrackMania/OnEventWayPointStructure.php rename to core/Callbacks/Structures/TrackMania/OnWayPointEventStructure.php index 43a036d6..f147a59d 100644 --- a/core/Callbacks/Structures/TrackMania/OnEventWayPointStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnWayPointEventStructure.php @@ -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 diff --git a/core/Callbacks/TrackManiaCallbacks.php b/core/Callbacks/TrackManiaCallbacks.php index bf0c661c..4ef87eab 100644 --- a/core/Callbacks/TrackManiaCallbacks.php +++ b/core/Callbacks/TrackManiaCallbacks.php @@ -4,11 +4,16 @@ namespace ManiaControl\Callbacks; use ManiaControl\Callbacks\Models\RecordCallback; use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure; +use ManiaControl\Callbacks\Structures\Common\UIPropertiesBaseStructure; use ManiaControl\Callbacks\Structures\TrackMania\OnCommandStructure; use ManiaControl\Callbacks\Structures\TrackMania\OnDefaultEventStructure; -use ManiaControl\Callbacks\Structures\TrackMania\OnEventStartLineStructure; -use ManiaControl\Callbacks\Structures\TrackMania\OnEventWayPointStructure; +use ManiaControl\Callbacks\Structures\TrackMania\OnPointsRepartitionStructure; +use ManiaControl\Callbacks\Structures\TrackMania\OnRespawnStructure; use ManiaControl\Callbacks\Structures\TrackMania\OnScoresStructure; +use ManiaControl\Callbacks\Structures\TrackMania\OnStartLineEventStructure; +use ManiaControl\Callbacks\Structures\TrackMania\OnStuntEventStructure; +use ManiaControl\Callbacks\Structures\TrackMania\OnWarmupStartEndRoundStructure; +use ManiaControl\Callbacks\Structures\TrackMania\OnWayPointEventStructure; use ManiaControl\ManiaControl; use ManiaControl\Utils\Formatter; @@ -51,7 +56,6 @@ class TrackManiaCallbacks implements CallbackListener { //return; //Leave that disabled while testing/implementing Callbacks } switch ($name) { - //MP4 New Callbacks case Callbacks::TM_SCORES: $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnScoresStructure($this->maniaControl, $data)); break; @@ -59,37 +63,39 @@ class TrackManiaCallbacks implements CallbackListener { $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnDefaultEventStructure($this->maniaControl, $data)); break; case Callbacks::TM_ONEVENTSTARTLINE: - $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnEventStartLineStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnStartLineEventStructure($this->maniaControl, $data)); break; case Callbacks::TM_ONCOMMAND: $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnCommandStructure($this->maniaControl, $data)); break; case Callbacks::TM_ONPLAYERADDED: case Callbacks::TM_ONPLAYERREMOVED: + case Callbacks::TM_ONGIVEUP: + case Callbacks::TM_ONSTARTCOUNTDOWN: $this->maniaControl->getCallbackManager()->triggerCallback($name, new BasePlayerTimeStructure($this->maniaControl, $data)); break; case Callbacks::TM_ONWAYPOINT: - $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnEventWayPointStructure($this->maniaControl, $data)); - break; - case Callbacks:: TM_ONGIVEUP: + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnWayPointEventStructure($this->maniaControl, $data)); break; case Callbacks::TM_ONRESPAWN: + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnRespawnStructure($this->maniaControl, $data)); break; case Callbacks::TM_ONSTUNT: - break; - case Callbacks::TM_ONSTARTCOUNTDOWN: + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnStuntEventStructure($this->maniaControl, $data)); break; case Callbacks::TM_WARMUPSTART: + case Callbacks::TM_WARMUPEND: + $this->maniaControl->getCallbackManager()->triggerCallback($name); break; case Callbacks::TM_WARMUPSTARTROUND: - break; case Callbacks::TM_WARMUPENDROUND: + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnWarmupStartEndRoundStructure($this->maniaControl, $data)); break; - case Callbacks::TM_WARMUPEND: + case Callbacks::TM_POINTSREPARTITION: + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnPointsRepartitionStructure($this->maniaControl, $data)); break; case Callbacks::TM_UIPROPERTIES: - //TODO structure, but wait for further update - $this->maniaControl->getCallbackManager()->triggerCallback($name, $data); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new UIPropertiesBaseStructure($this->maniaControl, $data)); break; } } diff --git a/core/Server/RankingManager.php b/core/Server/RankingManager.php index de6123b3..553061af 100644 --- a/core/Server/RankingManager.php +++ b/core/Server/RankingManager.php @@ -14,6 +14,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; /** * Class managing Rankings * + * @deprecated * @author ManiaControl Team * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3