Commit e9b2b562 authored by Chunchi Che's avatar Chunchi Che

add waiting

parent 1405e8d2
Pipeline #20778 passed with stages
in 15 minutes and 11 seconds
...@@ -48,3 +48,4 @@ export const MSG_DAMAGE = 91; ...@@ -48,3 +48,4 @@ export const MSG_DAMAGE = 91;
export const MSG_RECOVER = 92; export const MSG_RECOVER = 92;
export const MSG_PAY_LP_COST = 100; export const MSG_PAY_LP_COST = 100;
export const MSG_WIN = 5; export const MSG_WIN = 5;
export const MSG_WAITING = 3;
...@@ -21,6 +21,7 @@ import MsgSelectPositionAdapter from "./selectPosition"; ...@@ -21,6 +21,7 @@ import MsgSelectPositionAdapter from "./selectPosition";
import MsgSelectOptionAdapter from "./selectOption"; import MsgSelectOptionAdapter from "./selectOption";
import MsgSelectBattleCmdAdapter from "./selectBattleCmd"; import MsgSelectBattleCmdAdapter from "./selectBattleCmd";
import MsgSelectUnselectCardAdapter from "./selectUnselectCard"; import MsgSelectUnselectCardAdapter from "./selectUnselectCard";
import MsgWaitAdapter from "./wait";
import MsgDamage from "./damage"; import MsgDamage from "./damage";
import MsgRecover from "./recover"; import MsgRecover from "./recover";
import MsgWin from "./win"; import MsgWin from "./win";
...@@ -142,6 +143,11 @@ export default class GameMsgAdapter implements StocAdapter { ...@@ -142,6 +143,11 @@ export default class GameMsgAdapter implements StocAdapter {
break; break;
} }
case GAME_MSG.MSG_WAITING: {
gameMsg.wait = MsgWaitAdapter(gameData);
break;
}
default: { default: {
console.log("Unhandled GameMessage function=", func); console.log("Unhandled GameMessage function=", func);
......
import { ygopro } from "../../../idl/ocgcore";
import MsgWait = ygopro.StocGameMessage.MsgWait;
/*
* Msg Wait
*
* @param - null
*
* @usage - 后端通知前端等待对手操作
* */
export default (_data: Uint8Array) => {
return new MsgWait({});
};
...@@ -142,6 +142,8 @@ export interface DuelState { ...@@ -142,6 +142,8 @@ export interface DuelState {
result?: MsgWin.ActionType; result?: MsgWin.ActionType;
waiting?: boolean;
// UI相关 // UI相关
modalState: ModalState; modalState: ModalState;
} }
...@@ -257,6 +259,11 @@ const duelSlice = createSlice({ ...@@ -257,6 +259,11 @@ const duelSlice = createSlice({
setResult: (state, action: PayloadAction<MsgWin.ActionType>) => { setResult: (state, action: PayloadAction<MsgWin.ActionType>) => {
state.result = action.payload; state.result = action.payload;
}, },
// 等待状态`Reducer`
setWaiting: (state, action: PayloadAction<boolean>) => {
state.waiting = action.payload;
},
}, },
extraReducers(builder) { extraReducers(builder) {
handsCase(builder); handsCase(builder);
...@@ -336,6 +343,7 @@ export const { ...@@ -336,6 +343,7 @@ export const {
clearAllIdleInteractivities, clearAllIdleInteractivities,
clearAllPlaceInteractivities, clearAllPlaceInteractivities,
setResult, setResult,
setWaiting,
} = duelSlice.actions; } = duelSlice.actions;
export const selectDuelHsStart = (state: RootState) => { export const selectDuelHsStart = (state: RootState) => {
return state.duel.meInitInfo != null; return state.duel.meInitInfo != null;
...@@ -343,4 +351,7 @@ export const selectDuelHsStart = (state: RootState) => { ...@@ -343,4 +351,7 @@ export const selectDuelHsStart = (state: RootState) => {
export const selectDuelResult = (state: RootState) => { export const selectDuelResult = (state: RootState) => {
return state.duel.result; return state.duel.result;
}; };
export const selectWaiting = (state: RootState) => {
return state.duel.waiting;
};
export default duelSlice.reducer; export default duelSlice.reducer;
...@@ -20,11 +20,32 @@ import onMsgSelectUnselectCard from "./selectUnselectCard"; ...@@ -20,11 +20,32 @@ import onMsgSelectUnselectCard from "./selectUnselectCard";
import onMsgSelectYesNo from "./selectYesNo"; import onMsgSelectYesNo from "./selectYesNo";
import onMsgUpdateHp from "./updateHp"; import onMsgUpdateHp from "./updateHp";
import onMsgWin from "./win"; import onMsgWin from "./win";
import onMsgWait from "./wait";
import { setWaiting } from "../../reducers/duel/mod";
const ActiveList = [
"draw",
"new_turn",
"select_idle_cmd",
"select_place",
"select_card",
"select_chain",
"select_effect_yn",
"select_position",
"select_option",
"select_battle_cmd",
"select_unselect_card",
"select_yes_no",
];
export default function handleGameMsg(pb: ygopro.YgoStocMsg) { export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
const dispatch = store.dispatch; const dispatch = store.dispatch;
const msg = pb.stoc_game_msg; const msg = pb.stoc_game_msg;
if (ActiveList.includes(msg.gameMsg)) {
dispatch(setWaiting(false));
}
switch (msg.gameMsg) { switch (msg.gameMsg) {
case "start": { case "start": {
onMsgStart(msg.start, dispatch); onMsgStart(msg.start, dispatch);
...@@ -126,6 +147,11 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) { ...@@ -126,6 +147,11 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break; break;
} }
case "wait": {
onMsgWait(msg.wait, dispatch);
break;
}
default: { default: {
break; break;
} }
......
...@@ -5,9 +5,7 @@ import { ...@@ -5,9 +5,7 @@ import {
addHandsIdleInteractivity, addHandsIdleInteractivity,
addMagicIdleInteractivities, addMagicIdleInteractivities,
addMonsterIdleInteractivities, addMonsterIdleInteractivities,
clearHandsIdleInteractivity, clearAllIdleInteractivities,
clearMagicIdleInteractivities,
clearMonsterIdleInteractivities,
setEnableEp, setEnableEp,
setEnableM2, setEnableM2,
} from "../../reducers/duel/mod"; } from "../../reducers/duel/mod";
...@@ -19,9 +17,7 @@ export default (selectBattleCmd: MsgSelectBattleCmd, dispatch: AppDispatch) => { ...@@ -19,9 +17,7 @@ export default (selectBattleCmd: MsgSelectBattleCmd, dispatch: AppDispatch) => {
const cmds = selectBattleCmd.battle_cmds; const cmds = selectBattleCmd.battle_cmds;
// 先清掉之前的互动性 // 先清掉之前的互动性
dispatch(clearHandsIdleInteractivity(player)); dispatch(clearAllIdleInteractivities(player));
dispatch(clearMonsterIdleInteractivities(player));
dispatch(clearMagicIdleInteractivities(player));
const dispatcher = ( const dispatcher = (
battleData: MsgSelectBattleCmd.BattleCmd.BattleData, battleData: MsgSelectBattleCmd.BattleCmd.BattleData,
......
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import {
clearAllIdleInteractivities,
setWaiting,
} from "../../reducers/duel/mod";
import { AppDispatch } from "../../store";
export default (
_wait: ygopro.StocGameMessage.MsgWait,
dispatch: AppDispatch
) => {
dispatch(clearAllIdleInteractivities(0));
dispatch(clearAllIdleInteractivities(1));
dispatch(setWaiting(true));
};
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
selectOpInitInfo, selectOpInitInfo,
} from "../../reducers/duel/initInfoSlice"; } from "../../reducers/duel/initInfoSlice";
import { selectCurrentPlayerIsMe } from "../../reducers/duel/turnSlice"; import { selectCurrentPlayerIsMe } from "../../reducers/duel/turnSlice";
import { selectWaiting } from "../../reducers/duel/mod";
const Config = NeosConfig.ui.status; const Config = NeosConfig.ui.status;
const avatarSize = 40; const avatarSize = 40;
...@@ -19,12 +20,13 @@ const PlayerStatus = () => { ...@@ -19,12 +20,13 @@ const PlayerStatus = () => {
const meInfo = useAppSelector(selectMeInitInfo); const meInfo = useAppSelector(selectMeInitInfo);
const opInfo = useAppSelector(selectOpInitInfo); const opInfo = useAppSelector(selectOpInitInfo);
const myTurn = useAppSelector(selectCurrentPlayerIsMe); const myTurn = useAppSelector(selectCurrentPlayerIsMe);
const waiting = useAppSelector(selectWaiting) || false;
return ( return (
<CheckCard.Group <CheckCard.Group
bordered bordered
style={{ height: `${NeosConfig.ui.layout.header.height}` }} style={{ height: `${NeosConfig.ui.layout.header.height}` }}
value={myTurn ? ME_VALUE : OP_VALUE} value={myTurn && !waiting ? ME_VALUE : OP_VALUE}
> >
<CheckCard <CheckCard
avatar={ avatar={
......
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