From cde6d86e1bf4d1c29451428e03d76c14af2a4ec0 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sat, 1 Nov 2025 16:59:50 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=84=B4=20=EB=8B=B9=EA=B8=B0=EA=B8=B0?= =?UTF-8?q?,=20=ED=84=B4=20=EB=AF=B8=EB=A3=A8=EA=B8=B0=20=EC=82=AC?= =?UTF-8?q?=EB=A0=B9=ED=84=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Command/Nation/che_행동지시.php | 204 ++++++++++++++++++++++ hwe/sammo/GameConstBase.php | 1 + hwe/ts/processing/General/index.ts | 1 - hwe/ts/processing/Nation/che_행동지시.vue | 118 +++++++++++++ hwe/ts/processing/Nation/index.ts | 2 + hwe/ts/processing/args.ts | 2 +- 6 files changed, 326 insertions(+), 2 deletions(-) create mode 100644 hwe/sammo/Command/Nation/che_행동지시.php create mode 100644 hwe/ts/processing/Nation/che_행동지시.vue diff --git a/hwe/sammo/Command/Nation/che_행동지시.php b/hwe/sammo/Command/Nation/che_행동지시.php new file mode 100644 index 00000000..d0a21ce4 --- /dev/null +++ b/hwe/sammo/Command/Nation/che_행동지시.php @@ -0,0 +1,204 @@ +arg === null) { + return false; + } + if (!key_exists('isPull', $this->arg)) { + return false; + } + if (!key_exists('amount', $this->arg)) { + return false; + } + if (!key_exists('destGeneralID', $this->arg)) { + return false; + } + $isPull = $this->arg['isPull']; + $amount = $this->arg['amount']; + $destGeneralID = $this->arg['destGeneralID']; + if (!is_numeric($amount)) { + return false; + } + + if ($amount <= 0) { + return false; + } + if (!is_bool($isPull)) { + return false; + } + if (!is_int($destGeneralID)) { + return false; + } + if ($destGeneralID <= 0) { + return false; + } + $amount = Util::clamp($amount, 1, 5); + + $this->arg = [ + 'isPull' => $isPull, + 'amount' => $amount, + 'destGeneralID' => $destGeneralID + ]; + return true; + } + + protected function init() + { + $general = $this->generalObj; + + $this->setCity(); + $this->setNation(); + + $this->minConditionConstraints = [ + ConstraintHelper::NotBeNeutral(), + ConstraintHelper::OccupiedCity(), + ConstraintHelper::BeChief(), + ConstraintHelper::SuppliedCity(), + ]; + } + + protected function initWithArg() + { + $destGeneral = General::createObjFromDB($this->arg['destGeneralID']); + $this->setDestGeneral($destGeneral); + + if($this->arg['destGeneralID'] == $this->getGeneral()->getID()){ + $this->fullConditionConstraints=[ + ConstraintHelper::AlwaysFail('본인입니다') + ]; + return; + } + + $this->fullConditionConstraints = [ + ConstraintHelper::NotBeNeutral(), + ConstraintHelper::OccupiedCity(), + ConstraintHelper::BeChief(), + ConstraintHelper::SuppliedCity(), + ConstraintHelper::ExistsDestGeneral(), + ConstraintHelper::FriendlyDestGeneral() + ]; + } + + public function getCost(): array + { + return [0, 0]; + } + + public function getPreReqTurn(): int + { + return 0; + } + + public function getPostReqTurn(): int + { + return 0; + } + + public function getBrief(): string + { + $isPull = $this->arg['isPull']; + $amount = $this->arg['amount']; + $actSpecificName = $isPull ? '당기기' : '미루기'; + $destGeneral = $this->destGeneralObj; + return "【{$destGeneral->getName()}】 {$amount}턴 {$actSpecificName}"; + } + + + public function run(\Sammo\RandUtil $rng): bool + { + if (!$this->hasFullConditionMet()) { + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + + $general = $this->generalObj; + $date = $general->getTurnTime($general::TURNTIME_HM); + + $isPull = $this->arg['isPull']; + $amount = $this->arg['amount']; + $destGeneral = $this->destGeneralObj; + + if($isPull){ + pullGeneralCommand($destGeneral->getID(), $amount); + } + else{ + pushGeneralCommand($destGeneral->getID(), $amount); + } + + $logger = $general->getLogger(); + + $actDestText = $isPull ? '당겼습니다.' : '미루었습니다.'; + $actText = $isPull ? '당기도록' : '미루도록'; + $destGeneral->getLogger()->pushGeneralActionLog("{$general->getName()}의 지시로 {$amount}턴을 {$actDestText}", ActionLogger::PLAIN); + $logger->pushGeneralActionLog("{$destGeneral->getName()}에게 {$amount}턴을 {$actText} 지시했습니다. <1>$date"); + + $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); + StaticEventHandler::handleEvent($this->generalObj, $this->destGeneralObj, $this::class, $this->env, $this->arg ?? []); + $general->applyDB($db); + $destGeneral->applyDB($db); + + return true; + } + + public function exportJSVars(): array + { + $db = DB::db(); + $nationID = $this->getNationID(); + $troops = Util::convertArrayToDict($db->query('SELECT * FROM troop WHERE nation=%i', $nationID), 'troop_leader'); + $destRawGenerals = Util::convertArrayToDict($db->queryAllLists('SELECT no,name,officer_level,npc,gold,rice,leadership,strength,intel,city,crew,train,atmos,troop FROM general WHERE nation = %i ORDER BY npc,binary(name)', $nationID), 0); + + if($destRawGenerals){ + foreach ($db->queryAllLists( + 'SELECT general_id, brief FROM general_turn WHERE general_id IN %li AND turn_idx = 0', + array_keys($destRawGenerals) + ) as [$generalID, $brief]) { + if (!key_exists($generalID, $destRawGenerals)) { + continue; + } + $destRawGenerals[$generalID][] = $brief; + } + } + + + + return [ + 'procRes' => [ + 'troops' => $troops, + 'generals' => array_values($destRawGenerals), + 'generalsKey' => ['no', 'name', 'officerLevel', 'npc', 'gold', 'rice', 'leadership', 'strength', 'intel', 'cityID', 'crew', 'train', 'atmos', 'troopID', 'turn0Brief'], + 'cities' => \sammo\JSOptionsForCities(), + 'amountGuide' => [1, 2, 3, 4, 5], + 'minAmount' => 1, + 'maxAmount' => 5, + ] + ]; + } +} diff --git a/hwe/sammo/GameConstBase.php b/hwe/sammo/GameConstBase.php index 42b11afa..d9226882 100644 --- a/hwe/sammo/GameConstBase.php +++ b/hwe/sammo/GameConstBase.php @@ -384,6 +384,7 @@ class GameConstBase 'che_포상', 'che_몰수', 'che_부대탈퇴지시', + 'che_행동지시', ], '외교' => [ 'che_물자원조', diff --git a/hwe/ts/processing/General/index.ts b/hwe/ts/processing/General/index.ts index 30175a1a..61641a7b 100644 --- a/hwe/ts/processing/General/index.ts +++ b/hwe/ts/processing/General/index.ts @@ -10,7 +10,6 @@ import { default as che_장수대상임관 } from "./che_장수대상임관.vue" import { default as che_징병 } from "./che_징병.vue"; import { default as che_헌납 } from "./che_헌납.vue"; import { default as cr_건국 } from "./cr_건국.vue"; - import { default as ProcessCity } from "../ProcessCity.vue"; import { default as ProcessGeneralAmount } from "../ProcessGeneralAmount.vue"; diff --git a/hwe/ts/processing/Nation/che_행동지시.vue b/hwe/ts/processing/Nation/che_행동지시.vue new file mode 100644 index 00000000..63e82067 --- /dev/null +++ b/hwe/ts/processing/Nation/che_행동지시.vue @@ -0,0 +1,118 @@ + + + + diff --git a/hwe/ts/processing/Nation/index.ts b/hwe/ts/processing/Nation/index.ts index a067fa47..cea13cc7 100644 --- a/hwe/ts/processing/Nation/index.ts +++ b/hwe/ts/processing/Nation/index.ts @@ -3,6 +3,7 @@ import { default as che_국호변경 } from "./che_국호변경.vue"; import { default as che_물자원조 } from "./che_물자원조.vue"; import { default as che_불가침제의 } from "./che_불가침제의.vue"; import { default as che_피장파장 } from "./che_피장파장.vue"; +import { default as che_행동지시 } from "./che_행동지시.vue"; import { default as cr_인구이동 } from "./cr_인구이동.vue"; @@ -33,6 +34,7 @@ export const commandMap: Record