Commit 2106d11a authored by Chunchi Che's avatar Chunchi Che

fix small

parent 870910b1
......@@ -19,7 +19,7 @@ export default async (chainSolved: ygopro.StocGameMessage.MsgChainSolved) => {
if (target) {
target.chainIndex = undefined;
} else {
console.log(`<ChainSolved>target from ${location} is null`);
console.warn(`<ChainSolved>target from ${location} is null`);
}
} else {
console.warn(
......
......@@ -8,21 +8,22 @@ export default async (draw: ygopro.StocGameMessage.MsgDraw) => {
// 将卡从卡组移到手牌:设置zone、occupant、sequence
const handsLength = cardStore.at(ygopro.CardZone.HAND, draw.player).length;
cardStore
const newHands = cardStore
.at(ygopro.CardZone.DECK, draw.player)
.slice(-drawLength)
.forEach(async (card, idx) => {
const code = draw.cards[idx];
const meta = await fetchCard(code);
card.code = code;
card.meta = meta;
card.zone = ygopro.CardZone.HAND;
card.sequence = idx + handsLength;
});
.slice(-drawLength);
for (const idx in newHands) {
const card = newHands[Number(idx)];
const code = draw.cards[idx];
const meta = await fetchCard(code);
card.code = code;
card.meta = meta;
card.zone = ygopro.CardZone.HAND;
card.sequence = Number(idx) + handsLength;
}
// 抽卡动画
cardStore
.at(ygopro.CardZone.HAND, draw.player)
.forEach((card) => eventBus.emit(Report.Move, card.uuid));
// FIXME: `eventBus.emit`的方式能保证动画完成后才进行下一次msg的处理么
// 如果下一次msg来得很快,可能会有动画冲突?
};
......@@ -14,10 +14,20 @@ export default (shuffleHand: MsgShuffleHand) => {
t[code].push(sequence);
});
hands.forEach((hand) => {
const sequence = t[hand.code].shift();
if (sequence === undefined) {
throw new Error("手牌数量和洗牌后的数量不一致");
const target = t[hand.code];
if (target !== undefined) {
const sequence = target.shift();
if (sequence) {
hand.sequence = sequence;
} else {
console.warn(
`<ShuffleHand>sequence shift from target is null, controller=${controller} hands=${hands}, codes=${codes}`
);
}
} else {
console.warn(
`<ShuffleHand>target from records is null, controller=${controller} hands=${hands}, codes=${codes}`
);
}
hand.sequence = sequence;
});
};
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