refactored Scores Structure

This commit is contained in:
kremsy
2017-03-30 19:39:23 +02:00
parent ee2facb427
commit e9ed9d910c
9 changed files with 353 additions and 479 deletions

View File

@ -3,41 +3,28 @@
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\BaseStructure;
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 OnScores Structure Callback
* 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 BaseStructure {
private $responseId;
private $section;
private $useTeams;
private $winnerTeam;
private $winnerPlayer;
private $teamScores = array();
private $playerScores = array();
class OnScoresStructure extends CommonScoresStructure {
//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) {
//if($this instanceof OnScoresStructure)
$teamScore = new TeamScore();
$teamScore->setId($team->id);
$teamScore->setName($team->name);
@ -59,67 +46,4 @@ class OnScoresStructure extends BaseStructure {
}
}
/**
* 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;
}
}