updated stats
This commit is contained in:
parent
dcdb7f8226
commit
bb2e3b13fd
@ -255,7 +255,7 @@ class PlayerManager implements CallbackListener {
|
||||
* Save player in database and fill up object properties
|
||||
*
|
||||
* @param Player $player
|
||||
* @param int $joinCount
|
||||
* @internal param int $joinCount
|
||||
* @return bool
|
||||
*/
|
||||
private function savePlayer(Player &$player) {
|
||||
@ -308,7 +308,7 @@ class PlayerManager implements CallbackListener {
|
||||
$playerStatement->close();
|
||||
|
||||
// Increment the Player Join Count
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_JOIN_COUNT, $player, $this->maniaControl->server->getLogin());
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_JOIN_COUNT, $player, $this->maniaControl->server->getServerId());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -325,6 +325,6 @@ class PlayerManager implements CallbackListener {
|
||||
}
|
||||
$playedTime = time() - $player->joinTime;
|
||||
|
||||
return $this->maniaControl->statisticManager->insertStat(self::STAT_PLAYTIME, $player, $this->maniaControl->server->getLogin(), $playedTime);
|
||||
return $this->maniaControl->statisticManager->insertStat(self::STAT_PLAYTIME, $player, $this->maniaControl->server->getServerId(), $playedTime);
|
||||
}
|
||||
}
|
||||
|
@ -51,8 +51,6 @@ class Server implements CallbackListener {
|
||||
$this->serverCommands = new ServerCommands($maniaControl);
|
||||
|
||||
$this->initTables();
|
||||
|
||||
//$this->initServer();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -398,4 +396,11 @@ class Server implements CallbackListener {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getServerId() {
|
||||
return $this->serverId;
|
||||
}
|
||||
}
|
||||
|
@ -90,9 +90,9 @@ class StatisticCollector implements CallbackListener {
|
||||
|
||||
//Write Shoot Data into database
|
||||
if($this->onShootArray[$login] > $this->maniaControl->settingManager->getSetting($this, self::SETTING_ON_SHOOT_PRESTORE)) {
|
||||
$serverLogin = $this->maniaControl->server->getLogin();
|
||||
$serverId = $this->maniaControl->server->getServerId();
|
||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||
$this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $serverLogin, $this->onShootArray[$login]);
|
||||
$this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $serverId, $this->onShootArray[$login]);
|
||||
$this->onShootArray[$login] = 0;
|
||||
}
|
||||
}
|
||||
@ -114,8 +114,8 @@ class StatisticCollector implements CallbackListener {
|
||||
//Insert Data into Database, and destroy player
|
||||
if(isset($this->onShootArray[$player->login])) {
|
||||
if($this->onShootArray[$player->login] > 0) {
|
||||
$serverLogin = $this->maniaControl->server->getLogin();
|
||||
$this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $serverLogin, $this->onShootArray[$player->login]);
|
||||
$serverId = $this->maniaControl->server->getServerId();
|
||||
$this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $serverId, $this->onShootArray[$player->login]);
|
||||
}
|
||||
unset($this->onShootArray[$player->login]);
|
||||
}
|
||||
|
@ -55,11 +55,10 @@ class StatisticManager {
|
||||
*
|
||||
* @param $statName
|
||||
* @param $playerId
|
||||
* @param bool $serverLogin
|
||||
* @param int $serverId
|
||||
* @return int
|
||||
*/
|
||||
public function getStatisticData($statName, $playerId, $serverLogin = false) {
|
||||
$serverId = 0; //Temporary
|
||||
public function getStatisticData($statName, $playerId, $serverId = -1) {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$statId = $this->getStatId($statName);
|
||||
|
||||
@ -67,7 +66,7 @@ class StatisticManager {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!$serverLogin) {
|
||||
if($serverId == -1) {
|
||||
$query = "SELECT SUM(value) as value FROM `" . self::TABLE_STATISTICS . "` WHERE `statId` = " . $statId . " AND `playerId` = " . $playerId . ";";
|
||||
} else {
|
||||
$query = "SELECT value FROM `" . self::TABLE_STATISTICS . "` WHERE `statId` = " . $statId . " AND `playerId` = " . $playerId . " AND `serverLogin` = '" . $serverId . "';";
|
||||
@ -123,12 +122,13 @@ class StatisticManager {
|
||||
* Get all statistics of a certain palyer
|
||||
*
|
||||
* @param Player $player
|
||||
* @param int $serverId
|
||||
* @return array
|
||||
*/
|
||||
public function getAllPlayerStats(Player $player) {
|
||||
public function getAllPlayerStats(Player $player, $serverId = -1) {
|
||||
$playerStats = array(); //TODO improve performence
|
||||
foreach($this->stats as $stat) {
|
||||
$value = $this->getStatisticData($stat->name, $player->index);
|
||||
$value = $this->getStatisticData($stat->name, $player->index, $serverId);
|
||||
$playerStats[$stat->name] = array($stat, $value);
|
||||
}
|
||||
|
||||
@ -140,13 +140,13 @@ class StatisticManager {
|
||||
*
|
||||
* @param $statName
|
||||
* @param Player $player
|
||||
* @param string $serverLogin
|
||||
* @param int $serverId
|
||||
* @param $value , value to Add
|
||||
* @param string $statType
|
||||
* @internal param string $serverLogin
|
||||
* @return bool
|
||||
*/
|
||||
public function insertStat($statName, $player, $serverLogin = '', $value, $statType = self::STAT_TYPE_INT) {
|
||||
$serverId = 0; //Temporary
|
||||
public function insertStat($statName, $player, $serverId = -1, $value, $statType = self::STAT_TYPE_INT) {
|
||||
$statId = $this->getStatId($statName);
|
||||
|
||||
if($player == null) {
|
||||
@ -161,8 +161,8 @@ class StatisticManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
if($serverLogin == '') {
|
||||
$serverLogin = $this->maniaControl->server->getLogin();
|
||||
if($serverId == -1) {
|
||||
$serverId = $this->maniaControl->server->getServerId();
|
||||
}
|
||||
|
||||
|
||||
@ -201,12 +201,13 @@ class StatisticManager {
|
||||
*
|
||||
* @param $statName
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
* @param string $serverLogin
|
||||
* @param int $serverId
|
||||
* @internal param string $serverLogin
|
||||
* @internal param \ManiaControl\Players\Player $playerId
|
||||
* @return bool
|
||||
*/
|
||||
public function incrementStat($statName, $player, $serverLogin = '') {
|
||||
return $this->insertStat($statName, $player, $serverLogin, 1);
|
||||
public function incrementStat($statName, $player, $serverId = -1) {
|
||||
return $this->insertStat($statName, $player, $serverId, 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -325,7 +325,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
$message = 'Donation successful! Thanks.';
|
||||
}
|
||||
$this->maniaControl->chat->sendSuccess($message, $login);
|
||||
$this->maniaControl->statisticManager->insertStat(self::STAT_PLAYER_DONATIONS, $player, $this->maniaControl->server->getLogin(), $amount);
|
||||
$this->maniaControl->statisticManager->insertStat(self::STAT_PLAYER_DONATIONS, $player, $this->maniaControl->server->getServerId(), $amount);
|
||||
}
|
||||
} else {
|
||||
// Payout
|
||||
|
@ -272,8 +272,7 @@ class KarmaPlugin implements CallbackListener, Plugin {
|
||||
$voted = $this->getPlayerVote($player, $map);
|
||||
var_dump($voted);
|
||||
if(!$voted){
|
||||
var_dump("test");
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_PLAYER_MAPVOTES, $player, $this->maniaControl->server->getLogin());
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_PLAYER_MAPVOTES, $player, $this->maniaControl->server->getServerId());
|
||||
}
|
||||
|
||||
$success = $this->savePlayerVote($player, $map, $vote);
|
||||
|
Loading…
Reference in New Issue
Block a user