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

fix shuffle hand

parent fffc0d7c
......@@ -63,6 +63,7 @@ export default async (move: MsgMove) => {
console.warn(
`<Move>card from zone=${fromZone}, controller=${from.controler} sequence=${from.sequence} is null`
);
console.info(cardStore.at(fromZone, from.controler));
return;
}
}
......
......@@ -8,17 +8,14 @@ export default (shuffleHand: MsgShuffleHand) => {
// 本质上是要将手卡的sequence变成和codes一样的顺序
const hands = cardStore.at(ygopro.CardZone.HAND, controller);
const hash: Map<number, number> = new Map();
for (const idx in codes) {
const sequence = Number(idx);
const code = codes[sequence];
hash.set(code, (hash.get(code) || 0) + 1);
}
const hash = [...codes].reduce(
(hash, code, sequence) => hash.set(code, sequence),
new Map()
);
hands.forEach((hand) => {
const sequence = hash.get(hand.code);
if (sequence) {
if (sequence !== undefined) {
if (sequence >= 0) {
hand.sequence = sequence;
hash.set(hand.code, sequence - 1);
......
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