Backend code cleanup

This commit is contained in:
Anthony Wang 2021-05-09 15:42:24 -05:00
parent 013018ecae
commit 203f24bd9c
Signed by: a
GPG key ID: 6FD3502572299774

View file

@ -60,7 +60,7 @@ export default class Game {
const j = Math.floor(Math.random() * (i+1));
[cards[i], cards[j]] = [cards[j], cards[i]];
}
const handSize = 5; // 5 - this.room.clients.length/7;
const handSize = 5 - Math.floor(this.room.clients.length/7);
for (let i = 0; i < this.room.clients.length; ++i) {
this.players.push(new Player(this, this.room.clients[i]));
this.players[i].cards = cards.slice(i * handSize, (i + 1) * handSize);
@ -92,8 +92,8 @@ export default class Game {
}
async round() {
this.phase = 0;
this.players.forEach((p: Player) => { p.stack = []; });
this.players.forEach((p: Player) => { p.flipped = []; });
this.players.forEach((p: Player) => p.stack = []);
this.players.forEach((p: Player) => p.flipped = []);
await this.prepare(); // Phase 0
this.phase = 1;
this.lastPlayed = 0;