mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-11 23:26:08 +00:00
General fixes
+Added WW building plans to the "Small artifacts" section of the treasury +Fixed a bug that permitted to maintain a building in queue when destroyed by catapults +Fixed a bug that didn't count the catapult destruction of a building in building queue
This commit is contained in:
+13
-13
@@ -812,9 +812,12 @@ class Automation {
|
||||
|
||||
$newLevel = $battle->CalculateNewBuildingLevel($battlepart['catapults']['moral'], $battlepart['catapults']['updown'], $tblevel, $battlepart['catapults']['realAttackers'], $data['t8']);
|
||||
|
||||
//If that building was present in the building queue, we have to modify his level or remove it
|
||||
$database->modifyBData($data['to'], $tbid, [$newLevel, $tblevel]);
|
||||
|
||||
// building/field destroyed
|
||||
if ($newLevel == 0)
|
||||
{
|
||||
{
|
||||
// prepare data to be updated
|
||||
$fieldsToSet = ["f".$tbid];
|
||||
$fieldValuesToSet = [0];
|
||||
@@ -834,20 +837,18 @@ class Automation {
|
||||
$buildarray = $GLOBALS["bid".$tbgid];
|
||||
|
||||
// (great) warehouse level was changed
|
||||
if ($tbgid==10 || $tbgid==38) {
|
||||
if ($tbgid == 10 || $tbgid == 38) {
|
||||
$database->setMaxStoreForVillage($data['to'], $buildarray[$newLevel]['attri']);
|
||||
}
|
||||
|
||||
// (great) granary level was changed
|
||||
if ($tbgid==11 || $tbgid==39) {
|
||||
if ($tbgid == 11 || $tbgid == 39) {
|
||||
$database->setMaxCropForVillage($data['to'], $buildarray[$newLevel]['attri']);
|
||||
}
|
||||
|
||||
// oasis cannot be destroyed
|
||||
$pop = $this->recountPop($data['to'], false);
|
||||
if ($isoasis == 0) {
|
||||
if($pop == 0 && $can_destroy == 1) $village_destroyed = 1;
|
||||
}
|
||||
if ($isoasis == 0 && $pop == 0 && $can_destroy == 1) $village_destroyed = 1;
|
||||
|
||||
if ($isSecondRow) {
|
||||
if ($tbid > 0) {
|
||||
@@ -856,7 +857,7 @@ class Automation {
|
||||
}
|
||||
|
||||
// embassy level was changed
|
||||
if ($tbgid==18){
|
||||
if ($tbgid == 18){
|
||||
$info_cat .= $database->checkEmbassiesAfterBattle($data['to'], $bdo['f'.$catapultTarget], false);
|
||||
}
|
||||
|
||||
@@ -865,15 +866,14 @@ class Automation {
|
||||
$info_cat = "".$catp_pic.", ".$this->procResType($tbgid, $can_destroy)." <b>destroyed</b>.";
|
||||
|
||||
// embassy level was changed
|
||||
if ($tbgid==18){
|
||||
if ($tbgid == 18){
|
||||
$info_cat .= $database->checkEmbassiesAfterBattle($data['to'], $bdo['f'.$catapultTarget], false);
|
||||
}
|
||||
}
|
||||
}
|
||||
// building/field not damaged
|
||||
elseif ($newLevel == $tblevel)
|
||||
{
|
||||
if ($isSecondRow) {
|
||||
elseif($newLevel == $tblevel){
|
||||
if($isSecondRow) {
|
||||
if ($tbid > 0) {
|
||||
$info_cat .= "<tbody class=\"goods\"><tr><th>Information</th><td colspan=\"11\">
|
||||
<img class=\"unit u".$catp_pic."\" src=\"img/x.gif\" alt=\"Catapult\" title=\"Catapult\" /> ".$this->procResType($tbgid, $can_destroy)." was not damaged.</td></tr></tbody>";
|
||||
@@ -882,9 +882,9 @@ class Automation {
|
||||
$info_cat = "".$catp_pic.",".$this->procResType($tbgid, $can_destroy)." was not damaged.";
|
||||
}
|
||||
}
|
||||
else
|
||||
// building/field was damaged, let's calculate the actual damage
|
||||
{
|
||||
else
|
||||
{
|
||||
// update $bdo, so we don't have to reselect later
|
||||
$bdo['f'.$catapultTarget] = $newLevel;
|
||||
|
||||
|
||||
+22
-9
@@ -4941,7 +4941,7 @@ References: User ID/Message ID, Mode
|
||||
}
|
||||
|
||||
function checkEmbassiesAfterBattle($vid, $current_level, $use_cache = true) {
|
||||
$userData = $this->getUserArray($this->getVillageField($vid,"owner"), 1);
|
||||
$userData = $this->getUserArray($this->getVillageField($vid, "owner"), 1);
|
||||
|
||||
Automation::updateMax($this->getVillageField($vid,"owner"));
|
||||
$allianceStatus = $this->checkAllianceEmbassiesStatus([
|
||||
@@ -4951,16 +4951,29 @@ References: User ID/Message ID, Mode
|
||||
'lvl' => $current_level
|
||||
], false, $use_cache);
|
||||
|
||||
if ($allianceStatus === false) {
|
||||
return ' This player\'s alliance has been dispersed.';
|
||||
} else if ($allianceStatus === 0) {
|
||||
return ' Player was forced to leave their alliance.';
|
||||
} else {
|
||||
// all is good, no need to append additional alliance-related text
|
||||
return '';
|
||||
}
|
||||
if ($allianceStatus === false) return ' This player\'s alliance has been dispersed.';
|
||||
else if ($allianceStatus === 0) return ' Player was forced to leave their alliance.';
|
||||
else return ''; // all is good, no need to append additional alliance-related text
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify or delete a building being constructed/in queue
|
||||
*
|
||||
* @param int The village ID
|
||||
* @param int $field The field where the building is located
|
||||
* @param array $levels The new level of the building and the old one
|
||||
* @return bool Returns true if the query was successful, false otherwise
|
||||
*/
|
||||
|
||||
function modifyBData($wid, $field, $levels){
|
||||
list($wid, $field, $levels) = $this->escape_input((int) $wid, (int) $field, $levels);
|
||||
|
||||
if($levels[0] == 0) $q = "DELETE FROM " .TB_PREFIX. "bdata WHERE wid = $wid AND field = $field";
|
||||
else $q = "UPDATE " .TB_PREFIX. "bdata SET level = level - $levels[1] + $levels[0] WHERE wid = $wid AND field = $field";
|
||||
|
||||
return mysqli_query($this->dblink, $q);
|
||||
}
|
||||
|
||||
private function getBData($wid, $use_cache = true) {
|
||||
$wid = (int) $wid;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user