add attacks and casualties statistics

This commit is contained in:
unknown
2012-05-20 21:19:51 +03:00
parent 04eee11d75
commit b57797cd21
3 changed files with 136 additions and 4 deletions
+31
View File
@@ -2908,7 +2908,38 @@
$crop *= SPEED;
return $crop;
}
//general statistics
function addGeneralAttack($casualties) {
$time = time();
$q = "INSERT INTO " . TB_PREFIX . "general values (0,'$casualties','$time',1)";
return mysql_query($q, $this->connection) or die(mysql_error());
}
function getAttackByDate($time) {
$q = "SELECT * FROM " . TB_PREFIX . "general where shown = 1";
$result = $this->query_return($q);
$attack = 0;
foreach($result as $general){
if(date("j. M",$time) == date("j. M",$general['time'])){
$attack += 1;
}
}
return $attack;
}
function getAttackCasualties($time) {
$q = "SELECT * FROM " . TB_PREFIX . "general where shown = 1";
$result = $this->query_return($q);
$casualties = 0;
foreach($result as $general){
if(date("j. M",$time) == date("j. M",$general['time'])){
$casualties += $general['casualties'];
}
}
return $casualties;
}
}
;