Commit 429fe1e0 authored by Chunchi Che's avatar Chunchi Che

register animation in shuffleHand.ts

parent e06ef308
...@@ -144,7 +144,7 @@ async function _handleGameMsg(pb: ygopro.YgoStocMsg) { ...@@ -144,7 +144,7 @@ async function _handleGameMsg(pb: ygopro.YgoStocMsg) {
break; break;
} }
case "shuffle_hand": { case "shuffle_hand": {
onMsgShuffleHand(msg.shuffle_hand); await onMsgShuffleHand(msg.shuffle_hand);
break; break;
} }
......
import { ygopro } from "@/api"; import { ygopro } from "@/api";
import { eventbus, Task } from "@/infra";
import { cardStore } from "@/stores"; import { cardStore } from "@/stores";
type MsgShuffleHand = ygopro.StocGameMessage.MsgShuffleHand; type MsgShuffleHand = ygopro.StocGameMessage.MsgShuffleHand;
export default (shuffleHand: MsgShuffleHand) => { export default async (shuffleHand: MsgShuffleHand) => {
const { hands: codes, player: controller } = shuffleHand; const { hands: codes, player: controller } = shuffleHand;
// 本质上是要将手卡的sequence变成和codes一样的顺序 // 本质上是要将手卡的sequence变成和codes一样的顺序
...@@ -13,13 +14,16 @@ export default (shuffleHand: MsgShuffleHand) => { ...@@ -13,13 +14,16 @@ export default (shuffleHand: MsgShuffleHand) => {
hash.get(code)?.push(sequence); hash.get(code)?.push(sequence);
}); });
hands.forEach((hand) => { for (const hand of hands) {
const sequences = hash.get(hand.code); const sequences = hash.get(hand.code);
if (sequences !== undefined) { if (sequences !== undefined) {
const sequence = sequences.pop(); const sequence = sequences.pop();
if (sequence !== undefined) { if (sequence !== undefined) {
hand.location.sequence = sequence; hand.location.sequence = sequence;
hash.set(hand.code, sequences); hash.set(hand.code, sequences);
// 触发动画
await eventbus.call(Task.Move, hand.uuid);
} else { } else {
console.warn( console.warn(
`<ShuffleHand>sequence poped is none, controller=${controller}, code=${hand.code}, sequence=${sequence}` `<ShuffleHand>sequence poped is none, controller=${controller}, code=${hand.code}, sequence=${sequence}`
...@@ -32,5 +36,5 @@ export default (shuffleHand: MsgShuffleHand) => { ...@@ -32,5 +36,5 @@ export default (shuffleHand: MsgShuffleHand) => {
)}, codes=${codes}` )}, codes=${codes}`
); );
} }
}); }
}; };
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