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