finished first version of shootmania callbacks

This commit is contained in:
kremsy 2017-03-27 22:21:59 +02:00
parent 4f94fe0275
commit 5a7ee1c9be
13 changed files with 510 additions and 30 deletions

View File

@ -4,11 +4,16 @@ namespace ManiaControl\Callbacks;
use ManiaControl\Callbacks\Models\RecordCallback; use ManiaControl\Callbacks\Models\RecordCallback;
use ManiaControl\Callbacks\Structures\EliteBeginTurnStructure; use ManiaControl\Callbacks\Structures\EliteBeginTurnStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnActionCustomEventStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnActionEvent;
use ManiaControl\Callbacks\Structures\ShootMania\OnCaptureStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnCaptureStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnCommandStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnCommandStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnDefaultEventStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnDefaultEventStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnHitNearMissArmorEmptyStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnHitNearMissArmorEmptyStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerObjectStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerRequestActionChange;
use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerRequestRespawnStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerRequestRespawnStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerTriggersSectorStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnShootStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnShootStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnShotDenyStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnShotDenyStructure;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
@ -88,6 +93,22 @@ class ShootManiaCallbacks implements CallbackListener {
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERREQUESTRESPAWN, new OnPlayerRequestRespawnStructure($this->maniaControl, $data)); $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERREQUESTRESPAWN, new OnPlayerRequestRespawnStructure($this->maniaControl, $data));
break; break;
case Callbacks::SM_ONACTIONCUSTOMEVENT: case Callbacks::SM_ONACTIONCUSTOMEVENT:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONACTIONCUSTOMEVENT, new OnActionCustomEventStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONACTIONEVENT:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONACTIONEVENT, new OnActionEvent($this->maniaControl, $data));
break;
case Callbacks::SM_ONPLAYERTOUCHESOBJECT:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERTOUCHESOBJECT, new OnPlayerObjectStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONPLAYERTRIGGERSSECTOR:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERTRIGGERSSECTOR, new OnPlayerTriggersSectorStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONPLAYERTHROWSOBJECT:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERTHROWSOBJECT, new OnPlayerObjectStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONPLAYERREQUESTACTIONCHANGE:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERREQUESTACTIONCHANGE, new OnPlayerRequestActionChange($this->maniaControl, $data));
break; break;
//Old Callbacks //Old Callbacks
case 'LibXmlRpc_Rankings': case 'LibXmlRpc_Rankings':

View File

@ -3,7 +3,19 @@
namespace ManiaControl\Callbacks\Structures\ShootMania\Models; namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
class Landmark { use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
/**
* Landmark Model
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Landmark implements UsageInformationAble {
use UsageInformationTrait;
private $tag = ""; private $tag = "";
private $order = 0; private $order = 0;
private $id = ""; private $id = "";

View File

@ -2,7 +2,92 @@
namespace ManiaControl\Callbacks\Structures\ShootMania\Models; namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
//TODO describtion use ManiaControl\General\UsageInformationAble;
class PlayerScore { use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Players\Player;
/**
* PlayerScore Model
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PlayerScore implements UsageInformationAble {
use UsageInformationTrait;
private $player;
private $rank;
private $roundPoints;
private $mapPoints;
/**
* Returns the Player
*
* @return Player
*/
public function getPlayer() {
return $this->player;
}
/**
* @param \ManiaControl\Players\Player $player
*/
public function setPlayer(Player $player) {
$this->player = $player;
}
/**
* Returns the Rank
*
* @return int
*/
public function getRank() {
return $this->rank;
}
/**
* Sets the Rank
*
* @param int $rank
*/
public function setRank($rank) {
$this->rank = $rank;
}
/**
* Gets the Round Points
*
* @return int
*/
public function getRoundPoints() {
return $this->roundPoints;
}
/**
* Sets the RoundPoints
*
* @param int $roundPoints
*/
public function setRoundPoints($roundPoints) {
$this->roundPoints = $roundPoints;
}
/**
* Gets the Map Points
*
* @return int
*/
public function getMapPoints() {
return $this->mapPoints;
}
/**
* Sets the Map Points
*
* @param int $mapPoints
*/
public function setMapPoints($mapPoints) {
$this->mapPoints = $mapPoints;
}
} }

View File

