Commit 19073671 authored by timel's avatar timel

fix: remove useless await

parent 338735da
...@@ -36,6 +36,6 @@ export async function getStrings(description: number): Promise<string> { ...@@ -36,6 +36,6 @@ export async function getStrings(description: number): Promise<string> {
const code = description >> 4; const code = description >> 4;
const index = description & 0xf; const index = description & 0xf;
return getCardStr(await fetchCard(code), index) || ""; return getCardStr(fetchCard(code), index) || "";
} }
} }
...@@ -40,7 +40,7 @@ export default async (announce: MsgAnnounce) => { ...@@ -40,7 +40,7 @@ export default async (announce: MsgAnnounce) => {
case MsgAnnounce.AnnounceType.Card: { case MsgAnnounce.AnnounceType.Card: {
const options = []; const options = [];
for (const option of announce.options) { for (const option of announce.options) {
const meta = await fetchCard(option.code); const meta = fetchCard(option.code);
if (meta.text.name) { if (meta.text.name) {
options.push({ options.push({
info: meta.text.name, info: meta.text.name,
......
...@@ -18,7 +18,7 @@ export default async (chaining: ygopro.StocGameMessage.MsgChaining) => { ...@@ -18,7 +18,7 @@ export default async (chaining: ygopro.StocGameMessage.MsgChaining) => {
// 设置连锁序号 // 设置连锁序号
target.chainIndex = matStore.chains.length; target.chainIndex = matStore.chains.length;
const meta = await fetchCard(chaining.code); const meta = fetchCard(chaining.code);
// 这里不能设置`code`,因为存在一个场景: // 这里不能设置`code`,因为存在一个场景:
// 对方的`魔神仪-曼德拉护肤草`发动效果后,后端会发一次`MSG_SHUFFLE_HAND`,但传给前端的codes全是0,如果这里设置了`code`的话,在后面的`MSG_SHUFFLE_HAND`处理就会有问题。 // 对方的`魔神仪-曼德拉护肤草`发动效果后,后端会发一次`MSG_SHUFFLE_HAND`,但传给前端的codes全是0,如果这里设置了`code`的话,在后面的`MSG_SHUFFLE_HAND`处理就会有问题。
// target.code = meta.id; // target.code = meta.id;
......
...@@ -11,7 +11,7 @@ export default async (confirmCards: ygopro.StocGameMessage.MsgConfirmCards) => { ...@@ -11,7 +11,7 @@ export default async (confirmCards: ygopro.StocGameMessage.MsgConfirmCards) => {
if (target) { if (target) {
// 设置`occupant` // 设置`occupant`
const meta = await fetchCard(card.code); const meta = fetchCard(card.code);
target.meta = meta; target.meta = meta;
// 动画 // 动画
await callCardFocus(target.uuid); await callCardFocus(target.uuid);
......
...@@ -17,7 +17,7 @@ export default async (draw: ygopro.StocGameMessage.MsgDraw) => { ...@@ -17,7 +17,7 @@ export default async (draw: ygopro.StocGameMessage.MsgDraw) => {
for (const idx in newHands) { for (const idx in newHands) {
const card = newHands[Number(idx)]; const card = newHands[Number(idx)];
const code = draw.cards[idx]; const code = draw.cards[idx];
const meta = await fetchCard(code); const meta = fetchCard(code);
card.code = code; card.code = code;
card.meta = meta; card.meta = meta;
card.location.zone = ygopro.CardZone.HAND; card.location.zone = ygopro.CardZone.HAND;
......
...@@ -34,7 +34,7 @@ export default async (move: MsgMove) => { ...@@ -34,7 +34,7 @@ export default async (move: MsgMove) => {
const to = move.to; const to = move.to;
const reason = move.reason; const reason = move.reason;
const meta = await fetchCard(code); const meta = fetchCard(code);
if (meta.data.type !== undefined && (meta.data.type & TYPE_TOKEN) > 0) { if (meta.data.type !== undefined && (meta.data.type & TYPE_TOKEN) > 0) {
// 衍生物 // 衍生物
if (from.zone === DECK) { if (from.zone === DECK) {
......
...@@ -32,6 +32,6 @@ export default async (selectEffectYn: MsgSelectEffectYn) => { ...@@ -32,6 +32,6 @@ export default async (selectEffectYn: MsgSelectEffectYn) => {
// TODO: 国际化文案 // TODO: 国际化文案
const desc = fetchStrings(Region.System, effect_description); const desc = fetchStrings(Region.System, effect_description);
const meta = await fetchCard(code); const meta = fetchCard(code);
await displayYesNoModal(textGenerator(desc, meta, location)); await displayYesNoModal(textGenerator(desc, meta, location));
}; };
...@@ -13,7 +13,7 @@ export default async (selectOption: ygopro.StocGameMessage.MsgSelectOption) => { ...@@ -13,7 +13,7 @@ export default async (selectOption: ygopro.StocGameMessage.MsgSelectOption) => {
fetchStrings(Region.System, 556), fetchStrings(Region.System, 556),
await Promise.all( await Promise.all(
options.map(async ({ code, response }) => { options.map(async ({ code, response }) => {
const meta = await fetchCard(code >> 4); const meta = fetchCard(code >> 4);
const msg = getCardStr(meta, code & 0xf) || "[?]"; const msg = getCardStr(meta, code & 0xf) || "[?]";
return { msg, response }; return { msg, response };
}), }),
......
...@@ -6,7 +6,7 @@ type MsgSortCard = ygopro.StocGameMessage.MsgSortCard; ...@@ -6,7 +6,7 @@ type MsgSortCard = ygopro.StocGameMessage.MsgSortCard;
export default async (sortCard: MsgSortCard) => { export default async (sortCard: MsgSortCard) => {
const options = await Promise.all( const options = await Promise.all(
sortCard.options.map(async ({ code, response }) => { sortCard.options.map(async ({ code, response }) => {
const meta = await fetchCard(code!); const meta = fetchCard(code!);
return { return {
meta, meta,
response: response!, response: response!,
......
...@@ -106,7 +106,7 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => { ...@@ -106,7 +106,7 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => {
const genCard = (o: CardType) => { const genCard = (o: CardType) => {
const t = proxy(o); const t = proxy(o);
subscribeKey(t, "code", async (code) => { subscribeKey(t, "code", async (code) => {
const meta = await fetchCard(code ?? 0); const meta = fetchCard(code ?? 0);
t.meta = meta; t.meta = meta;
}); });
return t; return t;
......
...@@ -16,7 +16,7 @@ export default async (updateData: MsgUpdateData) => { ...@@ -16,7 +16,7 @@ export default async (updateData: MsgUpdateData) => {
if (target) { if (target) {
// 目前只更新以下字段 // 目前只更新以下字段
if (action?.code >= 0) { if (action?.code >= 0) {
const newMeta = await fetchCard(action.code); const newMeta = fetchCard(action.code);
target.code = action.code; target.code = action.code;
target.meta = newMeta; target.meta = newMeta;
} }
......
...@@ -24,7 +24,7 @@ export default async function handleErrorMsg(errorMsg: ygopro.StocErrorMsg) { ...@@ -24,7 +24,7 @@ export default async function handleErrorMsg(errorMsg: ygopro.StocErrorMsg) {
case ErrorType.DECKERROR: { case ErrorType.DECKERROR: {
const flag = error_code >> 28; const flag = error_code >> 28;
const code = error_code && 0xfffffff; const code = error_code && 0xfffffff;
const card = await fetchCard(code); const card = fetchCard(code);
const baseMsg = `卡组非法,请检查:${card.text.name}`; const baseMsg = `卡组非法,请检查:${card.text.name}`;
switch (flag) { switch (flag) {
case DECKERROR_LFLIST: { case DECKERROR_LFLIST: {
......
...@@ -30,7 +30,7 @@ const helper = async ( ...@@ -30,7 +30,7 @@ const helper = async (
code !== 0 code !== 0
? code ? code
: cardStore.at(location.zone, controller, location.sequence)?.code || 0; : cardStore.at(location.zone, controller, location.sequence)?.code || 0;
const meta = await fetchCard(newID); const meta = fetchCard(newID);
const effectDesc = effect_description const effectDesc = effect_description
? getCardStr(meta, effect_description & 0xf) ? getCardStr(meta, effect_description & 0xf)
......
...@@ -22,7 +22,7 @@ export const fetchSelectHintMeta = async ({ ...@@ -22,7 +22,7 @@ export const fetchSelectHintMeta = async ({
let selectHintMeta = ""; let selectHintMeta = "";
if (selectHintData > DESCRIPTION_LIMIT) { if (selectHintData > DESCRIPTION_LIMIT) {
// 针对`MSG_SELECT_PLACE`的特化逻辑 // 针对`MSG_SELECT_PLACE`的特化逻辑
const cardMeta = await fetchCard(selectHintData); const cardMeta = fetchCard(selectHintData);
selectHintMeta = fetchStrings(Region.System, 569).replace( selectHintMeta = fetchStrings(Region.System, 569).replace(
"[%ls]", "[%ls]",
cardMeta.text.name || "[?]", cardMeta.text.name || "[?]",
...@@ -55,7 +55,7 @@ export const fetchEsHintMeta = async ({ ...@@ -55,7 +55,7 @@ export const fetchEsHintMeta = async ({
? originMsg ? originMsg
: fetchStrings(Region.System, originMsg); : fetchStrings(Region.System, originMsg);
const cardMeta = cardID ? await fetchCard(cardID) : undefined; const cardMeta = cardID ? fetchCard(cardID) : undefined;
let esHint = newOriginMsg; let esHint = newOriginMsg;
......
...@@ -260,8 +260,8 @@ const Search: React.FC = () => { ...@@ -260,8 +260,8 @@ const Search: React.FC = () => {
] as const ] as const
).map(([label, onClick], key) => ({ key, label, onClick })); ).map(([label, onClick], key) => ({ key, label, onClick }));
const handleSearch = async (conditions: FtsConditions = searchConditions) => { const handleSearch = (conditions: FtsConditions = searchConditions) => {
const result = (await searchCards({ query: searchWord, conditions })) const result = searchCards({ query: searchWord, conditions })
.filter((card) => !isToken(card.data.type ?? 0)) .filter((card) => !isToken(card.data.type ?? 0))
.sort(sortRef.current); // 衍生物不显示 .sort(sortRef.current); // 衍生物不显示
setSearchResult(() => result); setSearchResult(() => result);
......
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