Commit b8660288 authored by chechunchi's avatar chechunchi

add select_position stoc adapter and service

parent 0117975b
......@@ -37,3 +37,4 @@ export const MSG_MOVE = 50;
export const MSG_SELECT_CARD = 15;
export const MSG_SELECT_CHAIN = 16;
export const MSG_SELECT_EFFECTYN = 12;
export const MSG_SELECT_POSITION = 19;
......@@ -17,6 +17,7 @@ import MsgMoveAdapter from "./move";
import MsgSelectCardAdapter from "./selectCard";
import MsgSelectChainAdapter from "./selectChain";
import MsgSelectEffectYnAdapter from "./selectEffectYn";
import MsgSelectPositionAdapter from "./selectPosition";
/*
* STOC GameMsg
......@@ -97,6 +98,11 @@ export default class GameMsgAdapter implements StocAdapter {
break;
}
case GAME_MSG.MSG_SELECT_POSITION: {
gameMsg.select_position = MsgSelectPositionAdapter(gameData);
break;
}
default: {
console.log("Unhandled GameMessage function=", func);
......
import { ygopro } from "../../../idl/ocgcore";
import { BufferReader } from "../../bufferIO";
import MsgSelectPosition = ygopro.StocGameMessage.MsgSelectPosition;
/*
* Msg Select Position
*
* @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 positions = reader.readUint8();
const msg = new MsgSelectPosition({
player,
code,
positions: [],
});
if ((positions & 0x1) > 0) {
msg.positions.push(ygopro.CardPosition.FACEUP_ATTACK);
} else if ((positions & 0x2) > 0) {
msg.positions.push(ygopro.CardPosition.FACEDOWN_ATTACK);
} else if ((positions & 0x4) > 0) {
msg.positions.push(ygopro.CardPosition.FACEUP_DEFENSE);
} else if ((positions & 0x8) > 0) {
msg.positions.push(ygopro.CardPosition.FACEDOWN_DEFENSE);
}
return msg;
};
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { AppDispatch } from "../../store";
import MsgSelectPosition = ygopro.StocGameMessage.MsgSelectPosition;
export default (selectPosition: MsgSelectPosition, dispatch: AppDispatch) => {
console.log(selectPosition);
};
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