diff --git a/hwe/ts/PageChiefCenter.vue b/hwe/ts/PageChiefCenter.vue index 4be4f61f..87032991 100644 --- a/hwe/ts/PageChiefCenter.vue +++ b/hwe/ts/PageChiefCenter.vue @@ -102,10 +102,11 @@ import { isString } from "lodash"; import { entriesWithType } from "./util/entriesWithType"; import TopItem from "@/ChiefCenter/TopItem.vue"; import BottomItem from "@/ChiefCenter/BottomItem.vue"; -import type { ChiefResponse, OptionalFull } from "./defs"; +import type { OptionalFull } from "./defs"; import { SammoAPI } from "./SammoAPI"; import { unwrap } from "@/util/unwrap"; import { StoredActionsHelper } from "./util/StoredActionsHelper"; +import type { ChiefResponse } from "./defs/API/NationCommand"; const props = defineProps({ maxChiefTurn: VueTypes.number.isRequired, @@ -145,7 +146,7 @@ watch(viewTarget, (val) => { async function reloadTable(): Promise { try { - const response = await SammoAPI.NationCommand.GetReservedCommand(); + const response = await SammoAPI.NationCommand.GetReservedCommand(); console.log(response); for (const [key, value] of entriesWithType(response)) { if (key === "result") { diff --git a/hwe/ts/PageInheritPoint.vue b/hwe/ts/PageInheritPoint.vue index d96947e0..57273ad1 100644 --- a/hwe/ts/PageInheritPoint.vue +++ b/hwe/ts/PageInheritPoint.vue @@ -206,6 +206,7 @@ import TopBackBar from "@/components/TopBackBar.vue"; import _ from "lodash"; import NumberInputWithInfo from "@/components/NumberInputWithInfo.vue"; import { SammoAPI } from "./SammoAPI"; +import type { inheritBuffType } from "./defs/API/InheritAction"; type InheritanceType = | "previous" @@ -292,15 +293,6 @@ const inheritanceViewText: Record import TopBackBar from "@/components/TopBackBar.vue"; import BottomBar from "@/components/BottomBar.vue"; -import type { BettingInfo, ToastType } from "@/defs"; +import type { ToastType } from "@/defs"; import { onMounted, ref } from "vue"; -import { SammoAPI, type ValidResponse } from "./SammoAPI"; +import { SammoAPI } from "./SammoAPI"; import { isString } from "lodash"; import { parseYearMonth } from "@/util/parseYearMonth"; import { joinYearMonth } from "./util/joinYearMonth"; import BettingDetail from "@/components/BettingDetail.vue"; import { BContainer, useToast } from "bootstrap-vue-3"; import { unwrap } from "./util/unwrap"; +import type { BettingListResponse } from "./defs/API/Betting"; + -type BettingListResponse = ValidResponse & { - bettingList: Record>; - year: number; - month: number; -}; const toasts = unwrap(useToast()); const year = ref(); @@ -58,7 +55,7 @@ function addToast(msg: ToastType) { console.log("시작!"); onMounted(async () => { try { - const result = await SammoAPI.Betting.GetBettingList(); + const result = await SammoAPI.Betting.GetBettingList(); year.value = result.year; month.value = result.month; yearMonth.value = joinYearMonth(result.year, result.month); diff --git a/hwe/ts/PartialReservedCommand.vue b/hwe/ts/PartialReservedCommand.vue index 646ef0a0..32de09a2 100644 --- a/hwe/ts/PartialReservedCommand.vue +++ b/hwe/ts/PartialReservedCommand.vue @@ -296,17 +296,7 @@ import type { TurnObj } from "@/defs"; import type { Args } from "./processing/args"; import { QueryActionHelper } from "./util/QueryActionHelper"; import SimpleClock from "./components/SimpleClock.vue"; - -type ReservedCommandResponse = { - result: true; - turnTime: string; - turnTerm: number; - year: number; - month: number; - date: string; - turn: TurnObj[]; - autorun_limit: null | number; -}; +import type { ReservedCommandResponse } from "./defs/API/Command"; const { maxTurn, maxPushTurn, commandList } = staticValues; diff --git a/hwe/ts/SammoAPI.ts b/hwe/ts/SammoAPI.ts index e607952c..4caabd87 100644 --- a/hwe/ts/SammoAPI.ts +++ b/hwe/ts/SammoAPI.ts @@ -3,6 +3,10 @@ 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"; export type { ValidResponse, InvalidResponse }; import { APIPathGen, NumVar } from "./util/APIPathGen.js"; +import type { BettingListResponse } from "./defs/API/Betting"; +import type { ReservedCommandResponse } from "./defs/API/Command"; +import type { ChiefResponse } from "./defs/API/NationCommand"; +import type { inheritBuffType } from "./defs/API/InheritAction"; const apiRealPath = { Betting: { @@ -10,11 +14,11 @@ const apiRealPath = { GetBettingDetail: NumVar('betting_id', GET as APICallT ), - GetBettingList: GET, + GetBettingList: GET as APICallT, }, Command: { - GetReservedCommand: GET as APICallT, - PushCommand: PATCH, + GetReservedCommand: GET as APICallT, + PushCommand: PATCH as APICallT<{amount: number}>, RepeatCommand: PATCH, ReserveCommand: PUT, ReserveBulkCommand: PUT as APICallT<{ @@ -27,17 +31,17 @@ const apiRealPath = { Join: POST, }, InheritAction: { - BuyHiddenBuff: PUT, - BuyRandomUnique: PUT, + BuyHiddenBuff: PUT as APICallT<{type: inheritBuffType, level: number}>, + BuyRandomUnique: PUT as APICallT, BuySpecificUnique: PUT, - ResetSpecialWar: PUT, - ResetTurnTime: PUT, + ResetSpecialWar: PUT as APICallT, + ResetTurnTime: PUT as APICallT, SetNextSpecialWar: PUT, }, Misc: { UploadImage: POST }, NationCommand: { - GetReservedCommand: GET, - PushCommand: PATCH, + GetReservedCommand: GET as APICallT, + PushCommand: PATCH as APICallT<{amount: number}>, RepeatCommand: PATCH, ReserveCommand: PUT, ReserveBulkCommand: PUT as APICallT<{ diff --git a/hwe/ts/defs/API/Betting.ts b/hwe/ts/defs/API/Betting.ts new file mode 100644 index 00000000..3a6db8b7 --- /dev/null +++ b/hwe/ts/defs/API/Betting.ts @@ -0,0 +1,7 @@ +import type { ValidResponse, BettingInfo } from "@/defs"; + +export type BettingListResponse = ValidResponse & { + bettingList: Record>; + year: number; + month: number; + }; \ No newline at end of file diff --git a/hwe/ts/defs/API/Command.ts b/hwe/ts/defs/API/Command.ts new file mode 100644 index 00000000..93b69992 --- /dev/null +++ b/hwe/ts/defs/API/Command.ts @@ -0,0 +1,12 @@ +import type { TurnObj } from "@/defs"; + +export type ReservedCommandResponse = { + result: true; + turnTime: string; + turnTerm: number; + year: number; + month: number; + date: string; + turn: TurnObj[]; + autorun_limit: null | number; + }; \ No newline at end of file diff --git a/hwe/ts/defs/API/InheritAction.ts b/hwe/ts/defs/API/InheritAction.ts new file mode 100644 index 00000000..ee4dced6 --- /dev/null +++ b/hwe/ts/defs/API/InheritAction.ts @@ -0,0 +1,9 @@ +export type inheritBuffType = + | "warAvoidRatio" + | "warCriticalRatio" + | "warMagicTrialProb" + | "domesticSuccessProb" + | "domesticFailProb" + | "warAvoidRatioOppose" + | "warCriticalRatioOppose" + | "warMagicTrialProbOppose"; \ No newline at end of file diff --git a/hwe/ts/defs/API/NationCommand.ts b/hwe/ts/defs/API/NationCommand.ts new file mode 100644 index 00000000..65c5e17c --- /dev/null +++ b/hwe/ts/defs/API/NationCommand.ts @@ -0,0 +1,30 @@ +import type { CommandItem, TurnObj } from "@/defs"; + +export type ChiefResponse = { + result: true; + lastExecute: string; + year: number; + month: number; + turnTerm: number; + date: string; + chiefList: Record< + number, + { + name: string | undefined; + turnTime: string | undefined; + officerLevelText: string; + officerLevel: number; + npcType: number; + turn: TurnObj[]; + } + >; + isChief: boolean; + autorun_limit: number; + officerLevel: number; + commandList: { + category: string; + values: CommandItem[]; + }[]; + mapName: string, + unitSet: string, +}; \ No newline at end of file diff --git a/hwe/ts/defs/index.ts b/hwe/ts/defs/index.ts index b547cd40..43f3a0f9 100644 --- a/hwe/ts/defs/index.ts +++ b/hwe/ts/defs/index.ts @@ -200,36 +200,6 @@ export type CommandItem = { searchText?: string; }; -export type ChiefResponse = { - result: true; - lastExecute: string; - year: number; - month: number; - turnTerm: number; - date: string; - chiefList: Record< - number, - { - name: string | undefined; - turnTime: string | undefined; - officerLevelText: string; - officerLevel: number; - npcType: number; - turn: TurnObj[]; - } - >; - isChief: boolean; - autorun_limit: number; - officerLevel: number; - commandList: { - category: string; - values: CommandItem[]; - }[]; - mapName: string, - unitSet: string, -}; - - type diplomacyInfo = { name: string, color?: string,