cardation
Version:
fundation of card games, card model
40 lines (39 loc) • 1.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const CardError_1 = require("../../error/CardError");
const Rank_1 = require("../rank/Rank");
const JokerCard_1 = require("./JokerCard");
class RedJokerCard extends JokerCard_1.default {
_rank;
_point = 10;
constructor(rank = Rank_1.default.RedJoker, point) {
super();
this._rank = rank;
this._point = this._rank;
if (point === undefined) {
this._point = this._rank;
}
else {
if (Number.isNaN(+point)) {
throw new CardError_1.default(`[RedJokerCard][constructor]: point is expected to be a number but get the type ${typeof point}!`);
}
this._point = +point;
}
}
getCardId() {
return `j${this._rank}.${this._point}`;
}
getPoint() {
return this._point;
}
getRank() {
return this._rank;
}
setPoint(point) {
this._point = point;
}
toString() {
return '🂿';
}
}
exports.default = RedJokerCard;