callback improvements

This commit is contained in:
kremsy 2014-12-21 23:21:59 +01:00
parent 5f7eff0660
commit 440d690279
5 changed files with 22 additions and 10 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
// TODO: method class for all the libxmlrpc get Methods, to fetch the callback asnyc // TODO: method class for all the libxmlrpc get Methods, to fetch the callback asnyc
// TODO implement all STOP callbacks
namespace ManiaControl\Callbacks; namespace ManiaControl\Callbacks;
/** /**
@ -37,12 +37,16 @@ interface Callbacks {
const BEGINROUND = 'Callbacks.BeginRound'; const BEGINROUND = 'Callbacks.BeginRound';
/** BeginTurn Callback: TurnNumber */ /** BeginTurn Callback: TurnNumber */
const BEGINTURN = 'Callbacks.BeginTurn'; const BEGINTURN = 'Callbacks.BeginTurn';
/** BeginTurnStop Callback: TurnNumber */
const BEGINTURNSTOP = 'Callbacks.BeginTurnStop';
/** BeginPlaying Callback */ /** BeginPlaying Callback */
const BEGINPLAYING = 'Callbacks.BeginPlaying'; const BEGINPLAYING = 'Callbacks.BeginPlaying';
/** EndPlaying Callback */ /** EndPlaying Callback */
const ENDPLAYING = 'Callbacks.EndPlaying'; const ENDPLAYING = 'Callbacks.EndPlaying';
/** EndTurn Callback: TurnNumber */ /** EndTurn Callback: TurnNumber */
const ENDTURN = 'Callbacks.EndTurn'; const ENDTURN = 'Callbacks.EndTurn';
/** EndTurnStop Callback: TurnNumber */
const ENDTURNSTOP = 'Callbacks.EndTurnStop';
/** EndRound Callback: RoundNumber */ /** EndRound Callback: RoundNumber */
const ENDROUND = 'Callbacks.EndRound'; const ENDROUND = 'Callbacks.EndRound';
/** EndSubmatch Callback: SubmatchNumber */ /** EndSubmatch Callback: SubmatchNumber */

View File

@ -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_BeginTurnStop':
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINTURNSTOP, $data[0]);
break;
case 'LibXmlRpc_BeginRound': case 'LibXmlRpc_BeginRound':
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINROUND, $data[0]); $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINROUND, $data[0]);
break; break;
@ -73,8 +76,10 @@ class LibXmlRpcCallbacks implements CallbackListener {
case 'LibXmlRpc_EndTurn': case 'LibXmlRpc_EndTurn':
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDTURN, $data[0]); $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDTURN, $data[0]);
break; break;
case 'LibXmlRpc_EndTurnStop':
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ENDTURNSTOP, $data[0]);
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':

View File

@ -41,7 +41,10 @@ class CaptureStructure {
public function getPlayerArray() { public function getPlayerArray() {
$playerArray = array(); $playerArray = array();
foreach ($this->playerArray as $login) { foreach ($this->playerArray as $login) {
$playerArray[$login] = $this->maniaControl->getPlayerManager()->getPlayer($this->playerArray); $player = $this->maniaControl->getPlayerManager()->getPlayer($login);
if($player){
$playerArray[$login] = $player;
}
} }
return $playerArray; return $playerArray;
} }

View File

@ -51,10 +51,10 @@ class NearMissStructure {
/** /**
* Get the distance * Get the distance
* *
* @return float * @return double
*/ */
public function getDistance() { public function getDistance() {
return $this->distance; return doubleval($this->distance);
} }
/** /**

View File

@ -38,7 +38,7 @@ class PlayerHitStructure {
$this->damage = $data[2]; $this->damage = $data[2];
$this->weapon = $data[3]; $this->weapon = $data[3];
$this->shooterPoints = $data[4]; $this->shooterPoints = $data[4];
//TODO remove key check in some months (hitDistance got implemented 2014-10-16) //TODO remove key check in some months (hitDistance got implemented 2014-10-16)
if (array_key_exists(5, $data)) { if (array_key_exists(5, $data)) {
$this->hitDistance = $data[5]; $this->hitDistance = $data[5];
@ -69,7 +69,7 @@ class PlayerHitStructure {
* @return int * @return int
*/ */
public function getDamage() { public function getDamage() {
return $this->damage; return intval($this->damage);
} }
/** /**
@ -78,7 +78,7 @@ class PlayerHitStructure {
* @return int * @return int
*/ */
public function getShooterPoints() { public function getShooterPoints() {
return $this->shooterPoints; return intval($this->shooterPoints);
} }
/** /**
@ -94,9 +94,9 @@ class PlayerHitStructure {
/** /**
* Get The Hit Distance * Get The Hit Distance
* *
* @return int * @return double
*/ */
public function getHitDistance() { public function getHitDistance() {
return $this->hitDistance; return doubleval($this->hitDistance);
} }
} }