diff --git a/hwe/sammo/Command/Nation/che_급습.php b/hwe/sammo/Command/Nation/che_급습.php index 14aaf13b..39f7d03e 100644 --- a/hwe/sammo/Command/Nation/che_급습.php +++ b/hwe/sammo/Command/Nation/che_급습.php @@ -223,7 +223,7 @@ class che_급습 extends Command\NationCommand return [ 'mapTheme' => \sammo\getMapTheme(), 'procRes' => [ - 'nations' => $nationList, + 'nationList' => $nationList, 'startYear' => $this->env['startyear'], ], ]; diff --git a/hwe/sammo/Command/Nation/che_물자원조.php b/hwe/sammo/Command/Nation/che_물자원조.php index 8c52fc5b..e77cc6e1 100644 --- a/hwe/sammo/Command/Nation/che_물자원조.php +++ b/hwe/sammo/Command/Nation/che_물자원조.php @@ -1,9 +1,13 @@ arg === null){ + protected function argTest(): bool + { + if ($this->arg === null) { return false; } - if(!key_exists('destNationID', $this->arg)){ + if (!key_exists('destNationID', $this->arg)) { return false; } $destNationID = $this->arg['destNationID']; - if(!is_int($destNationID)){ + if (!is_int($destNationID)) { return false; } - if($destNationID < 1){ + if ($destNationID < 1) { return false; } - if(!key_exists('amountList', $this->arg)){ + if (!key_exists('amountList', $this->arg)) { return false; } $amountList = $this->arg['amountList']; - if(!is_array($amountList)){ + if (!is_array($amountList)) { return false; } - if(count($amountList) != 2){ + if (count($amountList) != 2) { return false; } [$goldAmount, $riceAmount] = $amountList; - if(!is_int($goldAmount) || !is_int($riceAmount)){ + if (!is_int($goldAmount) || !is_int($riceAmount)) { return false; } - if($goldAmount < 0 || $riceAmount < 0){ + if ($goldAmount < 0 || $riceAmount < 0) { return false; } - if($goldAmount == 0 && $riceAmount == 0){ + if ($goldAmount == 0 && $riceAmount == 0) { return false; } $this->arg = [ - 'destNationID'=>$destNationID, - 'amountList'=>[$goldAmount, $riceAmount] + 'destNationID' => $destNationID, + 'amountList' => [$goldAmount, $riceAmount] ]; return true; } - protected function init(){ + protected function init() + { $general = $this->generalObj; $this->setCity(); $this->setNation(['gold', 'rice', 'surlimit']); - $this->minConditionConstraints=[ + $this->minConditionConstraints = [ ConstraintHelper::OccupiedCity(), ConstraintHelper::BeChief(), ConstraintHelper::SuppliedCity(), @@ -94,47 +101,51 @@ class che_물자원조 extends Command\NationCommand{ [$goldAmount, $riceAmount] = $this->arg['amountList']; $limit = $this->nation['level'] * GameConst::$coefAidAmount; - if($goldAmount > $limit || $riceAmount > $limit){ - $this->fullConditionConstraints[ - ConstraintHelper::AlwaysFail('작위 제한량 이상은 보낼 수 없습니다.') - ]; + if ($goldAmount > $limit || $riceAmount > $limit) { + $this->fullConditionConstraints[ConstraintHelper::AlwaysFail('작위 제한량 이상은 보낼 수 없습니다.')]; return; } - $this->fullConditionConstraints=[ + $this->fullConditionConstraints = [ ConstraintHelper::ExistsDestNation(), ConstraintHelper::OccupiedCity(), ConstraintHelper::BeChief(), ConstraintHelper::SuppliedCity(), - ConstraintHelper::ReqNationGold(GameConst::$basegold+(($goldAmount>0)?1:0)), - ConstraintHelper::ReqNationRice(GameConst::$baserice+(($riceAmount>0)?1:0)), + ConstraintHelper::ReqNationGold(GameConst::$basegold + (($goldAmount > 0) ? 1 : 0)), + ConstraintHelper::ReqNationRice(GameConst::$baserice + (($riceAmount > 0) ? 1 : 0)), ConstraintHelper::ReqNationValue('surlimit', '외교제한', '==', 0, '외교제한중입니다.'), ConstraintHelper::ReqDestNationValue('surlimit', '외교제한', '==', 0, '상대국이 외교제한중입니다.'), ]; } - public function getCost():array{ + public function getCost(): array + { return [0, 0]; } - public function getPreReqTurn():int{ + public function getPreReqTurn(): int + { return 0; } - public function getPostReqTurn():int{ + public function getPostReqTurn(): int + { //NOTE: 자체 postReqTurn 사용 return 12; } - public function getNextAvailableTurn():?int{ + public function getNextAvailableTurn(): ?int + { return null; } - public function setNextAvailable(?int $yearMonth=null){ + public function setNextAvailable(?int $yearMonth = null) + { return; } - public function getBrief():string{ + public function getBrief(): string + { [$goldAmount, $riceAmount] = $this->arg['amountList']; $goldAmountText = number_format($goldAmount); $riceAmountText = number_format($riceAmount); @@ -144,8 +155,9 @@ class che_물자원조 extends Command\NationCommand{ } - public function run():bool{ - if(!$this->hasFullConditionMet()){ + public function run(): bool + { + if (!$this->hasFullConditionMet()) { throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); } @@ -196,7 +208,7 @@ class che_물자원조 extends Command\NationCommand{ $broadcastMessage = "{$destNationName}{$josaRo} 금{$goldAmountText} 쌀{$riceAmountText}을 지원했습니다."; $chiefList = $db->queryFirstColumn('SELECT no FROM general WHERE officer_level >= 5 AND no != %i AND nation = %i', $generalID, $nationID); - foreach($chiefList as $chiefID){ + foreach ($chiefList as $chiefID) { $chiefLogger = new ActionLogger($chiefID, $nationID, $year, $month); $chiefLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN); $chiefLogger->flush(); @@ -211,7 +223,7 @@ class che_물자원조 extends Command\NationCommand{ $destBroadcastMessage = $broadcastMessage = "{$nationName}에서 금{$goldAmountText} 쌀{$riceAmountText}을 원조했습니다."; $destChiefList = $db->queryFirstColumn('SELECT no FROM general WHERE officer_level >= 5 AND nation = %i', $destNationID); - foreach($destChiefList as $destChiefID){ + foreach ($destChiefList as $destChiefID) { $destChiefLogger = new ActionLogger($destChiefID, $nationID, $year, $month); $destChiefLogger->pushGeneralActionLog($destBroadcastMessage, ActionLogger::PLAIN); $destChiefLogger->flush(); @@ -222,19 +234,19 @@ class che_물자원조 extends Command\NationCommand{ $destNationLogger->pushNationalHistoryLog("{$nationName}{$josaRoSrc}부터 금{$goldAmountText} 쌀{$riceAmountText}을 지원 받음"); $destNationStor = KVStorage::getStorage(DB::db(), $destNationID, 'nation_env'); - $destRecvAssist = $destNationStor->getValue('recv_assist')??[]; - $destRecvAssist["n{$nationID}"] = [$nationID, ($destRecvAssist["n{$nationID}"][1]??0) + $goldAmount + $riceAmount]; + $destRecvAssist = $destNationStor->getValue('recv_assist') ?? []; + $destRecvAssist["n{$nationID}"] = [$nationID, ($destRecvAssist["n{$nationID}"][1] ?? 0) + $goldAmount + $riceAmount]; $destNationStor->setValue('recv_assist', $destRecvAssist); $db->update('nation', [ - 'gold'=>$db->sqleval('gold - %i', $goldAmount), - 'rice'=>$db->sqleval('rice - %i', $riceAmount), - 'surlimit'=>$db->sqleval('surlimit + %i', $this->getPostReqTurn()) + 'gold' => $db->sqleval('gold - %i', $goldAmount), + 'rice' => $db->sqleval('rice - %i', $riceAmount), + 'surlimit' => $db->sqleval('surlimit + %i', $this->getPostReqTurn()) ], 'nation = %i', $nationID); $db->update('nation', [ - 'gold'=>$db->sqleval('gold + %i', $goldAmount), - 'rice'=>$db->sqleval('rice + %i', $riceAmount), + 'gold' => $db->sqleval('gold + %i', $goldAmount), + 'rice' => $db->sqleval('rice + %i', $riceAmount), ], 'nation = %i', $destNationID); $general->addExperience(5); @@ -246,6 +258,51 @@ class che_물자원조 extends Command\NationCommand{ return true; } + public function exportJSVars(): array + { + $generalObj = $this->generalObj; + $nationList = []; + foreach (getAllNationStaticInfo() as $destNation) { + $nationTarget = [ + 'id' => $destNation['nation'], + 'name' => $destNation['name'], + 'color' => $destNation['color'], + 'power' => $destNation['power'], + ]; + + //TODO: 물자원조 자체가 가능한지도 검사? + + if($nationTarget['id'] == $generalObj->getNationID()){ + $nationTarget['notAvailable'] = true; + } + + $nationList[] = $nationTarget; + } + $currentNationLevel = getNationStaticInfo($this->generalObj->getNationID())['level']; + + $nationLevelText = []; + foreach (\sammo\getNationLevelList() as $level => [$levelText,,]) { + $nationLevelText[$level] = $levelText; + } + + $amountGuide = []; + foreach (Util::range(1, $currentNationLevel + 1) as $nationLevel) { + $amountGuide[] = $nationLevel * GameConst::$coefAidAmount; + } + + return [ + 'mapTheme' => \sammo\getMapTheme(), + 'procRes' => [ + 'nationList' => $nationList, + 'currentNationLevel' => $currentNationLevel, + 'nationLevelText' => $nationLevelText, + 'minAmount' => 1000, + 'maxAmount' => Util::array_last($amountGuide), + 'amountGuide' => $amountGuide, + ], + ]; + } + public function getJSPlugins(): array { return [ @@ -259,34 +316,31 @@ class che_물자원조 extends Command\NationCommand{ $currentNationLevel = getNationStaticInfo($this->generalObj->getNationID())['level']; ob_start(); ?> -
-타국에게 원조합니다.
-작위별로 금액 제한이 있습니다.
- [$levelText,,]): ?> -:
- -원조할 국가를 목록에서 선택하세요.
- -국고 -병량 -
-
+
+ 타국에게 원조합니다.
+ 작위별로 금액 제한이 있습니다.
+ [$levelText,,]) : ?> + :
+ + 원조할 국가를 목록에서 선택하세요.
+ + 국고 + 병량 +
+
\sammo\getMapTheme(), 'procRes' => [ - 'nations' => $nationList, + 'nationList' => $nationList, 'startYear' => $this->env['startyear'], ], ]; diff --git a/hwe/ts/processing/AmountSelect.vue b/hwe/ts/processing/AmountSelect.vue index b8bbbd1e..2f50b9b1 100644 --- a/hwe/ts/processing/AmountSelect.vue +++ b/hwe/ts/processing/AmountSelect.vue @@ -20,6 +20,7 @@ class="form-control" :max="maxAmount" :min="minAmount" + :step="step" v-model="amount" placeholder="금액" /> @@ -69,8 +70,13 @@ export default defineComponent({ }, amountGuide: { type: Array as PropType, - reqquired: false, + required: false, }, + step: { + type: Number, + required: false, + default: 1, + } }, emits: ["update:modelValue"], watch: { diff --git a/hwe/ts/processing/General/che_임관.vue b/hwe/ts/processing/General/che_임관.vue index 66aff13a..b2771b63 100644 --- a/hwe/ts/processing/General/che_임관.vue +++ b/hwe/ts/processing/General/che_임관.vue @@ -10,7 +10,7 @@
국가 : - +
{{ commandName }} @@ -22,7 +22,7 @@
임관권유문
(); + const nationList = new Map(); for (const nationItem of procRes.nationList) { - nations.set(nationItem.id, nationItem); + nationList.set(nationItem.id, nationItem); } const selectedNationID = ref(procRes.nationList[0].id); @@ -89,7 +89,7 @@ export default defineComponent({ } return { - nations: ref(nations), + nationList: ref(nationList), selectedNationID, commandName, isBrightColor, diff --git a/hwe/ts/processing/General/che_장수대상임관.vue b/hwe/ts/processing/General/che_장수대상임관.vue index d902fa36..f1ab5e90 100644 --- a/hwe/ts/processing/General/che_장수대상임관.vue +++ b/hwe/ts/processing/General/che_장수대상임관.vue @@ -97,9 +97,9 @@ export default defineComponent({ return name; } - const nations = new Map(); + const nationList = new Map(); for (const nationItem of procRes.nationList) { - nations.set(nationItem.id, nationItem); + nationList.set(nationItem.id, nationItem); } async function submit(e: Event) { @@ -111,16 +111,10 @@ export default defineComponent({ unwrap(e.target).dispatchEvent(event); } - const nationList = new Map(); - for (const nationItem of procRes.nationList) { - nationList.set(nationItem.id, nationItem); - } - return { - nations: ref(nations), + nationList: ref(nationList), selectedGeneralID, generalList, - nationList, commandName, isBrightColor, textHelpGeneral, diff --git a/hwe/ts/processing/Nation/che_물자원조.vue b/hwe/ts/processing/Nation/che_물자원조.vue new file mode 100644 index 00000000..eeff6f85 --- /dev/null +++ b/hwe/ts/processing/Nation/che_물자원조.vue @@ -0,0 +1,129 @@ + + + diff --git a/hwe/ts/processing/Nation/che_선전포고.vue b/hwe/ts/processing/Nation/che_선전포고.vue index 2b2371f9..a2b2b393 100644 --- a/hwe/ts/processing/Nation/che_선전포고.vue +++ b/hwe/ts/processing/Nation/che_선전포고.vue @@ -29,7 +29,7 @@
국가 : - +
{{ commandName }} @@ -54,7 +54,7 @@ declare const mapTheme: string; declare const commandName: string; declare const procRes: { - nations: procNationList; + nationList: procNationList; startYear: number, }; @@ -74,12 +74,12 @@ export default defineComponent({ }, }, setup() { - const nations = new Map(); - for (const nationItem of procRes.nations) { - nations.set(nationItem.id, nationItem); + const nationList = new Map(); + for (const nationItem of procRes.nationList) { + nationList.set(nationItem.id, nationItem); } - const selectedNationID = ref(procRes.nations[0].id); + const selectedNationID = ref(procRes.nationList[0].id); const selectedCityObj = ref();//mapping용 function selectedNation(nationID: number) { @@ -98,7 +98,7 @@ export default defineComponent({ return { startYear: procRes.startYear, mapTheme: ref(mapTheme), - nations: ref(nations), + nationList: ref(nationList), selectedCityObj, selectedNationID, commandName, diff --git a/hwe/ts/processing/Nation/index.ts b/hwe/ts/processing/Nation/index.ts index 73bee302..4c3624b3 100644 --- a/hwe/ts/processing/Nation/index.ts +++ b/hwe/ts/processing/Nation/index.ts @@ -1,5 +1,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 NationProcess } from "./che_선전포고.vue"; import { default as GeneralAmountProcess } from "./che_몰수.vue"; import { default as GeneralCityProcess } from "./che_발령.vue"; @@ -9,6 +11,7 @@ export const commandMap: Record = { che_국호변경, che_급습: NationProcess, che_몰수: GeneralAmountProcess, + che_물자원조, che_선전포고: NationProcess, che_포상: GeneralAmountProcess, che_발령: GeneralCityProcess,