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

add removeHand redux

parent 31503a72
...@@ -140,6 +140,20 @@ export const addHandsInteractivityImpl: CaseReducer< ...@@ -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) => export const selectMeHands = (state: RootState) =>
state.duel.meHands || { cards: [] }; state.duel.meHands || { cards: [] };
export const selectOpHands = (state: RootState) => export const selectOpHands = (state: RootState) =>
......
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
handsCase, handsCase,
clearHandsInteractivityImpl, clearHandsInteractivityImpl,
addHandsInteractivityImpl, addHandsInteractivityImpl,
removeHandImpl,
} from "./handsSlice"; } from "./handsSlice";
import { newTurnImpl } from "./turnSlice"; import { newTurnImpl } from "./turnSlice";
import { newPhaseImpl } from "./phaseSlice"; import { newPhaseImpl } from "./phaseSlice";
...@@ -84,6 +85,7 @@ const duelSlice = createSlice({ ...@@ -84,6 +85,7 @@ const duelSlice = createSlice({
// 手牌相关`Reducer` // 手牌相关`Reducer`
clearHandsInteractivity: clearHandsInteractivityImpl, clearHandsInteractivity: clearHandsInteractivityImpl,
addHandsInteractivity: addHandsInteractivityImpl, addHandsInteractivity: addHandsInteractivityImpl,
removeHand: removeHandImpl,
// 怪兽区相关`Reducer` // 怪兽区相关`Reducer`
initMonsters: initMonstersImpl, initMonsters: initMonstersImpl,
...@@ -125,6 +127,7 @@ export const { ...@@ -125,6 +127,7 @@ export const {
initMagics, initMagics,
addMagicPlaceSelectAble, addMagicPlaceSelectAble,
clearMagicSelectInfo, clearMagicSelectInfo,
removeHand,
} = duelSlice.actions; } = duelSlice.actions;
export const selectDuelHsStart = (state: RootState) => { export const selectDuelHsStart = (state: RootState) => {
return state.duel.meInitInfo != null; 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