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']; $chiefs = $row['R2'];
$settlers += 3 * count($this->getMovement(5, $village->wid, 0)); $settlers += 3 * count($this->getMovement(5, $village->wid, 0));
$current_movement = $this->getMovement(3, $village->wid, 0); $current_movement = $this->getMovement(3, $village->wid, 0);
if(!empty($current_movement)) { if(!empty($current_movement)) {
foreach($current_movement as $build) { foreach($current_movement as $build) {
@@ -6831,20 +6832,7 @@ References: User ID/Message ID, Mode
$chiefs += $build['t9']; $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); $current_movement = $this->getMovement(4, $village->wid, 1);
if(!empty($current_movement)) { if(!empty($current_movement)) {
foreach($current_movement as $build) { 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 $trappedTroops = $this->getPrisoners($village->wid, 1);
if ($chiefs > 0) { if(!empty($trappedTroops)){
$settlerslots = 0; foreach($trappedTroops as $trapped){
} $settlers += $trapped['t10'];
$chiefs += $trapped['t9'];
}
}
$settlerslots = ($maxslots * 3) - ($chiefs * 3) - $settlers;
$chiefslots = $maxslots - $chiefs - floor(($settlers + 2) / 3); $chiefslots = $maxslots - $chiefs - floor(($settlers + 2) / 3);
if(!$technology->getTech(($session->tribe - 1) * 10 + 9)) { if(!$technology->getTech(($session->tribe - 1) * 10 + 9)) {
$chiefslots = 0; $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); $slots = array("chiefs" => $chiefslots, "settlers" => $settlerslots);
return $slots; return $slots;
} }
+6 -6
View File
@@ -27,9 +27,9 @@
</thead> </thead>
<tbody> <tbody>
<?php <?php
for ($i=($session->tribe-1)*10+9;$i<=($session->tribe*10);$i++) { for ($i = ($session->tribe - 1) * 10 + 9; $i <= ($session->tribe * 10); $i++) {
if ($slots['settlers']>0 && $i%10==0 || $slots['chiefs']>0 && $i%10==9 && $session->tribe != 4) { if ($slots['settlers'] > 0 && $i % 10 == 0 || $slots['chiefs'] > 0 && $i % 10 == 9 && $session->tribe != 4) {
$maxunit = MIN($technology->maxUnit($i),($i%10==0?$slots['settlers']:$slots['chiefs'])); $maxunit = MIN($technology->maxUnit($i), ($i % 10 == 0 ? $slots['settlers'] : $slots['chiefs']));
echo "<tr><td class=\"desc\"> echo "<tr><td class=\"desc\">
<div class=\"tit\"> <div class=\"tit\">
@@ -56,8 +56,8 @@ echo "<td class=\"val\"><input type=\"text\" class=\"text\" name=\"t".$i."\" val
</p> </p>
</form> </form>
<?php <?php
} else { }
echo '<div class="c">'.RESIDENCE_TRAIN_DESC.'</div>'; else echo '<div class="c">'.RESIDENCE_TRAIN_DESC.'</div>';
}
include ("25_progress.tpl"); include ("25_progress.tpl");
?> ?>
+7 -23
View File
@@ -1,20 +1,4 @@
<?php <?php
$artefact = count($database->getOwnUniqueArtefactInfo2($session->uid,5,3,0));
$artefact1 = count($database->getOwnUniqueArtefactInfo2($village->wid,5,1,1));
$artefact2 = count($database->getOwnUniqueArtefactInfo2($session->uid,5,2,0));
if($artefact > 0){
$artefact_bonus = 2;
$artefact_bonus2 = 1;
}else if($artefact1 > 0){
$artefact_bonus = 2;
$artefact_bonus2 = 1;
}else if($artefact2 > 0){
$artefact_bonus = 4;
$artefact_bonus2 = 3;
}else{
$artefact_bonus = 1;
$artefact_bonus2 = 1;
}
################################################################################# #################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ## ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ## ## --------------------------------------------------------------------------- ##
@@ -27,7 +11,7 @@
$slots = $database->getAvailableExpansionTraining(); $slots = $database->getAvailableExpansionTraining();
if ($slots['settlers']+$slots['chiefs']>0) { ?> if ($slots['settlers'] + $slots['chiefs'] > 0) { ?>
<form method="POST" name="snd" action="build.php"> <form method="POST" name="snd" action="build.php">
<input type="hidden" name="id" value="<?php echo $id; ?>" /> <input type="hidden" name="id" value="<?php echo $id; ?>" />
@@ -43,9 +27,9 @@
</thead> </thead>
<tbody> <tbody>
<?php <?php
for ($i=($session->tribe-1)*10+9;$i<=($session->tribe*10);$i++) { for ($i = ($session->tribe - 1) * 10 + 9; $i <= $session->tribe * 10; $i++) {
if ($slots['settlers']>0 && $i%10==0 || $slots['chiefs']>0 && $i%10==9 && $session->tribe != 4) { if ($slots['settlers'] > 0 && $i % 10 == 0 || $slots['chiefs'] > 0 && $i % 10 == 9 && $session->tribe != 4) {
$maxunit = MIN($technology->maxUnit($i),($i%10==0?$slots['settlers']:$slots['chiefs'])); $maxunit = MIN($technology->maxUnit($i), ($i % 10 == 0 ? $slots['settlers'] : $slots['chiefs']));
echo "<tr><td class=\"desc\"> echo "<tr><td class=\"desc\">
<div class=\"tit\"> <div class=\"tit\">
@@ -73,8 +57,8 @@ echo "<td class=\"val\"><input type=\"text\" class=\"text\" name=\"t".$i."\" val
</p> </p>
</form> </form>
<?php <?php
} else { }
echo '<div class="c">'.PALACE_TRAIN_DESC.'</div>'; else echo '<div class="c">'.PALACE_TRAIN_DESC.'</div>';
}
include ("26_progress.tpl"); include ("26_progress.tpl");
?> ?>