Commit b2f71ef0 authored by Chunchi Che's avatar Chunchi Che

impl onMsgNewTurn

parent c5d4e353
......@@ -11,6 +11,7 @@ import {
opAddHandsImpl,
meHandsCase,
} from "./handsSlice";
import { newTurnImpl } from "./turnSlice";
import { RootState } from "../../store";
export interface DuelState {
......@@ -18,6 +19,7 @@ export interface DuelState {
opInitInfo?: InitInfo; // 对手的初始状态
meHands?: Hands; // 自己的手牌
opHands?: Hands; // 对手的手牌
currentPlayer?: number; // 当前的操作方
}
const initialState: DuelState = {};
......@@ -30,13 +32,14 @@ const duelSlice = createSlice({
opInfoInit: opInfoInitImpl,
meAddHands: meAddHandsImpl,
opAddHands: opAddHandsImpl,
updateTurn: newTurnImpl,
},
extraReducers(builder) {
meHandsCase(builder);
},
});
export const { meInfoInit, opInfoInit, meAddHands, opAddHands } =
export const { meInfoInit, opInfoInit, meAddHands, opAddHands, updateTurn } =
duelSlice.actions;
export const selectDuelHsStart = (state: RootState) => {
return state.duel.meInitInfo != null;
......
import { PayloadAction, CaseReducer } from "@reduxjs/toolkit";
import { DuelState } from "./mod";
export const newTurnImpl: CaseReducer<DuelState, PayloadAction<number>> = (
state,
action
) => {
state.currentPlayer = action.payload;
};
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { AppDispatch } from "../../store";
import { updateTurn } from "../../reducers/duel/mod";
export default (
newTurn: ygopro.StocGameMessage.MsgNewTurn,
dispatch: AppDispatch
) => {
// TODO
const player = newTurn.player;
dispatch(updateTurn(player));
};
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