Commit d5270a03 authored by Chunchi Che's avatar Chunchi Che

Merge branch 'feat/shuffle_set_card' into 'main'

Feat/shuffle set card

See merge request mycard/Neos!230
parents 241cac78 1ee5b442
neos-protobuf @ cd10e6a5
Subproject commit b67b483ce9db064611619a2e1a8b8767b100d035
Subproject commit cd10e6a5f76cfda5ada5a39a9a7a526ca9c5e881
This diff is collapsed.
......@@ -64,3 +64,4 @@ export const MSG_ANNOUNCE_CARD = 142;
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;
......@@ -33,6 +33,7 @@ import MsgSelectPositionAdapter from "./selectPosition";
import MsgSelectSum from "./selectSum";
import MsgSelectTributeAdapter from "./selectTribute";
import MsgSelectUnselectCardAdapter from "./selectUnselectCard";
import MsgShuffleSetCard from "./shuffle_set_card";
import MsgSortCard from "./sortCard";
import MsgStartAdapter from "./start";
import MsgTossAdapter from "./toss";
......@@ -238,6 +239,11 @@ export default class GameMsgAdapter implements StocAdapter {
break;
}
case GAME_MSG.MSG_SHUFFLE_SET_CARD: {
gameMsg.shuffle_set_card = MsgShuffleSetCard(gameData);
break;
}
default: {
gameMsg.unimplemented = new ygopro.StocGameMessage.MsgUnimplemented({
command: func,
......
import { ygopro } from "@/api/ocgcore/idl/ocgcore";
import { BufferReaderExt } from "../../bufferIO";
import { numberToCardZone } from "../../util";
import MsgShuffleSetCard = ygopro.StocGameMessage.MsgShuffleSetCard;
/*
* Msg Shuffle Set Card
* @param - TODO
*
* @usage - 盖卡切洗
* */
export default (data: Uint8Array) => {
const reader = new BufferReaderExt(data);
const zone = numberToCardZone(reader.inner.readUint8());
const count = reader.inner.readUint8();
const from_locations = [];
const to_locations = [];
for (let i = 0; i < count; i++) {
from_locations.push(reader.readCardLocation());
}
for (let i = 0; i < count; i++) {
to_locations.push(reader.readCardLocation());
}
return new MsgShuffleSetCard({
zone,
from_locations,
to_locations,
});
};
......@@ -35,6 +35,7 @@ import onMsgSelectUnselectCard from "./selectUnselectCard";
import onMsgSelectYesNo from "./selectYesNo";
import onMsgSet from "./set";
import onMsgShuffleHand from "./shuffleHand";
import onMsgShuffleSetCard from "./shuffleSetCard";
import onMsgSortCard from "./sortCard";
import onMsgSpSummoned from "./spSummoned";
import onMsgSpSummoning from "./spSummoning";
......@@ -309,6 +310,11 @@ async function _handleGameMsg(pb: ygopro.YgoStocMsg) {
break;
}
case "shuffle_set_card": {
await onMsgShuffleSetCard(msg.shuffle_set_card);
break;
}
case "unimplemented": {
onUnimplemented(msg.unimplemented);
......
import { ygopro } from "@/api";
import { eventbus, Task } from "@/infra";
import { cardStore } from "@/stores";
import MsgShuffleSetCard = ygopro.StocGameMessage.MsgShuffleSetCard;
export default async (shuffleSetCard: MsgShuffleSetCard) => {
const from_locations = shuffleSetCard.from_locations;
const to_locations = shuffleSetCard.to_locations;
if (from_locations.length != to_locations.length) {
console.error(
"<ShuffleSetCard>length of from_locations and to_locations not matched"
);
return;
}
const count = from_locations.length;
for (let i = 0; i < count; i++) {
const from = from_locations[i];
const to = to_locations[i];
// TODO: 需要考虑超量么
const target = cardStore.at(from.zone, from.controller, from.sequence);
if (target) {
// 更新位置
target.location = to;
// 渲染动画
await eventbus.call(Task.Move, target.uuid);
} else {
console.warn(`<ShuffleSetCard>target from ${from} is null`);
}
}
};
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