fixed statistics code for custom callbacks

This commit is contained in:
Steffen Schröder 2014-07-21 14:53:05 +02:00
parent e18e29de9d
commit b9c6e7cb85

View File

@ -210,20 +210,27 @@ class StatisticCollector implements CallbackListener {
break; break;
case 'OnShoot': case 'OnShoot':
$paramsObject = json_decode($callback[1][1]); $paramsObject = json_decode($callback[1][1]);
if ($paramsObject && isset($paramsObject->Event)) {
$this->handleOnShoot($paramsObject->Event->Shooter->Login, $paramsObject->Event->WeaponNum); $this->handleOnShoot($paramsObject->Event->Shooter->Login, $paramsObject->Event->WeaponNum);
}
break; break;
case 'OnNearMiss': case 'OnNearMiss':
$paramsObject = json_decode($callback[1][1]); $paramsObject = json_decode($callback[1][1]);
if ($paramsObject && isset($paramsObject->Event)) {
$player = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Shooter->Login); $player = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Shooter->Login);
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_NEARMISS, $player); $this->maniaControl->statisticManager->incrementStat(self::STAT_ON_NEARMISS, $player);
}
break; break;
case 'OnCapture': case 'OnCapture':
$paramsObject = json_decode($callback[1][1]); $paramsObject = json_decode($callback[1][1]);
if ($paramsObject && isset($paramsObject->Event)) {
$player = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Player->Login); $player = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Player->Login);
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_CAPTURE, $player); $this->maniaControl->statisticManager->incrementStat(self::STAT_ON_CAPTURE, $player);
}
break; break;
case 'OnHit': case 'OnHit':
$paramsObject = json_decode($callback[1][1]); $paramsObject = json_decode($callback[1][1]);
if ($paramsObject && isset($paramsObject->Event)) {
$weapon = (int)$paramsObject->Event->WeaponNum; $weapon = (int)$paramsObject->Event->WeaponNum;
if (isset($paramsObject->Event->Shooter)) { if (isset($paramsObject->Event->Shooter)) {
$shooter = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Shooter->Login); $shooter = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Shooter->Login);
@ -238,9 +245,11 @@ class StatisticCollector implements CallbackListener {
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_GOT_HIT, $victim); $this->maniaControl->statisticManager->incrementStat(self::STAT_ON_GOT_HIT, $victim);
} }
} }
}
break; break;
case 'OnArmorEmpty': case 'OnArmorEmpty':
$paramsObject = json_decode($callback[1][1]); $paramsObject = json_decode($callback[1][1]);
if ($paramsObject && isset($paramsObject->Event)) {
$victim = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Victim->Login); $victim = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Victim->Login);
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_DEATH, $victim); $this->maniaControl->statisticManager->incrementStat(self::STAT_ON_DEATH, $victim);
if (isset($paramsObject->Event->Shooter->Login)) { if (isset($paramsObject->Event->Shooter->Login)) {
@ -250,11 +259,14 @@ class StatisticCollector implements CallbackListener {
} }
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_KILL, $shooter); $this->maniaControl->statisticManager->incrementStat(self::STAT_ON_KILL, $shooter);
} }
}
break; break;
case 'OnRequestRespawn': case 'OnRequestRespawn':
$paramsObject = json_decode($callback[1][1]); $paramsObject = json_decode($callback[1][1]);
if ($paramsObject && isset($paramsObject->Event)) {
$player = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Player->Login); $player = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Player->Login);
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_PLAYER_REQUEST_RESPAWN, $player); $this->maniaControl->statisticManager->incrementStat(self::STAT_ON_PLAYER_REQUEST_RESPAWN, $player);
}
break; break;
case 'EndTurn': //TODO make it for other modes working case 'EndTurn': //TODO make it for other modes working
$paramsObject = json_decode($callback[1][1]); $paramsObject = json_decode($callback[1][1]);