Commit b705673e authored by chechunchi's avatar chechunchi

add field disabled adapter and srevice

parent 59ea8e52
Pipeline #22330 passed with stages
in 12 minutes and 57 seconds
......@@ -65,3 +65,4 @@ export const MSG_ANNOUNCE_NUMBER = 143;
export const MSG_TOSS_COIN = 130;
export const MSG_TOSS_DICE = 131;
export const MSG_SHUFFLE_SET_CARD = 36;
export const MSG_FIELD_DISABLED = 56;
import { ygopro } from "@/api/ocgcore/idl/ocgcore";
import { BufferReader } from "../../../../../../rust-src/pkg/rust_src";
import MsgFieldDisabled = ygopro.StocGameMessage.MsgFieldDisabled;
import CardZone = ygopro.CardZone;
/*
* Msg Field Disabled
* @param - TODO
*
* @usage - 区域禁用
* */
export default (data: Uint8Array) => {
const reader = new BufferReader(data);
const flag = reader.readInt32();
const actions = [];
let filter = 0x1;
for (let i = 0; i < 5; i++, filter <<= 1) {
const disabled = (flag & filter) > 0;
actions.push(
new MsgFieldDisabled.Action({
controller: 0,
zone: CardZone.MZONE,
sequence: i,
disabled,
})
);
}
filter = 0x100;
for (let i = 0; i < 8; i++, filter <<= 1) {
const disabled = (flag & filter) > 0;
actions.push(
new MsgFieldDisabled.Action({
controller: 0,
zone: CardZone.SZONE,
sequence: i,
disabled,
})
);
}
filter = 0x10000;
for (let i = 0; i < 5; i++, filter <<= 1) {
const disabled = (flag & filter) > 0;
actions.push(
new MsgFieldDisabled.Action({
controller: 1,
zone: CardZone.MZONE,
sequence: i,
disabled,
})
);
}
filter = 0x1000000;
for (let i = 0; i < 8; i++, filter <<= 1) {
const disabled = (flag & filter) > 0;
actions.push(
new MsgFieldDisabled.Action({
controller: 1,
zone: CardZone.SZONE,
sequence: i,
disabled,
})
);
}
return new MsgFieldDisabled({
actions,
});
};
......@@ -14,6 +14,7 @@ import MsgAnnounceRace from "./announceRace";
import MsgAttack from "./attack";
import MsgDamage from "./damage";
import MsgDrawAdapter from "./draw";
import MsgFieldDisabledAdapter from "./fieldDisabled";
import MsgHintAdapter from "./hint";
import MsgNewPhaseAdapter from "./newPhase";
import MsgNewTurnAdapter from "./newTurn";
......@@ -244,6 +245,11 @@ export default class GameMsgAdapter implements StocAdapter {
break;
}
case GAME_MSG.MSG_FIELD_DISABLED: {
gameMsg.field_disabled = MsgFieldDisabledAdapter(gameData);
break;
}
default: {
gameMsg.unimplemented = new ygopro.StocGameMessage.MsgUnimplemented({
command: func,
......
import { ygopro } from "@/api";
import MsgFieldDisabled = ygopro.StocGameMessage.MsgFieldDisabled;
export default (fieldDisabled: MsgFieldDisabled) => {
console.log(fieldDisabled);
};
......@@ -11,6 +11,7 @@ import onMsgChaining from "./chaining";
import onMsgChainSolved from "./chainSolved";
import onConfirmCards from "./confirmCards";
import onMsgDraw from "./draw";
import onMsgFieldDisabled from "./fieldDisabled";
import onMsgFilpSummoned from "./flipSummoned";
import onMsgFlipSummoning from "./flipSummoning";
import onMsgHint from "./hint";
......@@ -315,6 +316,11 @@ async function _handleGameMsg(pb: ygopro.YgoStocMsg) {
break;
}
case "field_disabled": {
onMsgFieldDisabled(msg.field_disabled);
break;
}
case "unimplemented": {
onUnimplemented(msg.unimplemented);
......
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