Flesh and Blood card data
Ruleset and calculator scripts get Flesh and Blood cards as plain objects straight from the card catalog. This page lists every field on those objects and in the catalog globals, with a real example and a few recipes.
Where the cards show up:
- Card rules receive one card as their first argument.
- Deck and deck set rules receive
cardsById, an object keyed by card ref that holds every card in the deck (it can hold more). - Calculators receive
cardsByIdas their second argument.
See the ruleset script API and the calculator script API for the full function signatures.
Card keys and deck refs
A Flesh and Blood card in the catalog is a card identity: one card name at one pitch, with every printing of it listed under printings. The red, yellow and blue versions of a card are three identities, so Command and Conquer in red is its own card. Three kinds of id matter:
- The identity id,
card.id:fab-plus a hash, likefab-d2dbc5d0a6028396c6ed. - A printing id: one set and collector number in lowercase, like
arc159. - A variant id: one edition and foiling of a printing, like
arc159:f-r(first edition, rainbow foil). A variant'smetadatacarries its edition, foiling, rarity and TCGplayer product id.
A double-faced card is one identity keyed on its front face; the back face is on game.backFace and is never a deck card on its own.
cardsById is keyed by the deck's refs, and each one points to its identity:
- Count copies of "the same card" by
card.id, not by ref. - To read the printing a ref points to, find it in the list:
card.printings.find((p) => p.id === ref). ctx.globals.printings[ref]gives the identity id for a printing id, when globals are available.
A card rule gets the identity card itself, so card.id is always the identity id.
The game fields describe the identity. rarity is the rarity of its default printing (game.defaultPrintingId, the latest released standard-foil printing), and each printing's metadata has its own rarity and artists.
Guard against a missing card before reading from it: cardsById[ref] can be undefined when the catalog doesn't know a ref.
Card fields
Every card, in every game, has these top-level fields:
| Property | Type | Description |
|---|---|---|
id | string | Catalog id of the card identity ("01DE012" in LoR, "pikachu-ex--1f29b66b68bc" in Pokémon). |
slug? | string | The card's public URL segment (#2189, ADL §64): a frozen English slug, identical in every locale. Equals id for a game whose readable slugs are off (readableCardSlugsEnabled in @turny/game-adapters) or a card that has no readable slug yet. Pokémon keeps its <name>--<hash12> id as its slug; LoR's switch stays off for good, so its URLs stay its card codes. A page whose route param already equals slug renders; any other known key (the id, a history slug, an alias) redirects to it, so a card whose slug equals its id never redirects to itself.The catalog export (#2193) writes it only for a switched-on game and only when it differs from id, so an absent slug means the id: always read it through cardSlugOf (@turny/game-adapters). |
name | string | Display name in the catalog locale. |
setCode | string | Set of the card, or of its default printing ("set1", "sv2", "OGN"). |
collectible? | boolean | False for cards that can't go in a deck (LoR tokens and level-ups). |
assets? | CardCatalogCardAssetContract[] | Images of the card's default printing. |
printings? | CardPrintingContract[] | Every printing of the identity, default printing first (only some on a partial card, see partialPrintings). Absent in LoR. |
printingCount? | number | Lean list files (#1323), which omit printings, partial cards (see partialPrintings) and per-identity core files (#1522): how many printings the full card has. Absent on full cards and in games without printings. |
printingSetCodes? | string[] | Lean list files (#1323), partial cards and per-identity core files: the distinct set codes across the full card's printings, in printing order. Absent on full cards. |
printingsFile? | string | Per-identity core files (#1522) only: the card's printings file (identities/<id>.printings.<hash8>.json, relative to the locale directory, see cardCatalogIdentityPrintingsFileName), in place of printings. Absent when the printings are inline in the core file. |
partialPrintings? | boolean | True on a partial card (the featured-cards bundle, #1330): printings holds only some of the identity's printings (its default printing plus the ones the featured content references), while printingCount / printingSetCodes summarize all of them. Absent on full and list cards. |
hasImage? | boolean | False when none of the card's printings has an image in this language. Absent means it has one. |
languages? | CardLanguageEntry[] | Catalog locales that hold real text for this card (#2552). A locale whose entry is only fallback text is absent. Absent on older exports and in single-locale games. |
game? | TGameData | Game-specific fields; see the per-game *CardGameData type. |
Each entry of languages (CardLanguageEntry):
| Property | Type | Description |
|---|---|---|
locale | string | Catalog locale ("zh-tw", "de_de"), not an app locale. |
status | CardLanguageStatus | Where the text comes from: official (printed) or unofficial (a translation). |
Values of a language entry's status (CardLanguageStatus):
| Member | Value | Description |
|---|---|---|
Official | "official" | Printed in this language by the publisher. |
Unofficial | "unofficial" | Real text the publisher did not print in this language: a reconstruction or a translation. |
Printings
Each entry of printings (CardPrintingContract):
| Property | Type | Description |
|---|---|---|
id | string | Printing id; deck refs use it ("sv2-11" for Pokémon, "ogn-030-298" for Riftbound). |
setCode | string | Set the printing belongs to ("sv2", "OGN"). |
number? | string | Collector number within the set. |
language? | string | Language of the printing, when it is not the catalog's own. |
releaseDate? | string | Release date as the source gives it ("2023/06/09"). |
assets? | CardCatalogCardAssetContract[] | This printing's own images. |
variants? | CardVariantContract[] | Treatments of this printing (foil, alternate art, …). |
metadata? | JsonObject | Extra per-printing data (rarity, artist, store ids); game-specific. |
Each entry of a printing's variants:
| Property | Type | Description |
|---|---|---|
id | string | Variant id, usually <printing id>:<kind> ("ogn-030-298:normal"). |
kind? | string | Treatment kind ("normal", "foil", "alternate_art"); values are per game. |
label? | string | Display label, when the kind alone is not enough. |
metadata? | JsonObject | Extra per-variant data; game-specific. |
Each entry of assets (on the card and on each printing):
| Property | Type | Description |
|---|---|---|
kind | CardAssetKind | What the image shows: "card" (framed render), "full" (full art), "icon", "banner", "slice", "portrait", … |
url | string | Image URL. |
format? | CardAssetFormat | Image format ("webp"), when known. |
width? | number | Width in pixels, when known. |
height? | number | Height in pixels, when known. |
metadata? | JsonObject | Extra per-asset data; game-specific. |
Game fields (card.game)
Everything specific to Flesh and Blood lives on card.game. Types, classes and talents are lower-case tokens with spaces and hyphens turned into _ (defense_reaction, demi_hero); look them up in the globals for display names. A stat the card doesn't have is null, and a printed X or * is null too, with the raw value in variableStats.
| Property | Type | Description |
|---|---|---|
pitch | FabPitch | null | Pitch value; null for cards without a colour bar. Part of the identity. |
color | FabPitchColor | null | The printed colour bar as the source spells it, null when there is none. Almost always FAB_PITCH_COLOR_BY_PITCH of pitch, but not always: Goldfin Harpoon is printed yellow with no pitch value, so a text decklist line Goldfin Harpoon (Yellow) must match on colour, not pitch. |
cost | number | null | Resource cost. |
power | number | null | Attack power. |
defense | number | null | Defense value. |
health | number | null | Hero (and demi-hero / ally) life total. |
intelligence | number | null | Hero hand size. |
arcane | number | null | Arcane damage the card deals. |
variableStats? | FabVariableStats | Non-numeric printed stats ({ cost: "X" }); absent when every stat is numeric. |
types | FabCardType[] | Structural types, sorted (["action", "attack"]). |
classes | FabClass[] | Classes; ["generic"] for class-less cards, two for hybrid cards. |
talents | FabTalent[] | Talents; empty for untalented cards. |
subtypes | string[] | The rest of the type line as source tokens (["Sword"], ["Young"], ["Evo", "Base"]); open-ended, never compared as an enum. |
equipmentSlot | FabEquipmentSlot | null | Slot an equipment takes; null for anything else. |
weaponHands | FabWeaponHands | null | Hands a weapon takes; null for anything else. |
keywords | string[] | The card's own keywords as source tokens (["Go again", "Dominate"]). |
isHero | boolean | True for heroes (adult and young). |
isYoungHero | boolean | True for young heroes (Blitz / Silver Age); adult heroes play CC and LL. |
playedHorizontally | boolean | Printed landscape (Landmarks, some macros); gets its own art window. |
legalities | FabCardLegalities | Legality per format (see Legalities below). |
extraLegalities? | { upf: CardLegalityStatus; } & JsonObject | Formats carried as source legality data only, no Turny rule or preset (Ultimate Pit Fight). |
defaultPrintingId? | string | The representative printing (latest released standard-foil, no art variation); the deck-legal ref the builder pool exposes. |
isProvisional? | boolean | True while no printing of the card has released yet; absent once released. |
rarity | FabRarity | null | Rarity of the representative (default) printing's base variant. |
backFace? | FabCardBackFace | The back face of a double-faced card (see the module header); absent on single-faced cards. Back faces have no legality or pitch of their own. |
text? | string | Rules text with the source's markdown-ish markup. |
textPlain? | string | Rules text as plain text. |
typeText? | string | The printed type line ("Guardian Action - Attack"). |
Legalities
The legalities object, one entry per format:
| Property | Type | Description |
|---|---|---|
cc | CardLegalityStatus | Classic Constructed. |
blitz | CardLegalityStatus | Blitz. |
ll | CardLegalityStatus | Living Legend. |
commoner | CardLegalityStatus | Commoner. |
silver_age | CardLegalityStatus | Silver Age. |
Variable stats
The variableStats object:
| Property | Type | Description |
|---|---|---|
cost? | string | Printed cost ("X"). |
power? | string | Printed attack power ("*"). |
defense? | string | Printed defense. |
health? | string | Printed life. |
intelligence? | string | Printed intellect. |
arcane? | string | Printed arcane damage. |
Back face
The backFace object of a double-faced card:
| Property | Type | Description |
|---|---|---|
name | string | The back face's printed name. |
types | FabCardType[] | Structural types, as on the front face. |
classes | FabClass[] | Classes, as on the front face. |
talents | FabTalent[] | Talents, as on the front face. |
subtypes | string[] | The rest of the type line as source tokens. |
cost | number | null | Resource cost. |
power | number | null | Attack power. |
defense | number | null | Defense value. |
health | number | null | Life total. |
intelligence | number | null | Hand size. |
arcane | number | null | Arcane damage. |
variableStats? | FabVariableStats | Non-numeric printed stats; absent when every stat is numeric. |
keywords | string[] | The back face's keywords as source tokens. |
text? | string | Rules text with the source's markdown-ish markup. |
textPlain? | string | Rules text as plain text. |
typeText? | string | The printed type line. |
Printing metadata
Each printing's metadata:
| Property | Type | Description |
|---|---|---|
rarity | FabRarity | Rarity of the printing's BASE variant (standard foiling, no art variation). Rarity varies across a printing's variants (a cold-foil full-art variant of a Common is Marvel), so per-variant rarity lives on FabVariantMetadata.rarity. |
artists? | string[] | Artists credited on the printing. |
flavorText? | string | Printed flavour text, when any. |
Variant metadata
Each printing variant's metadata:
| Property | Type | Description |
|---|---|---|
edition | FabEdition | Print run ("first", "unlimited", "none", …). |
foiling | FabFoiling | Foil treatment ("standard", "rainbow_foil", "cold_foil", …). |
rarity | FabRarity | This variant's own rarity (the source gives one per edition x foiling x art). |
artVariations? | string[] | Source art-variation codes (["AA"] for alternate art, ["EA"] extended art). |
tcgplayerProductId? | string | TCGplayer product id, when the variant is listed there. |
imageUrl? | string | The source render for this variant (the LSS image host, or a fallback host). |
backImageUrl? | string | A same-card _BACK render (double-sided Marvel heroes); not a second face. |
Globals (ctx.globals)
The catalog's globals are lookup tables for the values on a card (classes: ["guardian"] resolves through ctx.globals.classes.guardian), the keyword glossary, the rules-text symbols and the printing map.
When globals are available
Globals are passed to ruleset scripts as ctx.globals (the last argument). Calculators may not receive ctx at all, and a ruleset can run without it too. Always check ctx && ctx.globals before using them and fall back to the raw value.
| Property | Type | Description |
|---|---|---|
classes? | Record<string, FabCatalogLookupEntry> | By FabClass value. |
talents? | Record<string, FabCatalogLookupEntry> | By FabTalent value. |
types? | Record<string, FabCatalogLookupEntry> | By FabCardType value. |
rarities? | Record<string, FabCatalogLookupEntry> | By FabRarity value. |
formats? | Record<string, FabCatalogLookupEntry> | By FabFormat value (the legalities keys). |
sets? | Record<string, FabCatalogSetLookupEntry> | By source set id. |
keywords? | Record<string, FabCatalogKeywordLookupEntry> | By source keyword name. |
symbols? | Record<string, FabCatalogSymbolEntry> | Card-text symbol inventory keyed by symbol key (p, r, d, h, i, t, c, u, x). |
printings? | Record<string, string> | Printing id → owning card identity id ("mst131" → "fab-…"), covering every emitted printing. A double-faced card's shared printing id maps to the front face's identity. Identity ids are never self-mapped. Same name and meaning as the other games' globals.printings. |
Lookup entries
Every table except symbols and printings maps a key to an entry with these fields:
| Property | Type | Description |
|---|---|---|
label | string | Display name in the catalog locale ("Attack Reaction"). |
color? | string | Display color set by an operator override; usually absent. |
icon? | string | null | Icon image URL set by an operator override; usually absent. |
order? | number | Sort position in filters and lists, lowest first. |
showInFilter? | boolean | Whether the entry is offered as a filter option; absent means shown. |
metadataRef? | FabCatalogMetadataReference | Anchor an operator override is matched on. |
Set entries
Entries of sets add:
| Property | Type | Description |
|---|---|---|
releaseDate? | string | null | Release date (YYYY-MM-DD) of the set's earliest edition, when known. |
Keyword entries
Entries of keywords add:
| Property | Type | Description |
|---|---|---|
description? | string | Reminder text: what the keyword does. |
Symbol entries
Each entry of symbols:
| Property | Type | Description |
|---|---|---|
token | string | The inline token as it appears in rules text ("{p}"). |
Example card
Command and Conquer (red), trimmed to two printings with one image each:
json
{
"id": "fab-d2dbc5d0a6028396c6ed",
"slug": "command-and-conquer-red",
"name": "Command and Conquer",
"setCode": "1HP",
"collectible": true,
"assets": [
{
"kind": "card",
"url": "https://cdn.turny.gg/cards/fab/assets/fab-d2dbc5d0a6028396c6ed-card-6265564160020d520a166028818ab80890d155e11b5011dec5acf49eee39f16b.webp"
}
],
"printings": [
{
"id": "1hp360",
"setCode": "1HP",
"number": "360",
"releaseDate": "2022-05-06",
"variants": [
{
"id": "1hp360:n-s",
"kind": "standard",
"metadata": {
"edition": "none",
"foiling": "standard",
"rarity": "majestic",
"tcgplayerProductId": "270947",
"imageUrl": "https://legendstory-production-s3-public.s3.amazonaws.com/media/cards/large/1HP360.webp"
}
}
],
"metadata": {
"rarity": "majestic",
"artists": ["Fajareka Setiawan"]
}
},
{
"id": "arc159",
"setCode": "ARC",
"number": "159",
"releaseDate": "2020-03-27",
"assets": [
{
"kind": "card",
"url": "https://cdn.turny.gg/cards/fab/assets/arc159-card-942a45de4e645df90c415a928ec2007b8af8c13483aae1f4e02013da317861ea.webp"
}
],
"variants": [
{
"id": "arc159:f-r",
"kind": "rainbow_foil",
"metadata": {
"edition": "first",
"foiling": "rainbow_foil",
"rarity": "majestic",
"tcgplayerProductId": "225899",
"imageUrl": "https://legendstory-production-s3-public.s3.amazonaws.com/media/cards/large/ARC159-RF.webp"
}
},
{
"id": "arc159:f-s",
"kind": "standard",
"metadata": {
"edition": "first",
"foiling": "standard",
"rarity": "majestic",
"tcgplayerProductId": "225899",
"imageUrl": "https://legendstory-production-s3-public.s3.amazonaws.com/media/cards/large/ARC159.webp"
}
},
{
"id": "arc159:u-r",
"kind": "rainbow_foil",
"metadata": {
"edition": "unlimited",
"foiling": "rainbow_foil",
"rarity": "majestic",
"tcgplayerProductId": "225899",
"imageUrl": "https://legendstory-production-s3-public.s3.amazonaws.com/media/cards/large/U-ARC159-RF.webp"
}
},
{
"id": "arc159:u-s",
"kind": "standard",
"metadata": {
"edition": "unlimited",
"foiling": "standard",
"rarity": "majestic",
"tcgplayerProductId": "225899",
"imageUrl": "https://legendstory-production-s3-public.s3.amazonaws.com/media/cards/large/U-ARC159.webp"
}
}
],
"metadata": {
"rarity": "majestic",
"artists": ["Fajareka Setiawan"]
}
}
],
"hasImage": true,
"game": {
"pitch": 1,
"color": "red",
"cost": 2,
"power": 6,
"defense": 3,
"health": null,
"intelligence": null,
"arcane": null,
"types": ["action", "attack"],
"classes": ["generic"],
"talents": [],
"subtypes": [],
"equipmentSlot": null,
"weaponHands": null,
"keywords": [],
"isHero": false,
"isYoungHero": false,
"playedHorizontally": false,
"legalities": {
"cc": "legal",
"blitz": "legal",
"ll": "legal",
"commoner": "not_legal",
"silver_age": "not_legal"
},
"extraLegalities": {
"upf": "unknown"
},
"rarity": "majestic",
"text": "Defense reaction cards can't be played this chain link. When this hits a hero, destroy all cards in their arsenal.",
"textPlain": "Defense reaction cards can't be played this chain link. When this hits a hero, destroy all cards in their arsenal.",
"typeText": "Generic Action - Attack",
"defaultPrintingId": "1hp360"
}
}Common recipes
js
// Calculator: copies per pitch value. Cards without a colour bar are left out.
export default function compute(pile, cardsById) {
const counts = { red: 0, yellow: 0, blue: 0 };
Object.keys(pile).forEach((ref) => {
const game = (cardsById[ref] && cardsById[ref].game) || {};
if (game.color in counts) {
counts[game.color] += pile[ref];
}
});
return {
widgets: [
{
kind: "donut",
label: "Pitch",
segments: Object.keys(counts).map((color) => ({
label: color,
value: counts[color],
})),
},
],
};
}js
// Calculator: copies at each resource cost, 4+ grouped.
export default function compute(pile, cardsById) {
const buckets = [0, 0, 0, 0, 0];
Object.keys(pile).forEach((ref) => {
const game = (cardsById[ref] && cardsById[ref].game) || {};
if (typeof game.cost !== "number") {
return; // Heroes, equipment and X costs have no number.
}
buckets[Math.min(game.cost, 4)] += pile[ref];
});
return {
widgets: [
{
kind: "histogram",
label: "Cost curve",
buckets: buckets,
labels: ["0", "1", "2", "3", "4+"],
},
],
};
}js
// Card rule: legal in Classic Constructed.
export default function validateCard(card) {
const legalities = (card.game && card.game.legalities) || {};
if (legalities.cc === "legal" || legalities.cc === "restricted") {
return true;
}
return {
valid: false,
issues: [{ message: card.name + " is not legal in Classic Constructed." }],
};
}js
// Card rule: Guardian or generic cards only. Uses the class's display name when globals exist.
export default function validateCard(card, ctx) {
const classes = (card.game && card.game.classes) || [];
if (classes.indexOf("guardian") !== -1 || classes.indexOf("generic") !== -1) {
return true;
}
const globals = ctx && ctx.globals;
const guardian =
globals && globals.classes && globals.classes.guardian
? globals.classes.guardian.label
: "guardian";
return {
valid: false,
issues: [{ message: card.name + " is not a " + guardian + " card." }],
};
}