Tarot Command

This commit is contained in:
Dragon Fire
2021-04-11 14:24:13 -04:00
parent 7e91c2f66d
commit d785a38a05
83 changed files with 2711 additions and 1 deletions
+24
View File
@@ -0,0 +1,24 @@
const path = require('path');
module.exports = class TarotCard {
constructor(data) {
this.rank = data.rank;
this.suit = data.suit;
this.name = data.name;
this.meanings = data.meanings;
this.keywords = data.keywords;
this.fortunes = data.fortune_telling;
}
get imagePath() {
return path.join(__dirname, '..', '..', 'assets', 'images', 'tarot', this.suit, `${this.rank}.jpg`);
}
randomLightMeaning() {
return this.meanings.light[Math.floor(Math.random() * this.meanings.light.length)];
}
randomShadowMeaning() {
return this.meanings.shadow[Math.floor(Math.random() * this.meanings.shadow.length)];
}
};
+34
View File
@@ -0,0 +1,34 @@
const TarotCard = require('./TarotCard');
const cards = require('../../assets/json/tarot');
const { shuffle } = require('../../util/Util');
module.exports = class TarotDeck {
constructor() {
this.deck = [];
this.makeCards();
}
makeCards() {
const newDeck = [];
for (const card of cards) {
newDeck.push(new TarotCard(card));
}
this.deck = shuffle(newDeck);
return this.deck;
}
draw(amount = 1) {
const cards = [];
for (let i = 0; i < amount; i++) {
const card = this.deck[0];
this.deck.shift();
cards.push(card);
}
return amount === 1 ? cards[0] : cards;
}
reset() {
this.makeCards();
return this;
}
};