mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-20 02:00:58 +00:00
+22
-7
@@ -773,6 +773,8 @@ class Building {
|
|||||||
// will be true if we should decrease player's gold by 1
|
// will be true if we should decrease player's gold by 1
|
||||||
// for master builder queue
|
// for master builder queue
|
||||||
$countMasterGold = false;
|
$countMasterGold = false;
|
||||||
|
// number of jobs to finish
|
||||||
|
$buildcount = ($this->buildArray ? count($this->buildArray) : 0);
|
||||||
|
|
||||||
foreach ($this->buildArray as $jobs) {
|
foreach ($this->buildArray as $jobs) {
|
||||||
if ($jobs['wid']==$village->wid) {
|
if ($jobs['wid']==$village->wid) {
|
||||||
@@ -781,14 +783,11 @@ class Building {
|
|||||||
$level = $jobs['level'];
|
$level = $jobs['level'];
|
||||||
if ($jobs['type'] != 25 AND $jobs['type'] != 26 AND $jobs['type'] != 40) {
|
if ($jobs['type'] != 25 AND $jobs['type'] != 26 AND $jobs['type'] != 40) {
|
||||||
$resource = $this->resourceRequired($jobs['field'],$jobs['type']);
|
$resource = $this->resourceRequired($jobs['field'],$jobs['type']);
|
||||||
if ($jobs['master'] == 0) {
|
// master builder involved
|
||||||
$q = "UPDATE ".TB_PREFIX."fdata set f".$jobs['field']." = ".$jobs['level'].", f".$jobs['field']."t = ".$jobs['type']." where vref = ".$jobs['wid'];
|
if ($jobs['master'] != 0) {
|
||||||
$countPlus2Gold = true;
|
|
||||||
} else {
|
|
||||||
// don't allow master builder to build anything
|
// don't allow master builder to build anything
|
||||||
// if we only have 2 gold, since that would take us to -1 gold
|
// if we only have 2 gold, since that would take us to -1 gold
|
||||||
if ($session->gold > 2) {
|
if ($session->gold > 2) {
|
||||||
$countMasterGold = true;
|
|
||||||
$villwood = $database->getVillageField($jobs['wid'],'wood');
|
$villwood = $database->getVillageField($jobs['wid'],'wood');
|
||||||
$villclay = $database->getVillageField($jobs['wid'],'clay');
|
$villclay = $database->getVillageField($jobs['wid'],'clay');
|
||||||
$villiron = $database->getVillageField($jobs['wid'],'iron');
|
$villiron = $database->getVillageField($jobs['wid'],'iron');
|
||||||
@@ -799,9 +798,17 @@ class Building {
|
|||||||
$buildclay = $buildarray[$level]['clay'];
|
$buildclay = $buildarray[$level]['clay'];
|
||||||
$buildiron = $buildarray[$level]['iron'];
|
$buildiron = $buildarray[$level]['iron'];
|
||||||
$buildcrop = $buildarray[$level]['crop'];
|
$buildcrop = $buildarray[$level]['crop'];
|
||||||
if($buildwood < $villwood && $buildclay < $villclay && $buildiron < $villiron && $buildcrop < $villcrop) {
|
if ($buildwood < $villwood && $buildclay < $villclay && $buildiron < $villiron && $buildcrop < $villcrop) {
|
||||||
|
$countMasterGold = true;
|
||||||
$enought_res = 1;
|
$enought_res = 1;
|
||||||
$q = "UPDATE ".TB_PREFIX."fdata set f".$jobs['field']." = ".$jobs['level'].", f".$jobs['field']."t = ".(int) $jobs['type']." where vref = ".(int) $jobs['wid'];
|
// we need to subtract resources for this, if another 2 jobs are active,
|
||||||
|
// as we'd never subtract those otherwise
|
||||||
|
if ($buildcount > 2) {
|
||||||
|
$database->setVillageField($jobs['wid'],'wood',($villwood - $buildwood));
|
||||||
|
$database->setVillageField($jobs['wid'],'clay',($villclay - $buildclay));
|
||||||
|
$database->setVillageField($jobs['wid'],'iron',($villiron - $buildiron));
|
||||||
|
$database->setVillageField($jobs['wid'],'crop',($villcrop - $buildcrop));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if we only have 2 gold, we need to cancel this job, as there will never
|
// if we only have 2 gold, we need to cancel this job, as there will never
|
||||||
@@ -810,6 +817,14 @@ class Building {
|
|||||||
$q = "DELETE FROM ".TB_PREFIX."bdata WHERE id = ".(int) $jobs['id'];
|
$q = "DELETE FROM ".TB_PREFIX."bdata WHERE id = ".(int) $jobs['id'];
|
||||||
$database->query($q);
|
$database->query($q);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// non-master builder build, we should count +2 gold for it
|
||||||
|
$countPlus2Gold = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update build level in the database
|
||||||
|
if ($countMasterGold || $countPlus2Gold) {
|
||||||
|
$q = "UPDATE ".TB_PREFIX."fdata set f".$jobs['field']." = ".$jobs['level'].", f".$jobs['field']."t = ".$jobs['type']." where vref = ".$jobs['wid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($exclude_master) && $database->query($q) && ($enought_res == 1 or $jobs['master'] == 0)) {
|
if (!isset($exclude_master) && $database->query($q) && ($enought_res == 1 or $jobs['master'] == 0)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user