Fixed a bug in Palace/Residence

+Fixed a bug (or fixed a fix?) that didn't permit to train chief and
settlers in the same village
+Fixed a bug that didn't count trapped chiefs and trapped settlers
+Fixed a bug that did count chiefs and settlers of other players as used
slots, if they were attacking/reinforcing you
-Removed an unused portion of code
This commit is contained in:
iopietro
2018-04-29 16:57:27 +02:00
parent 77e3cd68b0
commit 2530dcac6d
3 changed files with 23 additions and 54 deletions
+10 -25
View File
@@ -6824,6 +6824,7 @@ References: User ID/Message ID, Mode
$chiefs = $row['R2'];
$settlers += 3 * count($this->getMovement(5, $village->wid, 0));
$current_movement = $this->getMovement(3, $village->wid, 0);
if(!empty($current_movement)) {
foreach($current_movement as $build) {
@@ -6831,20 +6832,7 @@ References: User ID/Message ID, Mode
$chiefs += $build['t9'];
}
}
$current_movement = $this->getMovement(3, $village->wid, 1);
if(!empty($current_movement)) {
foreach($current_movement as $build) {
$settlers += $build['t10'];
$chiefs += $build['t9'];
}
}
$current_movement = $this->getMovement(4, $village->wid, 0);
if(!empty($current_movement)) {
foreach($current_movement as $build) {
$settlers += $build['t10'];
$chiefs += $build['t9'];
}
}
$current_movement = $this->getMovement(4, $village->wid, 1);
if(!empty($current_movement)) {
foreach($current_movement as $build) {
@@ -6882,25 +6870,22 @@ References: User ID/Message ID, Mode
}
}
}
// TODO: trapped settlers/chiefs calculation required
$settlerslots = ($maxslots * 3) - $chiefs - $settlers;
// don't allow training of settlers if there is at least 1 chief in the village
if ($chiefs > 0) {
$settlerslots = 0;
}
$trappedTroops = $this->getPrisoners($village->wid, 1);
if(!empty($trappedTroops)){
foreach($trappedTroops as $trapped){
$settlers += $trapped['t10'];
$chiefs += $trapped['t9'];
}
}
$settlerslots = ($maxslots * 3) - ($chiefs * 3) - $settlers;
$chiefslots = $maxslots - $chiefs - floor(($settlers + 2) / 3);
if(!$technology->getTech(($session->tribe - 1) * 10 + 9)) {
$chiefslots = 0;
}
// don't allow training of chieftains if there is at least 1 settler in the village
if ($settlers > 0) {
$chiefslots = 0;
}
$slots = array("chiefs" => $chiefslots, "settlers" => $settlerslots);
return $slots;
}