Commit 49652094 authored by Chunchi Che's avatar Chunchi Che

handle MSG_ADD_COUNTER and MSG_REMOVE_COUNTER

parent a815c8b9
Pipeline #20929 passed with stages
in 18 minutes and 4 seconds
......@@ -52,3 +52,5 @@ export const MSG_WAITING = 3;
export const MSG_UPDATE_DATA = 6;
export const MSG_RELOAD_FIELD = 162;
export const MSG_SELECT_SUM = 23;
export const MSG_ADD_COUNTER = 101;
export const MSG_REMOVE_COUNTER = 102;
import { ygopro } from "../../../idl/ocgcore";
import { BufferReaderExt } from "../../bufferIO";
import MsgUpdateCounter = ygopro.StocGameMessage.MsgUpdateCounter;
/*
* Msg Add Counter
* @param - TODO
*
* @usage - TODO
* */
export default (data: Uint8Array) => {
const reader = new BufferReaderExt(data);
const counterType = reader.inner.readUint16();
const location = reader.readCardShortLocation();
const count = reader.inner.readUint16();
return new MsgUpdateCounter({
counter_type: counterType,
location,
action_type: MsgUpdateCounter.ActionType.ADD,
count,
});
};
......@@ -28,6 +28,8 @@ import MsgWin from "./win";
import MsgUpdateDataAdapter from "./updateData";
import MsgReloadFieldAdapter from "./reloadField";
import MsgSelectSum from "./selectSum";
import MsgAddCounter from "./addCounter";
import MsgRemoveCounter from "./removeCounter";
import PENETRATE from "./penetrate";
/*
......@@ -166,6 +168,16 @@ export default class GameMsgAdapter implements StocAdapter {
break;
}
case GAME_MSG.MSG_ADD_COUNTER: {
gameMsg.update_counter = MsgAddCounter(gameData);
break;
}
case GAME_MSG.MSG_REMOVE_COUNTER: {
gameMsg.update_counter = MsgRemoveCounter(gameData);
break;
}
default: {
gameMsg.unimplemented = new ygopro.StocGameMessage.MsgUnimplemented({
command: func,
......
import { ygopro } from "../../../idl/ocgcore";
import { BufferReaderExt } from "../../bufferIO";
import MsgUpdateCounter = ygopro.StocGameMessage.MsgUpdateCounter;
/*
* Msg Remove Counter
* @param - TODO
*
* @usage - TODO
* */
export default (data: Uint8Array) => {
const reader = new BufferReaderExt(data);
const counterType = reader.inner.readUint16();
const location = reader.readCardShortLocation();
const count = reader.inner.readUint16();
return new MsgUpdateCounter({
counter_type: counterType,
location,
action_type: MsgUpdateCounter.ActionType.REMOVE,
count,
});
};
......@@ -26,6 +26,7 @@ import onMsgUpdateData from "./updateData";
import onMsgReloadField from "./reloadField";
import onMsgSelectSum from "./selectSum";
import onMsgSelectTribute from "./selectTribute";
import onMsgUpdateCounter from "./updateCounter";
import { setWaiting } from "../../reducers/duel/mod";
const ActiveList = [
......@@ -175,6 +176,11 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break;
}
case "update_counter": {
onMsgUpdateCounter(msg.update_counter, dispatch);
break;
}
case "unimplemented": {
onUnimplemented(msg.unimplemented, dispatch);
......
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { AppDispatch } from "../../store";
import MsgUpdateCounter = ygopro.StocGameMessage.MsgUpdateCounter;
export default (updateCounter: MsgUpdateCounter, dispatch: AppDispatch) => {
console.log(updateCounter);
};
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