mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-27 05:37:15 +00:00
fix: immediate finish (PLUS) allows master builder to build 2 levels
This commit is contained in:
+33
-31
@@ -786,39 +786,41 @@ class Building {
|
|||||||
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']);
|
||||||
// master builder involved
|
// master builder involved
|
||||||
if ($jobs['master'] != 0 && $this->meetRequirement($jobs['field'])) {
|
if ($jobs['master'] != 0) {
|
||||||
// don't allow master builder to build anything
|
if ($this->meetRequirement($jobs['field'])) {
|
||||||
// if we only have 2 gold, since that would take us to -1 gold
|
// don't allow master builder to build anything
|
||||||
if ($session->gold > 2) {
|
// if we only have 2 gold, since that would take us to -1 gold
|
||||||
$villwood = $database->getVillageField($jobs['wid'],'wood');
|
if ( $session->gold > 2 ) {
|
||||||
$villclay = $database->getVillageField($jobs['wid'],'clay');
|
$villwood = $database->getVillageField( $jobs['wid'], 'wood' );
|
||||||
$villiron = $database->getVillageField($jobs['wid'],'iron');
|
$villclay = $database->getVillageField( $jobs['wid'], 'clay' );
|
||||||
$villcrop = $database->getVillageField($jobs['wid'],'crop');
|
$villiron = $database->getVillageField( $jobs['wid'], 'iron' );
|
||||||
$type = $jobs['type'];
|
$villcrop = $database->getVillageField( $jobs['wid'], 'crop' );
|
||||||
$buildarray = $GLOBALS["bid".$type];
|
$type = $jobs['type'];
|
||||||
$buildwood = $buildarray[$level]['wood'];
|
$buildarray = $GLOBALS[ "bid" . $type ];
|
||||||
$buildclay = $buildarray[$level]['clay'];
|
$buildwood = $buildarray[ $level ]['wood'];
|
||||||
$buildiron = $buildarray[$level]['iron'];
|
$buildclay = $buildarray[ $level ]['clay'];
|
||||||
$buildcrop = $buildarray[$level]['crop'];
|
$buildiron = $buildarray[ $level ]['iron'];
|
||||||
if ($buildwood < $villwood && $buildclay < $villclay && $buildiron < $villiron && $buildcrop < $villcrop) {
|
$buildcrop = $buildarray[ $level ]['crop'];
|
||||||
$jobFinishSuccess = true;
|
if ( $buildwood < $villwood && $buildclay < $villclay && $buildiron < $villiron && $buildcrop < $villcrop ) {
|
||||||
$countMasterGold = true;
|
$jobFinishSuccess = true;
|
||||||
$enought_res = 1;
|
$countMasterGold = true;
|
||||||
// we need to subtract resources for this, if another 2 jobs are active,
|
$enought_res = 1;
|
||||||
// as we'd never subtract those otherwise
|
// we need to subtract resources for this, if another 2 jobs are active,
|
||||||
if ($buildcount > 2) {
|
// as we'd never subtract those otherwise
|
||||||
$database->setVillageField($jobs['wid'],'wood',($villwood - $buildwood));
|
if ( $buildcount > 2 ) {
|
||||||
$database->setVillageField($jobs['wid'],'clay',($villclay - $buildclay));
|
$database->setVillageField( $jobs['wid'], 'wood', ( $villwood - $buildwood ) );
|
||||||
$database->setVillageField($jobs['wid'],'iron',($villiron - $buildiron));
|
$database->setVillageField( $jobs['wid'], 'clay', ( $villclay - $buildclay ) );
|
||||||
$database->setVillageField($jobs['wid'],'crop',($villcrop - $buildcrop));
|
$database->setVillageField( $jobs['wid'], 'iron', ( $villiron - $buildiron ) );
|
||||||
|
$database->setVillageField( $jobs['wid'], 'crop', ( $villcrop - $buildcrop ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} 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
|
||||||
|
$exclude_master = true;
|
||||||
|
$q = "DELETE FROM " . TB_PREFIX . "bdata WHERE id = " . (int) $jobs['id'];
|
||||||
|
$database->query( $q );
|
||||||
}
|
}
|
||||||
} 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
|
|
||||||
$exclude_master = true;
|
|
||||||
$q = "DELETE FROM ".TB_PREFIX."bdata WHERE id = ".(int) $jobs['id'];
|
|
||||||
$database->query($q);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// non-master builder build, we should count +2 gold for it
|
// non-master builder build, we should count +2 gold for it
|
||||||
|
|||||||
Reference in New Issue
Block a user