the-game-domain
Version:
Complete domain layer for 'The Game' card game with rich business entities, automatic persistence, action tracking, and advanced game mechanics. Features Game, Player, Card, Deck, Pile entities with repository pattern, turn management, victory/defeat dete
41 lines • 999 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Card = void 0;
class Card {
constructor(_value, _id) {
this._value = _value;
this._id = _id;
this._validateValue(_value);
}
get value() {
return this._value;
}
get id() {
return this._id;
}
_validateValue(value) {
if (!Number.isInteger(value)) {
throw new Error('Card value must be an integer');
}
if (value < 1 || value > 100) {
throw new Error('Card value must be between 1 and 100');
}
}
equals(other) {
return this._value === other._value;
}
toString() {
return `Card(${this._value})`;
}
toJSON() {
return {
value: this._value,
...(this._id && { id: this._id })
};
}
static fromJSON(data) {
return new Card(data.value, data.id);
}
}
exports.Card = Card;
//# sourceMappingURL=Card.js.map