Commit a4ce41af authored by Chunchi Che's avatar Chunchi Che

add win ui

parent 14051878
Pipeline #20561 passed with stages
in 6 minutes and 41 seconds
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* *
* */ * */
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { InitInfo, infoInitImpl, updateHpImpl } from "./initInfoSlice"; import { InitInfo, infoInitImpl, updateHpImpl } from "./initInfoSlice";
import { TimeLimit, updateTimeLimitImpl } from "./timeLimit"; import { TimeLimit, updateTimeLimitImpl } from "./timeLimit";
...@@ -102,6 +103,7 @@ import { ...@@ -102,6 +103,7 @@ import {
removeExtraDeckImpl, removeExtraDeckImpl,
addExtraDeckIdleInteractivitiesImpl, addExtraDeckIdleInteractivitiesImpl,
} from "./extraDeckSlice"; } from "./extraDeckSlice";
import MsgWin = ygopro.StocGameMessage.MsgWin;
export interface DuelState { export interface DuelState {
selfType?: number; selfType?: number;
...@@ -139,6 +141,8 @@ export interface DuelState { ...@@ -139,6 +141,8 @@ export interface DuelState {
phase?: PhaseState; phase?: PhaseState;
result?: MsgWin.ActionType;
// UI相关 // UI相关
modalState: ModalState; modalState: ModalState;
} }
...@@ -250,6 +254,11 @@ const duelSlice = createSlice({ ...@@ -250,6 +254,11 @@ const duelSlice = createSlice({
// 通用的`Reducer` // 通用的`Reducer`
clearAllIdleInteractivities: clearAllIdleInteractivitiesImpl, clearAllIdleInteractivities: clearAllIdleInteractivitiesImpl,
clearAllPlaceInteractivities: clearAllPlaceInteractivitiesImpl, clearAllPlaceInteractivities: clearAllPlaceInteractivitiesImpl,
// 对局结果`Reducer`
setResult: (state, action: PayloadAction<MsgWin.ActionType>) => {
state.result = action.payload;
},
}, },
extraReducers(builder) { extraReducers(builder) {
handsCase(builder); handsCase(builder);
...@@ -329,8 +338,12 @@ export const { ...@@ -329,8 +338,12 @@ export const {
setCheckCardModalV2ResponseAble, setCheckCardModalV2ResponseAble,
clearAllIdleInteractivities, clearAllIdleInteractivities,
clearAllPlaceInteractivities, clearAllPlaceInteractivities,
setResult,
} = duelSlice.actions; } = duelSlice.actions;
export const selectDuelHsStart = (state: RootState) => { export const selectDuelHsStart = (state: RootState) => {
return state.duel.meInitInfo != null; return state.duel.meInitInfo != null;
}; };
export const selectDuelResult = (state: RootState) => {
return state.duel.result;
};
export default duelSlice.reducer; export default duelSlice.reducer;
...@@ -3,11 +3,17 @@ import { useAppSelector } from "../../hook"; ...@@ -3,11 +3,17 @@ import { useAppSelector } from "../../hook";
import { selectMeHint, selectOpHint } from "../../reducers/duel/hintSlice"; import { selectMeHint, selectOpHint } from "../../reducers/duel/hintSlice";
import { selectCurrentPhase } from "../../reducers/duel/phaseSlice"; import { selectCurrentPhase } from "../../reducers/duel/phaseSlice";
import { notification } from "antd"; import { notification } from "antd";
import { selectDuelResult } from "../../reducers/duel/mod";
import { useNavigate } from "react-router-dom";
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import MsgWin = ygopro.StocGameMessage.MsgWin;
const HintNotification = () => { const HintNotification = () => {
const meHint = useAppSelector(selectMeHint); const meHint = useAppSelector(selectMeHint);
const opHint = useAppSelector(selectOpHint); const opHint = useAppSelector(selectOpHint);
const currentPhase = useAppSelector(selectCurrentPhase); const currentPhase = useAppSelector(selectCurrentPhase);
const result = useAppSelector(selectDuelResult);
const navigate = useNavigate();
const [api, contextHolder] = notification.useNotification(); const [api, contextHolder] = notification.useNotification();
useEffect(() => { useEffect(() => {
...@@ -37,6 +43,24 @@ const HintNotification = () => { ...@@ -37,6 +43,24 @@ const HintNotification = () => {
} }
}, [currentPhase]); }, [currentPhase]);
useEffect(() => {
if (result) {
const message =
result == MsgWin.ActionType.Win
? "胜利"
: MsgWin.ActionType.Defeated
? "失败"
: "未知结果";
api.info({
message,
placement: "bottom",
onClose() {
navigate("/");
},
});
}
}, [result]);
return <>{contextHolder}</>; return <>{contextHolder}</>;
}; };
......
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