diff --git a/hwe/sammo/AutorunNationPolicy.php b/hwe/sammo/AutorunNationPolicy.php index 2641048d..af2d3b10 100644 --- a/hwe/sammo/AutorunNationPolicy.php +++ b/hwe/sammo/AutorunNationPolicy.php @@ -32,7 +32,7 @@ class AutorunNationPolicy { static $선전포고 = '선전포고'; static $천도 = '천도'; - + //실제 행동 static public $defaultPriority = [ @@ -141,7 +141,6 @@ class AutorunNationPolicy { public $minNPCWarLeadership = 40; public $minWarCrew = 1500; - public $allowNpcAttackCity = true; public $minNPCRecruitCityPopulation = 50000; public $safeRecruitCityPopulationRatio = 0.5; public $properWarTrainAtmos = 90; @@ -163,13 +162,12 @@ class AutorunNationPolicy { 'reqNPCWarRice'=>0, 'reqNPCDevelGold'=>0, 'reqNPCDevelRice'=>500, - + 'minimumResourceActionAmount'=>1000, - + 'minNPCWarLeadership'=>40, 'minWarCrew'=>1500, - - 'allowNpcAttackCity'=>true, + 'minNPCRecruitCityPopulation'=>50000, 'safeRecruitCityPopulationRatio'=>0.5, 'properWarTrainAtmos'=>90, @@ -194,7 +192,7 @@ class AutorunNationPolicy { $this->priority = $serverPolicy['priority']; } } - + if($nationPolicy){ foreach($nationPolicy['values']??[] as $policy=>$value){ @@ -209,7 +207,7 @@ class AutorunNationPolicy { $this->priority = $nationPolicy['priority']; } } - + if(!$this->priority){ $this->priority = $this::$defaultPriority; @@ -259,26 +257,26 @@ class AutorunNationPolicy { if(!key_exists('chief', $aiOptions)){ $this->can부대전방발령 = false; $this->can부대후방발령 = false; - + $this->can부대유저장후방발령 = false; $this->can유저장후방발령 = false; $this->can유저장전방발령 = false; $this->can유저장구출발령 = false; $this->can유저장내정발령 = false; - + $this->canNPC후방발령 = false; $this->canNPC전방발령 = false; $this->canNPC구출발령 = false; $this->canNPC내정발령 = false; - + $this->can유저장긴급포상 = false; $this->can유저장포상 = false; //$this->can유저장몰수 = false; - + $this->canNPC긴급포상 = false; $this->canNPC포상 = false; $this->canNPC몰수 = false; - + $this->can선전포고 = false; $this->can천도 = false; } diff --git a/hwe/ts/NPCControl.vue b/hwe/ts/NPCControl.vue index 8b30684b..5b936f4b 100644 --- a/hwe/ts/NPCControl.vue +++ b/hwe/ts/NPCControl.vue @@ -3,493 +3,281 @@
국가 정책
최근 설정: - {{ rawNationPolicy.valueSetter ?? "-없음-" }} - ({{ rawNationPolicy.valueSetTime ?? "설정 기록 없음" }}) + {{ nationPolicy.valueSetter ?? "-없음-" }} + ({{ nationPolicy.valueSetTime ?? "설정 기록 없음" }})
-
- -
- -
-
-
- 이보다 많으면 포상, 적으면 몰수/헌납합니다.(긴급포상 제외) -
+ 이보다 많으면 포상, 적으면 몰수/헌납합니다.(긴급포상 + 제외)
+
+ 이보다 많으면 포상, 적으면 몰수/헌납합니다.(긴급포상 + 제외) +
+
+
+
+ 유저장긴급포상시 이보다 금이 적은 장수에게 포상합니다.
0이면 + 보병 6회 징병({{ (defaultStatMax * 100).toLocaleString() }} * 6) + 가능한 금을 기준으로 하며, 그 수치는 현재 + {{ + zeroPolicy.reqHumanWarUrgentGold.toLocaleString() + }}입니다.
+
+
+ 유저장긴급포상시 이보다 쌀이 적은 장수에게 포상합니다.
0이면 + 기본 병종으로 {{ (defaultStatMax * 100).toLocaleString() }} * 6명 + 사살 가능한 쌀을 기준으로 하며, 그 수치는 현재 + {{ + zeroPolicy.reqHumanWarUrgentRice.toLocaleString() + }}입니다.
+
+
+
+
+ 유저전투장에게 주는 금입니다. 이보다 적으면 포상합니다.
+ 0이면 유저전투장 긴급포상 금의 2배를 기준으로 하며, 그 수치는 현재 + {{ + (calcPolicyValue("reqHumanWarUrgentGold") * 2).toLocaleString() + }}입니다.
+
+
+ 유저전투장에게 주는 쌀입니다. 이보다 적으면 포상합니다.
+ 0이면 유저전투장 긴급포상 쌀의 2배를 기준으로 하며, 그 수치는 현재 + {{ + (calcPolicyValue("reqHumanWarUrgentRice") * 2).toLocaleString() + }}입니다.
+
+
+
+
+ 유저내정장에게 주는 금입니다. 이보다 적으면 + 포상합니다. +
+
+ 유저내정장에게 주는 쌀입니다. 이보다 적으면 + 포상합니다. +
+
+
+
+ NPC전투장에게 주는 금입니다. 이보다 적으면 포상합니다.
+ 0이면 기본 병종 4회({{ (defaultStatNPCMax * 100).toLocaleString() }} + * 4) 징병비를 기준으로 하며, 그 수치는 현재 + {{ + zeroPolicy.reqNPCWarGold.toLocaleString() + }}입니다.
+
+
+ NPC전투장에게 주는 쌀입니다. 이보다 적으면 포상합니다.
+ 0이면 기본 병종으로 + {{ (defaultStatNPCMax * 100).toLocaleString() }} * 4명 사살 가능한 + 쌀을 기준으로 하며, 그 수치는 현재 + {{ + zeroPolicy.reqNPCWarRice.toLocaleString() + }}입니다.
+
+
+
+
+ NPC내정장에게 주는 금입니다. 이보다 5배 더 많다면 헌납합니다.
0이면 + 30턴 내정 가능한 금을 기준으로 하며, 그 수치는 현재 + {{ zeroPolicy.reqNPCDevelGold }}입니다.
+
+
+ NPC내정장에게 주는 쌀입니다. 이보다 5배 더 많다면 + 헌납합니다. +
+
+
+
+ 연산결과가 이 단위보다 적다면 수행하지 + 않습니다. +
+
+ 이보다 적을 때에는 징병을 시도합니다. +
+
+
+
+ 도시의 인구가 이보다 낮으면 NPC는 도시에서 징병하지 않고 후방 + 워프합니다.
NPC의 최대 병력수보다 낮게 설정하면 제자리에서 + 정착장려를 합니다.
+
+
+ 전쟁 시 후방 발령, 후방 워프의 기준 인구입니다. 이보다 많다면 + '충분하다'고 판단합니다.
NPC의 최대 병력수보다 낮게 설정하면 + 제자리에서 정착장려를 합니다.
+
+
+
+
+ 이 수치보다 같거나 높으면 NPC전투장으로 + 분류됩니다. +
+
+ 훈련/사기진작 기준치입니다. 이보다 같거나 높으면 + 출병합니다. +
+
+ -
-
- -
- -
-
-
- 이보다 많으면 포상, 적으면 몰수/헌납합니다.(긴급포상 제외) -
-
-
-
-
-
- -
- -
-
-
- - 유저장긴급포상시 이보다 금이 적은 장수에게 포상합니다.
0이면 - 보병 6회 징병({{ defaultStatMax * 100 }} * 6) 가능한 금을 기준으로 - 하며, 그 수치는 현재 - {{ zeroPolicy.reqHumanWarUrgentGold }}입니다.
-
-
-
-
- -
- -
-
-
- 유저장긴급포상시 이보다 쌀이 적은 장수에게 포상합니다.
0이면 - 기본 병종으로 {{ defaultStatMax * 100 * 6 }}명 사살 가능한 쌀을 - 기준으로 하며, 그 수치는 현재 - {{ zeroPolicy.reqHumanWarUrgentRice }}입니다.
-
-
-
-
-
-
- -
- -
-
-
- 유저전투장에게 주는 금입니다. 이보다 적으면 포상합니다.
- 0이면 유저전투장 긴급포상 금의 2배를 기준으로 하며, 그 수치는 현재 - {{ nationPolicy.reqHumanWarRecommandGold }}입니다.
-
-
-
-
- -
- -
-
-
- 유저전투장에게 주는 쌀입니다. 이보다 적으면 포상합니다.
- 0이면 유저전투장 긴급포상 쌀의 2배를 기준으로 하며, 그 수치는 현재 - {{ nationPolicy.reqHumanWarRecommandRice }}입니다.
-
-
-
-
-
-
- -
- -
-
-
- 유저내정장에게 주는 금입니다. 이보다 적으면 포상합니다. -
-
-
-
- -
- -
-
-
- 유저내정장에게 주는 쌀입니다. 이보다 적으면 포상합니다. -
-
-
-
-
-
- -
- -
-
-
- NPC전투장에게 주는 금입니다. 이보다 적으면 포상합니다.
- 0이면 기본 병종 4회({{ defaultStatNPCMax * 100 }} - * 4) 징병비를 기준으로 하며, 그 수치는 현재 - {{ nationPolicy.reqNPCWarGold }}입니다.
-
-
-
-
- -
- -
-
-
- NPC전투장에게 주는 쌀입니다. 이보다 적으면 포상합니다.
- 0이면 기본 병종으로 - {{ defaultStatNPCMax * 100 * 4 }}명 사살 가능한 쌀을 기준으로 - 하며, 그 수치는 현재 {{ nationPolicy.reqNPCWarRice }}입니다.
-
-
-
-
-
-
- -
- -
-
-
- NPC내정장에게 주는 금입니다. 이보다 5배 더 많다면 헌납합니다.
0이면 - 30턴 내정 가능한 금을 기준으로 하며, 그 수치는 현재 - {{ nationPolicy.reqNPCDevelGold }}입니다.
-
-
-
-
- -
- -
-
-
- NPC내정장에게 주는 쌀입니다. 이보다 5배 더 많다면 - 헌납합니다. -
-
-
-
-
-
- -
- -
-
-
- 연산결과가 이 단위보다 적다면 수행하지 않습니다. -
-
-
-
- -
- -
-
-
- 이보다 적을 때에는 징병을 시도합니다. -
-
-
-
-
-
- -
- -
-
-
- 이보다 낮으면 NPC는 도시에서 징병하지 않고 후방 - 워프합니다. -
-
-
-
- -
- -
-
-
- 전쟁 시 후방 발령, 후방 워프의 기준 인구입니다. 이보다 많다면 - '충분하다'고 판단합니다. -
-
-
-
-
-
- -
- -
-
-
- 이 수치보다 같거나 높으면 NPC전투장으로 분류됩니다. -
-
-
-
- -
- -
-
-
- 훈련/사기진작 기준치입니다. 이보다 같거나 높으면 - 출병합니다. -
-
-
전투 부대는 작업중입니다(json양식: {부대번호:[시작도시번호(아국),도착도시번호(적군)],...})
후방 징병 부대는 작업중입니다(json양식: [부대번호,...])
내정 부대는 작업중입니다(json양식: [부대번호,...]) - - - + + -
-
-
- - -
- +
+
+
+ +
+
@@ -497,8 +285,8 @@
최근 설정: - {{ rawNationPolicy.prioritySetter ?? "-없음-" }} - ({{ rawNationPolicy.prioritySetTime ?? "설정 기록 없음" }}) + {{ chiefActionPriority.prioritySetter ?? "-없음-" }} + ({{ chiefActionPriority.prioritySetTime ?? "설정 기록 없음" }})
@@ -597,7 +385,17 @@ import { defineComponent } from "vue"; import "../scss/bootstrap5.scss"; import "../scss/game_bg.scss"; -import { NationPolicy, NPCChiefActions, NPCGeneralActions } from "./defs"; +import { + InvalidResponse, + NationPolicy, + NPCChiefActions, + NPCGeneralActions, +} from "./defs"; +import NumberInputWithInfo from "./components/NumberInputWithInfo.vue"; +import { cloneDeep, isEqual, last } from "lodash"; +import { unwrap } from "./util/unwrap"; +import { convertFormData } from "./util/convertFormData"; +import axios from "axios"; declare const nationID: number; @@ -605,6 +403,9 @@ declare const defaultNationPolicy: NationPolicy; declare const currentNationPolicy: NationPolicy; declare const defaultNationPriority: NationPolicy; +declare const zeroPolicy: NationPolicy; +declare const autoPolicy: NationPolicy; + declare const currentNationPriority: NPCChiefActions[]; declare const availableNationPriorityItems: NPCChiefActions[]; declare const defaultGeneralActionPriority: NPCChiefActions[]; @@ -613,24 +414,97 @@ declare const currentGeneralActionPriority: NPCGeneralActions[]; declare const availableGeneralActionPriorityItems: NPCGeneralActions[]; declare const defaultStatNPCMax: number; +declare const defaultStatMax: number; export default defineComponent({ name: "NPCControl", - data(){ - return { - nationID, - defaultStatNPCMax, - nationPolicy: currentNationPolicy, - - chiefActionPriority: currentNationPriority, - //chiefActionUnused: [], - generalActionPriority: currentGeneralActionPriority, - //generalActionUnsed: [], - - displayOrder: [ - - ], + components: { + NumberInputWithInfo, + }, + methods: { + resetPolicy() { + this.nationPolicy = cloneDeep(defaultNationPolicy); + //TODO: toast + }, + rollbackPolicy() { + if (!confirm("이전 설정으로 되돌릴까요?")) { + return; } - } + let lastPolicy = unwrap(last(this.nationPolicyStack)); + while (this.nationPolicyStack.length > 1) { + if (!isEqual(lastPolicy, this.nationPolicy)) { + break; + } + this.nationPolicyStack.pop(); + lastPolicy = unwrap(last(this.nationPolicyStack)); + } + this.nationPolicy = cloneDeep(lastPolicy); + //TODO: toast + }, + async submitPolicy() { + if (!confirm("저장할까요?")) { + return; + } + + try { + const response = await axios({ + url: "j_set_npc_control.php", + responseType: "json", + method: "post", + data: convertFormData({ + type: "nationPolicy", + data: JSON.stringify(this.nationPolicy), + }), + }); + const result: InvalidResponse = response.data; + if (!result.result) { + throw result.reason; + } + } catch (e) { + console.error(e); + //TODO: toast + return; + } + + //TODO: submit + //TODO: toast + const lastPolicy = unwrap(last(this.nationPolicyStack)); + if (!isEqual(lastPolicy, this.nationPolicy)) { + const { nationPolicy } = this; + this.nationPolicyStack.push(cloneDeep(nationPolicy)); + } + }, + calcPolicyValue( + title: keyof NationPolicy + ): NationPolicy[keyof NationPolicy] { + if (!(title in this.nationPolicy)) { + throw `${title}이 NationPolicy key가 아님`; + } + if (this.nationPolicy[title] == 0) { + return this.zeroPolicy[title]; + } + return this.nationPolicy[title]; + }, + }, + data() { + return { + reqNationGold: 110, + + nationID, + defaultStatMax, + defaultStatNPCMax, + nationPolicy: cloneDeep(currentNationPolicy), + nationPolicyStack: [currentNationPolicy], + zeroPolicy, + autoPolicy, + + chiefActionPriority: cloneDeep(currentNationPriority), + //chiefActionUnused: [], + generalActionPriority: cloneDeep(currentGeneralActionPriority), + //generalActionUnsed: [], + + displayOrder: [], + }; + }, }); diff --git a/hwe/ts/components/NumberInputWithInfo.vue b/hwe/ts/components/NumberInputWithInfo.vue index 8b054b16..393408a8 100644 --- a/hwe/ts/components/NumberInputWithInfo.vue +++ b/hwe/ts/components/NumberInputWithInfo.vue @@ -1,10 +1,9 @@