49 lines
1.6 KiB
PHP
49 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace ManiaControl\Callbacks\Structures\ShootMania;
|
|
|
|
|
|
use ManiaControl\Callbacks\Structures\Common\CommonScoresStructure;
|
|
use ManiaControl\Callbacks\Structures\ShootMania\Models\PlayerScore;
|
|
use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore;
|
|
use ManiaControl\ManiaControl;
|
|
|
|
|
|
/**
|
|
* Structure Class for the Shootmania 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 CommonScoresStructure {
|
|
|
|
public function __construct(ManiaControl $maniaControl, $data) {
|
|
parent::__construct($maniaControl, $data);
|
|
|
|
$jsonObj = $this->getPlainJsonObject();
|
|
|
|
foreach ($jsonObj->teams as $team) {
|
|
//if($this instanceof OnScoresStructure)
|
|
$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;
|
|
}
|
|
|
|
}
|
|
} |