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']; }