Prevent cards that aren't in the unknown from being discarded
This commit is contained in:
parent
1aa3e2b8ac
commit
4506b97101
1 changed files with 3 additions and 0 deletions
|
|
@ -53,6 +53,9 @@ export class Deck<T> {
|
||||||
* @param card The card to add to the discard pile
|
* @param card The card to add to the discard pile
|
||||||
*/
|
*/
|
||||||
public discard(card: T) {
|
public discard(card: T) {
|
||||||
|
if (!this._unknown.includes(card)) {
|
||||||
|
throw new Error("Cannot discard a card that doesn't exist in the deck");
|
||||||
|
};
|
||||||
this._unknown = this._unknown.filter(x => x != card);
|
this._unknown = this._unknown.filter(x => x != card);
|
||||||
this._discard.push(card);
|
this._discard.push(card);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue