callback improvements
This commit is contained in:
parent
609337434d
commit
5f7eff0660
@ -98,6 +98,11 @@ interface Callbacks {
|
|||||||
/** OnPlayerRequestRespawn Callback: Player */
|
/** OnPlayerRequestRespawn Callback: Player */
|
||||||
const ONPLAYERREQUESTRESPAWN = 'Callbacks.OnPlayerRequestRespawn';
|
const ONPLAYERREQUESTRESPAWN = 'Callbacks.OnPlayerRequestRespawn';
|
||||||
|
|
||||||
|
/** Elite OnBeginTurn Callback: EliteBeginTurnStructure */
|
||||||
|
const ELITE_ONBEGINTURN = "Callbacks.EliteOnBeginTurn";
|
||||||
|
/** Elite OnEndTurn Callback: integer (VictoryTypes) */
|
||||||
|
const ELITE_ONENDTURN = "Callbacks.EliteOnEndTurn";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TrackMania Callbacks
|
* TrackMania Callbacks
|
||||||
*/
|
*/
|
||||||
@ -111,4 +116,5 @@ interface Callbacks {
|
|||||||
const ONRESPAWN = 'Callbacks.OnRespawn';
|
const ONRESPAWN = 'Callbacks.OnRespawn';
|
||||||
/** OnStunt Callback */
|
/** OnStunt Callback */
|
||||||
const ONSTUNT = 'Callbacks.OnStunt';
|
const ONSTUNT = 'Callbacks.OnStunt';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,9 @@ class LibXmlRpcCallbacks implements CallbackListener {
|
|||||||
case 'LibXmlRpc_BeginTurn':
|
case 'LibXmlRpc_BeginTurn':
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINTURN, $data[0]);
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINTURN, $data[0]);
|
||||||
break;
|
break;
|
||||||
|
case 'LibXmlRpc_BeginRound':
|
||||||
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINROUND, $data[0]);
|
||||||
|
break;
|
||||||
case 'LibXmlRpc_BeginPlaying':
|
case 'LibXmlRpc_BeginPlaying':
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINPLAYING);
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINPLAYING);
|
||||||
break;
|
break;
|
||||||
@ -71,6 +74,7 @@ class LibXmlRpcCallbacks implements CallbackListener {
|
|||||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDTURN, $data[0]);
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDTURN, $data[0]);
|
||||||
break;
|
break;
|
||||||
case 'LibXmlRpc_EndRound':
|
case 'LibXmlRpc_EndRound':
|
||||||
|
var_dump("test");
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDROUND, $data[0]);
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDROUND, $data[0]);
|
||||||
break;
|
break;
|
||||||
case 'LibXmlRpc_EndSubmatch':
|
case 'LibXmlRpc_EndSubmatch':
|
||||||
@ -131,11 +135,11 @@ class LibXmlRpcCallbacks implements CallbackListener {
|
|||||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONARMOREMPTY, new ArmorEmptyStructure($this->maniaControl, $data));
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONARMOREMPTY, new ArmorEmptyStructure($this->maniaControl, $data));
|
||||||
break;
|
break;
|
||||||
case 'LibXmlRpc_OnCapture':
|
case 'LibXmlRpc_OnCapture':
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONARMOREMPTY, new CaptureStructure($this->maniaControl, $data));
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONCAPTURE, new CaptureStructure($this->maniaControl, $data));
|
||||||
break;
|
break;
|
||||||
case 'LibXmlRpc_OnPlayerRequestRespawn':
|
case 'LibXmlRpc_OnPlayerRequestRespawn':
|
||||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($data[0]);
|
$player = $this->maniaControl->getPlayerManager()->getPlayer($data[0]);
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONARMOREMPTY, $player);
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONPLAYERREQUESTRESPAWN, $player);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace ManiaControl\Callbacks;
|
namespace ManiaControl\Callbacks;
|
||||||
|
|
||||||
use ManiaControl\Callbacks\Models\RecordCallback;
|
use ManiaControl\Callbacks\Models\RecordCallback;
|
||||||
|
use ManiaControl\Callbacks\Structures\EliteBeginTurnStructure;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,6 +61,12 @@ class ShootManiaCallbacks implements CallbackListener {
|
|||||||
case 'WarmUp_Status':
|
case 'WarmUp_Status':
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::WARMUPSTATUS, $data[0]);
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::WARMUPSTATUS, $data[0]);
|
||||||
break;
|
break;
|
||||||
|
case 'Elite_BeginTurn':
|
||||||
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ELITE_ONBEGINTURN, new EliteBeginTurnStructure($this->maniaControl, $data));
|
||||||
|
break;
|
||||||
|
case 'Elite_EndTurn':
|
||||||
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ELITE_ONENDTURN, $data[0]);
|
||||||
|
break;
|
||||||
case self::CB_TIMEATTACK_ONCHECKPOINT:
|
case self::CB_TIMEATTACK_ONCHECKPOINT:
|
||||||
$this->handleTimeAttackOnCheckpoint($name, $data);
|
$this->handleTimeAttackOnCheckpoint($name, $data);
|
||||||
break;
|
break;
|
||||||
|
52
core/Callbacks/Structures/EliteBeginTurnStructure.php
Normal file
52
core/Callbacks/Structures/EliteBeginTurnStructure.php
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ManiaControl\Callbacks\Structures;
|
||||||
|
|
||||||
|
use ManiaControl\ManiaControl;
|
||||||
|
use ManiaControl\Players\Player;
|
||||||
|
|
||||||
|
class EliteBeginTurnStructure {
|
||||||
|
/*
|
||||||
|
* Private properties
|
||||||
|
*/
|
||||||
|
private $attackerLogin;
|
||||||
|
private $defenderLogins;
|
||||||
|
|
||||||
|
/** @var ManiaControl $maniaControl */
|
||||||
|
private $maniaControl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new Elite BeginTurnStructure
|
||||||
|
*
|
||||||
|
* @param ManiaControl $maniaControl
|
||||||
|
* @param array $data
|
||||||
|
*/
|
||||||
|
public function __construct(ManiaControl $maniaControl, array $data) {
|
||||||
|
$this->maniaControl = $maniaControl;
|
||||||
|
$this->attackerLogin = $data[0];
|
||||||
|
$this->defenderLogins = $data[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the attacker
|
||||||
|
*
|
||||||
|
* @return Player
|
||||||
|
*/
|
||||||
|
public function getAttacker() {
|
||||||
|
return $this->maniaControl->getPlayerManager()->getPlayer($this->attackerLogin);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the defenders as an Player Array
|
||||||
|
*
|
||||||
|
* @return Player[]
|
||||||
|
*/
|
||||||
|
public function getDefenders() {
|
||||||
|
$defenders = array();
|
||||||
|
foreach (explode(";", $this->defenderLogins) as $defenderLogin) {
|
||||||
|
$defenders[] = $this->maniaControl->getPlayerManager()->getPlayer($defenderLogin);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $defenders;
|
||||||
|
}
|
||||||
|
}
|
17
core/Callbacks/Structures/VictoryTypes.php
Normal file
17
core/Callbacks/Structures/VictoryTypes.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ManiaControl\Callbacks\Structures;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VictoryTypes Interface (only available in Elite atm)
|
||||||
|
*
|
||||||
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||||
|
* @copyright 2014 ManiaControl Team
|
||||||
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
|
*/
|
||||||
|
interface VictoryTypes {
|
||||||
|
const TIME_LIMIT = 1;
|
||||||
|
const CAPTURE = 2;
|
||||||
|
const ATTACKER_ELIMINATED = 3;
|
||||||
|
const DEFENDERS_ELIMINATED = 4;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user