2017-03-29 13:28:32 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl\Callbacks\Structures\TrackMania;
|
|
|
|
|
2017-03-30 19:39:23 +02:00
|
|
|
use ManiaControl\Callbacks\Structures\Common\CommonScoresStructure;
|
2017-03-29 13:28:32 +02:00
|
|
|
use ManiaControl\Callbacks\Structures\TrackMania\Models\PlayerScore;
|
|
|
|
use ManiaControl\Callbacks\Structures\TrackMania\Models\TeamScore;
|
|
|
|
use ManiaControl\ManiaControl;
|
|
|
|
|
|
|
|
/**
|
2017-03-30 19:39:23 +02:00
|
|
|
* Structure Class for the Trackmania OnScores Structure Callback
|
2017-03-29 13:28:32 +02:00
|
|
|
*
|
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
|
|
|
* @copyright 2014-2017 ManiaControl Team
|
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
|
|
|
*/
|
2017-03-30 19:39:23 +02:00
|
|
|
class OnScoresStructure extends CommonScoresStructure {
|
2017-03-29 13:28:32 +02:00
|
|
|
|
|
|
|
public function __construct(ManiaControl $maniaControl, $data) {
|
|
|
|
parent::__construct($maniaControl, $data);
|
|
|
|
|
|
|
|
$jsonObj = $this->getPlainJsonObject();
|
|
|
|
|
|
|
|
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);
|
2017-03-30 19:39:23 +02:00
|
|
|
$playerScore->setBestRaceTime($jsonPlayer->bestracetime);
|
|
|
|
$playerScore->setBestLapTime($jsonPlayer->bestlaptime);
|
|
|
|
$playerScore->setStuntScore($jsonPlayer->stuntscore);
|
2017-03-29 13:28:32 +02:00
|
|
|
|
|
|
|
$this->playerScores[$jsonPlayer->login] = $playerScore;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|