refac: APICall에 타입 지정
- 비 undefined 타입에서 ?타입 호출 제거 - API 소속 type들을 defs/API/ 로 이동 - 모든 SammoAPI, SammoRootAPI 지정
This commit is contained in:
@@ -65,7 +65,6 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getNpcColor } from "@/common_legacy";
|
import { getNpcColor } from "@/common_legacy";
|
||||||
import type { ChiefResponse } from "@/defs";
|
|
||||||
import { formatTime } from "@/util/formatTime";
|
import { formatTime } from "@/util/formatTime";
|
||||||
import { mb_strwidth } from "@/util/mb_strwidth";
|
import { mb_strwidth } from "@/util/mb_strwidth";
|
||||||
import { parseTime } from "@/util/parseTime";
|
import { parseTime } from "@/util/parseTime";
|
||||||
@@ -77,6 +76,7 @@ import VueTypes from "vue-types";
|
|||||||
import DragSelect from "@/components/DragSelect.vue";
|
import DragSelect from "@/components/DragSelect.vue";
|
||||||
import { BButton } from "bootstrap-vue-3";
|
import { BButton } from "bootstrap-vue-3";
|
||||||
import { QueryActionHelper } from "@/util/QueryActionHelper";
|
import { QueryActionHelper } from "@/util/QueryActionHelper";
|
||||||
|
import type { ChiefResponse } from "@/defs/API/NationCommand";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
style: VueTypes.object.isRequired,
|
style: VueTypes.object.isRequired,
|
||||||
|
|||||||
+2
-14
@@ -249,6 +249,7 @@ import { abilityLeadint, abilityLeadpow, abilityPowint, abilityRand } from "@uti
|
|||||||
import { clone, shuffle, sum } from "lodash";
|
import { clone, shuffle, sum } from "lodash";
|
||||||
import NumberInputWithInfo from "@/components/NumberInputWithInfo.vue";
|
import NumberInputWithInfo from "@/components/NumberInputWithInfo.vue";
|
||||||
import { SammoAPI } from "./SammoAPI";
|
import { SammoAPI } from "./SammoAPI";
|
||||||
|
import type { JoinArgs } from "./defs/API/General";
|
||||||
|
|
||||||
declare const nationList: {
|
declare const nationList: {
|
||||||
nation: number;
|
nation: number;
|
||||||
@@ -306,19 +307,6 @@ declare module "@vue/runtime-core" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type APIArgs = {
|
|
||||||
name: string;
|
|
||||||
leadership: number;
|
|
||||||
strength: number;
|
|
||||||
intel: number;
|
|
||||||
pic: boolean;
|
|
||||||
character: string;
|
|
||||||
inheritSpecial?: string;
|
|
||||||
inheritTurntime?: number;
|
|
||||||
inheritCity?: number;
|
|
||||||
inheritBonusStat?: [number, number, number];
|
|
||||||
};
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "PageJoin",
|
name: "PageJoin",
|
||||||
components: {
|
components: {
|
||||||
@@ -329,7 +317,7 @@ export default defineComponent({
|
|||||||
const displayTable = JSON.parse(localStorage.getItem(`conf.${serverID}.join.displayTable`) ?? "true");
|
const displayTable = JSON.parse(localStorage.getItem(`conf.${serverID}.join.displayTable`) ?? "true");
|
||||||
const displayInherit = JSON.parse(localStorage.getItem(`conf.${serverID}.join.displayInherit`) ?? "true");
|
const displayInherit = JSON.parse(localStorage.getItem(`conf.${serverID}.join.displayInherit`) ?? "true");
|
||||||
const nationListShuffled = shuffle(nationList);
|
const nationListShuffled = shuffle(nationList);
|
||||||
const args: APIArgs = {
|
const args: JoinArgs = {
|
||||||
name: member.name,
|
name: member.name,
|
||||||
leadership: stats.total - 2 * Math.floor(stats.total / 3),
|
leadership: stats.total - 2 * Math.floor(stats.total / 3),
|
||||||
strength: Math.floor(stats.total / 3),
|
strength: Math.floor(stats.total / 3),
|
||||||
|
|||||||
@@ -244,7 +244,6 @@ import { type diplomacyState, diplomacyStateInfo, type NationStaticItem } from "
|
|||||||
import { SammoAPI } from "./SammoAPI";
|
import { SammoAPI } from "./SammoAPI";
|
||||||
import { joinYearMonth } from "@/util/joinYearMonth";
|
import { joinYearMonth } from "@/util/joinYearMonth";
|
||||||
import { parseYearMonth } from "@/util/parseYearMonth";
|
import { parseYearMonth } from "@/util/parseYearMonth";
|
||||||
import type { ValidResponse } from "./util/callSammoAPI";
|
|
||||||
import { useToast, BContainer } from "bootstrap-vue-3";
|
import { useToast, BContainer } from "bootstrap-vue-3";
|
||||||
import { unwrap } from "./util/unwrap";
|
import { unwrap } from "./util/unwrap";
|
||||||
|
|
||||||
@@ -256,9 +255,6 @@ type NationItem = NationStaticItem & {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
type SetBlockWarResponse = ValidResponse & {
|
|
||||||
availableCnt: number;
|
|
||||||
};
|
|
||||||
declare const staticValues: {
|
declare const staticValues: {
|
||||||
editable: boolean;
|
editable: boolean;
|
||||||
nationMsg: string;
|
nationMsg: string;
|
||||||
@@ -501,7 +497,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
async function setBlockWar() {
|
async function setBlockWar() {
|
||||||
try {
|
try {
|
||||||
const result = await SammoAPI.Nation.SetBlockWar<SetBlockWarResponse>({ value: self.policy.blockWar });
|
const result = await SammoAPI.Nation.SetBlockWar({ value: self.policy.blockWar });
|
||||||
self.warSettingCnt.remain = result.availableCnt;
|
self.warSettingCnt.remain = result.availableCnt;
|
||||||
toasts.info({
|
toasts.info({
|
||||||
title: "변경",
|
title: "변경",
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ import { parseTime } from "@util/parseTime";
|
|||||||
import { parseYearMonth } from "@util/parseYearMonth";
|
import { parseYearMonth } from "@util/parseYearMonth";
|
||||||
import DragSelect from "@/components/DragSelect.vue";
|
import DragSelect from "@/components/DragSelect.vue";
|
||||||
import { SammoAPI } from "./SammoAPI";
|
import { SammoAPI } from "./SammoAPI";
|
||||||
import type { CommandItem, ReserveCommandResponse } from "@/defs";
|
import type { CommandItem } from "@/defs";
|
||||||
import CommandSelectForm from "@/components/CommandSelectForm.vue";
|
import CommandSelectForm from "@/components/CommandSelectForm.vue";
|
||||||
import { BButton, BButtonGroup, BDropdownItem, BDropdown, BDropdownText, BDropdownDivider } from "bootstrap-vue-3";
|
import { BButton, BButtonGroup, BDropdownItem, BDropdown, BDropdownText, BDropdownDivider } from "bootstrap-vue-3";
|
||||||
import { StoredActionsHelper } from "./util/StoredActionsHelper";
|
import { StoredActionsHelper } from "./util/StoredActionsHelper";
|
||||||
@@ -536,7 +536,7 @@ async function reserveCommand() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await SammoAPI.Command.ReserveCommand<ReserveCommandResponse>({
|
const result = await SammoAPI.Command.ReserveCommand({
|
||||||
turnList: reqTurnList,
|
turnList: reqTurnList,
|
||||||
action: commandName,
|
action: commandName,
|
||||||
});
|
});
|
||||||
|
|||||||
+76
-28
@@ -1,16 +1,25 @@
|
|||||||
import type { BettingDetailResponse, ReserveBulkCommandResponse } from "./defs";
|
|
||||||
import type { Args } from "./processing/args";
|
import type { Args } from "./processing/args";
|
||||||
import { callSammoAPI, extractHttpMethod, GET, PATCH, POST, PUT, type APITail, type APICallT, type RawArgType, type ValidResponse, type InvalidResponse } from "./util/callSammoAPI";
|
import {
|
||||||
|
callSammoAPI, extractHttpMethod, GET, PATCH, POST, PUT,
|
||||||
|
type APITail, type APICallT, type RawArgType, type ValidResponse, type InvalidResponse
|
||||||
|
} from "./util/callSammoAPI";
|
||||||
export type { ValidResponse, InvalidResponse };
|
export type { ValidResponse, InvalidResponse };
|
||||||
import { APIPathGen, NumVar } from "./util/APIPathGen.js";
|
import { APIPathGen, NumVar } from "./util/APIPathGen.js";
|
||||||
import type { BettingListResponse } from "./defs/API/Betting";
|
import type { BettingDetailResponse, BettingListResponse } from "./defs/API/Betting";
|
||||||
import type { ReservedCommandResponse } from "./defs/API/Command";
|
import type { ReserveBulkCommandResponse, ReserveCommandResponse, ReservedCommandResponse } from "./defs/API/Command";
|
||||||
import type { ChiefResponse } from "./defs/API/NationCommand";
|
import type { ChiefResponse } from "./defs/API/NationCommand";
|
||||||
import type { inheritBuffType } from "./defs/API/InheritAction";
|
import type { inheritBuffType } from "./defs/API/InheritAction";
|
||||||
|
import type { SetBlockWarResponse } from "./defs/API/Nation";
|
||||||
|
import type { UploadImageResponse } from "./defs/API/Misc";
|
||||||
|
import type { JoinArgs } from "./defs/API/General";
|
||||||
|
|
||||||
const apiRealPath = {
|
const apiRealPath = {
|
||||||
Betting: {
|
Betting: {
|
||||||
Bet: PUT,
|
Bet: PUT as APICallT<{
|
||||||
|
bettingID: number,
|
||||||
|
bettingType: number[],
|
||||||
|
amount: number,
|
||||||
|
}>,
|
||||||
GetBettingDetail: NumVar('betting_id',
|
GetBettingDetail: NumVar('betting_id',
|
||||||
GET as APICallT<undefined, BettingDetailResponse>
|
GET as APICallT<undefined, BettingDetailResponse>
|
||||||
),
|
),
|
||||||
@@ -18,50 +27,89 @@ const apiRealPath = {
|
|||||||
},
|
},
|
||||||
Command: {
|
Command: {
|
||||||
GetReservedCommand: GET as APICallT<undefined, ReservedCommandResponse>,
|
GetReservedCommand: GET as APICallT<undefined, ReservedCommandResponse>,
|
||||||
PushCommand: PATCH as APICallT<{amount: number}>,
|
PushCommand: PUT as APICallT<{
|
||||||
RepeatCommand: PATCH,
|
amount: number
|
||||||
ReserveCommand: PUT,
|
}>,
|
||||||
|
RepeatCommand: PUT as APICallT<{
|
||||||
|
amount: number
|
||||||
|
}>,
|
||||||
|
ReserveCommand: PUT as APICallT<{
|
||||||
|
turnList: number[],
|
||||||
|
action: string,
|
||||||
|
arg?: Args
|
||||||
|
}, ReserveCommandResponse>,
|
||||||
ReserveBulkCommand: PUT as APICallT<{
|
ReserveBulkCommand: PUT as APICallT<{
|
||||||
turnList: number[],
|
turnList: number[],
|
||||||
action: string,
|
action: string,
|
||||||
arg: Args
|
arg?: Args
|
||||||
}[], ReserveBulkCommandResponse>,
|
}[], ReserveBulkCommandResponse>,
|
||||||
},
|
},
|
||||||
General: {
|
General: {
|
||||||
Join: POST,
|
Join: POST as APICallT<JoinArgs>,
|
||||||
},
|
},
|
||||||
InheritAction: {
|
InheritAction: {
|
||||||
BuyHiddenBuff: PUT as APICallT<{type: inheritBuffType, level: number}>,
|
BuyHiddenBuff: PUT as APICallT<{
|
||||||
|
type: inheritBuffType,
|
||||||
|
level: number
|
||||||
|
}>,
|
||||||
BuyRandomUnique: PUT as APICallT<undefined>,
|
BuyRandomUnique: PUT as APICallT<undefined>,
|
||||||
BuySpecificUnique: PUT,
|
BuySpecificUnique: PUT as APICallT<{
|
||||||
|
item: string,
|
||||||
|
amount: number,
|
||||||
|
}>,
|
||||||
ResetSpecialWar: PUT as APICallT<undefined>,
|
ResetSpecialWar: PUT as APICallT<undefined>,
|
||||||
ResetTurnTime: PUT as APICallT<undefined>,
|
ResetTurnTime: PUT as APICallT<undefined>,
|
||||||
SetNextSpecialWar: PUT,
|
SetNextSpecialWar: PUT as APICallT<{
|
||||||
|
type: string,
|
||||||
|
}>,
|
||||||
|
},
|
||||||
|
Misc: {
|
||||||
|
UploadImage: POST as APICallT<{
|
||||||
|
imageData: string,
|
||||||
|
}, UploadImageResponse>
|
||||||
},
|
},
|
||||||
Misc: { UploadImage: POST },
|
|
||||||
NationCommand: {
|
NationCommand: {
|
||||||
GetReservedCommand: GET as APICallT<undefined, ChiefResponse>,
|
GetReservedCommand: GET as APICallT<undefined, ChiefResponse>,
|
||||||
PushCommand: PATCH as APICallT<{amount: number}>,
|
PushCommand: PUT as APICallT<{
|
||||||
RepeatCommand: PATCH,
|
amount: number
|
||||||
ReserveCommand: PUT,
|
}>,
|
||||||
|
RepeatCommand: PUT as APICallT<{
|
||||||
|
amount: number
|
||||||
|
}>,
|
||||||
|
ReserveCommand: PUT as APICallT<{
|
||||||
|
turnList: number[],
|
||||||
|
action: string,
|
||||||
|
arg?: Args
|
||||||
|
}, ReserveCommandResponse>,
|
||||||
ReserveBulkCommand: PUT as APICallT<{
|
ReserveBulkCommand: PUT as APICallT<{
|
||||||
turnList: number[],
|
turnList: number[],
|
||||||
action: string,
|
action: string,
|
||||||
arg: Args
|
arg?: Args
|
||||||
}[], ReserveBulkCommandResponse>,
|
}[], ReserveBulkCommandResponse>,
|
||||||
},
|
},
|
||||||
Nation: {
|
Nation: {
|
||||||
SetNotice: PUT,
|
SetNotice: PUT as APICallT<{
|
||||||
SetScoutMsg: PUT,
|
msg: string,
|
||||||
SetBill: PUT,
|
}>,
|
||||||
SetRate: PUT,
|
SetScoutMsg: PUT as APICallT<{
|
||||||
SetSecretLimit: PUT,
|
msg: string,
|
||||||
SetBlockWar: PUT,
|
}>,
|
||||||
SetBlockScout: PUT,
|
SetBill: PATCH as APICallT<{
|
||||||
|
amount: number,
|
||||||
|
}>,
|
||||||
|
SetRate: PATCH as APICallT<{
|
||||||
|
amount: number,
|
||||||
|
}>,
|
||||||
|
SetSecretLimit: PATCH as APICallT<{
|
||||||
|
amount: number,
|
||||||
|
}>,
|
||||||
|
SetBlockWar: PATCH as APICallT<{
|
||||||
|
value: boolean,
|
||||||
|
}, SetBlockWarResponse>,
|
||||||
|
SetBlockScout: PATCH as APICallT<{
|
||||||
|
value: boolean,
|
||||||
|
}>,
|
||||||
},
|
},
|
||||||
Test: NumVar('id', {
|
|
||||||
SetThis: PUT,
|
|
||||||
})
|
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const SammoAPI = APIPathGen(apiRealPath, (path: string[], tail: APITail, pathParam) => {
|
export const SammoAPI = APIPathGen(apiRealPath, (path: string[], tail: APITail, pathParam) => {
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import type { AutoLoginFailed, AutoLoginNonceResponse, AutoLoginResponse } from "./defs/API/Login";
|
import type { AutoLoginFailed, AutoLoginNonceResponse, AutoLoginResponse, LoginFailed, LoginResponse } from "./defs/API/Login";
|
||||||
import { APIPathGen } from "./util/APIPathGen";
|
import { APIPathGen } from "./util/APIPathGen";
|
||||||
import { callSammoAPI, extractHttpMethod, GET, POST, type APICallT, type APITail, type InvalidResponse, type RawArgType, type ValidResponse } from "./util/callSammoAPI";
|
import { callSammoAPI, extractHttpMethod, GET, POST, type APICallT, type APITail, type InvalidResponse, type RawArgType, type ValidResponse } from "./util/callSammoAPI";
|
||||||
export type { ValidResponse, InvalidResponse };
|
export type { ValidResponse, InvalidResponse };
|
||||||
|
|
||||||
const apiRealPath = {
|
const apiRealPath = {
|
||||||
Login: {
|
Login: {
|
||||||
LoginByID: POST,
|
LoginByID: POST as APICallT<{
|
||||||
|
username: string,
|
||||||
|
password: string,
|
||||||
|
}, LoginResponse, LoginFailed>,
|
||||||
LoginByToken: POST as APICallT<{
|
LoginByToken: POST as APICallT<{
|
||||||
hashedToken: string,
|
hashedToken: string,
|
||||||
token_id: number,
|
token_id: number,
|
||||||
|
|||||||
@@ -129,7 +129,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { BettingDetailResponse, BettingInfo, ToastType } from "@/defs";
|
import type { ToastType } from "@/defs";
|
||||||
|
import type { BettingDetailResponse, BettingInfo } from "@/defs/API/Betting";
|
||||||
import { SammoAPI } from "@/SammoAPI";
|
import { SammoAPI } from "@/SammoAPI";
|
||||||
import { joinYearMonth } from "@/util/joinYearMonth";
|
import { joinYearMonth } from "@/util/joinYearMonth";
|
||||||
import { parseYearMonth } from "@/util/parseYearMonth";
|
import { parseYearMonth } from "@/util/parseYearMonth";
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ import VueTypes from "vue-types";
|
|||||||
import DragSelect from "@/components/DragSelect.vue";
|
import DragSelect from "@/components/DragSelect.vue";
|
||||||
import { isString, range, trim } from "lodash";
|
import { isString, range, trim } from "lodash";
|
||||||
import { SammoAPI } from "@/SammoAPI";
|
import { SammoAPI } from "@/SammoAPI";
|
||||||
import type { ChiefResponse, CommandItem, ReserveCommandResponse, TurnObj } from "@/defs";
|
import type { CommandItem, TurnObj } from "@/defs";
|
||||||
import { QueryActionHelper } from "@/util/QueryActionHelper";
|
import { QueryActionHelper } from "@/util/QueryActionHelper";
|
||||||
import type { Args } from "@/processing/args";
|
import type { Args } from "@/processing/args";
|
||||||
import type { StoredActionsHelper } from "@/util/StoredActionsHelper";
|
import type { StoredActionsHelper } from "@/util/StoredActionsHelper";
|
||||||
@@ -275,6 +275,7 @@ import { getNpcColor } from "@/common_legacy";
|
|||||||
import { BButton, BDropdownItem, BDropdownText, BButtonGroup, BDropdownDivider, BDropdown } from "bootstrap-vue-3";
|
import { BButton, BDropdownItem, BDropdownText, BButtonGroup, BDropdownDivider, BDropdown } from "bootstrap-vue-3";
|
||||||
import CommandSelectForm from "@/components/CommandSelectForm.vue";
|
import CommandSelectForm from "@/components/CommandSelectForm.vue";
|
||||||
import SimpleClock from "@/components/SimpleClock.vue";
|
import SimpleClock from "@/components/SimpleClock.vue";
|
||||||
|
import type { ChiefResponse } from "@/defs/API/NationCommand";
|
||||||
|
|
||||||
type TurnObjWithTime = TurnObj & {
|
type TurnObjWithTime = TurnObj & {
|
||||||
time: string;
|
time: string;
|
||||||
@@ -539,7 +540,7 @@ async function reserveCommand() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await SammoAPI.NationCommand.ReserveCommand<ReserveCommandResponse>({
|
const result = await SammoAPI.NationCommand.ReserveCommand({
|
||||||
turnList: reqTurnList,
|
turnList: reqTurnList,
|
||||||
action: commandName,
|
action: commandName,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,38 @@
|
|||||||
import type { ValidResponse, BettingInfo } from "@/defs";
|
import type { ValidResponse } from "@/defs";
|
||||||
|
|
||||||
export type BettingListResponse = ValidResponse & {
|
export type BettingListResponse = ValidResponse & {
|
||||||
bettingList: Record<number, Omit<BettingInfo & { totalAmount: number }, "candidates">>;
|
bettingList: Record<number, Omit<BettingInfo & { totalAmount: number }, "candidates">>;
|
||||||
year: number;
|
year: number;
|
||||||
month: number;
|
month: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export type BettingDetailResponse = ValidResponse & {
|
||||||
|
bettingInfo: BettingInfo;
|
||||||
|
bettingDetail: [string, number][];
|
||||||
|
myBetting: [string, number][];
|
||||||
|
remainPoint: number;
|
||||||
|
year: number;
|
||||||
|
month: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type BettingInfo = {
|
||||||
|
id: number;
|
||||||
|
type: 'nationBetting',
|
||||||
|
name: string;
|
||||||
|
finished: boolean;
|
||||||
|
selectCnt: number;
|
||||||
|
isExclusive?: boolean;
|
||||||
|
reqInheritancePoint: boolean;
|
||||||
|
openYearMonth: number;
|
||||||
|
closeYearMonth: number;
|
||||||
|
candidates: SelectItem[];
|
||||||
|
winner?: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SelectItem = {
|
||||||
|
title: string;
|
||||||
|
info?: string;
|
||||||
|
isHtml?: boolean;
|
||||||
|
aux?: Record<string, unknown>;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,12 +1,22 @@
|
|||||||
import type { TurnObj } from "@/defs";
|
import type { TurnObj } from "@/defs";
|
||||||
|
|
||||||
export type ReservedCommandResponse = {
|
export type ReservedCommandResponse = {
|
||||||
result: true;
|
result: true;
|
||||||
turnTime: string;
|
turnTime: string;
|
||||||
turnTerm: number;
|
turnTerm: number;
|
||||||
year: number;
|
year: number;
|
||||||
month: number;
|
month: number;
|
||||||
date: string;
|
date: string;
|
||||||
turn: TurnObj[];
|
turn: TurnObj[];
|
||||||
autorun_limit: null | number;
|
autorun_limit: null | number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ReserveCommandResponse = {
|
||||||
|
result: true,
|
||||||
|
brief: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ReserveBulkCommandResponse = {
|
||||||
|
result: true,
|
||||||
|
briefList: string[],
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
export type JoinArgs = {
|
||||||
|
name: string;
|
||||||
|
leadership: number;
|
||||||
|
strength: number;
|
||||||
|
intel: number;
|
||||||
|
pic: boolean;
|
||||||
|
character: string;
|
||||||
|
inheritSpecial?: string;
|
||||||
|
inheritTurntime?: number;
|
||||||
|
inheritCity?: number;
|
||||||
|
inheritBonusStat?: [number, number, number];
|
||||||
|
};
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import type { ValidResponse } from "@/defs";
|
||||||
|
|
||||||
|
export type UploadImageResponse = ValidResponse & {
|
||||||
|
path: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import type { ValidResponse } from "@/defs";
|
||||||
|
|
||||||
|
export type SetBlockWarResponse = ValidResponse & {
|
||||||
|
availableCnt: number;
|
||||||
|
};
|
||||||
@@ -32,16 +32,6 @@ export type GeneralListResponse = {
|
|||||||
token: Record<number, number>,
|
token: Record<number, number>,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ReserveCommandResponse = {
|
|
||||||
result: true,
|
|
||||||
brief: string,
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ReserveBulkCommandResponse = {
|
|
||||||
result: true,
|
|
||||||
briefList: string[],
|
|
||||||
}
|
|
||||||
|
|
||||||
export type NationLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
export type NationLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
||||||
export const NationLevelText: Record<NationLevel, string> = {
|
export const NationLevelText: Record<NationLevel, string> = {
|
||||||
0: '방랑군',
|
0: '방랑군',
|
||||||
@@ -211,35 +201,3 @@ export const diplomacyStateInfo: Record<diplomacyState, diplomacyInfo> = {
|
|||||||
2: { name: '통상' },
|
2: { name: '통상' },
|
||||||
7: { name: '불가침', color: 'green' },
|
7: { name: '불가침', color: 'green' },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export type SelectItem = {
|
|
||||||
title: string;
|
|
||||||
info?: string;
|
|
||||||
isHtml?: boolean;
|
|
||||||
aux?: Record<string, unknown>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type BettingInfo = {
|
|
||||||
id: number;
|
|
||||||
type: 'nationBetting',
|
|
||||||
name: string;
|
|
||||||
finished: boolean;
|
|
||||||
selectCnt: number;
|
|
||||||
isExclusive?: boolean;
|
|
||||||
reqInheritancePoint: boolean;
|
|
||||||
openYearMonth: number;
|
|
||||||
closeYearMonth: number;
|
|
||||||
candidates: SelectItem[];
|
|
||||||
winner?: number[];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export type BettingDetailResponse = ValidResponse & {
|
|
||||||
bettingInfo: BettingInfo;
|
|
||||||
bettingDetail: [string, number][];
|
|
||||||
myBetting: [string, number][];
|
|
||||||
remainPoint: number;
|
|
||||||
year: number;
|
|
||||||
month: number;
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ $(async function ($) {
|
|||||||
let result: LoginResponse | LoginFailed;
|
let result: LoginResponse | LoginFailed;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = await SammoRootAPI.Login.LoginByID<LoginResponse, LoginFailed>({
|
result = await SammoRootAPI.Login.LoginByID({
|
||||||
username: values.username,
|
username: values.username,
|
||||||
password: hash_pw,
|
password: hash_pw,
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ interface EmptyAPICallT<ResultType extends ValidResponse, ErrorType extends Inva
|
|||||||
(args: undefined, returnError: true): Promise<ResultType | ErrorType>;
|
(args: undefined, returnError: true): Promise<ResultType | ErrorType>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
export type ArgTypeOf<T> = T extends APICallT<infer A, any, any> ? A : never;
|
||||||
|
|
||||||
export type APICallT<
|
export type APICallT<
|
||||||
ArgType extends RawArgType,
|
ArgType extends RawArgType,
|
||||||
ResultType extends ValidResponse = ValidResponse,
|
ResultType extends ValidResponse = ValidResponse,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { isString } from 'lodash';
|
|||||||
import { type Args, testSubmitArgs } from './processing/args';
|
import { type Args, testSubmitArgs } from './processing/args';
|
||||||
import { SammoAPI } from './SammoAPI';
|
import { SammoAPI } from './SammoAPI';
|
||||||
import { StoredActionsHelper } from './util/StoredActionsHelper';
|
import { StoredActionsHelper } from './util/StoredActionsHelper';
|
||||||
import type { ReserveCommandResponse } from './defs';
|
import type { ReserveCommandResponse } from './defs/API/Command';
|
||||||
|
|
||||||
declare const staticValues: {
|
declare const staticValues: {
|
||||||
serverNick: string,
|
serverNick: string,
|
||||||
@@ -31,11 +31,11 @@ async function submitCommand<T extends ReserveCommandResponse>(isChiefTurn: bool
|
|||||||
throw new TypeError(`Invalied Type ${testResult[0]}, ${testResult[2]} should be ${testResult[1]}`);
|
throw new TypeError(`Invalied Type ${testResult[0]}, ${testResult[2]} should be ${testResult[1]}`);
|
||||||
}
|
}
|
||||||
console.log('trySubmit', arg);
|
console.log('trySubmit', arg);
|
||||||
const responseP = targetAPI<T>({
|
const responseP = targetAPI({
|
||||||
action,
|
action,
|
||||||
turnList,
|
turnList,
|
||||||
arg,
|
arg,
|
||||||
});
|
}) as Promise<T>;
|
||||||
|
|
||||||
const storedActionsHelper = new StoredActionsHelper(staticValues.serverNick, isChiefTurn?'nation':'general', staticValues.mapName, staticValues.unitSet);
|
const storedActionsHelper = new StoredActionsHelper(staticValues.serverNick, isChiefTurn?'nation':'general', staticValues.mapName, staticValues.unitSet);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user