Commit 2801e6de authored by chechunchi's avatar chechunchi

add selectEffectYn stoc adapter and service

parent e97750fd
...@@ -36,3 +36,4 @@ export const MSG_SELECT_PLACE = 18; ...@@ -36,3 +36,4 @@ export const MSG_SELECT_PLACE = 18;
export const MSG_MOVE = 50; export const MSG_MOVE = 50;
export const MSG_SELECT_CARD = 15; export const MSG_SELECT_CARD = 15;
export const MSG_SELECT_CHAIN = 16; export const MSG_SELECT_CHAIN = 16;
export const MSG_SELECT_EFFECTYN = 12;
...@@ -16,6 +16,7 @@ import MsgSelectPlaceAdapter from "./selectPlace"; ...@@ -16,6 +16,7 @@ import MsgSelectPlaceAdapter from "./selectPlace";
import MsgMoveAdapter from "./move"; import MsgMoveAdapter from "./move";
import MsgSelectCardAdapter from "./selectCard"; import MsgSelectCardAdapter from "./selectCard";
import MsgSelectChainAdapter from "./selectChain"; import MsgSelectChainAdapter from "./selectChain";
import MsgSelectEffectYnAdapter from "./selectEffectYn";
/* /*
* STOC GameMsg * STOC GameMsg
...@@ -91,6 +92,11 @@ export default class GameMsgAdapter implements StocAdapter { ...@@ -91,6 +92,11 @@ export default class GameMsgAdapter implements StocAdapter {
break; break;
} }
case GAME_MSG.MSG_SELECT_EFFECTYN: {
gameMsg.select_effect_yn = MsgSelectEffectYnAdapter(gameData);
break;
}
default: { default: {
console.log("Unhandled GameMessage function=", func); console.log("Unhandled GameMessage function=", func);
......
import { ygopro } from "../../../idl/ocgcore";
import { BufferReader } from "../../bufferIO";
import MsgSelectEffectYn = ygopro.StocGameMessage.MsgSelectEffectYn;
/*
* Msg Select EffectYn
*
* @param - see: https://code.mycard.moe/mycard/neos-protobuf/-/blob/main/idl/ocgcore.neos-protobuf
* @usage - 玩家选择是否发动效果
*
* */
export default (data: Uint8Array) => {
const reader = new BufferReader(data, true);
const player = reader.readUint8();
const code = reader.readUint32();
const location = reader.readCardLocation();
const effect_description = reader.readUint32();
return new MsgSelectEffectYn({
player,
code,
location,
effect_description,
});
};
...@@ -10,6 +10,7 @@ import onMsgSelectPlace from "./selectPlace"; ...@@ -10,6 +10,7 @@ import onMsgSelectPlace from "./selectPlace";
import onMsgMove from "./move"; import onMsgMove from "./move";
import onMsgSelectCard from "./selectCard"; import onMsgSelectCard from "./selectCard";
import onMsgSelectChain from "./selectChain"; import onMsgSelectChain from "./selectChain";
import onMsgSelectEffectYn from "./selectEffectYn";
export default function handleGameMsg(pb: ygopro.YgoStocMsg) { export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
const dispatch = store.dispatch; const dispatch = store.dispatch;
...@@ -18,74 +19,70 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) { ...@@ -18,74 +19,70 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
switch (msg.gameMsg) { switch (msg.gameMsg) {
case "start": { case "start": {
const start = msg.start; const start = msg.start;
onMsgStart(start, dispatch); onMsgStart(start, dispatch);
break; break;
} }
case "draw": { case "draw": {
const draw = msg.draw; const draw = msg.draw;
onMsgDraw(draw, dispatch); onMsgDraw(draw, dispatch);
break; break;
} }
case "new_turn": { case "new_turn": {
const newTurn = msg.new_turn; const newTurn = msg.new_turn;
onMsgNewTurn(newTurn, dispatch); onMsgNewTurn(newTurn, dispatch);
break; break;
} }
case "new_phase": { case "new_phase": {
const newPhase = msg.new_phase; const newPhase = msg.new_phase;
onMsgNewPhase(newPhase, dispatch); onMsgNewPhase(newPhase, dispatch);
break; break;
} }
case "hint": { case "hint": {
const hint = msg.hint; const hint = msg.hint;
onMsgHint(hint, dispatch); onMsgHint(hint, dispatch);
break; break;
} }
case "select_idle_cmd": { case "select_idle_cmd": {
const selectIdleCmd = msg.select_idle_cmd; const selectIdleCmd = msg.select_idle_cmd;
onMsgSelectIdleCmd(selectIdleCmd, dispatch); onMsgSelectIdleCmd(selectIdleCmd, dispatch);
break; break;
} }
case "select_place": { case "select_place": {
const selectPlace = msg.select_place; const selectPlace = msg.select_place;
onMsgSelectPlace(selectPlace, dispatch); onMsgSelectPlace(selectPlace, dispatch);
break; break;
} }
case "move": { case "move": {
const move = msg.move; const move = msg.move;
onMsgMove(move, dispatch); onMsgMove(move, dispatch);
break; break;
} }
case "select_card": { case "select_card": {
const selectCard = msg.select_card; const selectCard = msg.select_card;
onMsgSelectCard(selectCard, dispatch); onMsgSelectCard(selectCard, dispatch);
break; break;
} }
case "select_chain": { case "select_chain": {
const selectChain = msg.select_chain; const selectChain = msg.select_chain;
onMsgSelectChain(selectChain, dispatch); onMsgSelectChain(selectChain, dispatch);
break; break;
} }
case "select_effect_yn": {
const selectEffectYn = msg.select_effect_yn;
onMsgSelectEffectYn(selectEffectYn, dispatch);
break;
}
default: { default: {
break; break;
} }
......
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { AppDispatch } from "../../store";
import MsgSelectEffectYn = ygopro.StocGameMessage.MsgSelectEffectYn;
export default (selectEffectYn: MsgSelectEffectYn, dispatch: AppDispatch) => {
console.log(selectEffectYn);
};
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