From 9fc10e0f65e33c52f71246a0ca73d48a8771368d Mon Sep 17 00:00:00 2001 From: hide_d Date: Fri, 14 Sep 2018 02:35:27 +0900 Subject: [PATCH] =?UTF-8?q?=EB=86=8D=EC=A7=80=20=EA=B0=9C=EA=B0=84,=20?= =?UTF-8?q?=EC=83=81=EC=97=85=20=ED=88=AC=EC=9E=90=EB=A5=BC=20=EC=99=B8?= =?UTF-8?q?=EB=B6=80=20=EC=BB=A4=EB=A7=A8=EB=93=9C=EB=A1=9C=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func_process.php | 55 +++++++------------------------ hwe/sammo/Command/BaseCommand.php | 6 +++- hwe/sammo/General.php | 4 +++ 3 files changed, 20 insertions(+), 45 deletions(-) diff --git a/hwe/func_process.php b/hwe/func_process.php index f43e7f42..9d71d0eb 100644 --- a/hwe/func_process.php +++ b/hwe/func_process.php @@ -208,53 +208,20 @@ function process_1(array $rawGeneral, int $type){ $actionName = '상업 투자'; } - [$startYear, $year, $month, $develCost] = $gameStor->getValuesAsArray(['startyear', 'year', 'month', 'develcost']); + $env = $gameStor->getValues(['startyear', 'year', 'month', 'develcost']); + $general = new General($rawGeneral, null, $env['year'], $env['month']); - $general = new General($rawGeneral, $year, $month); - $logger = $general->getLogger(); - - $nationTypeObj = $general->getNationTypeObj(); - $generalLevelObj = $general->getGeneralLevelObj(); - - $reqGold = $nationTypeObj->onCalcDomestic($cityKey, 'cost', $develCost); - $reqGold = $generalLevelObj->onCalcDomestic($cityKey, 'cost', $develCost); - - $city = $db->queryFirstRow('SELECT * FROM city WHERE city = %i', $general->getCityID()); - - $constraints = [ - ['NoNeutral'], - ['NoWanderingNation'], - ['OccupiedCity'], - ['SuppliedCity'], - ['ReqGeneralGold', $reqGold], - ['RemainCityCapacity', [$cityKey, $actionName]] - ]; - $failReason = Constraint::testAll($constraints, [ - 'nation'=>$general->getStaticNation(), - 'city'=>$city, - 'general'=>$general->getRaw(), - ]); - - if($failReason !== null){ - $logger->pushGeneralActionLog("{$failReason} {$sabotageName} 실패. <1>{$date}"); - return; + if($type == 1){ + $cmdObj = new Command\che_농지개간($general, $env); + } + else{ + $cmdObj = new Command\che_상업투자($general, $env); } - $trust = Util::valutFit($city['trust'], 50); - - $score = getGeneralIntel($general, true, true, true, false); - $score *= $trust / 100; - $score *= getDomesticExpLevelBonus($general['explevel']); - $score *= Util::randRange(0.8, 1.2); - $score = $nationTypeObj->onCalcDomestic($cityKey, 'score', $score); - $score = $generalLevelObj->onCalcDomestic($cityKey, 'score', $score); - - ['succ'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, 2); - $successRatio = $naionTypeObj->onCalcDomestic($cityKey, 'success', $successRatio); - $successRatio = $generalLevelObj->onCalcDomestic($cityKey, 'success', $successRatio); - - - + if(!$cmdObj->isAvailable()){ + return; + } + $cmdObj->run(); } function process_1_old(&$general, $type) { diff --git a/hwe/sammo/Command/BaseCommand.php b/hwe/sammo/Command/BaseCommand.php index c479162c..a38c4436 100644 --- a/hwe/sammo/Command/BaseCommand.php +++ b/hwe/sammo/Command/BaseCommand.php @@ -34,7 +34,7 @@ abstract class BaseCommand{ protected $logger; - public function __construct(General $generalObj, array $env, $arg){ + public function __construct(General $generalObj, array $env, $arg = null){ $this->generalObj = $generalObj; $this->logger = $generalObj->getLogger(); $this->env = $env; @@ -50,9 +50,13 @@ abstract class BaseCommand{ return; } $this->city = $db->queryFirstRow('SELECT * FROM city WHERE city=%i', $this->generalObj->getVar('city')); + $this->generalObj->setRawCity($this->city); return; } $this->city = $db->queryFirstRow('SELECT %lb FROM city WHERE city=%i', $args, $this->generalObj->getVar('city')); + if($this->generalObj->getRawCity() === null){ + $this->generalObj->setRawCity($this->city); + } } protected function setNation(?array $args = null){ diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index 7359b67f..2648ccf8 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -101,6 +101,10 @@ class General implements iActionTrigger{ return $this->rawCity; } + function setRawCity(?array $city){ + $this->city = $city; + } + function getCityID():int{ return $this->raw['city']; }