From 2d86383e811dec9181dd2604e52826bdb3035fde Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 29 Jun 2012 04:18:33 +0300 Subject: [PATCH] make automate regenerate troops system (now admin not need to make it every time) --- Admin/admin.php | 3 +- GameEngine/Automation.php | 21 +++++++++++ GameEngine/Database/db_MYSQL.php | 62 +++++++++++++++++++++++++++++++- Templates/menu.tpl | 1 - install/data/sql.sql | 1 + 5 files changed, 84 insertions(+), 4 deletions(-) diff --git a/Admin/admin.php b/Admin/admin.php index 988a6cd2..aec2e2c2 100644 --- a/Admin/admin.php +++ b/Admin/admin.php @@ -126,8 +126,7 @@ $timeformat = new timeFormatGenerator; Give All Res Bonus Reset Res Bonus
- Natars & Nature - Populate Oases + Natars Add WW Villages Add WW Buildingplan Villages
diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index f005e47d..bb030c1c 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -207,6 +207,7 @@ class Automation { $this->updateStore(); $this->procClimbers(); $this->CheckBan(); + $this->regenerateOasisTroops(); } private function loyaltyRegeneration() { @@ -3909,6 +3910,26 @@ $crannyimg = " $max2"; + $array = $database->query_return($q); + foreach($array as $oasis) { + $database->populateOasisUnits($oasis['wref'],$oasis['high']); + $database->updateOasis($oasis['wref']); + } + } } $automation = new Automation; ?> \ No newline at end of file diff --git a/GameEngine/Database/db_MYSQL.php b/GameEngine/Database/db_MYSQL.php index 9b34762d..df1d8fd5 100644 --- a/GameEngine/Database/db_MYSQL.php +++ b/GameEngine/Database/db_MYSQL.php @@ -508,6 +508,65 @@ class MYSQL_DB { } } + function populateOasisUnits($wid, $high) { + $basearray = $this->getMInfo($wid); + $basearray = $this->getOasisInfo($wid); + if($basearray2['high'] == 0){ + $max = rand(15,30); + }elseif($basearray2['high'] == 1){ + $max = rand(70,90); + }elseif($basearray2['high'] == 2){ + $max = rand(100,140); + } + //each Troop is a Set for oasis type like mountains have rats spiders and snakes fields tigers elphants clay wolves so on stonger one more not so less + switch($basearray['oasistype']) { + case 1: + case 2: + //+25% lumber per hour + $q = "UPDATE " . TB_PREFIX . "units SET u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max.")"; + $result = mysql_query($q, $this->connection); + break; + case 3: + //+25% lumber and +25% crop per hour + $q = "UPDATE " . TB_PREFIX . "units SET u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")"; + $result = mysql_query($q, $this->connection); + break; + case 4: + case 5: + //+25% clay per hour + $q = "UPDATE " . TB_PREFIX . "units SET u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max.")"; + $result = mysql_query($q, $this->connection); + break; + case 6: + //+25% clay and +25% crop per hour + $q = "UPDATE " . TB_PREFIX . "units SET u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")"; + $result = mysql_query($q, $this->connection); + break; + case 7: + case 8: + //+25% iron per hour + $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u34 = u34 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max.")"; + $result = mysql_query($q, $this->connection); + break; + case 9: + //+25% iron and +25% crop + $q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u34 = u34 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u34 <= ".$max.")"; + $result = mysql_query($q, $this->connection); + break; + case 10: + case 11: + //+25% crop per hour + $q = "UPDATE " . TB_PREFIX . "units SET u33 = u33 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u33 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")"; + $result = mysql_query($q, $this->connection); + break; + case 12: + //+50% crop per hour + $q = "UPDATE " . TB_PREFIX . "units SET u33 = u33 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u33 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")"; + $result = mysql_query($q, $this->connection); + break; + } + } + function populateOasisUnitsLow() { $q2 = "SELECT * FROM " . TB_PREFIX . "odata where conqured = 0"; $result2 = mysql_query($q2, $this->connection); @@ -2712,6 +2771,7 @@ class MYSQL_DB { return false; } } + function populateOasisdata() { $q2 = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0"; $result2 = mysql_query($q2, $this->connection); @@ -2719,7 +2779,7 @@ class MYSQL_DB { $wid = $row['id']; $basearray = $this->getOMInfo($wid); //We switch type of oasis and instert record with apropriate infomation. - $q = "INSERT into " . TB_PREFIX . "odata VALUES ('" . $basearray['id'] . "'," . $basearray['oasistype'] . ",0,400,400,400,400,400,400," . time() . ",100,2,'Unoccupied Oasis')"; + $q = "INSERT into " . TB_PREFIX . "odata VALUES ('" . $basearray['id'] . "'," . $basearray['oasistype'] . ",0,400,400,400,400,400,400," . time() . ",100,2,'Unoccupied Oasis',".rand(0,2).")"; $result = mysql_query($q, $this->connection); } } diff --git a/Templates/menu.tpl b/Templates/menu.tpl index 24f96d04..f70153b2 100644 --- a/Templates/menu.tpl +++ b/Templates/menu.tpl @@ -45,7 +45,6 @@ div.c1 {text-align: center} echo "Update Top 10"; echo "System message"; echo "Create Natars"; - echo "Populate Oasis"; } ?>

Game Rules diff --git a/install/data/sql.sql b/install/data/sql.sql index adae4880..67fa7dfa 100644 --- a/install/data/sql.sql +++ b/install/data/sql.sql @@ -1024,6 +1024,7 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%odata` ( `loyalty` int(11) NOT NULL DEFAULT '100', `owner` int(11) unsigned NOT NULL DEFAULT '2', `name` varchar(32) NOT NULL DEFAULT 'Unoccupied Oasis', + `high` tinyint(1) unsigned NOT NULL, PRIMARY KEY (`wref`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;