From cc158344843855a6a23f694e817ef4ce666cbce2 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Fri, 15 Jul 2022 00:29:51 +0900 Subject: [PATCH] =?UTF-8?q?wip:=20=EC=B6=9C=EB=A0=A5=20=EC=8B=9C=EC=9E=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/API/Nation/GetNationInfo.php | 18 ++++++++++++++++- hwe/templates/commandButton.php | 2 +- hwe/ts/PageBattleCenter.vue | 14 ++++++++++++- hwe/ts/SammoAPI.ts | 3 ++- hwe/ts/build_exports.json | 1 + hwe/ts/defs/API/Nation.ts | 28 +++++++++++++++++++++++++- 6 files changed, 61 insertions(+), 5 deletions(-) diff --git a/hwe/sammo/API/Nation/GetNationInfo.php b/hwe/sammo/API/Nation/GetNationInfo.php index e0823ae0..fe0c2fd0 100644 --- a/hwe/sammo/API/Nation/GetNationInfo.php +++ b/hwe/sammo/API/Nation/GetNationInfo.php @@ -26,7 +26,13 @@ class GetNationInfo extends \sammo\BaseAPI { public function validateArgs(): ?string { - return null; + $v = new Validator($this->args); + $v->rule('boolean', 'full'); + + if (!$v->validate()) { + return $v->errorStr(); + } + return null; } public function getRequiredSessionMode(): int @@ -48,6 +54,16 @@ class GetNationInfo extends \sammo\BaseAPI ]; } + $isFull = $this->args['full'] ?? false; + + if(!$isFull){ + $nation = getNationStaticInfo($nationID); + return [ + 'result' => true, + 'nation' => $nation, + ]; + } + $generalObj = General::createGeneralObjFromDB($session->generalID, null, 1); $gameStor = KVStorage::getStorage($db, 'game_env'); diff --git a/hwe/templates/commandButton.php b/hwe/templates/commandButton.php index 2fc26597..29c513c7 100644 --- a/hwe/templates/commandButton.php +++ b/hwe/templates/commandButton.php @@ -13,7 +13,7 @@ '>세력 장수 중원 정보 현재 도시 -'>감 찰 부 +'>감 찰 부 유산 관리 내 정보&설정 diff --git a/hwe/ts/PageBattleCenter.vue b/hwe/ts/PageBattleCenter.vue index 408e6af2..d393515d 100644 --- a/hwe/ts/PageBattleCenter.vue +++ b/hwe/ts/PageBattleCenter.vue @@ -14,7 +14,7 @@ - + @@ -41,6 +41,7 @@ import { unwrap } from "@/util/unwrap"; import { merge2DArrToObjectArr } from "@/util/merge2DArrToObjectArr"; import { getNpcColor } from "@/common_legacy"; import GeneralBasicCard from "./components/GeneralBasicCard.vue"; +import type { NationStaticItem } from "./defs"; const toasts = unwrap(useToast()); @@ -57,12 +58,15 @@ const orderBy = ref("turntime"); const targetGeneral = ref(); const targetGeneralID = ref(queryValues.generalID ?? undefined); +const nationInfo = ref(); + watch([generalList, targetGeneralID], ([generalList, targetGeneralID]) => { if (targetGeneralID === undefined) return; targetGeneral.value = generalList.get(targetGeneralID); }); watch([generalList, orderBy], ([generalList, orderBy]) => { + console.log(generalList); const list = Array.from(generalList.values()); list.sort((a, b) => { const [, getter, isAsc] = textMap[orderBy]; @@ -90,16 +94,24 @@ async function reload(): Promise { console.log("갱신 시도"); try { + const nationP = SammoAPI.Nation.GetNationInfo({}); const { column, list, permission, troops, env } = await SammoAPI.Nation.GeneralList(); + if (permission === 0) { throw "권한이 부족합니다."; } + console.log(list); const rawGeneralList = merge2DArrToObjectArr(column, list); + const newList = new Map(); for (const general of rawGeneralList) { newList.set(general.no, general); } + generalList.value = newList; + + const { nation } = await nationP; + nationInfo.value = nation; } catch (e) { toasts.danger({ title: "오류", diff --git a/hwe/ts/SammoAPI.ts b/hwe/ts/SammoAPI.ts index bf6e3a48..9ac1395e 100644 --- a/hwe/ts/SammoAPI.ts +++ b/hwe/ts/SammoAPI.ts @@ -18,7 +18,7 @@ import type { BettingDetailResponse, BettingListResponse } from "./defs/API/Bett import type { ReserveBulkCommandResponse, ReserveCommandResponse, ReservedCommandResponse } from "./defs/API/Command"; import type { ChiefResponse } from "./defs/API/NationCommand"; import type { inheritBuffType, InheritLogResponse } from "./defs/API/InheritAction"; -import type { SetBlockWarResponse, GeneralListResponse as NationGeneralListResponse } from "./defs/API/Nation"; +import type { SetBlockWarResponse, GeneralListResponse as NationGeneralListResponse, LiteNationInfoResponse, NationInfoResponse } from "./defs/API/Nation"; import type { UploadImageResponse } from "./defs/API/Misc"; import type { GeneralLogType, GetGeneralLogResponse, JoinArgs } from "./defs/API/General"; import type { @@ -231,6 +231,7 @@ const apiRealPath = { troopID: number; troopName: string; }>, + GetNationInfo: GET as APICallT<{full?: boolean}, NationInfoResponse>, }, Vote: { AddComment: POST as APICallT<{ diff --git a/hwe/ts/build_exports.json b/hwe/ts/build_exports.json index 20065ecc..51550860 100644 --- a/hwe/ts/build_exports.json +++ b/hwe/ts/build_exports.json @@ -23,6 +23,7 @@ }, "ingame_vue": { "v_auction": "v_auction.ts", + "v_battleCenter": "v_battleCenter.ts", "v_inheritPoint": "v_inheritPoint.ts", "v_board": "v_board.ts", "v_cachedMap": "v_cachedMap", diff --git a/hwe/ts/defs/API/Nation.ts b/hwe/ts/defs/API/Nation.ts index a1f64fe4..b51d68cc 100644 --- a/hwe/ts/defs/API/Nation.ts +++ b/hwe/ts/defs/API/Nation.ts @@ -1,4 +1,4 @@ -import type { ValuesOf, TurnObj } from "@/defs"; +import type { ValuesOf, TurnObj, NationStaticItem } from "@/defs"; import type { GameObjClassKey } from "@/defs/GameObj"; import type { ValidResponse } from "@/SammoAPI"; @@ -127,3 +127,29 @@ export type RawGeneralListP2 = ValidResponse & { } export type GeneralListResponse = RawGeneralListP0 | RawGeneralListP1 | RawGeneralListP2; + +export type NationItem = NationStaticItem & { + gold: number; + rice: number; + bill: number; + rate: number; + secretlimit: number; + chief_set: number; + scout: number; + war: number; + strategic_cmd_limit: number; + surlimit: number; + tech: number; +} + +export type LiteNationInfoResponse = ValidResponse & { + nation: NationStaticItem; +} + +export type NationInfoResponse = (ValidResponse & { + nation: NationStaticItem; +}) | (ValidResponse &{ + nation: NationItem; + impossibleStrategicCommandLists: [string, number][]; + troops: Record; +}) \ No newline at end of file