From ed0bc5e19fd701e591bb8c4ab8f827f4dc81d5cb Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sun, 17 Jul 2022 01:34:34 +0900 Subject: [PATCH] =?UTF-8?q?fix,refac:=20Nation/GetGeneralList=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=B6=80=EB=8C=80=EC=A0=95=EB=B3=B4=EB=8A=94=20?= =?UTF-8?q?=EA=B3=B5=EA=B0=9C=EB=90=98=EC=96=B4=EC=95=BC=20=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/API/Nation/GeneralList.php | 20 +++++++++++++------- hwe/ts/PageNationGeneral.vue | 4 ++-- hwe/ts/defs/API/Nation.ts | 9 +++++---- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/hwe/sammo/API/Nation/GeneralList.php b/hwe/sammo/API/Nation/GeneralList.php index e2345d21..292a41ab 100644 --- a/hwe/sammo/API/Nation/GeneralList.php +++ b/hwe/sammo/API/Nation/GeneralList.php @@ -44,6 +44,8 @@ class GeneralList extends \sammo\BaseAPI 'belong' => 0, 'connect' => 0, + 'troop' => 0, + 'con' => 1, 'specage' => 1, 'specage2' => 1, @@ -63,7 +65,6 @@ class GeneralList extends \sammo\BaseAPI 'officer_level' => 1, 'officer_city' => 1, 'defence_train' => 1, - 'troop' => 1, 'crewtype' => 1, 'crew' => 1, 'train' => 1, @@ -271,13 +272,18 @@ class GeneralList extends \sammo\BaseAPI $generalList[] = $item; } - if ($this->permission >= 1) { - $troops = $db->queryAllLists('SELECT troop_leader,name FROM troop WHERE nation = %i', $nationID); - } else { - $troops = null; + $troops = []; + foreach ($db->queryAllLists('SELECT troop_leader,name FROM troop WHERE nation = %i', $nationID) as [$troopLeaderID, $troopName]) { + if (!key_exists($troopLeaderID, $rawGeneralList)) { + continue; + } + $troopTurnTime = $rawGeneralList[$troopLeaderID]['turntime']; + $troops[] = [ + 'id' => $troopLeaderID, + 'name' => $troopName, + 'turntime' => $troopTurnTime + ]; } - - $result = [ 'result' => true, 'permission' => $this->permission, diff --git a/hwe/ts/PageNationGeneral.vue b/hwe/ts/PageNationGeneral.vue index 4b528870..fbb65c1b 100644 --- a/hwe/ts/PageNationGeneral.vue +++ b/hwe/ts/PageNationGeneral.vue @@ -83,8 +83,8 @@ async function reload() { return { permission, st0: true, st1: true, st2: true, ...v }; }); - for (const [troopLeader, troopName] of troops) { - troopList.value[troopLeader] = troopName; + for (const {id: troopID, name:troopName} of troops) { + troopList.value[troopID] = troopName; } } else { throw `?? ${permission}`; diff --git a/hwe/ts/defs/API/Nation.ts b/hwe/ts/defs/API/Nation.ts index b51d68cc..126f2278 100644 --- a/hwe/ts/defs/API/Nation.ts +++ b/hwe/ts/defs/API/Nation.ts @@ -39,6 +39,8 @@ export type GeneralListItemP0 = { reservedCommand: TurnObj[] | null, autorun_limit: number, + + troop: number, } export type GeneralListItemP1 = { @@ -61,7 +63,6 @@ export type GeneralListItemP1 = { officer_level: number, officer_city: number, defence_train: number, - troop: number, crewtype: GameObjClassKey, crew: number, train: number, @@ -106,7 +107,7 @@ export type RawGeneralListP0 = ValidResponse & { permission: 0, column: (keyof GeneralListItemP0)[], list: ValuesOf[][], - troops?: null, + troops: {id: number, name: string, turntime: string}[], env: ResponseEnv, } @@ -114,7 +115,7 @@ export type RawGeneralListP1 = ValidResponse & { permission: 1, column: (keyof GeneralListItemP1)[], list: ValuesOf[][], - troops?: null, + troops: {id: number, name: string, turntime: string}[], env: ResponseEnv, } @@ -122,7 +123,7 @@ export type RawGeneralListP2 = ValidResponse & { permission: 2 | 3 | 4, column: (keyof GeneralListItemP2)[], list: ValuesOf[][], - troops: [number, string][], + troops: {id: number, name: string, turntime: string}[], env: ResponseEnv, }