2017-03-30 19:39:23 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl\Callbacks\Structures\Common;
|
|
|
|
|
|
|
|
|
|
|
|
use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore;
|
|
|
|
use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore;
|
2017-04-04 19:40:19 +02:00
|
|
|
use ManiaControl\General\JsonSerializable;
|
|
|
|
use ManiaControl\General\JsonSerializeTrait;
|
2017-03-30 19:39:23 +02:00
|
|
|
use ManiaControl\ManiaControl;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Structure Class for the OnScores Structure Callback
|
|
|
|
*
|
2017-04-07 23:26:35 +02:00
|
|
|
* @api
|
2017-03-30 19:39:23 +02:00
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
2019-01-05 21:02:24 +01:00
|
|
|
* @copyright 2014-2019 ManiaControl Team
|
2017-03-30 19:39:23 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
|
|
|
*/
|
2017-04-07 18:30:48 +02:00
|
|
|
class CommonScoresStructure extends BaseResponseStructure {
|
2017-03-30 19:39:23 +02:00
|
|
|
protected $section;
|
|
|
|
protected $useTeams;
|
|
|
|
protected $winnerTeam;
|
|
|
|
protected $winnerPlayer;
|
|
|
|
protected $teamScores = array();
|
|
|
|
protected $playerScores = array();
|
|
|
|
|
2017-04-07 23:26:35 +02:00
|
|
|
/**
|
|
|
|
* CommonScoresStructure constructor.
|
|
|
|
*
|
|
|
|
* @param \ManiaControl\ManiaControl $maniaControl
|
|
|
|
* @param $data
|
|
|
|
*/
|
2017-03-30 19:39:23 +02:00
|
|
|
public function __construct(ManiaControl $maniaControl, $data) {
|
|
|
|
parent::__construct($maniaControl, $data);
|
|
|
|
|
|
|
|
$jsonObj = $this->getPlainJsonObject();
|
|
|
|
|
|
|
|
$this->section = $jsonObj->section;
|
2017-03-30 22:04:29 +02:00
|
|
|
$this->useTeams = $jsonObj->useteams;
|
|
|
|
$this->winnerTeam = $jsonObj->winnerteam;
|
2017-03-30 19:39:23 +02:00
|
|
|
|
|
|
|
$this->winnerPlayer = $this->maniaControl->getPlayerManager()->getPlayer($jsonObj->winnerplayer);
|
|
|
|
|
|
|
|
foreach ($jsonObj->teams as $team) {
|
|
|
|
if ($this instanceof \ManiaControl\Callbacks\Structures\TrackMania\OnScoresStructure) {
|
|
|
|
$teamScore = new \ManiaControl\Callbacks\Structures\TrackMania\Models\TeamScore();
|
|
|
|
} else {
|
|
|
|
$teamScore = new \ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore();
|
|
|
|
}
|
|
|
|
|
2017-04-04 19:40:19 +02:00
|
|
|
$teamScore->setTeamId($team->id);
|
2017-03-30 19:39:23 +02:00
|
|
|
$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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Winner Player Object
|
|
|
|
*
|
2017-04-07 23:26:35 +02:00
|
|
|
* @api
|
2017-03-30 19:39:23 +02:00
|
|
|
* @return \ManiaControl\Players\Player
|
|
|
|
*/
|
|
|
|
public function getWinnerPlayer() {
|
|
|
|
return $this->winnerPlayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* < Current progress of the match. Can be "" | "EndRound" | "EndMap" | "EndMatch"
|
|
|
|
*
|
2017-04-07 23:26:35 +02:00
|
|
|
* @api
|
2017-03-30 19:39:23 +02:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getSection() {
|
|
|
|
return $this->section;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if the GameMode uses Teams or not
|
|
|
|
*
|
2017-04-07 23:26:35 +02:00
|
|
|
* @api
|
2017-03-30 19:39:23 +02:00
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function getUseTeams() {
|
|
|
|
return $this->useTeams;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Winner Team Id
|
|
|
|
*
|
2017-04-07 23:26:35 +02:00
|
|
|
* @api
|
2017-03-30 19:39:23 +02:00
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getWinnerTeamId() {
|
|
|
|
return $this->winnerTeam;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the TeamScores
|
|
|
|
*
|
2017-04-07 23:26:35 +02:00
|
|
|
* @api
|
2017-03-30 19:39:23 +02:00
|
|
|
* @return TeamScore[]
|
|
|
|
*/
|
|
|
|
public function getTeamScores() {
|
|
|
|
return $this->teamScores;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Player Scores
|
|
|
|
*
|
2017-04-07 23:26:35 +02:00
|
|
|
* @api
|
2017-03-30 19:39:23 +02:00
|
|
|
* @return CommonPlayerScore[]
|
|
|
|
*/
|
|
|
|
public function getPlayerScores() {
|
|
|
|
return $this->playerScores;
|
|
|
|
}
|
|
|
|
}
|