First Batch TM Callbacks
Gonna work on the others
This commit is contained in:
134
core/Callbacks/Structures/TrackMania/Models/PlayerScore.php
Normal file
134
core/Callbacks/Structures/TrackMania/Models/PlayerScore.php
Normal file
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Callbacks\Structures\TrackMania\Models;
|
||||
|
||||
use ManiaControl\General\UsageInformationAble;
|
||||
use ManiaControl\General\UsageInformationTrait;
|
||||
use ManiaControl\Players\Player;
|
||||
|
||||
/**
|
||||
* PlayerScore Model
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2017 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class PlayerScore implements UsageInformationAble {
|
||||
use UsageInformationTrait;
|
||||
|
||||
private $player;
|
||||
private $rank;
|
||||
private $roundPoints;
|
||||
private $mapPoints;
|
||||
private $matchPoints;
|
||||
private $bestraceTime;
|
||||
private $bestlapTime;
|
||||
private $stuntScore;
|
||||
|
||||
/**
|
||||
* Returns the Player
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public function getPlayer() {
|
||||
return $this->player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
*/
|
||||
public function setPlayer(Player $player) {
|
||||
$this->player = $player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Rank
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRank() {
|
||||
return $this->rank;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Rank
|
||||
*
|
||||
* @param int $rank
|
||||
*/
|
||||
public function setRank($rank) {
|
||||
$this->rank = $rank;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Round Points
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRoundPoints() {
|
||||
return $this->roundPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the RoundPoints
|
||||
*
|
||||
* @param int $roundPoints
|
||||
*/
|
||||
public function setRoundPoints($roundPoints) {
|
||||
$this->roundPoints = $roundPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Map Points
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMapPoints() {
|
||||
return $this->mapPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Map Points
|
||||
*
|
||||
* @param int $mapPoints
|
||||
*/
|
||||
public function setMapPoints($mapPoints) {
|
||||
$this->mapPoints = $mapPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bestRaceTime
|
||||
*
|
||||
* @param int $bestraceTime
|
||||
*/
|
||||
public function getbestraceTime(){
|
||||
return $this->bestraceTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bestRaceTime
|
||||
*
|
||||
* @param int $bestraceTime
|
||||
*/
|
||||
public function getbestraceTime(){
|
||||
return $this->bestraceTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bestlapTime
|
||||
*
|
||||
* @param int $bestlapTime
|
||||
*/
|
||||
public function getbestlapTime(){
|
||||
return $this->bestlapTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the StuntScore
|
||||
*
|
||||
* @param int $bestraceTime
|
||||
*/
|
||||
public function getstuntScore(){
|
||||
return $this->stuntScore;
|
||||
}
|
||||
|
||||
}
|
93
core/Callbacks/Structures/TrackMania/Models/TeamScore.php
Normal file
93
core/Callbacks/Structures/TrackMania/Models/TeamScore.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Callbacks\Structures\TrackMania\Models;
|
||||
|
||||
use ManiaControl\General\UsageInformationAble;
|
||||
use ManiaControl\General\UsageInformationTrait;
|
||||
|
||||
/**
|
||||
* TeamScore Model
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2017 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class TeamScore implements UsageInformationAble {
|
||||
use UsageInformationTrait;
|
||||
|
||||
private $id;
|
||||
private $name;
|
||||
private $roundPoints;
|
||||
private $mapPoints;
|
||||
private $matchPoints;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id
|
||||
*/
|
||||
public function setId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $name
|
||||
*/
|
||||
public function setName($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRoundPoints() {
|
||||
return $this->roundPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $roundPoints
|
||||
*/
|
||||
public function setRoundPoints($roundPoints) {
|
||||
$this->roundPoints = $roundPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMapPoints() {
|
||||
return $this->mapPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mapPoints
|
||||
*/
|
||||
public function setMapPoints($mapPoints) {
|
||||
$this->mapPoints = $mapPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMatchPoints() {
|
||||
return $this->matchPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $matchPoints
|
||||
*/
|
||||
public function setMatchPoints($matchPoints) {
|
||||
$this->matchPoints = $matchPoints;
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Callbacks\Structures\TrackMania;
|
||||
|
||||
|
||||
use ManiaControl\Callbacks\Structures\BaseStructure;
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
/**
|
||||
* Structure Class for the EventStartLine Structure Callback
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2017 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnEventStartLineStructure extends BaseStructure {
|
||||
private $time;
|
||||
private $player;
|
||||
|
||||
public function __construct(ManiaControl $maniaControl, $data) {
|
||||
parent::__construct($maniaControl, $data);
|
||||
|
||||
$this->time = $this->getPlainJsonObject()->time;
|
||||
$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Server time when the event occured
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTime() {
|
||||
return $this->time;
|
||||
}
|
||||
|
||||
/**
|
||||
* < player who triggered the action
|
||||
*
|
||||
* @return \ManiaControl\Players\Player
|
||||
*/
|
||||
public function getPlayer() {
|
||||
return $this->player;
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Callbacks\Structures\TrackMania;
|
||||
|
||||
|
||||
use ManiaControl\Callbacks\Structures\BaseStructure;
|
||||
use ManiaControl\Callbacks\Models\RecordCallback;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Utils\Formatter;
|
||||
|
||||
/**
|
||||
* Structure Class for the Default Event Structure Callback
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2017 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnEventWayPointStructure extends BaseStructure {
|
||||
private $time;
|
||||
private $player;
|
||||
private $racetime;
|
||||
private $laptime;
|
||||
private $stuntsscore;
|
||||
private $checkpointinrace;
|
||||
private $checkpointinlap;
|
||||
private $isendrace;
|
||||
private $isendlap;
|
||||
private $blockid;
|
||||
private $speed;
|
||||
private $distance;
|
||||
|
||||
public function __construct(ManiaControl $maniaControl, $data) {
|
||||
parent::__construct($maniaControl, $data);
|
||||
|
||||
$this->time = $this->getPlainJsonObject()->time;
|
||||
$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login);
|
||||
$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;
|
||||
$this->isendrace = $this->getPlainJsonObject()->isendrace;
|
||||
$this->isendlap = $this->getPlainJsonObject()->isendlap;
|
||||
$this->blockid = $this->getPlainJsonObject()->blockid;
|
||||
$this->speed = $this->getPlainJsonObject()->speed;
|
||||
$this->distance = $this->getPlainJsonObject()->distance;
|
||||
|
||||
// Build callback
|
||||
$wayPointCallback = new RecordCallback();
|
||||
$wayPointCallback->rawCallback = $data;
|
||||
$wayPointCallback->setPlayer($this->player);
|
||||
$wayPointCallback->blockId = $this->blockid;
|
||||
$wayPointCallback->time = $this->racetime;
|
||||
$wayPointCallback->checkpoint = $this->checkpointinrace;
|
||||
$wayPointCallback->isEndRace = Formatter::parseBoolean($this->isendrace);
|
||||
$wayPointCallback->lapTime = $this->laptime;
|
||||
$wayPointCallback->lapCheckpoint = $this->checkpointinlap;
|
||||
$wayPointCallback->lap = 0;
|
||||
$wayPointCallback->isEndLap = Formatter::parseBoolean($this->isendlap);
|
||||
if ($wayPointCallback->checkpoint > 0) {
|
||||
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||
$wayPointCallback->lap += $wayPointCallback->checkpoint / $currentMap->nbCheckpoints;
|
||||
}
|
||||
if ($wayPointCallback->isEndRace) {
|
||||
$wayPointCallback->name = $wayPointCallback::FINISH;
|
||||
} else if ($wayPointCallback->isEndLap) {
|
||||
$wayPointCallback->name = $wayPointCallback::LAPFINISH;
|
||||
} else {
|
||||
$wayPointCallback->name = $wayPointCallback::CHECKPOINT;
|
||||
}
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback($wayPointCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Server time when the event occured
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTime() {
|
||||
return $this->time;
|
||||
}
|
||||
|
||||
/**
|
||||
* < player who triggered the action
|
||||
*
|
||||
* @return \ManiaControl\Players\Player
|
||||
*/
|
||||
public function getPlayer() {
|
||||
return $this->player;
|
||||
}
|
||||
|
||||
}
|
125
core/Callbacks/Structures/TrackMania/OnScoresStructure.php
Normal file
125
core/Callbacks/Structures/TrackMania/OnScoresStructure.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Callbacks\Structures\TrackMania;
|
||||
|
||||
|
||||
use ManiaControl\Callbacks\Structures\BaseStructure;
|
||||
use ManiaControl\Callbacks\Structures\TrackMania\Models\PlayerScore;
|
||||
use ManiaControl\Callbacks\Structures\TrackMania\Models\TeamScore;
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
/**
|
||||
* Structure Class for the OnScores Structure Callback
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2017 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnScoresStructure extends BaseStructure {
|
||||
private $responseId;
|
||||
private $section;
|
||||
private $useTeams;
|
||||
private $winnerTeam;
|
||||
private $winnerPlayer;
|
||||
private $teamScores = array();
|
||||
private $playerScores = array();
|
||||
|
||||
//TODO test
|
||||
public function __construct(ManiaControl $maniaControl, $data) {
|
||||
parent::__construct($maniaControl, $data);
|
||||
|
||||
$jsonObj = $this->getPlainJsonObject();
|
||||
|
||||
$this->responseId = $jsonObj->responseId;
|
||||
$this->section = $jsonObj->section;
|
||||
$this->useTeams = $jsonObj->useTeams;
|
||||
$this->winnerTeam = $jsonObj->winnerTeam;
|
||||
|
||||
$this->winnerPlayer = $this->maniaControl->getPlayerManager()->getPlayer($jsonObj->winnerplayer);
|
||||
|
||||
foreach ($jsonObj->teams as $team) {
|
||||
$teamScore = new TeamScore();
|
||||
$teamScore->setId($team->id);
|
||||
$teamScore->setName($team->name);
|
||||
$teamScore->setRoundPoints($team->roundpoints);
|
||||
$teamScore->setMatchPoints($team->matchpoints);
|
||||
$teamScore->setMapPoints($team->mappoints);
|
||||
|
||||
$this->teamScores[$team->id] = $teamScore; //TODO verify that different teams have different ids
|
||||
}
|
||||
|
||||
foreach ($jsonObj->players as $jsonPlayer) {
|
||||
$playerScore = new PlayerScore();
|
||||
$playerScore->setPlayer($this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login));
|
||||
$playerScore->setRank($jsonPlayer->rank);
|
||||
$playerScore->setRoundPoints($jsonPlayer->roundpoints);
|
||||
$playerScore->setMapPoints($jsonPlayer->mappoints);
|
||||
|
||||
$this->playerScores[$jsonPlayer->login] = $playerScore;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Winner Player Object
|
||||
*
|
||||
* @return \ManiaControl\Players\Player
|
||||
*/
|
||||
public function getWinnerPlayer() {
|
||||
return $this->winnerPlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Response Id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResponseId() {
|
||||
return $this->responseId;
|
||||
}
|
||||
|
||||
/**
|
||||
* < Current progress of the match. Can be "" | "EndRound" | "EndMap" | "EndMatch"
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSection() {
|
||||
return $this->section;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the GameMode uses Teams or not
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getUseTeams() {
|
||||
return $this->useTeams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Winner Team Id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getWinnerTeamId() {
|
||||
return $this->winnerTeam;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TeamScores
|
||||
*
|
||||
* @return TeamScore[]
|
||||
*/
|
||||
public function getTeamScores() {
|
||||
return $this->teamScores;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Player Scores
|
||||
*
|
||||
* @return PlayerScore[]
|
||||
*/
|
||||
public function getPlayerScores() {
|
||||
return $this->playerScores;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user