Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
deleteCardFromHand replace discardCard in playCard
Browse files Browse the repository at this point in the history
  • Loading branch information
Tikidoodlep1 committed May 7, 2024
1 parent 14d1509 commit 439c673
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/engine/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,15 @@ export class Player {
}
}

deleteCardFromHand(card: Card) {
for (var i = 0; i < this.hand.length; i++) {
if (card.equals(this.hand[i])) {
this.hand.splice(i, 1);
return;
}
}
}

drawCard(amount: number, useAction: boolean) {
for (let i = 0; i < amount; i++) {
if (this.deck.length >= 0) {
Expand Down Expand Up @@ -605,7 +614,7 @@ export class Game extends AbstractGame {
if (card.play(pos, pos.ownerId)) {
Game.getInstance().getPlayerById(playerId).actions -=
card.getCost();
Game.getInstance().getPlayerById(playerId).discardCard(card);
Game.getInstance().getPlayerById(playerId).deleteCardFromHand(card);
return Game.getInstance().dispatchEvent(
new PlayCardEvent(card, pos.ownerId),
);
Expand Down Expand Up @@ -641,6 +650,7 @@ export class Game extends AbstractGame {
return false;
}
}

function randomInt(min: number, max: number) {
return Math.floor((max - min) * Math.random()) + min;
}

0 comments on commit 439c673

Please sign in to comment.