Commit 77a984a0 authored by Chunchi Che's avatar Chunchi Che

add removeHand redux

parent 31503a72
......@@ -140,6 +140,20 @@ export const addHandsInteractivityImpl: CaseReducer<
}
};
// 删除手牌
export const removeHandImpl: CaseReducer<
DuelState,
PayloadAction<[number, number]>
> = (state, action) => {
const controler = action.payload[0];
const sequence = action.payload[1];
const hands = judgeSelf(controler, state) ? state.meHands : state.opHands;
if (hands) {
hands.cards = hands.cards.filter((_, idx) => idx != sequence);
}
};
export const selectMeHands = (state: RootState) =>
state.duel.meHands || { cards: [] };
export const selectOpHands = (state: RootState) =>
......
......@@ -11,6 +11,7 @@ import {
handsCase,
clearHandsInteractivityImpl,
addHandsInteractivityImpl,
removeHandImpl,
} from "./handsSlice";
import { newTurnImpl } from "./turnSlice";
import { newPhaseImpl } from "./phaseSlice";
......@@ -84,6 +85,7 @@ const duelSlice = createSlice({
// 手牌相关`Reducer`
clearHandsInteractivity: clearHandsInteractivityImpl,
addHandsInteractivity: addHandsInteractivityImpl,
removeHand: removeHandImpl,
// 怪兽区相关`Reducer`
initMonsters: initMonstersImpl,
......@@ -125,6 +127,7 @@ export const {
initMagics,
addMagicPlaceSelectAble,
clearMagicSelectInfo,
removeHand,
} = 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