cardation
Version:
fundation of card games, card model
52 lines (51 loc) • 1.39 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const CardError_1 = require("../../error/CardError");
const SuitCard_1 = require("./SuitCard");
const Rank_1 = require("../rank/Rank");
const utils_1 = require("../serialization/utils");
class AceCard extends SuitCard_1.default {
_suit;
_rank;
_point;
constructor(suit, point) {
super();
this._suit = suit;
this._rank = Rank_1.default.A;
if (point === undefined) {
this._point = this._rank;
}
else {
if (Number.isNaN(+point)) {
throw new CardError_1.default(`[AceCard][constructor]: point is expected to be a number but get the type ${typeof point}!`);
}
this._point = +point;
}
}
getCardId() {
return `${this._suit.getShortName()}${this._rank}.${this._point}`;
}
getPoint() {
return this._point;
}
setPoint(point) {
this._point = point;
}
getRank() {
return this._rank;
}
getCardSuit() {
return this._suit;
}
toString() {
return `${this._suit.getIcon()}A`;
}
/**
* Convert the card to a colored string, which can be printed to the console.
* @returns {string}
*/
getGraph() {
return (0, utils_1.getGraph)(this);
}
}
exports.default = AceCard;