diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index f70bcb45..cbfdf362 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -167,6 +167,7 @@ class Automation { if(!file_exists("GameEngine/Prevention/settlers.txt") or time()-filemtime("GameEngine/Prevention/settlers.txt")>10) { $this->sendSettlersComplete(); } + $this->updateGeneralAttack(); $this->updateStore(); } @@ -537,7 +538,7 @@ class Automation { $time = time(); $q = "SELECT * FROM ".TB_PREFIX."movement, ".TB_PREFIX."attacks where ".TB_PREFIX."movement.ref = ".TB_PREFIX."attacks.id and ".TB_PREFIX."movement.proc = '0' and ".TB_PREFIX."movement.sort_type = '3' and ".TB_PREFIX."attacks.attack_type != '2' and endtime < $time ORDER BY endtime ASC"; $dataarray = $database->query_return($q); - + $totalattackdead = 0; foreach($dataarray as $data) { //set base things //$battle->resolveConflict($data); @@ -1027,6 +1028,7 @@ class Automation { $totaldead_alldef[5] = $dead['41']+$dead['42']+$dead['43']+$dead['44']+$dead['45']+$dead['46']+$dead['47']+$dead['48']+$dead['49']+$dead['50']; $totaldead_alldef = $totaldead_alldef[1]+$totaldead_alldef[2]+$totaldead_alldef[3]+$totaldead_alldef[4]+$totaldead_alldef[5]+$deadhero; + $totalattackdead += $totaldead_alldef; /* if($battlepart['casualties_defender'][1] == 0) { $dead11 = 0; } else { $dead11 = $battlepart['casualties_defender'][1]; } if($battlepart['casualties_defender'][2] == 0) { $dead12 = 0; } else { $dead12 = $battlepart['casualties_defender'][2]; } @@ -1063,7 +1065,8 @@ class Automation { //top 10 attack and defence update - $totaldead_att = $dead1+$dead2+$dead3+$dead4+$dead5+$dead6+$dead7+$dead8+$dead9+$dead10; + $totaldead_att = $dead1+$dead2+$dead3+$dead4+$dead5+$dead6+$dead7+$dead8+$dead9+$dead10+$dead11; + $totalattackdead += $totaldead_att; for($i=1;$i<=50;$i++) { $totaldead_def += $dead[''.$i.'']; } @@ -2019,7 +2022,10 @@ $crannyimg = "addNotice($from['owner'],$to['wref'],$ownally,3,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data_fail,$AttackArrivalTime); } } - unset($Attacker); + if($type == 3 or $type == 4){ + $database->addGeneralAttack($totalattackdead); + } + unset($Attacker); unset($Defender); unset($Enforce); unset($unitssend_att); @@ -2041,8 +2047,15 @@ $crannyimg = "query_return($q); + foreach($array as $general) { + if(time() - (86400*8) > $general['time']){ + mysql_query("UPDATE ".TB_PREFIX."general SET shown = 0 WHERE id = ".$general['id'].""); + } + } + } + private function MasterBuilder() { global $database; $q = "SELECT * FROM ".TB_PREFIX."bdata WHERE master = 1"; diff --git a/GameEngine/Database/db_MYSQL.php b/GameEngine/Database/db_MYSQL.php index 04719e63..bedfccb4 100644 --- a/GameEngine/Database/db_MYSQL.php +++ b/GameEngine/Database/db_MYSQL.php @@ -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; + } } ; diff --git a/Templates/Ranking/general.tpl b/Templates/Ranking/general.tpl index ef7a3f47..33e36897 100644 --- a/Templates/Ranking/general.tpl +++ b/Templates/Ranking/general.tpl @@ -100,4 +100,80 @@ echo "%"; ?> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Miscellaneous
AttacksCasualtiesDate
getAttackByDate(time()); ?>getAttackCasualties(time()); ?>
getAttackByDate(time()-(86400*1)); ?>getAttackCasualties(time()-(86400*1)); ?>
getAttackByDate(time()-(86400*2)); ?>getAttackCasualties(time()-(86400*2)); ?>
getAttackByDate(time()-(86400*3)); ?>getAttackCasualties(time()-(86400*3)); ?>
getAttackByDate(time()-(86400*4)); ?>getAttackCasualties(time()-(86400*4)); ?>
getAttackByDate(time()-(86400*5)); ?>getAttackCasualties(time()-(86400*5)); ?>
getAttackByDate(time()-(86400*6)); ?>getAttackCasualties(time()-(86400*6)); ?>
+ + +