From 05eb4366b16c86d3067d7178aa9f939c7cc3f01c Mon Sep 17 00:00:00 2001 From: Hide_D Date: Mon, 25 Dec 2023 14:54:44 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=A0=91=EA=B2=BD=EA=B7=80=ED=99=98,?= =?UTF-8?q?=20=EB=8B=A4=20=EC=A0=84=EB=9E=B5=20=EC=A1=B0=EA=B1=B4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Command/UserAction/g65_병장기지원.php | 12 +- hwe/sammo/Command/UserAction/g65_입대독려.php | 12 +- hwe/sammo/Command/UserAction/g65_접경귀환.php | 104 ++++++++++++++++++ hwe/sammo/Command/UserAction/g65_철야내정.php | 12 +- hwe/sammo/GameConstBase.php | 6 +- 5 files changed, 135 insertions(+), 11 deletions(-) create mode 100644 hwe/sammo/Command/UserAction/g65_접경귀환.php diff --git a/hwe/sammo/Command/UserAction/g65_병장기지원.php b/hwe/sammo/Command/UserAction/g65_병장기지원.php index 57e3d0ed..ad2c9562 100644 --- a/hwe/sammo/Command/UserAction/g65_병장기지원.php +++ b/hwe/sammo/Command/UserAction/g65_병장기지원.php @@ -3,6 +3,7 @@ namespace sammo\Command\UserAction; use sammo\ActionBuff\g65_징병비용무시; use \sammo\Command; +use sammo\Constraint\ConstraintHelper; class g65_병장기지원 extends Command\UserActionCommand{ static protected $actionName = '병장기지원'; @@ -23,9 +24,10 @@ class g65_병장기지원 extends Command\UserActionCommand{ } protected function init(){ - //아무것도 하지 않음 - $this->fullConditionConstraints=[]; - + $this->fullConditionConstraints = [ + ConstraintHelper::NotBeNeutral(), + ConstraintHelper::OccupiedCity() + ]; } public function getPreReqTurn():int{ @@ -41,6 +43,10 @@ class g65_병장기지원 extends Command\UserActionCommand{ } public function run(\Sammo\RandUtil $rng):bool{ + if (!$this->hasFullConditionMet()) { + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + $general = $this->generalObj; $general->addInstantBuff(new g65_징병비용무시(), 1); diff --git a/hwe/sammo/Command/UserAction/g65_입대독려.php b/hwe/sammo/Command/UserAction/g65_입대독려.php index 1592ecbb..5895c8c0 100644 --- a/hwe/sammo/Command/UserAction/g65_입대독려.php +++ b/hwe/sammo/Command/UserAction/g65_입대독려.php @@ -3,6 +3,7 @@ namespace sammo\Command\UserAction; use sammo\ActionBuff\g65_징병인구무시; use \sammo\Command; +use sammo\Constraint\ConstraintHelper; class g65_입대독려 extends Command\UserActionCommand{ static protected $actionName = '입대독려'; @@ -23,9 +24,10 @@ class g65_입대독려 extends Command\UserActionCommand{ } protected function init(){ - //아무것도 하지 않음 - $this->fullConditionConstraints=[]; - + $this->fullConditionConstraints = [ + ConstraintHelper::NotBeNeutral(), + ConstraintHelper::OccupiedCity() + ]; } public function getPreReqTurn():int{ @@ -41,6 +43,10 @@ class g65_입대독려 extends Command\UserActionCommand{ } public function run(\Sammo\RandUtil $rng):bool{ + if (!$this->hasFullConditionMet()) { + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + $general = $this->generalObj; $general->addInstantBuff(new g65_징병인구무시(), 1); diff --git a/hwe/sammo/Command/UserAction/g65_접경귀환.php b/hwe/sammo/Command/UserAction/g65_접경귀환.php new file mode 100644 index 00000000..290a06be --- /dev/null +++ b/hwe/sammo/Command/UserAction/g65_접경귀환.php @@ -0,0 +1,104 @@ +getPostReqTurn(); + return "적군 도시 소재 시 접경으로 귀환(재사용 대기 {$postReqTurn})"; + } + + protected function init() + { + $this->fullConditionConstraints = [ + ConstraintHelper::NotBeNeutral(), + ConstraintHelper::NotWanderingNation(), + ConstraintHelper::NotOccupiedCity() + ]; + } + + public function getPreReqTurn(): int + { + return 0; + } + + public function getPostReqTurn(): int + { + return 60; + } + + public function getCost(): array + { + return [0, 0]; + } + + public function run(\Sammo\RandUtil $rng): bool + { + if (!$this->hasFullConditionMet()) { + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + + $general = $this->generalObj; + $cityID = $general->getCityID(); + $logger = $general->getLogger(); + + $distanceList = searchDistance($cityID, 3, true); + + $occupiedCityList = new \Ds\Set($db->queryFirstColumn( + 'SELECT city FROM city WHERE nation = %i AND city IN %li AND supply = 1', + $general->getNationID(), + array_merge(...$distanceList) + )); + + $nearestCityList = []; + foreach ($distanceList as $cityList) { + foreach ($cityList as $cityID) { + if ($occupiedCityList->contains($cityID)) { + $nearestCityList[] = $cityID; + } + } + if ($nearestCityList) { + break; + } + } + + if (!$nearestCityList) { + $logger->pushGeneralActionLog("3칸 이내에 아국 도시가 없습니다."); + return false; + } + + $destCityID = $rng->choice($nearestCityList); + $destCityName = CityConst::byID($destCityID)->name; + + $josaRo = JosaUtil::pick($destCityName, '로'); + $logger->pushGeneralActionLog("{$destCityName}{$josaRo} 접경귀환했습니다."); + $general->setVar('city', $destCityID); + + $general->applyDB($db); + return true; + } +} diff --git a/hwe/sammo/Command/UserAction/g65_철야내정.php b/hwe/sammo/Command/UserAction/g65_철야내정.php index 3d73969a..734e3adc 100644 --- a/hwe/sammo/Command/UserAction/g65_철야내정.php +++ b/hwe/sammo/Command/UserAction/g65_철야내정.php @@ -3,6 +3,7 @@ namespace sammo\Command\UserAction; use sammo\ActionBuff\g65_내정성공; use \sammo\Command; +use sammo\Constraint\ConstraintHelper; class g65_철야내정 extends Command\UserActionCommand{ static protected $actionName = '철야내정'; @@ -23,9 +24,10 @@ class g65_철야내정 extends Command\UserActionCommand{ } protected function init(){ - //아무것도 하지 않음 - $this->fullConditionConstraints=[]; - + $this->fullConditionConstraints = [ + ConstraintHelper::NotBeNeutral(), + ConstraintHelper::OccupiedCity() + ]; } public function getPreReqTurn():int{ @@ -41,6 +43,10 @@ class g65_철야내정 extends Command\UserActionCommand{ } public function run(\Sammo\RandUtil $rng):bool{ + if (!$this->hasFullConditionMet()) { + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + $general = $this->generalObj; $general->addInstantBuff(new g65_내정성공(), 2); diff --git a/hwe/sammo/GameConstBase.php b/hwe/sammo/GameConstBase.php index 09506aa4..d498c474 100644 --- a/hwe/sammo/GameConstBase.php +++ b/hwe/sammo/GameConstBase.php @@ -400,10 +400,12 @@ class GameConstBase public static $availableUserActionCommand = [ '개인 전략' => [ '휴식', - 'g65_병사연회', - 'g65_철야내정', 'g65_의원소환', + 'g65_철야내정', + 'g65_접경귀환', 'g65_병장기지원', + 'g65_입대독려', + 'g65_병사연회', ] ];