Fix : end turn and draw cards
This commit is contained in:
@@ -35,6 +35,8 @@ export class GameService {
|
||||
player.discard,
|
||||
game,
|
||||
);
|
||||
|
||||
await this.drawToHand(5, player, game);
|
||||
}
|
||||
|
||||
const index = game.teams.indexOf(currentTurn);
|
||||
@@ -87,7 +89,7 @@ export class GameService {
|
||||
discard: Container,
|
||||
game: Document<Game> & Game,
|
||||
) {
|
||||
if (amount >= from.cards.length) {
|
||||
if (amount <= from.cards.length) {
|
||||
await this.distributeCards(from.cards.slice(0, amount), from, to, game);
|
||||
await game.save();
|
||||
return;
|
||||
@@ -126,17 +128,18 @@ export class GameService {
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
}
|
||||
for (const c of cards) {
|
||||
const shallow = [...cards];
|
||||
for (const c of shallow) {
|
||||
const index = from.cards.indexOf(c);
|
||||
from.cards.splice(index, 1);
|
||||
to.cards.push(c);
|
||||
}
|
||||
await game.save();
|
||||
this.eventEmitter.emit('sse.game.' + game._id.toHexString(), {
|
||||
type: 'distributeCards',
|
||||
from: from._id.toHexString(),
|
||||
to: to._id.toHexString(),
|
||||
cards: cards,
|
||||
cards: shallow,
|
||||
});
|
||||
await game.save();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user