ChessNut/engine/core/hand.js
2025-10-15 09:23:03 +02:00

29 lines
No EOL
546 B
JavaScript

import Card from './card.js';
class Hand {
constructor() {
/** @type {Array(Card)} */
this.cards = [];
}
/**
* @param {Card} card
*/
pushCard(card) {
this.cards.push(card);
}
/**
* @param {number} index
* @returns {Card|null}
*/
popCard(index) {
if (index < 0 || index >= this.cards.length) {
return null;
} else {
let c = this.cards.at(index);
this.cards.splice(index, 1);
return c;
}
}
}