mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-09-19 00:27:17 +00:00
Merge pull request #509 from iopietro/master
Fixed a building bug and some cleanup Fixed the issue #506.
This commit is contained in:
@@ -3219,7 +3219,8 @@ class Automation {
|
|||||||
,$troopsdead9
|
,$troopsdead9
|
||||||
,$troopsdead10
|
,$troopsdead10
|
||||||
,$troopsdead11
|
,$troopsdead11
|
||||||
,$DefenderUnit);
|
,$DefenderUnit
|
||||||
|
,$info_trap);
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
|
|
||||||
|
|||||||
+24
-47
@@ -42,29 +42,6 @@ class Building {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function residenceOfPalaceBuildInProgress() {
|
|
||||||
global $database, $village;
|
|
||||||
|
|
||||||
$residenceOrPalaceInProgress = $database->getBuildingByType2($village->wid, '25, 26');
|
|
||||||
$residenceBuildInProgress = false;
|
|
||||||
$palaceBuildInProgress = false;
|
|
||||||
|
|
||||||
if (count($residenceOrPalaceInProgress)) {
|
|
||||||
foreach ($residenceOrPalaceInProgress as $record) {
|
|
||||||
if ($record == 25) {
|
|
||||||
$residenceBuildInProgress = true;
|
|
||||||
} else {
|
|
||||||
$palaceBuildInProgress = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'residence' => $residenceBuildInProgress,
|
|
||||||
'palace' => $palaceBuildInProgress
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Checks whether to allow building Wonder of the World
|
* Checks whether to allow building Wonder of the World
|
||||||
* above current level. This includes checks for WW upgrade
|
* above current level. This includes checks for WW upgrade
|
||||||
@@ -144,19 +121,9 @@ class Building {
|
|||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
$levels = $database->getResourceLevel($village->wid);
|
$levels = $database->getResourceLevel($village->wid);
|
||||||
$progresses = $this->residenceOfPalaceBuildInProgress();
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!(
|
!(
|
||||||
// check if we're not trying to hack-build residence and palace together
|
|
||||||
(
|
|
||||||
!in_array($tid, [25, 26]) ||
|
|
||||||
(
|
|
||||||
($tid == 25 && $progresses['palace'] === false) ||
|
|
||||||
($tid == 26 && $progresses['residence'] === false)
|
|
||||||
)
|
|
||||||
) &&
|
|
||||||
|
|
||||||
// don't allow building WW to level 51 with a waiting loop
|
// don't allow building WW to level 51 with a waiting loop
|
||||||
(
|
(
|
||||||
$tid != 99 ||
|
$tid != 99 ||
|
||||||
@@ -183,6 +150,11 @@ class Building {
|
|||||||
(
|
(
|
||||||
$levels['f'.$tid.'t'] == $id ||
|
$levels['f'.$tid.'t'] == $id ||
|
||||||
$levels['f'.$tid.'t'] == 0
|
$levels['f'.$tid.'t'] == 0
|
||||||
|
) &&
|
||||||
|
// check that we're not trying to build in the walls id
|
||||||
|
(
|
||||||
|
($tid == 40 && in_array($id, [31, 32, 33])) ||
|
||||||
|
$tid != 40
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
if ( !isset($_GET['master']) && $this->checkResource( $id, $tid ) != 4 ) {
|
if ( !isset($_GET['master']) && $this->checkResource( $id, $tid ) != 4 ) {
|
||||||
@@ -590,18 +562,6 @@ class Building {
|
|||||||
global $database,$village,$session,$logging;
|
global $database,$village,$session,$logging;
|
||||||
|
|
||||||
if($this->allocated < $this->maxConcurrent) {
|
if($this->allocated < $this->maxConcurrent) {
|
||||||
// check if we're not trying to hack-build residence and palace together
|
|
||||||
if (
|
|
||||||
($progresses = $this->residenceOfPalaceBuildInProgress()) &&
|
|
||||||
(
|
|
||||||
!in_array($tid, [25, 26]) ||
|
|
||||||
(
|
|
||||||
($tid == 25 && $progresses['palace'] === false) ||
|
|
||||||
($tid == 26 && $progresses['residence'] === false)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
|
|
||||||
if ( $tid == 16 ) {
|
if ( $tid == 16 ) {
|
||||||
$id = 39;
|
$id = 39;
|
||||||
} else if ( $tid == 31 || $tid == 32 || $tid == 33 ) {
|
} else if ( $tid == 31 || $tid == 32 || $tid == 33 ) {
|
||||||
@@ -640,6 +600,23 @@ class Building {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search through all user's villages if the castle is built or not
|
||||||
|
*
|
||||||
|
* @return boolean Returns true if the castle is already built in the whole account, otherwise returns false
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function isCastleBuilt(){
|
||||||
|
global $database, $session;
|
||||||
|
|
||||||
|
$villages = $database->getProfileVillages($session->uid);
|
||||||
|
foreach ($villages as $vil){
|
||||||
|
if(in_array(26, $database->getResourceLevel($vil['wref']))){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function meetRequirement($id) {
|
private function meetRequirement($id) {
|
||||||
@@ -677,8 +654,8 @@ class Building {
|
|||||||
case 22: return $this->getTypeLevel(15) >= 3 && $this->getTypeLevel(19) >= 3 && !$isBuilt;
|
case 22: return $this->getTypeLevel(15) >= 3 && $this->getTypeLevel(19) >= 3 && !$isBuilt;
|
||||||
case 23: return !$isBuilt || $this->getTypeLevel($id) == 10;
|
case 23: return !$isBuilt || $this->getTypeLevel($id) == 10;
|
||||||
case 24: return $this->getTypeLevel(22) >= 10 && $this->getTypeLevel(15) >= 10 && !$isBuilt;
|
case 24: return $this->getTypeLevel(22) >= 10 && $this->getTypeLevel(15) >= 10 && !$isBuilt;
|
||||||
case 25: return $this->getTypeLevel(15) >= 5 && $this->getTypeLevel(26) == 0 && !$isBuilt;
|
case 25: return $this->getTypeLevel(15) >= 5 && !$isBuilt && !$this->getTypeField(26);
|
||||||
case 26: return $this->getTypeLevel(18) >= 1 && $this->getTypeLevel(15) >= 5 && $this->getTypeLevel(25) == 0 && !$isBuilt;
|
case 26: return $this->getTypeLevel(18) >= 1 && $this->getTypeLevel(15) >= 5 && !$isBuilt && !$this->isCastleBuilt() && !$this->getTypeField(25);
|
||||||
case 27: return $this->getTypeLevel(15) >= 10 && !$isBuilt;
|
case 27: return $this->getTypeLevel(15) >= 10 && !$isBuilt;
|
||||||
case 28: return $this->getTypeLevel(17) == 20 && $this->getTypeLevel(20) >= 10 && !$isBuilt;
|
case 28: return $this->getTypeLevel(17) == 20 && $this->getTypeLevel(20) >= 10 && !$isBuilt;
|
||||||
case 29: return $this->getTypeLevel(19) == 20 && $village->capital == 0 && !$isBuilt;
|
case 29: return $this->getTypeLevel(19) == 20 && $village->capital == 0 && !$isBuilt;
|
||||||
|
|||||||
@@ -98,12 +98,8 @@ $greatwarehouse1 = getTypeCount(38);
|
|||||||
$greatgranary1 = getTypeCount(39);
|
$greatgranary1 = getTypeCount(39);
|
||||||
$greatworkshop1 = getTypeCount(42);
|
$greatworkshop1 = getTypeCount(42);
|
||||||
|
|
||||||
$residenceOrPalaceInProgress = $building->residenceOfPalaceBuildInProgress();
|
|
||||||
$residenceBuildInProgress = $residenceOrPalaceInProgress['residence'];
|
|
||||||
$palaceBuildInProgress = $residenceOrPalaceInProgress['palace'];
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div id="build" class="gid0"><h1<?php echo CONSTRUCT_NEW_BUILDING;?></h1>
|
<div id="build" class="gid0"><h1><?php echo CONSTRUCT_NEW_BUILDING;?></h1>
|
||||||
<?php
|
<?php
|
||||||
if($mainbuilding == 0 && $mainbuilding1 == 0 && $id != 39 && $id != 40) {
|
if($mainbuilding == 0 && $mainbuilding1 == 0 && $id != 39 && $id != 40) {
|
||||||
include("avaliable/mainbuilding.tpl");
|
include("avaliable/mainbuilding.tpl");
|
||||||
@@ -167,47 +163,15 @@ include("avaliable/grainmill.tpl");
|
|||||||
if($granary >= 1 && $warehouse >= 1 && $mainbuilding >= 3 && $market == 0 && $market1 == 0 && $id != 39 && $id != 40) {
|
if($granary >= 1 && $warehouse >= 1 && $mainbuilding >= 3 && $market == 0 && $market1 == 0 && $id != 39 && $id != 40) {
|
||||||
include("avaliable/marketplace.tpl");
|
include("avaliable/marketplace.tpl");
|
||||||
}
|
}
|
||||||
if($mainbuilding >= 5 && $residence == 0 && $residence1 == 0 && $id != 39 && $id != 40 && $palace == 0 && !$palaceBuildInProgress) {
|
if($mainbuilding >= 5 && $residence == 0 && $residence1 == 0 && $id != 39 && $id != 40 && $palace == 0 && $palace1 == 0) {
|
||||||
include("avaliable/residence.tpl");
|
include("avaliable/residence.tpl");
|
||||||
}
|
}
|
||||||
if($academy == 0 && $academy1 == 0 && $mainbuilding >= 3 && $barrack >= 3 && $id != 39 && $id != 40) {
|
if($academy == 0 && $academy1 == 0 && $mainbuilding >= 3 && $barrack >= 3 && $id != 39 && $id != 40) {
|
||||||
include("avaliable/academy.tpl");
|
include("avaliable/academy.tpl");
|
||||||
}
|
}
|
||||||
|
if($palace == 0 && $palace1 == 0 && !$building->isCastleBuilt() && $village->natar == 0 && $embassy >= 1 && $mainbuilding >= 5 && $id != 39 && $id != 40 && $residence == 0 && $residence1 == 0) {
|
||||||
if($palace == 0 && $palace1 == 0 && $village->natar == 0 && $embassy >= 1 && $mainbuilding >= 5 && $id != 39 && $id != 40 && $residence == 0 && $residence1 == 0) {
|
|
||||||
|
|
||||||
//Fix Castle
|
|
||||||
//id user
|
|
||||||
$user = $session->uid;
|
|
||||||
|
|
||||||
|
|
||||||
//loop search village user
|
|
||||||
$villages = $database->getProfileVillages($user);
|
|
||||||
foreach ($villages as $villaggi_array){
|
|
||||||
|
|
||||||
//loop structure village
|
|
||||||
$query1 = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".(int) $villaggi_array['wref']."");
|
|
||||||
$strutture= mysqli_fetch_array($query1);
|
|
||||||
if($strutture == false)
|
|
||||||
$strutture = [];
|
|
||||||
//search Castle in array structure village
|
|
||||||
$test = in_array(26,$strutture);
|
|
||||||
|
|
||||||
if ($test){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//if Castle no ready include palace.tpl
|
|
||||||
if (!$test && !$residenceBuildInProgress){
|
|
||||||
include("avaliable/palace.tpl");
|
include("avaliable/palace.tpl");
|
||||||
}
|
}
|
||||||
|
|
||||||
//end Fix
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if($blacksmith == 0 && $blacksmith1 == 0 && $academy >= 3 && $mainbuilding >= 3 && $id != 39 && $id != 40) {
|
if($blacksmith == 0 && $blacksmith1 == 0 && $academy >= 3 && $mainbuilding >= 3 && $id != 39 && $id != 40) {
|
||||||
include("avaliable/blacksmith.tpl");
|
include("avaliable/blacksmith.tpl");
|
||||||
}
|
}
|
||||||
@@ -286,7 +250,7 @@ if($armoury == 0 && ($mainbuilding <= 2 || $academy == 0)) {
|
|||||||
if($cropland <= 4) {
|
if($cropland <= 4) {
|
||||||
include("soon/grainmill.tpl");
|
include("soon/grainmill.tpl");
|
||||||
}
|
}
|
||||||
if(isset($marketplace) && $marketplace == 0 && ($mainbuilding <= 2 || $granary <= 0 || $warehouse <= 0)) {
|
if($marketplace == 0 && ($mainbuilding <= 2 || $granary <= 0 || $warehouse <= 0)) {
|
||||||
include("soon/marketplace.tpl");
|
include("soon/marketplace.tpl");
|
||||||
}
|
}
|
||||||
if($residence == 0 && $mainbuilding <= 4) {
|
if($residence == 0 && $mainbuilding <= 4) {
|
||||||
@@ -295,42 +259,9 @@ if($residence == 0 && $mainbuilding <= 4) {
|
|||||||
if($academy == 0 && ($mainbuilding <= 2 || $barrack <= 2)) {
|
if($academy == 0 && ($mainbuilding <= 2 || $barrack <= 2)) {
|
||||||
include("soon/academy.tpl");
|
include("soon/academy.tpl");
|
||||||
}
|
}
|
||||||
if($embassy == 0 || $mainbuilding >= 2 && $mainbuilding <= 4 && $village->natar == 0) {
|
if($embassy == 0 || $mainbuilding >= 2 && $mainbuilding <= 4 && !$building->isCastleBuilt() && $village->natar == 0) {
|
||||||
//Fix Castle
|
|
||||||
//id user
|
|
||||||
$user = $session->uid;
|
|
||||||
|
|
||||||
//connect to DB
|
|
||||||
//mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
|
||||||
//mysqli_select_db(SQL_DB);
|
|
||||||
|
|
||||||
//loop search village user
|
|
||||||
$villages = $database->getProfileVillages($user);
|
|
||||||
foreach ($villages as $villaggi_array){
|
|
||||||
|
|
||||||
//loop structure village
|
|
||||||
$query1 = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".(int) $villaggi_array['wref']."");
|
|
||||||
$strutture= mysqli_fetch_array($query1);
|
|
||||||
|
|
||||||
//search Castle in array structure village
|
|
||||||
if($strutture !== false)
|
|
||||||
$test = in_array(26,$strutture);
|
|
||||||
else
|
|
||||||
$test = in_array(26,[]);
|
|
||||||
if ($test){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//if Castle no ready include palace.tpl
|
|
||||||
if (!$test){
|
|
||||||
include("soon/palace.tpl");
|
include("soon/palace.tpl");
|
||||||
}
|
}
|
||||||
|
|
||||||
//end Fix
|
|
||||||
}
|
|
||||||
if($blacksmith == 0 && ($academy <= 2 || $mainbuilding <= 2)) {
|
if($blacksmith == 0 && ($academy <= 2 || $mainbuilding <= 2)) {
|
||||||
include("soon/blacksmith.tpl");
|
include("soon/blacksmith.tpl");
|
||||||
}
|
}
|
||||||
@@ -388,64 +319,64 @@ href="javascript:show_build_list('all');"><?php echo SHOW_MORE;?></a></p>
|
|||||||
<div id="build_list_all" class="hide">
|
<div id="build_list_all" class="hide">
|
||||||
<?php
|
<?php
|
||||||
if($academy == 0 && ($mainbuilding == 1 || $barrack == 0)) {
|
if($academy == 0 && ($mainbuilding == 1 || $barrack == 0)) {
|
||||||
include("soon/academy.tpl");
|
include_once("soon/academy.tpl");
|
||||||
}
|
}
|
||||||
if($palace == 0 && ($embassy == 0 || $mainbuilding <= 2) && $village->natar == 0) {
|
if($palace == 0 && ($embassy == 0 || $mainbuilding <= 2) && $village->natar == 0) {
|
||||||
include("soon/palace.tpl");
|
include_once("soon/palace.tpl");
|
||||||
}
|
}
|
||||||
if($blacksmith == 0 && ($academy == 0 || $mainbuilding == 1)) {
|
if($blacksmith == 0 && ($academy == 0 || $mainbuilding == 1)) {
|
||||||
include("soon/blacksmith.tpl");
|
include_once("soon/blacksmith.tpl");
|
||||||
}
|
}
|
||||||
if($stonemason == 0 && ($palace == 0 || $mainbuilding <= 2) && $residence == 0) {
|
if($stonemason == 0 && ($palace == 0 || $mainbuilding <= 2) && $residence == 0) {
|
||||||
include("soon/stonemason.tpl");
|
include_once("soon/stonemason.tpl");
|
||||||
}
|
}
|
||||||
if($stable == 0 && ($blacksmith == 0 || $academy <= 2)) {
|
if($stable == 0 && ($blacksmith == 0 || $academy <= 2)) {
|
||||||
include("soon/stable.tpl");
|
include_once("soon/stable.tpl");
|
||||||
}
|
}
|
||||||
if($treasury == 0 && $mainbuilding <= 5) {
|
if($treasury == 0 && $mainbuilding <= 5) {
|
||||||
include("soon/treasury.tpl");
|
include_once("soon/treasury.tpl");
|
||||||
}
|
}
|
||||||
if($brickyard == 0 && ($claypit <= 5 || $mainbuilding <= 2)) {
|
if($brickyard == 0 && ($claypit <= 5 || $mainbuilding <= 2)) {
|
||||||
include("soon/brickyard.tpl");
|
include_once("soon/brickyard.tpl");
|
||||||
}
|
}
|
||||||
if($sawmill == 0 && ($woodcutter <= 5 || $mainbuilding <= 2)) {
|
if($sawmill == 0 && ($woodcutter <= 5 || $mainbuilding <= 2)) {
|
||||||
include("soon/sawmill.tpl");
|
include_once("soon/sawmill.tpl");
|
||||||
}
|
}
|
||||||
if($ironfoundry == 0 && ($ironmine <= 5 || $mainbuilding <= 2)) {
|
if($ironfoundry == 0 && ($ironmine <= 5 || $mainbuilding <= 2)) {
|
||||||
include("soon/ironfoundry.tpl");
|
include_once("soon/ironfoundry.tpl");
|
||||||
}
|
}
|
||||||
if($workshop == 0 && ($academy <= 5 || $mainbuilding <= 2)) {
|
if($workshop == 0 && ($academy <= 5 || $mainbuilding <= 2)) {
|
||||||
include("soon/workshop.tpl");
|
include_once("soon/workshop.tpl");
|
||||||
}
|
}
|
||||||
if($tournamentsquare == 0 && $rallypoint <= 7) {
|
if($tournamentsquare == 0 && $rallypoint <= 7) {
|
||||||
include("soon/tsquare.tpl");
|
include_once("soon/tsquare.tpl");
|
||||||
}
|
}
|
||||||
if($bakery == 0 && ($grainmill == 0 || $cropland <= 5 || $mainbuilding <= 2)) {
|
if($bakery == 0 && ($grainmill == 0 || $cropland <= 5 || $mainbuilding <= 2)) {
|
||||||
include("soon/bakery.tpl");
|
include_once("soon/bakery.tpl");
|
||||||
}
|
}
|
||||||
if($townhall == 0 && ($mainbuilding <= 5 || $academy <= 5)) {
|
if($townhall == 0 && ($mainbuilding <= 5 || $academy <= 5)) {
|
||||||
include("soon/townhall.tpl");
|
include_once("soon/townhall.tpl");
|
||||||
}
|
}
|
||||||
if($tradeoffice == 0 && ($market <= 10 || $stable <= 5)) {
|
if($tradeoffice == 0 && ($market <= 10 || $stable <= 5)) {
|
||||||
include("soon/tradeoffice.tpl");
|
include_once("soon/tradeoffice.tpl");
|
||||||
}
|
}
|
||||||
if($session->tribe == 1 && $horsedrinkingtrough == 0 && ($rallypoint <= 5 || $stable <= 10)) {
|
if($session->tribe == 1 && $horsedrinkingtrough == 0 && ($rallypoint <= 5 || $stable <= 10)) {
|
||||||
include("soon/horsedrinking.tpl");
|
include_once("soon/horsedrinking.tpl");
|
||||||
}
|
}
|
||||||
if($brewery == 0 && ($rallypoint <= 5 || $granary <= 10) && $session->tribe == 2 && $village->capital == 1) {
|
if($brewery == 0 && ($rallypoint <= 5 || $granary <= 10) && $session->tribe == 2 && $village->capital == 1) {
|
||||||
include("soon/brewery.tpl");
|
include_once("soon/brewery.tpl");
|
||||||
}
|
}
|
||||||
if($greatbarracks == 0 && $barrack >= 15 && $village->capital == 0) {
|
if($greatbarracks == 0 && $barrack >= 15 && $village->capital == 0) {
|
||||||
include("soon/greatbarracks.tpl");
|
include_once("soon/greatbarracks.tpl");
|
||||||
}
|
}
|
||||||
if($greatstable == 0 && $stable >= 15 && $village->capital == 0) {
|
if($greatstable == 0 && $stable >= 15 && $village->capital == 0) {
|
||||||
include("soon/greatstable.tpl");
|
include_once("soon/greatstable.tpl");
|
||||||
}
|
}
|
||||||
if($greatworkshop == 0 && $workshop >= 15 && $village->capital == 0 && GREAT_WKS) {
|
if($greatworkshop == 0 && $workshop >= 15 && $village->capital == 0 && GREAT_WKS) {
|
||||||
include("soon/greatworkshop.tpl");
|
include_once("soon/greatworkshop.tpl");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div><script language="JavaScript" type="text/javascript">
|
</div><script type="text/javascript">
|
||||||
function show_build_list(list) {
|
function show_build_list(list) {
|
||||||
// aktuelle liste, aktueller link
|
// aktuelle liste, aktueller link
|
||||||
var build_list = document.getElementById('build_list_'+list);
|
var build_list = document.getElementById('build_list_'+list);
|
||||||
|
|||||||
Reference in New Issue
Block a user