2017-03-25 12:55:09 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl\Callbacks\Structures\ShootMania;
|
|
|
|
|
|
|
|
|
|
|
|
use ManiaControl\Callbacks\Structures\BaseStructure;
|
|
|
|
use ManiaControl\Callbacks\Structures\ShootMania\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 {
|
2017-03-26 12:42:20 +02:00
|
|
|
private $responseId;
|
|
|
|
private $section;
|
|
|
|
private $useTeams;
|
|
|
|
private $winnerTeam;
|
|
|
|
private $winnerPlayer;
|
2017-03-25 12:55:09 +01:00
|
|
|
private $teamScores = array();
|
2017-03-26 12:42:20 +02:00
|
|
|
private $players; //TODO implement
|
2017-03-25 12:55:09 +01:00
|
|
|
|
|
|
|
//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
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO implement player
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-03-26 12:42:20 +02:00
|
|
|
* Get the Winner Player Object
|
|
|
|
*
|
|
|
|
* @return \ManiaControl\Players\Player
|
2017-03-25 12:55:09 +01:00
|
|
|
*/
|
|
|
|
public function getWinnerPlayer() {
|
|
|
|
return $this->winnerPlayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-03-26 12:42:20 +02:00
|
|
|
* Get the Response Id
|
|
|
|
*
|
|
|
|
* @return string
|
2017-03-25 12:55:09 +01:00
|
|
|
*/
|
|
|
|
public function getResponseId() {
|
|
|
|
return $this->responseId;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-03-26 12:42:20 +02:00
|
|
|
* < Current progress of the match. Can be "" | "EndRound" | "EndMap" | "EndMatch"
|
|
|
|
*
|
|
|
|
* @return string
|
2017-03-25 12:55:09 +01:00
|
|
|
*/
|
|
|
|
public function getSection() {
|
|
|
|
return $this->section;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-03-26 12:42:20 +02:00
|
|
|
* Returns if the GameMode uses Teams or not
|
|
|
|
*
|
2017-03-25 12:55:09 +01:00
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function getUseTeams() {
|
|
|
|
return $this->useTeams;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-03-26 12:42:20 +02:00
|
|
|
* Get the Winner Team Id
|
|
|
|
*
|
2017-03-25 12:55:09 +01:00
|
|
|
* @return int
|
|
|
|
*/
|
2017-03-26 12:42:20 +02:00
|
|
|
public function getWinnerTeamId() {
|
2017-03-25 12:55:09 +01:00
|
|
|
return $this->winnerTeam;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-03-26 12:42:20 +02:00
|
|
|
* Returns the TeamScores
|
|
|
|
*
|
2017-03-25 12:55:09 +01:00
|
|
|
* @return TeamScore[]
|
|
|
|
*/
|
|
|
|
public function getTeamScores() {
|
|
|
|
return $this->teamScores;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-03-26 12:42:20 +02:00
|
|
|
* Get The Player Scores
|
|
|
|
*
|
2017-03-25 12:55:09 +01:00
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getPlayers() {
|
|
|
|
//TODO proper implementation
|
|
|
|
return $this->players;
|
|
|
|
}
|
|
|
|
}
|