Commit aae088cd authored by chechunchi's avatar chechunchi

fix

parent f8b621eb
Pipeline #19538 passed with stages
in 5 minutes and 55 seconds
......@@ -3,7 +3,7 @@ import { DuelState } from "./mod";
import { RootState } from "../../store";
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { PayloadAction, CaseReducer } from "@reduxjs/toolkit";
import { CardState } from "./generic";
import { CardState, InteractType } from "./generic";
export interface FieldState {
inner?: CardState;
......@@ -38,6 +38,25 @@ export const initFieldImpl: CaseReducer<DuelState, PayloadAction<number>> = (
}
};
export const addFieldPlaceInteractivitiesImpl: CaseReducer<
DuelState,
PayloadAction<number>
> = (state, action) => {
const controler = action.payload;
const field = judgeSelf(controler, state) ? state.meField : state.opField;
if (field && field.inner) {
field.inner.placeInteractivities = {
interactType: InteractType.PLACE_SELECTABLE,
response: {
controler,
zone: ygopro.CardZone.ONFIELD,
sequence: 0,
},
};
}
};
export const clearFieldPlaceInteractivitiesImpl: CaseReducer<
DuelState,
PayloadAction<number>
......
......@@ -68,6 +68,7 @@ import {
FieldState,
initFieldImpl,
clearFieldPlaceInteractivitiesImpl,
addFieldPlaceInteractivitiesImpl,
} from "./fieldSlice";
export interface DuelState {
......@@ -161,6 +162,7 @@ const duelSlice = createSlice({
// 场地区相关`Reducer`
initField: initFieldImpl,
clearFieldPlaceInteractivities: clearFieldPlaceInteractivitiesImpl,
addFieldPlaceInteractivities: addFieldPlaceInteractivitiesImpl,
// UI相关`Reducer`
setCardModalIsOpen: setCardModalIsOpenImpl,
......@@ -235,6 +237,7 @@ export const {
initExclusion,
initField,
clearFieldPlaceInteractivities,
addFieldPlaceInteractivities,
} = duelSlice.actions;
export const selectDuelHsStart = (state: RootState) => {
return state.duel.meInitInfo != null;
......
......@@ -4,6 +4,7 @@ import MsgSelectPlace = ygopro.StocGameMessage.MsgSelectPlace;
import {
addMonsterPlaceInteractivities,
addMagicPlaceInteractivities,
addFieldPlaceInteractivities,
} from "../../reducers/duel/mod";
export default (selectPlace: MsgSelectPlace, dispatch: AppDispatch) => {
......@@ -29,6 +30,11 @@ export default (selectPlace: MsgSelectPlace, dispatch: AppDispatch) => {
break;
}
case ygopro.CardZone.ONFIELD: {
dispatch(addFieldPlaceInteractivities(place.controler));
break;
}
default: {
console.warn(`Unhandled zoneType: ${place.zone}`);
}
......
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