From ffe09c6a7bca8b849bc8b007515b30f152170c71 Mon Sep 17 00:00:00 2001 From: armando1980 Date: Wed, 18 Dec 2013 19:02:57 -0500 Subject: [PATCH] kill units if you do not have in stock and crop production is negative by armando kill units if you do not have in stock and crop production is negative --- GameEngine/Automation.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index dd85a18a..2351cafb 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -4392,7 +4392,7 @@ $wallimg = "query_return($q); - if(count($enforcearray)==0){ + if(count($enforcearray)>0){ foreach ($enforcearray as $enforce){ for($i = 0 ; $i <= 50 ; $i++){ $units = $enforce['u'.$i]; @@ -4450,16 +4450,21 @@ $wallimg = "0) { + if ($hungry['crop']>0 && $oldcrop <=0) { $killunits = intval($difcrop/$hungry['crop']); }else $killunits=0; if($killunits > 0){ + $pskolko = abs($skolko); + if($killunits > $pskolko && $skolko <0){ + $killunits = $pskolko; + } if (isset($enf)){ if($killunits < $maxcount){ $database->modifyEnforce($enf, $maxtype, $killunits, 0); $database->setVillageField($starv['wref'], 'starv', $upkeep); $database->setVillageField($starv['wref'], 'starvupdate', $time); + $database->modifyResource($starv['wref'],0,0,0,$hungry['crop'],1); if($maxtype == "hero"){ $heroid = $database->getHeroField($database->getVillageField($enf,"owner"),"heroid"); $database->modifyHero("dead", 1, $heroid); @@ -4474,6 +4479,7 @@ $wallimg = "modifyUnit($starv['wref'], array($maxtype), array($killunits), array(0)); $database->setVillageField($starv['wref'], 'starv', $upkeep); $database->setVillageField($starv['wref'], 'starvupdate', $time); + $database->modifyResource($starv['wref'],0,0,0,$hungry['crop'],1); if($maxtype == "hero"){ $heroid = $database->getHeroField($starv['owner'],"heroid"); $database->modifyHero("dead", 1, $heroid);