Commit 98b281d7 authored by Chunchi Che's avatar Chunchi Che

add navigatin

parent be7512d0
......@@ -6,6 +6,7 @@
import { createSlice } from "@reduxjs/toolkit";
import { InitInfo, meInfoInitImpl, opInfoInitImpl } from "./initInfoSlice";
import { Hands, meAddHandsImpl, opAddHandsImpl } from "./handsSlice";
import { RootState } from "../../store";
export interface DuelState {
meInitInfo?: InitInfo; // 自己的初始状态
......@@ -29,4 +30,7 @@ const duelSlice = createSlice({
export const { meInfoInit, opInfoInit, meAddHands, opAddHands } =
duelSlice.actions;
export const selectDuelHsStart = (state: RootState) => {
return state.duel.meInitInfo != null;
};
export default duelSlice.reducer;
......@@ -14,7 +14,10 @@ import {
unSelectTpAble,
} from "../reducers/moraSlice";
import { selectPlayer0, selectPlayer1 } from "../reducers/playerSlice";
import { selectDuelHsStart } from "../reducers/duel/mod";
import { store } from "../store";
import { useEffect } from "react";
import { useNavigate } from "react-router-dom";
// TODO: 应该展示聊天信息
export default function Mora() {
......@@ -23,6 +26,13 @@ export default function Mora() {
const selectTpAble = useAppSelector(selectTpSelectAble);
const player0 = useAppSelector(selectPlayer0);
const player1 = useAppSelector(selectPlayer1);
const duelHsStart = useAppSelector(selectDuelHsStart);
useEffect(() => {
if (duelHsStart) {
useNavigate()("/duel");
}
}, [duelHsStart]);
const handleSelectScissors = () => {
sendHandResult("scissors");
......
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