tarotap
Version:
Complete 78-card Tarot deck library with 17-language support (EN/DE/ES/FR/IT/JA/KO/NL/PT/RU/TW/ZH/TH/TR/PL/DA/NO) and TypeScript
154 lines • 5.06 kB
JavaScript
"use strict";
/**
* Tarotap - Professional AI Tarot Reading Library
*
* Complete 78-card Tarot deck with comprehensive functionality
* Powering https://tarotap.com/en - Free AI Tarot Divination Platform
*
* @author Tarotap Team <https://tarotap.com/en>
* @version 1.0.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SUITS = exports.MINOR_ARCANA_COUNT = exports.MAJOR_ARCANA_COUNT = exports.TOTAL_CARDS = exports.cards = void 0;
exports.getAllCards = getAllCards;
exports.getCardById = getCardById;
exports.getRandomCard = getRandomCard;
exports.drawCards = drawCards;
exports.getMajorArcana = getMajorArcana;
exports.getMinorArcana = getMinorArcana;
exports.getCardsBySuit = getCardsBySuit;
exports.searchCards = searchCards;
const cards_en_1 = require("./data/cards-en");
const cards_de_1 = require("./data/cards-de");
const cards_es_1 = require("./data/cards-es");
const cards_fr_1 = require("./data/cards-fr");
const cards_it_1 = require("./data/cards-it");
const cards_ja_1 = require("./data/cards-ja");
const cards_ko_1 = require("./data/cards-ko");
const cards_nl_1 = require("./data/cards-nl");
const cards_pt_1 = require("./data/cards-pt");
const cards_ru_1 = require("./data/cards-ru");
const cards_tw_1 = require("./data/cards-tw");
const cards_zh_1 = require("./data/cards-zh");
const cards_th_1 = require("./data/cards-th");
const cards_tr_1 = require("./data/cards-tr");
const cards_pl_1 = require("./data/cards-pl");
const cards_da_1 = require("./data/cards-da");
const cards_no_1 = require("./data/cards-no");
/**
* Get cards by language
*/
function getCardsByLanguage(language) {
switch (language) {
case 'de':
return cards_de_1.tarotCardsDE;
case 'es':
return cards_es_1.tarotCardsES;
case 'fr':
return cards_fr_1.tarotCardsFR;
case 'it':
return cards_it_1.tarotCardsIT;
case 'ja':
return cards_ja_1.tarotCardsJA;
case 'ko':
return cards_ko_1.tarotCardsKO;
case 'nl':
return cards_nl_1.tarotCardsNL;
case 'pt':
return cards_pt_1.tarotCardsPT;
case 'ru':
return cards_ru_1.tarotCardsRU;
case 'tw':
return cards_tw_1.tarotCardsTW;
case 'zh':
return cards_zh_1.tarotCardsZH;
case 'th':
return cards_th_1.tarotCardsTH;
case 'tr':
return cards_tr_1.tarotCardsTR;
case 'pl':
return cards_pl_1.tarotCardsPL;
case 'da':
return cards_da_1.tarotCardsDA;
case 'no':
return cards_no_1.tarotCardsNO;
case 'en':
default:
return cards_en_1.tarotCards;
}
}
/**
* Get all tarot cards (English by default)
*/
function getAllCards(language = 'en') {
return getCardsByLanguage(language);
}
/**
* Get a specific card by ID
*/
function getCardById(cardId, language = 'en') {
const cards = getCardsByLanguage(language);
return cards.find(card => card.id === cardId) || null;
}
/**
* Get a random card from the deck
*/
function getRandomCard(language = 'en') {
const cards = getCardsByLanguage(language);
const randomIndex = Math.floor(Math.random() * cards.length);
return cards[randomIndex];
}
/**
* Get multiple random cards (for spreads)
*/
function drawCards(count = 1, allowDuplicates = false, language = 'en') {
if (count <= 0)
return [];
const cards = getCardsByLanguage(language);
if (allowDuplicates) {
return Array.from({ length: count }, () => getRandomCard(language));
}
if (count > cards.length) {
throw new Error(`Cannot draw ${count} unique cards from a deck of ${cards.length}`);
}
const shuffled = [...cards].sort(() => Math.random() - 0.5);
return shuffled.slice(0, count);
}
/**
* Get Major Arcana cards only (22 cards)
*/
function getMajorArcana(language = 'en') {
const cards = getCardsByLanguage(language);
return cards.slice(0, 22);
}
/**
* Get Minor Arcana cards only (56 cards)
*/
function getMinorArcana(language = 'en') {
const cards = getCardsByLanguage(language);
return cards.slice(22);
}
/**
* Get cards by suit (for Minor Arcana)
*/
function getCardsBySuit(suit, language = 'en') {
const cards = getCardsByLanguage(language);
const suitLower = suit.toLowerCase();
return cards.filter(card => card.id.includes(`-of-${suitLower}`));
}
/**
* Search cards by name
*/
function searchCards(query, language = 'en') {
const cards = getCardsByLanguage(language);
const queryLower = query.toLowerCase();
return cards.filter(card => card.name.toLowerCase().includes(queryLower) ||
card.id.toLowerCase().includes(queryLower));
}
// Export data and constants
exports.cards = cards_en_1.tarotCards;
exports.TOTAL_CARDS = cards_en_1.tarotCards.length;
exports.MAJOR_ARCANA_COUNT = 22;
exports.MINOR_ARCANA_COUNT = 56;
exports.SUITS = ['wands', 'cups', 'swords', 'pentacles'];
//# sourceMappingURL=index.js.map