added scores shootmania callback -> TODO implement players there in a good way, maybe a Object including these properties and a getPlayer() method with a reference to the player (setable without maniacontrol reference in the object itself)

This commit is contained in:
kremsy 2017-03-25 12:55:09 +01:00
parent 970d54cc35
commit 4804e0ab55
5 changed files with 237 additions and 14 deletions

View File

@ -0,0 +1,14 @@
<?php
/**
* Created by PhpStorm.
* User: Lukas
* Date: 25. Mär. 2017
* Time: 12:44
*/
namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
class PlayerScore {
}

View File

@ -0,0 +1,88 @@
<?php
/**
* Created by PhpStorm.
* User: Lukas
* Date: 25. Mär. 2017
* Time: 12:43
*/
namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
class TeamScore {
private $id;
private $name;
private $roundPoints;
private $mapPoints;
private $matchPoints;
/**
* @return mixed
*/
public function getId() {
return $this->id;
}
/**
* @param mixed $id
*/
public function setId($id) {
$this->id = $id;
}
/**
* @return mixed
*/
public function getName() {
return $this->name;
}
/**
* @param mixed $name
*/
public function setName($name) {
$this->name = $name;
}
/**
* @return mixed
*/
public function getRoundPoints() {
return $this->roundPoints;
}
/**
* @param mixed $roundPoints
*/
public function setRoundPoints($roundPoints) {
$this->roundPoints = $roundPoints;
}
/**
* @return mixed
*/
public function getMapPoints() {
return $this->mapPoints;
}
/**
* @param mixed $mapPoints
*/
public function setMapPoints($mapPoints) {
$this->mapPoints = $mapPoints;
}
/**
* @return mixed
*/
public function getMatchPoints() {
return $this->matchPoints;
}
/**
* @param mixed $matchPoints
*/
public function setMatchPoints($matchPoints) {
$this->matchPoints = $matchPoints;
}
}

View File

@ -18,8 +18,8 @@ use ManiaControl\Players\Player;
*/ */
class OnCaptureStructure extends BaseStructure { class OnCaptureStructure extends BaseStructure {
public $time; public $time;
public $landMark; private $landMark;
private $playerArray = array(); private $playerArray = array();
@ -46,6 +46,11 @@ class OnCaptureStructure extends BaseStructure {
$this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter); $this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter);
} }
/** Dumps the Object with some Information */
public function dump() {
var_dump($this->landMark);
parent::dump();
}
/** /**
* Get the logins * Get the logins

View File

@ -20,10 +20,10 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure {
public $time; public $time;
public $weapon; public $weapon;
public $damage; public $damage;
public $shooterPosition;
public $victimPosition;
public $distance = 0; //Note no distance on the OnHit and ArmorEmpty yet public $distance = 0; //Note no distance on the OnHit and ArmorEmpty yet
private $shooterPosition;
private $victimPosition;
protected $shooter; protected $shooter;
protected $victim; protected $victim;
@ -40,10 +40,10 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure {
public function __construct(ManiaControl $maniaControl, $data) { public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data); parent::__construct($maniaControl, $data);
$jsonObj = $this->getPlainJsonObject(); $jsonObj = $this->getPlainJsonObject();
$this->time = $jsonObj->time; $this->time = $jsonObj->time;
$this->weapon = $jsonObj->weapon; $this->weapon = $jsonObj->weapon;
$this->damage = $jsonObj->damage; $this->damage = $jsonObj->damage;
$this->shooterPosition = new Position(); $this->shooterPosition = new Position();
$this->shooterPosition->setX($jsonObj->shooterposition->x); $this->shooterPosition->setX($jsonObj->shooterposition->x);
@ -63,6 +63,17 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure {
$this->victim = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim); $this->victim = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim);
} }
/** Dumps the Object with some Information */
public function dump() {
var_dump("Dump of property Shooter Position");
var_dump($this->shooterPosition);
var_dump("Dump of property Victim Position");
var_dump($this->victimPosition);
parent::dump();
var_dump("With getShooter() you get a Player Object");
var_dump("With getVictim() you get a Player Object");
}
/** /**
* @return int * @return int
*/ */
@ -123,10 +134,4 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure {
return $this->distance; return $this->distance;
} }
/** Dumps the Object with some Information */
public function dump() {
parent::dump();
var_dump("With getShooter() you get a Player Object");
var_dump("With getVictim() you get a Player Object");
}
} }

View File

@ -0,0 +1,111 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\BaseStructure;
use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
/**
* 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 {
public $responseId;
public $section;
public $useTeams;
public $winnerTeam;
public $winnerPlayer;
private $teamScores = array();
public $players; //TODO implement
//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
}
/** Dumps the Object with some Information */
public function dump() {
parent::dump();
var_dump("With getWinnerPlayer() you get a Player Object");
var_dump($this->teamScores);
}
/**
* @return Player
*/
public function getWinnerPlayer() {
return $this->winnerPlayer;
}
/**
* @return mixed
*/
public function getResponseId() {
return $this->responseId;
}
/**
* @return mixed
*/
public function getSection() {
return $this->section;
}
/**
* @return boolean
*/
public function getUseTeams() {
return $this->useTeams;
}
/**
* @return int
*/
public function getWinnerTeam() {
return $this->winnerTeam;
}
/**
* @return TeamScore[]
*/
public function getTeamScores() {
return $this->teamScores;
}
/**
* @return mixed
*/
public function getPlayers() {
//TODO proper implementation
return $this->players;
}
}