card-games-typescript
Version:
Card deck and high or low game library built with TypeScript
39 lines (38 loc) • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Card = exports.valueCards = void 0;
exports.valueCards = {
2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, J: 11, Q: 12, K: 13, A: 14
};
const symbolUnicodes = {
clubs: "\u2663",
hearts: "\u2665",
spades: "\u2660",
diamonds: "\u2666"
};
class Card {
constructor(rank, suite) {
this.compare = (otherCard) => {
if (this.value == otherCard.value) {
return 0;
}
if (this.value > otherCard.value) {
return 1;
}
if (this.value < otherCard.value) {
return -1;
}
};
this.isSameCard = (otherCard) => {
if (this.value === otherCard.value && this.suite === otherCard.suite) {
return true;
}
return false;
};
this.rank = rank;
this.suite = suite;
this.value = exports.valueCards[rank];
this.unicode = `${symbolUnicodes[this.suite]}${rank}`;
}
}
exports.Card = Card;