mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-09-04 17:37:21 +00:00
fix: gold can go to negative values
Master builder cannot be used if we only have 2 gold and we chose to insta-finish everything. In such case, master builder task will be deleted instead of completed. Fixes #264
This commit is contained in:
+23
-14
@@ -785,20 +785,29 @@ class Building {
|
|||||||
$q = "UPDATE ".TB_PREFIX."fdata set f".$jobs['field']." = ".$jobs['level'].", f".$jobs['field']."t = ".$jobs['type']." where vref = ".$jobs['wid'];
|
$q = "UPDATE ".TB_PREFIX."fdata set f".$jobs['field']." = ".$jobs['level'].", f".$jobs['field']."t = ".$jobs['type']." where vref = ".$jobs['wid'];
|
||||||
$countPlus2Gold = true;
|
$countPlus2Gold = true;
|
||||||
} else {
|
} else {
|
||||||
$countMasterGold = true;
|
// don't allow master builder to build anything
|
||||||
$villwood = $database->getVillageField($jobs['wid'],'wood');
|
// if we only have 2 gold, since that would take us to -1 gold
|
||||||
$villclay = $database->getVillageField($jobs['wid'],'clay');
|
if ($session->gold > 2) {
|
||||||
$villiron = $database->getVillageField($jobs['wid'],'iron');
|
$countMasterGold = true;
|
||||||
$villcrop = $database->getVillageField($jobs['wid'],'crop');
|
$villwood = $database->getVillageField($jobs['wid'],'wood');
|
||||||
$type = $jobs['type'];
|
$villclay = $database->getVillageField($jobs['wid'],'clay');
|
||||||
$buildarray = $GLOBALS["bid".$type];
|
$villiron = $database->getVillageField($jobs['wid'],'iron');
|
||||||
$buildwood = $buildarray[$level]['wood'];
|
$villcrop = $database->getVillageField($jobs['wid'],'crop');
|
||||||
$buildclay = $buildarray[$level]['clay'];
|
$type = $jobs['type'];
|
||||||
$buildiron = $buildarray[$level]['iron'];
|
$buildarray = $GLOBALS["bid".$type];
|
||||||
$buildcrop = $buildarray[$level]['crop'];
|
$buildwood = $buildarray[$level]['wood'];
|
||||||
if($buildwood < $villwood && $buildclay < $villclay && $buildiron < $villiron && $buildcrop < $villcrop) {
|
$buildclay = $buildarray[$level]['clay'];
|
||||||
$enought_res = 1;
|
$buildiron = $buildarray[$level]['iron'];
|
||||||
$q = "UPDATE ".TB_PREFIX."fdata set f".$jobs['field']." = ".$jobs['level'].", f".$jobs['field']."t = ".(int) $jobs['type']." where vref = ".(int) $jobs['wid'];
|
$buildcrop = $buildarray[$level]['crop'];
|
||||||
|
if($buildwood < $villwood && $buildclay < $villclay && $buildiron < $villiron && $buildcrop < $villcrop) {
|
||||||
|
$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'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// if we only have 2 gold, we need to cancel this job, as there will never
|
||||||
|
// be enough gold now in our account to finish this up
|
||||||
|
$q = "DELETE FROM ".TB_PREFIX."bdata WHERE id = ".(int) $jobs['id'];
|
||||||
|
$database->query($q);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user