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; ...@@ -52,3 +52,5 @@ export const MSG_WAITING = 3;
export const MSG_UPDATE_DATA = 6; export const MSG_UPDATE_DATA = 6;
export const MSG_RELOAD_FIELD = 162; export const MSG_RELOAD_FIELD = 162;
export const MSG_SELECT_SUM = 23; 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"; ...@@ -28,6 +28,8 @@ import MsgWin from "./win";
import MsgUpdateDataAdapter from "./updateData"; import MsgUpdateDataAdapter from "./updateData";
import MsgReloadFieldAdapter from "./reloadField"; import MsgReloadFieldAdapter from "./reloadField";
import MsgSelectSum from "./selectSum"; import MsgSelectSum from "./selectSum";
import MsgAddCounter from "./addCounter";
import MsgRemoveCounter from "./removeCounter";
import PENETRATE from "./penetrate"; import PENETRATE from "./penetrate";
/* /*
...@@ -166,6 +168,16 @@ export default class GameMsgAdapter implements StocAdapter { ...@@ -166,6 +168,16 @@ export default class GameMsgAdapter implements StocAdapter {
break; 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: { default: {
gameMsg.unimplemented = new ygopro.StocGameMessage.MsgUnimplemented({ gameMsg.unimplemented = new ygopro.StocGameMessage.MsgUnimplemented({
command: func, 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"; ...@@ -26,6 +26,7 @@ import onMsgUpdateData from "./updateData";
import onMsgReloadField from "./reloadField"; import onMsgReloadField from "./reloadField";
import onMsgSelectSum from "./selectSum"; import onMsgSelectSum from "./selectSum";
import onMsgSelectTribute from "./selectTribute"; import onMsgSelectTribute from "./selectTribute";
import onMsgUpdateCounter from "./updateCounter";
import { setWaiting } from "../../reducers/duel/mod"; import { setWaiting } from "../../reducers/duel/mod";
const ActiveList = [ const ActiveList = [
...@@ -175,6 +176,11 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) { ...@@ -175,6 +176,11 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break; break;
} }
case "update_counter": {
onMsgUpdateCounter(msg.update_counter, dispatch);
break;
}
case "unimplemented": { case "unimplemented": {
onUnimplemented(msg.unimplemented, dispatch); 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