/* ============================================================
TROX – Gemeinsames Karten-Zeichenmodul
------------------------------------------------------------
Eine einzige Quelle für das Kartendesign.
Wird von generate_cards.js (ganze Karten) UND
generate_box.js (skalierte Mini-Karten im Fächer) genutzt,
damit die Box-Karten exakt den echten Karten entsprechen.
Bezugssystem: Alle Zeichenfunktionen arbeiten in den
Koordinaten der ORIGINAL-Karte (694 x 1069). Für andere
Maße/Skalierungen wird außen herum transformiert.
============================================================ */
// Referenzmaße der Original-Karte (Designraster)
const REF_W = 694;
const REF_H = 1069;
// Farben + Codes (Y = Yellow, G = Green – englische Logik)
const SUITS = {
Rot: { hex: '#E53935', code: 'R', name: 'Red' }, // Trumpf
Gelb: { hex: '#FDD835', code: 'Y', name: 'Yellow' },
Gruen: { hex: '#43A047', code: 'G', name: 'Green' },
Schwarz: { hex: '#212121', code: 'B', name: 'Black' },
};
// ------------------------------------------------------------
// Symbolzentrum (rotationssymmetrisches Paar) – Koordinaten
// relativ zum Kartenmittelpunkt (0,0).
// ------------------------------------------------------------
function centerIcons(colorName, hex) {
if (colorName === 'Rot') {
const crown = `
`;
return `
${crown}
${crown}`;
}
if (colorName === 'Gruen') {
const leaf = `
`;
return `
${leaf}
${leaf}`;
}
if (colorName === 'Gelb') {
const sunRay = ``;
const singleSun = `
${sunRay}
${sunRay}
${sunRay}
${sunRay}
${sunRay}
${sunRay}
${sunRay}
${sunRay}`;
return `
${singleSun}
${singleSun}`;
}
// Schwarz – Zahnrad-Paar
const singleGear = `
`;
return `
${singleGear}
${singleGear}`;
}
// ------------------------------------------------------------
// cardArtwork: der gesamte Karteninhalt OHNE den weißen
// Kartenkörper – als , gezeichnet im Raster width x height.
// safe = Abstand für Eckelemente & Zierrand
// drawBorder = Zierrand zeichnen (ja bei echten Karten)
// ------------------------------------------------------------
function cardArtwork(colorName, num, { width = REF_W, height = REF_H, safe = 35, drawBorder = true, cornerRadius = 30 } = {}) {
const suit = SUITS[colorName];
const hex = suit.hex;
const cardCode = `TK-${suit.code}${num}`;
const cornerX = safe + 20;
const cornerNumY = safe + 55;
const cornerCodeY = cornerNumY + 22;
const centerGap = 70;
const border = drawBorder
? ``
: '';
return `
${border}
${num}
${cardCode}
${num}
${cardCode}
${num}
${cardCode}
${num}
${cardCode}
${num}
${centerIcons(colorName, hex)}
${num}
`;
}
// CSS-Klassen, die cardArtwork voraussetzt (font-size SKALIERBAR über fontScale)
function cardStyles(hex, fontScale = 1) {
return `
.trox-cnum { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: bold; font-size: ${65 * fontScale}px; }
.trox-code { font-family: 'Helvetica Neue', Arial, sans-serif; font-weight: bold; font-size: ${14 * fontScale}px; fill: #888888; letter-spacing: 1px; }
.trox-bignum { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: bold; font-size: ${320 * fontScale}px; letter-spacing: -10px; }`;
}
// ------------------------------------------------------------
// buildCardSVG: vollständige, eigenständige Karten-SVG.
// ------------------------------------------------------------
function buildCardSVG(colorName, num, { width = REF_W, height = REF_H, safe = 35, cornerRadius = 35 } = {}) {
const suit = SUITS[colorName];
return ``;
}
// ------------------------------------------------------------
// miniCardGroup: eine VOLLSTÄNDIGE Karte als skalierte ,
// zentriert auf (cx,cy), gedreht um rot Grad. Für den Box-Fächer.
// Zeichnet Schatten + weißen Körper + komplettes Artwork,
// alles im Referenzraster und dann sauber herunterskaliert.
// ------------------------------------------------------------
function miniCardGroup(colorName, num, cx, cy, targetWidth, rot = 0) {
const suit = SUITS[colorName];
const scale = targetWidth / REF_W; // ein einziger Skalenfaktor → 1:1 Optik
const w = REF_W, h = REF_H;
return `
${cardArtwork(colorName, num, { width: w, height: h, safe: 35, drawBorder: true, cornerRadius: 30 })}
`;
}
module.exports = {
REF_W, REF_H, SUITS,
centerIcons, cardArtwork, cardStyles, buildCardSVG, miniCardGroup,
};