Commit c183ae29 authored by Chunchi Che's avatar Chunchi Che

add select sum adapter

parent 82f06f20
Pipeline #20887 failed with stages
in 15 minutes and 30 seconds
......@@ -49,4 +49,16 @@ export class BufferReaderExt {
});
}
}
readCardShortLocation(): ygopro.CardLocation {
const controler = this.inner.readUint8();
const location = this.inner.readUint8();
const sequence = this.inner.readUint8();
return new ygopro.CardLocation({
controler,
location: numberToCardZone(location),
sequence,
});
}
}
......@@ -51,3 +51,4 @@ export const MSG_WIN = 5;
export const MSG_WAITING = 3;
export const MSG_UPDATE_DATA = 6;
export const MSG_RELOAD_FIELD = 162;
export const MSG_SELECT_SUM = 23;
......@@ -27,6 +27,7 @@ import MsgRecover from "./recover";
import MsgWin from "./win";
import MsgUpdateDataAdapter from "./updateData";
import MsgReloadFieldAdapter from "./reloadField";
import MsgSelectSum from "./selectSum";
import PENETRATE from "./penetrate";
/*
......@@ -160,6 +161,11 @@ export default class GameMsgAdapter implements StocAdapter {
break;
}
case GAME_MSG.MSG_SELECT_SUM: {
gameMsg.select_sum = MsgSelectSum(gameData);
break;
}
default: {
gameMsg.unimplemented = new ygopro.StocGameMessage.MsgUnimplemented({
command: func,
......
import { ygopro } from "../../../idl/ocgcore";
import { BufferReaderExt } from "../../bufferIO";
import MsgSelectSum = ygopro.StocGameMessage.MsgSelectSum;
/*
* Msg Select Sum
*
* @param -
*
* @usage -
* */
export default (data: Uint8Array) => {
const reader = new BufferReaderExt(data);
const overflow = reader.inner.readUint8();
const player = reader.inner.readUint8();
const level = reader.inner.readInt32();
const min = reader.inner.readUint8();
const max = reader.inner.readUint8();
const msg = new MsgSelectSum({
overflow,
player,
level_sum: level,
min,
max,
must_select_cards: [],
selectable_cards: [],
});
const mustCount = reader.inner.readUint8();
for (let i = 0; i < mustCount; i++) {
const code = reader.inner.readInt32();
const location = reader.readCardShortLocation();
const para = reader.inner.readInt32();
msg.must_select_cards.push(
new MsgSelectSum.Info({
code,
location,
level1: para & 0xffff,
level2: para >> 16,
response: i,
})
);
}
const selectAbleCount = reader.inner.readUint8();
for (let i = 0; i < selectAbleCount; i++) {
const code = reader.inner.readInt32();
const location = reader.readCardShortLocation();
const para = reader.inner.readInt32();
msg.selectable_cards.push(
new MsgSelectSum.Info({
code,
location,
level1: para & 0xffff,
level2: para >> 16,
response: i,
})
);
}
return msg;
};
......@@ -24,6 +24,7 @@ import onMsgWait from "./wait";
import onUnimplemented from "./unimplemented";
import onMsgUpdateData from "./updateData";
import onMsgReloadField from "./reloadField";
import onMsgSelectSum from "./selectSum";
import { setWaiting } from "../../reducers/duel/mod";
const ActiveList = [
......@@ -163,6 +164,11 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break;
}
case "select_sum": {
onMsgSelectSum(msg.select_sum, dispatch);
break;
}
case "unimplemented": {
onUnimplemented(msg.unimplemented, dispatch);
......
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { AppDispatch } from "../../store";
import MsgSelectSum = ygopro.StocGameMessage.MsgSelectSum;
export default (selectSum: MsgSelectSum, dispatch: AppDispatch) => {
console.log(selectSum);
};
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