From 77a1d9879d150099c1b72dd26a67cf9ccb560478 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Sat, 21 Oct 2017 22:38:01 +0200 Subject: [PATCH] fix: Great Workshop shown as error in Admin (editing Village) --- Admin/function.php | 1 + GameEngine/Admin/function.php | 1 + GameEngine/Building.php | 23 +++++++++++++++++++++-- todo.txt | 5 +++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Admin/function.php b/Admin/function.php index e5aab18f..6a76fb04 100644 --- a/Admin/function.php +++ b/Admin/function.php @@ -206,6 +206,7 @@ class funct { case 39: $build = "Great Granary"; break; case 40: $build = "Wonder of the World"; break; case 41: $build = "Horse Drinking Trough"; break; + case 42: $build = "Great Workshop"; break; default: $build = "Error"; break; } return $build; diff --git a/GameEngine/Admin/function.php b/GameEngine/Admin/function.php index eccf75b1..4ac42f3d 100755 --- a/GameEngine/Admin/function.php +++ b/GameEngine/Admin/function.php @@ -202,6 +202,7 @@ class funct { case 39: $build = "Great Granary"; break; case 40: $build = "Wonder of the World"; break; case 41: $build = "Horse Drinking Trough"; break; + case 42: $build = "Great Workshop"; break; default: $build = "Error"; break; } return $build; diff --git a/GameEngine/Building.php b/GameEngine/Building.php index 38ffa364..0fa523b0 100755 --- a/GameEngine/Building.php +++ b/GameEngine/Building.php @@ -663,32 +663,48 @@ class Building { public function getTypeLevel($tid,$vid=0) { global $village,$database; + $keyholder = array(); + if($vid == 0) { $resourcearray = $village->resarray; } else { $resourcearray = $database->getResourceLevel($vid); } + foreach(array_keys($resourcearray,$tid) as $key) { if(strpos($key,'t')) { $key = preg_replace("/[^0-9]/", '', $key); array_push($keyholder, $key); } } + $element = count($keyholder); + + // if we count more than 1 instance of the building (mostly resource fields) if($element >= 2) { + // resource field if($tid <= 4) { $temparray = array(); + for($i=0;$i<=$element-1;$i++) { + // collect current field level array_push($temparray,$resourcearray['f'.$keyholder[$i]]); } + + // find out the maximum field level for this village + $maValue = max($temparray); foreach ($temparray as $key => $val) { - if ($val == max($temparray)) - $target = $key; + if ($val == $maValue) { + $target = $key; + } } } + // village building else { $target = 0; + + // find the highest level built for this building type for($i=1;$i<=$element-1;$i++) { if($resourcearray['f'.$keyholder[$i]] > $resourcearray['f'.$keyholder[$target]]) { $target = $i; @@ -696,12 +712,15 @@ class Building { } } } + // if we count only a single building else if($element == 1) { $target = 0; } + // no building matching search criteria else { return 0; } + if($keyholder[$target] != "") { return $resourcearray['f'.$keyholder[$target]]; } diff --git a/todo.txt b/todo.txt index d2eba04f..06321e3d 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,3 @@ -- add PayPal listener to verify gold transactions imediatelly - add combat Simulator link to options for a village/oasis (Centre map, Raid, Send Troops...) - don't show Support & Taskmaster in stats - add Support login possibility into Admin (ask for password during installation, create Support messages section) @@ -23,4 +22,6 @@ - add registered date into user details in Admin - npc shop button is missing from settlers training (palace) - should random attacks from Natars when building Wonder of the World be unit-less? -- send forum replies in a forum where a user is active also to that user's mailbox \ No newline at end of file +- send forum replies in a forum where a user is active also to that user's mailbox +- make an option for admin to be raidable (in profile?) +- add PayPal listener to verify gold transactions imediatelly \ No newline at end of file