Prevent cards that aren't in the unknown from being discarded

This commit is contained in:
Oliver Akins 2022-06-23 11:39:39 -06:00
parent 1aa3e2b8ac
commit 4506b97101
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99

View file

@ -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);
}; };