Commit c91d637a authored by Chunchi Che's avatar Chunchi Che

Merge branch 'fix/select_option' into 'main'

fix selectOption service

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