Commit b42b70b0 authored by Chunchi Che's avatar Chunchi Che

fix selectOption service

parent 625200f7
Pipeline #23389 passed with stages
in 15 minutes and 43 seconds
......@@ -29,13 +29,13 @@ export function fetchStrings(region: Region, id: string | number): string {
return localStorage.getItem(`${region}_${id}`) || "";
}
export async function getStrings(description: number): Promise<string> {
export function getStrings(description: number): string {
if (description < DESCRIPTION_LIMIT) {
return fetchStrings(Region.System, description);
} else {
const code = description >> 4;
const index = description & 0xf;
return getCardStr(fetchCard(code), index) || "";
return getCardStr(fetchCard(code), index) ?? "[?]";
}
}
......@@ -18,7 +18,7 @@ export default async (hint: MsgHint) => {
break;
}
case MsgHint.HintType.HINT_SELECTMSG: {
await fetchSelectHintMeta({
fetchSelectHintMeta({
selectHintData: hint.hint_data,
esHint: "",
});
......
......@@ -67,7 +67,7 @@ export default async (selectChain: MsgSelectChain) => {
case 2: // 处理多张
case 3: {
// 处理强制发动的卡
await fetchSelectHintMeta({
fetchSelectHintMeta({
selectHintData: 203,
});
const { selecteds, mustSelects, selectables } = await fetchCheckCardMeta(
......
import {
fetchCard,
fetchStrings,
getCardStr,
Region,
type ygopro,
} from "@/api";
import { fetchStrings, getStrings, Region, type ygopro } from "@/api";
import { displayOptionModal } from "@/ui/Duel/Message";
export default async (selectOption: ygopro.StocGameMessage.MsgSelectOption) => {
const options = selectOption.options;
await displayOptionModal(
fetchStrings(Region.System, 556),
await Promise.all(
options.map(async ({ code, response }) => {
const meta = fetchCard(code >> 4);
const info = getCardStr(meta, code & 0xf) ?? "[?]";
return { info, response };
}),
),
options.map(({ code, response }) => ({
info: getStrings(code),
response,
})),
1,
);
};
......@@ -7,6 +7,6 @@ export default async (selectYesNo: MsgSelectYesNo) => {
const _player = selectYesNo.player;
const effect_description = selectYesNo.effect_description;
const msg = await getStrings(effect_description);
const msg = getStrings(effect_description);
await displayYesNoModal(msg);
};
......@@ -10,7 +10,7 @@ export const fetchCommonHintMeta = (code: number) => {
matStore.hint.msg = fetchStrings(Region.System, code);
};
export const fetchSelectHintMeta = async ({
export const fetchSelectHintMeta = ({
selectHintData,
esHint,
}: {
......@@ -26,7 +26,7 @@ export const fetchSelectHintMeta = async ({
cardMeta.text.name || "[?]",
);
} else {
selectHintMeta = await getStrings(selectHintData);
selectHintMeta = getStrings(selectHintData);
}
matStore.hint.code = selectHintData;
......
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