@ -3,8 +3,19 @@
namespace ManiaControl\Callbacks\Structures\ShootMania\Models; namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
//TODO describtion use ManiaControl\General\UsageInformationAble;
class Position { use ManiaControl\General\UsageInformationTrait;
/**
* Position Model
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Position implements UsageInformationAble {
use UsageInformationTrait;
private $x = 0; private $x = 0;
private $y = 0; private $y = 0;
private $z = 0; private $z = 0;

View File

@ -2,8 +2,19 @@
namespace ManiaControl\Callbacks\Structures\ShootMania\Models; namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
//TODO describtion use ManiaControl\General\UsageInformationAble;
class TeamScore { use ManiaControl\General\UsageInformationTrait;
/**
* TeamScore Model
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class TeamScore implements UsageInformationAble {
use UsageInformationTrait;
private $id; private $id;
private $name; private $name;
private $roundPoints; private $roundPoints;

View File

@ -0,0 +1,91 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnCustomEvent 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 OnActionCustomEventStructure extends BaseStructure {
private $time;
private $actionId;
private $shooter;
private $victim;
private $param1;
private $param2 = array();
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->actionId = $this->getPlainJsonObject()->actionid;
$this->victim = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim);
$this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter);
$this->param1 = $this->getPlainJsonObject()->param1;
$this->param2 = $this->getPlainJsonObject()->param2;
}
/**
* Returns Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* < Id of the action that triggered the event
*
* @return string
*/
public function getActionId() {
return $this->actionId;
}
/**
* < Login of the player who shot if any
*
* @return \ManiaControl\Players\Player
*/
public function getShooter() {
return $this->shooter;
}
/**
* < player who got hit if any
*
* @return \ManiaControl\Players\Player
*/
public function getVictim() {
return $this->victim;
}
/**
* < First custom param of the event
*
* @return string
*/
public function getParam1() {
return $this->param1;
}
/**
* < Second custom param of the event
*
* @return array
*/
public function getParam2() {
return $this->param2;
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnCustomEvent 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 OnActionEvent extends BaseStructure {
private $time;
private $player;
private $actionInput;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->actionInput = $this->getPlainJsonObject()->actioninput;
$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login);
}
/**
* Returns Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* < player who triggered the action
*
* @return \ManiaControl\Players\Player
*/
public function getPlayer() {
return $this->player;
}
/**
* < The input pressed to trigger the action
*
* @return string
*/
public function getActionInput() {
return $this->actionInput;
}
}

View File

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

View File

@ -0,0 +1,80 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnPlayerTouchesObject 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 OnPlayerObjectStructure extends BaseStructure {
private $time;
private $player;
private $objectId;
private $modelId;
private $modelName;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->objectId = $this->getPlainJsonObject()->objectid;
$this->modelId = $this->getPlainJsonObject()->modelid;
$this->modelName = $this->getPlainJsonObject()->modelname;
$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login);
}
/**
* Returns Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* < Login of the player who touched the object
*
* @return \ManiaControl\Players\Player
*/
public function getPlayer() {
return $this->player;
}
/**
* < The id of the object
*
* @return string
*/
public function getObjectId() {
return $this->objectId;
}
/**
* < The id of the object model
*
* @return string
*/
public function getModelId() {
return $this->modelId;
}
/**
* < The name of the object model
*
* @return string
*/
public function getModelName() {
return $this->modelName;
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnPlayerRequestActionChange 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 OnPlayerRequestActionChange extends BaseStructure {
private $time;
private $player;
private $actionChange;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->actionChange = $this->getPlainJsonObject()->actionChange;
$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login);
}
/**
* Returns Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* < player who requested a new action
*
* @return \ManiaControl\Players\Player
*/
public function getPlayer() {
return $this->player;
}
/**
* < Can be -1 (request previous action) or 1 (request next action)
*
* @return string
*/
public function getActionChange() {
return $this->actionChange;
}
}

View File

@ -27,7 +27,6 @@ class OnPlayerRequestRespawnStructure extends BaseStructure {
$this->time = $this->getPlainJsonObject()->time; $this->time = $this->getPlainJsonObject()->time;
$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login); $this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login);
$this->getUsage();
} }
/** /**

View File

@ -0,0 +1,59 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnPlayerTriggersSector 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 OnPlayerTriggersSectorStructure extends BaseStructure {
private $time;
private $player;
private $sectorId;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->sectorId = $this->getPlainJsonObject()->sectorid;
$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login);
}
/**
* Returns Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* < player who touched the object
*
* @return \ManiaControl\Players\Player
*/
public function getPlayer() {
return $this->player;
}
/**
* < Id of the triggered sector
*
* @return string
*/
public function getSectorId() {
return $this->sectorId;
}
}

View File

@ -4,6 +4,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\BaseStructure; use ManiaControl\Callbacks\Structures\BaseStructure;
use ManiaControl\Callbacks\Structures\ShootMania\Models\PlayerScore;
use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore; use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
@ -20,8 +21,8 @@ class OnScoresStructure extends BaseStructure {
private $useTeams; private $useTeams;
private $winnerTeam; private $winnerTeam;
private $winnerPlayer; private $winnerPlayer;
private $teamScores = array(); private $teamScores = array();
private $players; //TODO implement private $playerScores = array();
//TODO test //TODO test
public function __construct(ManiaControl $maniaControl, $data) { public function __construct(ManiaControl $maniaControl, $data) {
@ -47,7 +48,16 @@ class OnScoresStructure extends BaseStructure {
$this->teamScores[$team->id] = $teamScore; //TODO verify that different teams have different ids $this->teamScores[$team->id] = $teamScore; //TODO verify that different teams have different ids
} }
//TODO implement player 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;
}
} }
/** /**
@ -105,12 +115,11 @@ class OnScoresStructure extends BaseStructure {
} }
/** /**
* Get The Player Scores * Get the Player Scores
* *
* @return mixed * @return PlayerScore[]
*/ */
public function getPlayers() { public function getPlayerScores() {
//TODO proper implementation return $this->playerScores;
return $this->players;
} }
} }