fix,refac: Nation/GetGeneralList에서 부대정보는 공개되어야 함

This commit is contained in:
2022-07-17 01:37:07 +09:00
parent 020a2d2668
commit ed0bc5e19f
3 changed files with 20 additions and 13 deletions
+13 -7
View File
@@ -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,
+2 -2
View File
@@ -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}`;
+5 -4
View File
@@ -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<GeneralListItemP0>[][],
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<GeneralListItemP1>[][],
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<GeneralListItemP2>[][],
troops: [number, string][],
troops: {id: number, name: string, turntime: string}[],
env: ResponseEnv,
}