export class Stack { constructor() { this.cards = []; } allows(card) { return card.color === 'BLACK' || this.cards.length === 0 || this.cards[this.cards.length - 1].allows(card); } add(card) { this.cards.push(card); if (this.cards.length > 5) { this.cards.splice(0, 1); } return true; } setTopColor(color) { this.cards[this.cards.length - 1].actualColor = color; } draw(renderer) { if (this.cards.length === 0) { return; } for (let i = 0; i < 5 && i < this.cards.length; i++) { this.cards[i].draw(renderer, -i * 6, -i * 6); } } }