From 4721348d5681fd80007a18b11b96d3b248c4d37c Mon Sep 17 00:00:00 2001 From: Shadow Date: Wed, 27 Nov 2013 11:20:52 +0200 Subject: [PATCH] Update Automation.php --- GameEngine/Automation.php | 105 +++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 52 deletions(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index cef28072..39d48cf5 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -233,54 +233,53 @@ class Automation { $this->artefactOfTheFool(); } - private function loyaltyRegeneration() { - if(file_exists("GameEngine/Prevention/loyalty.txt")) { + private function loyaltyRegeneration() { + if(file_exists("GameEngine/Prevention/loyalty.txt")) { unlink("GameEngine/Prevention/loyalty.txt"); } + //fix by ronix //create new file to check filetime //not every click regenerate but 1 minute or after - $ourFileHandle = fopen("GameEngine/Prevention/loyalty.txt", 'w'); - fclose($ourFileHandle); - global $database; - $array = array(); - $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE loyalty<>100"; - $array = $database->query_return($q); - if(!empty($array)) { - foreach($array as $loyalty) { - if($this->getTypeLevel(25,$loyalty['wref']) >= 1){ - $value = $this->getTypeLevel(25,$loyalty['wref']); - }elseif($this->getTypeLevel(26,$loyalty['wref']) >= 1){ - $value = $this->getTypeLevel(26,$loyalty['wref']); - } else { - $value = 0; - } - $newloyalty = min(100,$loyalty['loyalty']+$value*(time()-$loyalty['lastupdated'])/(60*60)); - $q = "UPDATE ".TB_PREFIX."odata SET loyalty = $newloyalty, lastupdated=".time()." WHERE wref = '".$loyalty['wref']."'"; - $database->query($q); - } - } - $array = array(); - $q = "SELECT * FROM ".TB_PREFIX."odata WHERE loyalty<>100"; - $array = $database->query_return($q); - if(!empty($array)) { - foreach($array as $loyalty) { - if($this->getTypeLevel(25,$loyalty['conqured']) >= 1){ - $value = $this->getTypeLevel(25,$loyalty['conqured']); - }elseif($this->getTypeLevel(26,$loyalty['conqured']) >= 1){ - $value = $this->getTypeLevel(26,$loyalty['conqured']); - } else { - $value = 0; - } - $newloyalty = min(100,$loyalty['loyalty']+$value*(time()-$loyalty['lastupdate'])/(60*60)); - $q = "UPDATE ".TB_PREFIX."odata SET loyalty = $newloyalty WHERE wref = '".$loyalty['wref']."'"; - $database->query($q); - } - } - //if(file_exists("GameEngine/Prevention/loyalty.txt")) { - // unlink("GameEngine/Prevention/loyalty.txt"); - //} - } + + $ourFileHandle = fopen("GameEngine/Prevention/loyalty.txt", 'w'); + fclose($ourFileHandle); + global $database; + $array = array(); + $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE loyalty<>100"; + $array = $database->query_return($q); + if(!empty($array)) { + foreach($array as $loyalty) { + if($this->getTypeLevel(25,$loyalty['wref']) >= 1){ + $value = $this->getTypeLevel(25,$loyalty['wref']); + }elseif($this->getTypeLevel(26,$loyalty['wref']) >= 1){ + $value = $this->getTypeLevel(26,$loyalty['wref']); + } else { + $value = 0; + } + $newloyalty = min(100,$loyalty['loyalty']+$value*(time()-$loyalty['lastupdate2'])/(60*60)); + $q = "UPDATE ".TB_PREFIX."vdata SET loyalty = $newloyalty, lastupdate2=".time()." WHERE wref = '".$loyalty['wref']."'"; + $database->query($q); + } + } + $array = array(); + $q = "SELECT * FROM ".TB_PREFIX."odata WHERE loyalty<>100"; + $array = $database->query_return($q); + if(!empty($array)) { + foreach($array as $loyalty) { + if($this->getTypeLevel(25,$loyalty['conqured']) >= 1){ + $value = $this->getTypeLevel(25,$loyalty['conqured']); + }elseif($this->getTypeLevel(26,$loyalty['conqured']) >= 1){ + $value = $this->getTypeLevel(26,$loyalty['conqured']); + } else { + $value = 0; + } + $newloyalty = min(100,$loyalty['loyalty']+$value*(time()-$loyalty['lastupdated'])/(60*60)); + $q = "UPDATE ".TB_PREFIX."odata SET loyalty = $newloyalty, lastupdated=".time()." WHERE wref = '".$loyalty['wref']."'"; + $database->query($q); + } + } + } private function getfieldDistance($coorx1, $coory1, $coorx2, $coory2) { $max = 2 * WORLD_MAX + 1; @@ -357,7 +356,7 @@ class Automation { $database->query($q); $q = "DELETE FROM ".TB_PREFIX."bdata where wid = ".$village; $database->query($q); - $q = "DELETE FROM ".TB_PREFIX."enforcement where from = ".$village; + $q = "DELETE FROM ".TB_PREFIX."enforcement where `from` = ".$village; $database->query($q); $q = "DELETE FROM ".TB_PREFIX."fdata where vref = ".$village; $database->query($q); @@ -388,7 +387,7 @@ class Automation { $database->addMovement(4,$movedata['to'],$movedata['from'],$movedata['ref'],$time,$time+$time2); $database->setMovementProc($movedata['moveid']); } - $q = "DELETE FROM ".TB_PREFIX."movement where from = ".$village; + $q = "DELETE FROM ".TB_PREFIX."movement where `from` = ".$village; $database->query($q); $getprisoners = $database->getPrisoners($village); foreach($getprisoners as $pris) { @@ -1017,7 +1016,7 @@ class Automation { if(file_exists("GameEngine/Prevention/sendunits.txt")) { unlink("GameEngine/Prevention/sendunits.txt"); } - global $bid23,$bid34,$database,$battle,$village,$technology,$logging,$generator,$session; + global $bid23,$bid34,$database,$battle,$village,$technology,$logging,$generator,$session,$units; $reload=false; $ourFileHandle = fopen("GameEngine/Prevention/sendunits.txt", 'w'); fclose($ourFileHandle); @@ -1060,8 +1059,8 @@ class Automation { $cannotsend = 0; $movements = $database->getMovement("34",$data['to'],1); for($y=0;$y < count($movements);$y++){ - $returntime = $units[$y]['endtime']-time(); - if($units[$y]['sort_type'] == 4 && $units[$y]['from'] != 0 && $returntime <= 10){ + $returntime = $unit[$y]['endtime']-time(); + if($unit[$y]['sort_type'] == 4 && $unit[$y]['from'] != 0 && $returntime <= 10){ $cannotsend = 1; } } @@ -2384,7 +2383,7 @@ class Automation { $database->query($q); $database->addTech($data['to']); //delete reinforcement - $q = "DELETE FROM ".TB_PREFIX."enforcement WHERE from = ".$data['to'].""; + $q = "DELETE FROM ".TB_PREFIX."enforcement WHERE `from` = ".$data['to'].""; $database->query($q); // check buildings $pop1 = $database->getVillageField($data['from'],"pop"); @@ -2430,6 +2429,8 @@ class Automation { $value = $data['to']; } $database->setVillageField($data['from'],$exp,$value); + //remove oasis related to village + $units->returnTroops($data['to'],1); $chiefing_village = 1; } @@ -2565,9 +2566,9 @@ $wallimg = "Informationnone of your soldiers have returned."; - $data_fail = ''.$from['owner'].','.$from['wref'].','.$owntribe.','.$unitssend_att.','.$unitsdead_att.','.$steal[0].','.$steal[1].','.$steal[2].','.$steal[3].','.$battlepart['bounty'].','.$to['owner'].','.$to['wref'].','.addslashes($to['name']).','.$targettribe.',,,'.$rom.','.$unitssend_deff[1].','.$unitsdead_deff[1].','.$ger.','.$unitssend_deff[2].','.$unitsdead_deff[2].','.$gal.','.$unitssend_deff[3].','.$unitsdead_deff[3].','.$nat.','.$unitssend_deff[4].','.$unitsdead_deff[4].','.$natar.','.$unitssend_deff[5].','.$unitsdead_deff[5].',,,'.$data['t11'].','.$dead11.','.$unitstraped_att.',,'.$info_ram.','.$info_cat.','.$info_chief.','.$info_troop; - + $info_troop= "
Informationnone of your soldiers have returned."; + $data_fail = ''.$from['owner'].','.$from['wref'].','.$owntribe.','.$unitssend_att.','.$unitsdead_att.','.$steal[0].','.$steal[1].','.$steal[2].','.$steal[3].','.$battlepart['bounty'].','.$to['owner'].','.$to['wref'].','.addslashes($to['name']).','.$targettribe.',,,'.$rom.','.$unitssend_deff[1].','.$unitsdead_deff[1].','.$ger.','.$unitssend_deff[2].','.$unitsdead_deff[2].','.$gal.','.$unitssend_deff[3].','.$unitsdead_deff[3].','.$nat.','.$unitssend_deff[4].','.$unitsdead_deff[4].','.$natar.','.$unitssend_deff[5].','.$unitsdead_deff[5].',,,'.$data['t11'].','.$dead11.','.$unitstraped_att.',,'.$info_ram.','.$info_cat.','.$info_chief.','.$info_troop; + //Undetected and detected in here. if($scout){