Commit 3c38ffb5 authored by timel's avatar timel

refactor: deck api

parent 5226ac18
Pipeline #21138 failed with stages
in 6 minutes and 23 seconds
{
"hero": {
"main": [
14124483,
9411399,
9411399,
18094166,
18094166,
18094166,
40044918,
40044918,
59392529,
50720316,
50720316,
27780618,
27780618,
16605586,
16605586,
22865492,
22865492,
23434538,
23434538,
14558127,
14558127,
13650422,
83965310,
81439173,
8949584,
8949584,
32807846,
52947044,
45906428,
24094653,
21143940,
21143940,
21143940,
48130397,
24224830,
24224830,
12071500,
24299458,
24299458,
10045474
],
"extra": [
86165817,
41209827,
29095552,
40854197,
60461804,
60461804,
22908820,
58481572,
58481572,
89870349,
46759931,
63813056,
1948619,
58004362,
58004362
],
"side": [
27204311,
34267821,
34267821,
43534808,
43534808,
94145021,
94145021,
18144506,
54693926,
54693926,
43898403,
43898403,
65681983,
23002292
]
}
}
// import axios from "axios"; import { DECKS } from "./structureDeck";
import DECKS from "./deck.json";
const DeckManager = _objToMap(DECKS); const DeckManager = _objToMap(DECKS);
export interface IDeck {
main?: number[];
extra?: number[];
side?: number[];
}
/* /*
* 返回卡组资源。 * 返回卡组资源。
* *
...@@ -20,13 +13,20 @@ export interface IDeck { ...@@ -20,13 +13,20 @@ export interface IDeck {
export async function fetchDeck(deck: string): Promise<IDeck> { export async function fetchDeck(deck: string): Promise<IDeck> {
const res = DeckManager.get(deck); const res = DeckManager.get(deck);
return res || { main: [], extra: [], side: [] }; return res ?? { deckName: "undefined", main: [], extra: [], side: [] };
} }
function _objToMap(object: any): Map<string, IDeck> { function _objToMap(object: IDeck[]): Map<string, IDeck> {
let map = new Map(); const map: Map<string, IDeck> = new Map();
Object.keys(object).forEach((key) => map.set(key, object[key])); object.forEach((value) => map.set(value.deckName, value));
return map; return map;
} }
export interface IDeck {
deckName: string;
main: number[];
extra: number[];
side: number[];
}
export * from "./deckManager";
import type { IDeck } from ".";
/**
* 预设卡组。
*/
export const DECKS: IDeck[] = [
{
deckName: "hero",
main: [
14124483, 9411399, 9411399, 18094166, 18094166, 18094166, 40044918,
40044918, 59392529, 50720316, 50720316, 27780618, 27780618, 16605586,
16605586, 22865492, 22865492, 23434538, 23434538, 14558127, 14558127,
13650422, 83965310, 81439173, 8949584, 8949584, 32807846, 52947044,
45906428, 24094653, 21143940, 21143940, 21143940, 48130397, 24224830,
24224830, 12071500, 24299458, 24299458, 10045474,
],
extra: [
86165817, 41209827, 29095552, 40854197, 60461804, 60461804, 22908820,
58481572, 58481572, 89870349, 46759931, 63813056, 1948619, 58004362,
58004362,
],
side: [
27204311, 34267821, 34267821, 43534808, 43534808, 94145021, 94145021,
18144506, 54693926, 54693926, 43898403, 43898403, 65681983, 23002292,
],
},
{
deckName: "Sky Striker Ace",
main: [
27204311, 33331231, 37351133, 37351133, 26077387, 26077387, 26077387,
23434538, 23434538, 23434538, 14558127, 14558127, 14558127, 97268402,
97268402, 18144506, 25955749, 99550630, 35261759, 35261759, 73628505,
63166095, 63166095, 46271408, 67169062, 32807846, 70368879, 70368879,
51227866, 9726840, 9726840, 52340444, 24224830, 24224830, 98338152,
98338152, 24299458, 24010609, 24010609, 97616504, 50005218, 67616300,
10045474, 10045474,
],
extra: [
85289965, 86066372, 49202162, 38342335, 45819647, 2857636, 50588353,
75147529, 12421694, 90673288, 90673288, 90673288, 63288573, 8491308,
8491308,
],
side: [
27204311, 33331231, 34267821, 34267821, 24508238, 73642296, 59438930,
59438930, 5133471, 24299458, 83326048, 83326048, 69452756, 69452756,
23002292,
],
},
];
/// <reference types="react-scripts" />
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_IS_AI_MODE: string;
readonly VITE_IS_AI_FIRST: string;
readonly VITE_AI_MODE_DEFAULT_DECK: string;
}
interface ImportMeta {
readonly env: ImportMetaEnv;
}
/// <reference types="react-scripts" />
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment