aboutsummaryrefslogtreecommitdiff
path: root/back/src/Game.ts
diff options
context:
space:
mode:
authorAnthony Wang2021-05-07 13:21:19 -0500
committerAnthony Wang2021-05-07 13:21:19 -0500
commit87f9951aad3fe0b3d4378bdd5b45d192e527fd71 (patch)
tree8cf2b5c4f917e0a969cfa647e92ea7898ad27f60 /back/src/Game.ts
parent59f816569719416108e900939cccadb0ab2d413e (diff)
Ready for alpha releasev0.1-alpha
Diffstat (limited to 'back/src/Game.ts')
-rw-r--r--back/src/Game.ts15
1 files changed, 5 insertions, 10 deletions
diff --git a/back/src/Game.ts b/back/src/Game.ts
index 15155fd..6dbe502 100644
--- a/back/src/Game.ts
+++ b/back/src/Game.ts
@@ -19,13 +19,10 @@ class Player {
}
sendGameState() {
const i = this.game.players.indexOf(this);
- const otherPlayers = [];
- for (let j = 1; j < this.game.players.length; ++j)
- otherPlayers.push(this.game.players[(i + j) % this.game.players.length]);
this.client.socket.emit('gameState', {
cards: this.cards,
rank: this.rank,
- players: otherPlayers.map((p: Player) => ({
+ players: this.game.players.map((p: Player) => ({
username: p.client.username,
numCards: p.cards.length,
stackSize: p.stack.length,
@@ -129,8 +126,7 @@ export default class Game {
delete p.disconnectListener;
(() => {
p.stack = stack;
- p.client.socket.disconnect();
- logSocket(p.client.socket, 'Bad cards argument on turn');
+ return;
})();
resolve();
});
@@ -180,7 +176,7 @@ export default class Game {
if (this.players[selectedPlayer].stack.length > 0) {
if (this.players[selectedPlayer].stack[0].suit === Suit.Diamonds ||
this.players[selectedPlayer].stack[0].suit === Suit.Hearts) this.phase = 3; // Red card
- this.players[selectedPlayer].stack.splice(0);
+ this.players[selectedPlayer].stack.splice(0, 1);
return;
}
p.client.socket.disconnect();
@@ -202,9 +198,8 @@ export default class Game {
p.client.once('giveup', card => {
delete p.disconnectListener;
(() => {
- p.cards.splice(card); // Remove card, may want to check if it is valid
- p.client.socket.disconnect();
- logSocket(p.client.socket, 'Bad cards argument on turn');
+ p.cards.splice(card, 1);
+ return;
})();
resolve();
});