Commit f98dd1ca authored by Chunchi Che's avatar Chunchi Che

fix fetchCheckCardMetasV2

parent 8fb09d50
......@@ -65,6 +65,7 @@ export const fetchCheckCardMeta = createAsyncThunk(
effectDescCode?: number;
};
}) => {
// FIXME: 这里如果传的`controler`如果是对手,对应的`code`会为零,这时候就无法更新对应的`Meta`信息了,后续需要修复
const meta = await fetchCard(param.option.code, true);
const effectDesc = param.option.effectDescCode
? getCardStr(meta, param.option.effectDescCode & 0xf)
......@@ -102,7 +103,7 @@ export const checkCardModalCase = (
const newID =
code != 0
? code
: zone && sequence
: zone !== undefined && sequence !== undefined
? findCardByLocation(state, controler, zone, sequence)?.occupant?.id
: undefined;
......
......@@ -7,6 +7,8 @@ import {
} from "@reduxjs/toolkit";
import { fetchCard } from "../../../api/cards";
import { RootState } from "../../../store";
import { ygopro } from "../../../api/ocgcore/idl/ocgcore";
import { findCardByLocation } from "../util";
// 更新打开状态
export const setCheckCardModalV2IsOpenImpl: DuelReducer<boolean> = (
......@@ -55,7 +57,12 @@ export const fetchCheckCardMetasV2 = createAsyncThunk(
async (param: {
controler: number;
selected: boolean;
options: { code: number; response: number }[];
options: {
code: number;
zone: ygopro.CardZone;
sequence: number;
response: number;
}[];
}) => {
const metas = await Promise.all(
param.options.map(async (option) => {
......@@ -76,9 +83,19 @@ export const checkCardModalV2Case = (
builder: ActionReducerMapBuilder<DuelState>
) => {
builder.addCase(fetchCheckCardMetasV2.pending, (state, action) => {
const controler = action.meta.arg.controler;
const selected = action.meta.arg.selected;
const options = action.meta.arg.options;
for (const option of options) {
if (option.code == 0) {
const newCode =
findCardByLocation(state, controler, option.zone, option.sequence)
?.occupant?.id || 0;
option.code = newCode;
}
}
if (selected) {
state.modalState.checkCardModalV2.selectedOptions = options;
} else {
......
......@@ -32,7 +32,12 @@ export default (
controler,
selected: false,
options: selectableCards.map((card) => {
return { code: card.code, response: card.response };
return {
code: card.code,
zone: card.location.location,
sequence: card.location.sequence,
response: card.response,
};
}),
})
);
......@@ -42,7 +47,12 @@ export default (
controler,
selected: true,
options: selectedCards.map((card) => {
return { code: card.code, response: card.response };
return {
code: card.code,
zone: card.location.location,
sequence: card.location.sequence,
response: card.response,
};
}),
})
);
......
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