Commit 10a2248d authored by Chunchi Che's avatar Chunchi Che

add clearAllPlaceInteractivitiesImpl

parent 62dc2ba3
Pipeline #19761 failed with stages
in 4 minutes and 32 seconds
import { clearIdleInteractivities, DuelReducer } from "./generic";
import { clearIdleInteractivities, clearPlaceInteractivities, DuelReducer } from "./generic";
import { judgeSelf } from "./util";
export const clearAllIdleInteractivitiesImpl: DuelReducer<number> = (
......@@ -25,3 +25,28 @@ export const clearAllIdleInteractivitiesImpl: DuelReducer<number> = (
states.forEach((item) => clearIdleInteractivities(item));
};
export const clearAllPlaceInteractivitiesImpl: DuelReducer<number> = (
state,
action
) => {
const player = action.payload;
const states = judgeSelf(player, state)
? [
state.meHands,
state.meMonsters,
state.meMagics,
state.meCemetery,
state.meExclusion,
]
: [
state.opHands,
state.opMonsters,
state.opMagics,
state.opCemetery,
state.opExclusion,
];
states.forEach((item) => clearPlaceInteractivities(item));
};
......@@ -90,7 +90,7 @@ import {
exclusionCase,
} from "./exclusionSlice";
import { DeckState, initDeckImpl } from "./deckSlice";
import { clearAllIdleInteractivitiesImpl } from "./commonSlice";
import { clearAllIdleInteractivitiesImpl, clearAllPlaceInteractivitiesImpl } from "./commonSlice";
export interface DuelState {
selfType?: number;
......@@ -228,6 +228,7 @@ const duelSlice = createSlice({
// 通用的`Reducer`
clearAllIdleInteractivities: clearAllIdleInteractivitiesImpl,
clearAllPlaceInteractivities: clearAllPlaceInteractivitiesImpl,
},
extraReducers(builder) {
handsCase(builder);
......@@ -300,6 +301,7 @@ export const {
resetCheckCardModalV2,
setCheckCardModalV2ResponseAble,
clearAllIdleInteractivities,
clearAllPlaceInteractivities
} = duelSlice.actions;
export const selectDuelHsStart = (state: RootState) => {
return state.duel.meInitInfo != null;
......
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