Commit 4d4fe7b0 authored by Chunchi Che's avatar Chunchi Che

hand reload field

parent b303d331
......@@ -50,3 +50,4 @@ export const MSG_PAY_LP_COST = 100;
export const MSG_WIN = 5;
export const MSG_WAITING = 3;
export const MSG_UPDATE_DATA = 6;
export const MSG_RELOAD_FIELD = 162;
......@@ -26,6 +26,7 @@ import MsgDamage from "./damage";
import MsgRecover from "./recover";
import MsgWin from "./win";
import MsgUpdateDataAdapter from "./updateData";
import MsgReloadFieldAdapter from "./reloadField";
import PENETRATE from "./penetrate";
/*
......@@ -154,6 +155,11 @@ export default class GameMsgAdapter implements StocAdapter {
break;
}
case GAME_MSG.MSG_RELOAD_FIELD: {
gameMsg.reload_field = MsgReloadFieldAdapter(gameData);
break;
}
default: {
gameMsg.unimplemented = new ygopro.StocGameMessage.MsgUnimplemented({
command: func,
......
import { ygopro } from "../../../idl/ocgcore";
// @ts-ignore
import { BufferReaderExt } from "../../bufferIO";
import MsgReloadField = ygopro.StocGameMessage.MsgReloadField;
import { numberToCardPosition } from "../../util";
export default (data: Uint8Array) => {
const reader = new BufferReaderExt(data);
const duel_rule = reader.inner.readUint8();
const actions = [];
for (let player = 0; player < 2; player += 1) {
const lp = reader.inner.readUint32();
const zone_actions = [];
// MZONE
for (let sequence = 0; sequence < 7; sequence += 1) {
const flag = reader.inner.readUint8();
if (flag) {
const position = reader.inner.readUint8();
const overlay_count = reader.inner.readUint8();
zone_actions.push(
new MsgReloadField.ZoneAction({
zone: ygopro.CardZone.MZONE,
sequence,
position: numberToCardPosition(position),
overlay_count,
})
);
}
}
// SZONE
for (let sequence = 0; sequence < 6; sequence += 1) {
const flag = reader.inner.readUint8();
if (flag) {
const position = reader.inner.readUint8();
zone_actions.push(
new MsgReloadField.ZoneAction({
zone: ygopro.CardZone.SZONE,
sequence,
position: numberToCardPosition(position),
})
);
}
}
const main_size = reader.inner.readUint8();
const hand_size = reader.inner.readUint8();
const grace_size = reader.inner.readUint8();
const removed_size = reader.inner.readUint8();
const extra_size = reader.inner.readUint8();
const extra_p_size = reader.inner.readUint8();
const chain_size = reader.inner.readUint8();
const chain_actions = [];
for (let i = 0; i < chain_size; i += 1) {
const chain_code = reader.inner.readUint32();
const location = reader.readCardLocation();
const triggering_controller = reader.inner.readUint8();
const triggering_location = reader.inner.readUint8();
const triggering_sequence = reader.inner.readUint8();
const effect_description = reader.inner.readUint32();
chain_actions.push(
new MsgReloadField.ChainAction({
chain_code,
location,
triggering_controller,
triggering_location,
triggering_sequence,
effect_description,
})
);
}
actions.push(
new MsgReloadField.Action({
player,
lp,
zone_actions,
main_size,
hand_size,
grace_size,
removed_size,
extra_size,
extra_p_size,
chain_size,
chain_actions,
})
);
}
return new MsgReloadField({
duel_rule,
actions,
});
};
......@@ -23,6 +23,7 @@ import onMsgWin from "./win";
import onMsgWait from "./wait";
import onUnimplemented from "./unimplemented";
import onMsgUpdateData from "./updateData";
import onMsgReloadField from "./reloadField";
import { setWaiting } from "../../reducers/duel/mod";
const ActiveList = [
......@@ -157,6 +158,11 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break;
}
case "reload_field": {
onMsgReloadField(msg.reload_field, dispatch);
break;
}
case "unimplemented": {
onUnimplemented(msg.unimplemented, dispatch);
......
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { AppDispatch } from "../../store";
import MsgReloadField = ygopro.StocGameMessage.MsgReloadField;
export default (reloadField: MsgReloadField, dispatch: AppDispatch) => {
console.log(reloadField);
};
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