Commit 723f6bfa authored by Chunchi Che's avatar Chunchi Che

add stoc adapter

parent a8834c1d
......@@ -42,3 +42,5 @@ export const MSG_SELECT_POSITION = 19;
export const MSG_SELECT_OPTION = 14;
export const MSG_SELECT_BATTLE_CMD = 10;
export const MSG_SELECT_UNSELECT_CARD = 26;
export const MSG_DAMAGE = 91;
export const MSG_RECOVER = 92;
import { ygopro } from "../../../idl/ocgcore";
import { BufferReader } from "../../bufferIO";
/*
* Msg Damage
*
* @param player - 玩家编号
* @param value - 减少的Hp数值
* */
export default (data: Uint8Array) => {
const reader = new BufferReader(data, true);
const player = reader.readUint8();
const value = reader.readInt32();
return new ygopro.StocGameMessage.MsgUpdateHp({
player,
type_: ygopro.StocGameMessage.MsgUpdateHp.ActionType.DAMAGE,
value,
});
};
......@@ -20,6 +20,8 @@ import MsgSelectPositionAdapter from "./selectPosition";
import MsgSelectOptionAdapter from "./selectOption";
import MsgSelectBattleCmdAdapter from "./selectBattleCmd";
import MsgSelectUnselectCardAdapter from "./selectUnselectCard";
import MsgDamage from "./damage";
import MsgRecover from "./recover";
import PENETRATE from "./penetrate";
/*
......@@ -117,6 +119,16 @@ export default class GameMsgAdapter implements StocAdapter {
break;
}
case GAME_MSG.MSG_DAMAGE: {
gameMsg.update_up = MsgDamage(gameData);
break;
}
case GAME_MSG.MSG_RECOVER: {
gameMsg.update_up = MsgRecover(gameData);
break;
}
default: {
console.log("Unhandled GameMessage function=", func);
......
import { ygopro } from "../../../idl/ocgcore";
import { BufferReader } from "../../bufferIO";
/*
* Msg Recover
*
* @param player - 玩家编号
* @param value - 回复的Hp数值
* */
export default (data: Uint8Array) => {
const reader = new BufferReader(data, true);
const player = reader.readUint8();
const value = reader.readInt32();
return new ygopro.StocGameMessage.MsgUpdateHp({
player,
type_: ygopro.StocGameMessage.MsgUpdateHp.ActionType.RECOVER,
value,
});
};
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