Files
troxler-skat/card-game/generate_cards.js
2026-05-31 14:39:45 -05:00

42 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const fs = require('fs');
const path = require('path');
const { buildCardSVG, SUITS } = require('./trox_card');
/* ============================================================
TROX Kartenvorderseiten Generator
node generate_cards.js tgc | original | both
Nutzt das gemeinsame Modul trox_card.js (eine Quelle fürs Design).
Codes: R=Red(Trumpf), Y=Yellow, G=Green, S=Black.
============================================================ */
const MODE = (process.argv[2] || 'both').toLowerCase();
const SPECS = {
tgc: { width: 825, height: 1125, safe: 75, cornerRadius: 0, dir: 'karten_export_tgc' },
original: { width: 694, height: 1069, safe: 35, cornerRadius: 35, dir: 'karten_export_original' },
};
function generate(variant) {
const spec = SPECS[variant];
const outputDir = path.join(__dirname, spec.dir);
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir, { recursive: true });
let count = 0;
for (const colorName of Object.keys(SUITS)) {
for (let num = 1; num <= 20; num++) {
const svg = buildCardSVG(colorName, num, {
width: spec.width, height: spec.height, safe: spec.safe, cornerRadius: spec.cornerRadius,
});
const fileName = `${colorName}_${String(num).padStart(2, '0')}.svg`;
fs.writeFileSync(path.join(outputDir, fileName), svg);
count++;
}
}
console.log(` [${variant}] ${count} Karten -> ${spec.dir}/ (${spec.width}x${spec.height})`);
}
console.log('TROX Karten werden generiert ...');
if (MODE === 'tgc' || MODE === 'both') generate('tgc');
if (MODE === 'original' || MODE === 'both') generate('original');
console.log('Fertig.');