Commit e1585af1 authored by Chunchi Che's avatar Chunchi Che

fix select_card service bug

parent 296eaf09
Pipeline #19751 passed with stages
in 4 minutes and 4 seconds
...@@ -6,8 +6,9 @@ import { ...@@ -6,8 +6,9 @@ import {
} from "@reduxjs/toolkit"; } from "@reduxjs/toolkit";
import { RootState } from "../../../store"; import { RootState } from "../../../store";
import { DuelState } from "../mod"; import { DuelState } from "../mod";
import { judgeSelf } from "../util"; import { findCardByLocation, judgeSelf } from "../util";
import { fetchCard, getCardStr } from "../../../api/cards"; import { fetchCard, getCardStr } from "../../../api/cards";
import { ygopro } from "../../../api/ocgcore/idl/ocgcore";
// 更新卡牌选择弹窗打开状态 // 更新卡牌选择弹窗打开状态
export const setCheckCardModalIsOpenImpl: CaseReducer< export const setCheckCardModalIsOpenImpl: CaseReducer<
...@@ -56,7 +57,13 @@ export const fetchCheckCardMeta = createAsyncThunk( ...@@ -56,7 +57,13 @@ export const fetchCheckCardMeta = createAsyncThunk(
async (param: { async (param: {
controler: number; controler: number;
tagName: string; tagName: string;
option: { code: number; response: number; effectDescCode?: number }; option: {
code: number;
zone?: ygopro.CardZone;
sequence?: number;
response: number;
effectDescCode?: number;
};
}) => { }) => {
const meta = await fetchCard(param.option.code, true); const meta = await fetchCard(param.option.code, true);
const effectDesc = param.option.effectDescCode const effectDesc = param.option.effectDescCode
...@@ -84,23 +91,34 @@ export const checkCardModalCase = ( ...@@ -84,23 +91,34 @@ export const checkCardModalCase = (
const controler = action.meta.arg.controler; const controler = action.meta.arg.controler;
const tagName = action.meta.arg.tagName; const tagName = action.meta.arg.tagName;
const code = action.meta.arg.option.code; const code = action.meta.arg.option.code;
const zone = action.meta.arg.option.zone;
const sequence = action.meta.arg.option.sequence;
const response = action.meta.arg.option.response; const response = action.meta.arg.option.response;
const combinedTagName = judgeSelf(controler, state) const combinedTagName = judgeSelf(controler, state)
? `我方的${tagName}` ? `我方的${tagName}`
: `对方的${tagName}`; : `对方的${tagName}`;
for (const tag of state.modalState.checkCardModal.tags) { const newID =
if (tag.tagName === combinedTagName) { code != 0
tag.options.push({ code, response }); ? code
return; : zone && sequence
? findCardByLocation(state, controler, zone, sequence)?.occupant?.id
: undefined;
if (newID) {
for (const tag of state.modalState.checkCardModal.tags) {
if (tag.tagName === combinedTagName) {
tag.options.push({ code: newID, response });
return;
}
} }
}
state.modalState.checkCardModal.tags.push({ state.modalState.checkCardModal.tags.push({
tagName: combinedTagName, tagName: combinedTagName,
options: [{ code, response }], options: [{ code: newID, response }],
}); });
}
}); });
builder.addCase(fetchCheckCardMeta.fulfilled, (state, action) => { builder.addCase(fetchCheckCardMeta.fulfilled, (state, action) => {
const controler = action.payload.controler; const controler = action.payload.controler;
......
...@@ -25,7 +25,12 @@ export default (selectCard: MsgSelectCard, dispatch: AppDispatch) => { ...@@ -25,7 +25,12 @@ export default (selectCard: MsgSelectCard, dispatch: AppDispatch) => {
fetchCheckCardMeta({ fetchCheckCardMeta({
controler: card.location.controler, controler: card.location.controler,
tagName, tagName,
option: { code: card.code, response: card.response }, option: {
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