Commit 9be99836 authored by Chunchi Che's avatar Chunchi Che

impl onSelectIdleCmd

parent f600e0f6
Pipeline #18481 passed with stages
in 3 minutes and 40 seconds
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
import { DuelState } from "./mod"; import { DuelState } from "./mod";
import { RootState } from "../../store"; import { RootState } from "../../store";
import { fetchCard, CardMeta } from "../../api/cards"; import { fetchCard, CardMeta } from "../../api/cards";
import { judgeSelf, Card, InteractType, Interactivity } from "./util"; import { judgeSelf, Card, Interactivity } from "./util";
import * as UICONFIG from "../../config/ui"; import * as UICONFIG from "../../config/ui";
export interface Hands { export interface Hands {
......
...@@ -47,8 +47,14 @@ const duelSlice = createSlice({ ...@@ -47,8 +47,14 @@ const duelSlice = createSlice({
}, },
}); });
export const { setSelfType, infoInit, updateTurn, updatePhase } = export const {
duelSlice.actions; setSelfType,
infoInit,
updateTurn,
updatePhase,
clearHandsInteractivity,
addHandsInteractivity,
} = duelSlice.actions;
export const selectDuelHsStart = (state: RootState) => { export const selectDuelHsStart = (state: RootState) => {
return state.duel.meInitInfo != null; return state.duel.meInitInfo != null;
}; };
......
import { ygopro } from "../../api/ocgcore/idl/ocgcore"; import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { AppDispatch } from "../../store"; import { AppDispatch } from "../../store";
import { InteractType } from "../../reducers/duel/util";
import {
clearHandsInteractivity,
addHandsInteractivity,
} from "../../reducers/duel/mod";
import MsgSelectIdleCmd = ygopro.StocGameMessage.MsgSelectIdleCmd;
export default ( export default (selectIdleCmd: MsgSelectIdleCmd, dispatch: AppDispatch) => {
selectIdleCmd: ygopro.StocGameMessage.MsgSelectIdleCmd, const player = selectIdleCmd.player;
dispatch: AppDispatch const cmds = selectIdleCmd.idle_cmds;
) => {};
// 先清掉之前的手牌互动性
dispatch(clearHandsInteractivity(player));
for (let cmd of cmds) {
let interactType;
switch (cmd.idle_type) {
case MsgSelectIdleCmd.IdleCmd.IdleType.SUMMON: {
interactType = InteractType.SUMMON;
break;
}
case MsgSelectIdleCmd.IdleCmd.IdleType.SPSUMMON: {
interactType = InteractType.SP_SUMMON;
break;
}
case MsgSelectIdleCmd.IdleCmd.IdleType.POS_CHANGE: {
interactType = InteractType.POS_CHANGE;
break;
}
case MsgSelectIdleCmd.IdleCmd.IdleType.MSET: {
interactType = InteractType.MSET;
break;
}
case MsgSelectIdleCmd.IdleCmd.IdleType.SSET: {
interactType = InteractType.SSET;
break;
}
case MsgSelectIdleCmd.IdleCmd.IdleType.ACTIVATE: {
interactType = InteractType.ACTIVATE;
break;
}
}
for (let data of cmd.idle_datas) {
const card_info = data.card_info;
if (card_info.location === 0) {
// 目前只处理手牌场景
if (interactType === InteractType.ACTIVATE) {
// 发动效果会多一个字段
dispatch(
addHandsInteractivity({
player,
index: card_info.sequence,
interactivity: {
interactType,
activateIndex: data.effect_description,
},
})
);
} else if (interactType) {
dispatch(
addHandsInteractivity({
player,
index: card_info.sequence,
interactivity: { interactType },
})
);
}
}
}
}
};
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