Commit 1ee5b442 authored by chechunchi's avatar chechunchi

update shuffleSetCard.ts

parent f8597fc0
Pipeline #22308 passed with stages
in 13 minutes and 54 seconds
......@@ -311,7 +311,7 @@ async function _handleGameMsg(pb: ygopro.YgoStocMsg) {
break;
}
case "shuffle_set_card": {
onMsgShuffleSetCard(msg.shuffle_set_card);
await onMsgShuffleSetCard(msg.shuffle_set_card);
break;
}
......
import { ygopro } from "@/api";
import { eventbus, Task } from "@/infra";
import { cardStore } from "@/stores";
import MsgShuffleSetCard = ygopro.StocGameMessage.MsgShuffleSetCard;
export default (shuffleSetCard: MsgShuffleSetCard) => {
console.log(shuffleSetCard);
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