deckhearth/lib/custom-cards-fields.js
Randall Stillwell 147041d292 feat(designer): rarity badges, flavor quotes with dividers, full-art mode
- rarity now renders as shape+color symbol anchored inside the type bar
  (circle/diamond/pentagon/star per rarity) — fixes straddling gem alignment
- new flavor_quote field: centered italic quotation with ornamental
  diamond dividers between description/actions/quote
- framed | fullart toggle: full-art bleeds artwork edge-to-edge with
  title/cost top scrim and type/text bottom scrim
- shared pickDesignFields lib so create/update routes cannot drift
- migration 1787685911000: art_mode + flavor_quote columns
2026-08-24 16:19:24 -05:00

25 lines
919 B
JavaScript

/**
* Shared field normalization for custom card designs.
* Single source of truth so the create and update routes never drift.
*/
export function pickDesignFields(body = {}) {
const str = (v) => (typeof v === 'string' ? v.trim() : null);
const artMode = str(body.art_mode) || str(body.artMode) || 'framed';
return {
name: str(body.name),
manaCost: str(body.mana_cost) || str(body.manaCost),
cardType: str(body.card_type) || str(body.cardType),
rarity: str(body.rarity),
rulesText: str(body.rules_text) || str(body.description),
actions: str(body.actions),
flavorQuote: str(body.flavor_quote) || str(body.flavorQuote),
power: str(body.power),
toughness: str(body.toughness),
frameId: str(body.frame_id) || str(body.frameId) || 'classic',
artworkUrl: str(body.artwork_url) || str(body.artworkUrl),
artMode: artMode === 'fullart' ? 'fullart' : 'framed',
};
}