Commit 8eea7636 authored by Chunchi Che's avatar Chunchi Che

add idle_cmd

parent 6c849a0a
Pipeline #18457 passed with stages
in 3 minutes and 33 seconds
import { ygopro } from "../idl/ocgcore";
const OFFSET_UINT8 = 1;
const OFFSET_INT8 = 1;
const OFFSET_UINT16 = 2;
......@@ -49,4 +51,15 @@ export class BufferReader {
return ret;
}
readCardInfo(): ygopro.StocGameMessage.CardInfo {
const cardInfo = new ygopro.StocGameMessage.CardInfo({});
cardInfo.code = this.readUint32();
cardInfo.controler = this.readUint8();
cardInfo.location = this.readUint8();
cardInfo.sequence = this.readUint8();
return cardInfo;
}
}
......@@ -28,3 +28,4 @@ export const MSG_DRAW = 90;
export const MSG_NEW_TURN = 40;
export const MSG_NEW_PHASE = 41;
export const MSG_HINT = 2;
export const MSG_SELECT_IDLE_CMD = 11;
......@@ -11,6 +11,7 @@ import MsgDrawAdapter from "./draw";
import MsgNewTurnAdapter from "./newTurn";
import MsgNewPhaseAdapter from "./newPhase";
import MsgHintAdapter from "./hint";
import MsgSelectIdleCmdAdapter from "./selectIdleCmd";
/*
* STOC GameMsg
......@@ -61,6 +62,11 @@ export default class GameMsgAdapter implements StocAdapter {
break;
}
case GAME_MSG.MSG_SELECT_IDLE_CMD: {
gameMsg.select_idle_cmd = MsgSelectIdleCmdAdapter(gameData);
break;
}
default: {
console.log("Unhandled GameMessage function=", func);
......
import { ygopro } from "../../../idl/ocgcore";
import { BufferReader } from "../../bufferIO";
import MsgSelectIdleCmd = ygopro.StocGameMessage.MsgSelectIdleCmd;
const LITTLE_ENDIAN = true;
/*
* Msg Select Idle Command
*
* @param - see: https://code.mycard.moe/mycard/neos-protobuf/-/blob/main/idl/ocgcore.proto#L258
*
* @usage - 玩家可选择的操作
* */
export default (data: Uint8Array) => {
const reader = new BufferReader(data, LITTLE_ENDIAN);
const msg = new MsgSelectIdleCmd({});
msg.player = reader.readUint8();
// summon
const summonCmd = new MsgSelectIdleCmd.IdleCmd({
idle_type: MsgSelectIdleCmd.IdleCmd.IdleType.SUMMON,
idle_datas: [],
});
const summonCount = reader.readUint8();
for (let i = 0; i < summonCount; i++) {
const idleData = new MsgSelectIdleCmd.IdleCmd.IdleData({
card_info: reader.readCardInfo(),
});
summonCmd.idle_datas.push(idleData);
}
// spsummon
const spSummonCmd = new MsgSelectIdleCmd.IdleCmd({
idle_type: MsgSelectIdleCmd.IdleCmd.IdleType.SPSUMMON,
idle_datas: [],
});
const spSummonCount = reader.readUint8();
for (let i = 0; i < spSummonCount; i++) {
const idleData = new MsgSelectIdleCmd.IdleCmd.IdleData({
card_info: reader.readCardInfo(),
});
spSummonCmd.idle_datas.push(idleData);
}
// pos change
const posChangeCmd = new MsgSelectIdleCmd.IdleCmd({
idle_type: MsgSelectIdleCmd.IdleCmd.IdleType.POS_CHANGE,
idle_datas: [],
});
const posChangeCount = reader.readUint8();
for (let i = 0; i < posChangeCount; i++) {
const idleData = new MsgSelectIdleCmd.IdleCmd.IdleData({
card_info: reader.readCardInfo(),
});
posChangeCmd.idle_datas.push(idleData);
}
// mset
const mSetCmd = new MsgSelectIdleCmd.IdleCmd({
idle_type: MsgSelectIdleCmd.IdleCmd.IdleType.MSET,
idle_datas: [],
});
const mSetCount = reader.readUint8();
for (let i = 0; i < mSetCount; i++) {
const idleData = new MsgSelectIdleCmd.IdleCmd.IdleData({
card_info: reader.readCardInfo(),
});
mSetCmd.idle_datas.push(idleData);
}
// sset
const sSetCmd = new MsgSelectIdleCmd.IdleCmd({
idle_type: MsgSelectIdleCmd.IdleCmd.IdleType.SSET,
idle_datas: [],
});
const sSetCount = reader.readUint8();
for (let i = 0; i < sSetCount; i++) {
const idleData = new MsgSelectIdleCmd.IdleCmd.IdleData({
card_info: reader.readCardInfo(),
});
sSetCmd.idle_datas.push(idleData);
}
// activate
const activateCmd = new MsgSelectIdleCmd.IdleCmd({
idle_type: MsgSelectIdleCmd.IdleCmd.IdleType.ACTIVATE,
idle_datas: [],
});
const activateCount = reader.readUint8();
for (let i = 0; i < activateCount; i++) {
const idleData = new MsgSelectIdleCmd.IdleCmd.IdleData({
card_info: reader.readCardInfo(),
effect_description: reader.readUint32(),
});
activateCmd.idle_datas.push(idleData);
}
msg.idle_cmds = [
summonCmd,
spSummonCmd,
posChangeCmd,
mSetCmd,
sSetCmd,
activateCmd,
];
msg.enable_bp = reader.readUint8() === 1;
msg.enable_ep = reader.readUint8() === 1;
msg.enable_shuffle = reader.readUint8() === 1;
return msg;
};
......@@ -5,6 +5,7 @@ import onMsgDraw from "./draw";
import onMsgNewTurn from "./newTurn";
import onMsgNewPhase from "./newPhase";
import onMsgHint from "./hint";
import onMsgSelectIdleCmd from "./selectIdleCmd";
export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
const dispatch = store.dispatch;
......@@ -46,6 +47,13 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break;
}
case "select_idle_cmd": {
const selectIdleCmd = msg.select_idle_cmd;
onMsgSelectIdleCmd(selectIdleCmd, dispatch);
break;
}
default: {
break;
}
......
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { AppDispatch } from "../../store";
export default (
selectIdleCmd: ygopro.StocGameMessage.MsgSelectIdleCmd,
dispatch: AppDispatch
) => {
// TODO
console.log(selectIdleCmd);
};
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