Commit e08981e6 authored by Chunchi Che's avatar Chunchi Che

add MsgHint

parent ade51646
Pipeline #18342 passed with stages
in 3 minutes
Subproject commit dcf16e3665ad64a5882b6d84996f642952d38fcc
Subproject commit b1387888e6e895e186f5dde1ff986f11305a3b84
This diff is collapsed.
......@@ -2,6 +2,7 @@ const OFFSET_UINT8 = 1;
const OFFSET_INT8 = 1;
const OFFSET_UINT16 = 2;
const OFFSET_UINT32 = 4;
const OFFSET_INT32 = 4;
export class BufferReader {
dataView: DataView;
......@@ -41,4 +42,11 @@ export class BufferReader {
return ret;
}
readInt32(): number {
const ret = this.dataView.getInt32(this.offset, this.littleEndian);
this.offset += OFFSET_INT32;
return ret;
}
}
......@@ -27,3 +27,4 @@ export const MSG_START = 4;
export const MSG_DRAW = 90;
export const MSG_NEW_TURN = 40;
export const MSG_NEW_PHASE = 41;
export const MSG_HINT = 2;
import { ygopro } from "../../../idl/ocgcore";
import { BufferReader } from "../../bufferIO";
const LITTLE_ENDIAN = true;
/*
* Msg Hint
*
* @param hintType: char - 提示的类型
* @param hintPlayer: char - 提示的玩家
* @param hintData: int32 - 提示的数据
*
* @usage - 显示提示信息
* */
export default (data: Uint8Array) => {
const reader = new BufferReader(data, LITTLE_ENDIAN);
const hintCommand = reader.readUint8();
const hintPlayer = reader.readUint8();
const hintData = reader.readInt32();
let hintType = ygopro.StocGameMessage.MsgHint.HintType.UNKNOWN;
switch (hintCommand) {
case 0x01: {
// TODO
break;
}
case 0x02: {
// TODO
break;
}
case 0x03: {
hintType = ygopro.StocGameMessage.MsgHint.HintType.SELECT_LOCATION;
break;
}
case 0x04: {
hintType = ygopro.StocGameMessage.MsgHint.HintType.SELECT_EFFECT;
break;
}
case 0x05: {
// TODO
break;
}
case 0x06: {
hintType = ygopro.StocGameMessage.MsgHint.HintType.SELECT_RACE;
break;
}
case 0x07: {
hintType = ygopro.StocGameMessage.MsgHint.HintType.SELECT_ATTRIBUTE;
break;
}
case 0x08: {
// TODO
break;
}
case 0x09: {
hintType = ygopro.StocGameMessage.MsgHint.HintType.SELECT_NUMBER;
break;
}
case 0x0a: {
// TODO
break;
}
case 0x0b: {
hintType = ygopro.StocGameMessage.MsgHint.HintType.SELECT_REGION;
break;
}
default: {
break;
}
}
return new ygopro.StocGameMessage.MsgHint({
hint_type: hintType,
player: hintPlayer,
hint_data: hintData,
});
};
......@@ -10,6 +10,7 @@ import MsgStartAdapter from "./start";
import MsgDrawAdapter from "./draw";
import MsgNewTurnAdapter from "./newTurn";
import MsgNewPhaseAdapter from "./newPhase";
import MsgHintAdapter from "./hint";
/*
* STOC GameMsg
......@@ -55,6 +56,11 @@ export default class GameMsgAdapter implements StocAdapter {
break;
}
case GAME_MSG.MSG_HINT: {
gameMsg.hint = MsgHintAdapter(gameData);
break;
}
default: {
console.log("Unhandled GameMessage function=", func);
......
......@@ -4,6 +4,7 @@ import onMsgStart from "./start";
import onMsgDraw from "./draw";
import onMsgNewTurn from "./newTurn";
import onMsgNewPhase from "./newPhase";
import onMsgHint from "./hint";
export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
const dispatch = store.dispatch;
......@@ -38,6 +39,13 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break;
}
case "hint": {
const hint = msg.hint;
onMsgHint(hint, dispatch);
break;
}
default: {
console.log("Unhandled GameMsg=" + msg.gameMsg);
......
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { AppDispatch } from "../../store";
export default (
hint: ygopro.StocGameMessage.MsgHint,
dispatch: AppDispatch
) => {
// TODO
console.log(hint);
};
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