#import "../theme/variables.typ": theme #import "../theme/decorations.typ" as spacers #import "../core/macros.typ" as macros #import "../build_config.typ": recto-pagebreak //----- CREATURE RENDERER ----- //----- STYLE CONFIGURATION ----- // Main spacing rhythm. #let creature-spacing = ( section: 8pt, content: 6pt, component: 4pt, ) // General component boxes. #let creature-box = ( inset: 8pt, radius: 2pt, stroke: 0.7pt, fill: theme.parchment-light, border: theme.border, ) // Fluff box. #let creature-fluff = ( inset: ( left: 10pt, right: 10pt, top: 7pt, bottom: 7pt, ), stroke: 2pt, accent: theme.blood, fill: theme.parchment-light, author-size: 9pt, ) // Ability box. #let creature-ability = ( inset: ( top: 4pt, bottom: 4pt, left: 7pt, right: 7pt, ), stroke: 1.5pt, accent: theme.dark-gold, fill: theme.parchment-light, label-size: 9pt, name-size: 11pt, passive-inset: ( left: 5pt, right: 5pt, top: 3pt, bottom: 3pt, ), passive-radius: 8pt, passive-stroke: 0.5pt, passive-size: 8.5pt, passive-fill: theme.parchment-dark, ) // Stats box. #let creature-stats = ( inset: 7pt, radius: 2pt, stroke: 0.5pt, border: theme.border, fill: theme.parchment-light, title-size: 9pt, ) // Stage box. #let creature-stage = ( inset: 8pt, radius: 2pt, stroke: 0.7pt, border: theme.border, fill: theme.parchment-light, title-size: 12pt, symbol-size: 8pt, symbol-gap: 4pt, ) // Creature title. #let creature-title = ( size: 20pt, weight: "bold", fill: theme.blood, symbol-size: 8pt, symbol-fill: theme.dark-gold, symbol-gap: 3pt, ) // Creature image. #let creature-image = ( height: 50%, stroke: 1pt, border: theme.border, inset: 2pt, radius: 3pt, ) //----- STAGE NAMES ----- #let stage-name(number) = { ( ( "Premier", "Deuxième", "Troisième", "Quatrième", "Cinquième", "Sixième", "Septième", ).at(number - 1) + " stade" ) } #let eval-typst(markup) = { if type(markup) == str { eval(markup, mode: "markup", scope: macros.bigscope) } else { markup } } //----- FLUFF ----- #let fluff(content, author) = { block( width: 100%, inset: creature-fluff.inset, stroke: ( left: creature-fluff.stroke + creature-fluff.accent, ), fill: creature-fluff.fill, )[ #emph[« #content »] #align(right)[ #text( size: creature-fluff.author-size, fill: theme.muted, )[ --- #author. ] ] ] } //----- ABILITY ----- #let render-ability(ability-type, description, name: none) = { let label = if ability-type == "actif" { "Actif" } else if ability-type == "alteration" { "Altération" } else if ability-type == "effect" { "Effet" } else { "Passif" } block( width: 100%, inset: creature-ability.inset, stroke: ( left: creature-ability.stroke + creature-ability.accent, ), fill: creature-ability.fill, )[ #text( size: creature-ability.label-size, weight: "bold", fill: creature-ability.accent, )[ #label ] #if name != none [ #h(4pt) #text( size: creature-ability.name-size, weight: "bold", fill: theme.blood, )[ #eval-typst(name) ] #eval-typst(description) ] else { let passives = if type(description) == array { description } else if type(description) == str { description.split(",") } else { (description,) } if passives.len() > 0 { passives .map(passive => ( box( inset: creature-ability.passive-inset, radius: creature-ability.passive-radius, stroke: ( creature-ability.passive-stroke + theme.border ), fill: creature-ability.passive-fill, )[ #text( size: creature-ability.passive-size, )[ #eval-typst(passive) ] ] )) .join(" ") } } ] } //----- STATS ----- #let render-stats(stats) = { if stats.max != none { block( width: 100%, inset: creature-stats.inset, radius: creature-stats.radius, stroke: creature-stats.stroke + creature-stats.border, fill: creature-stats.fill, )[ #text( size: creature-stats.title-size, weight: "bold", fill: theme.dark-gold, )[ Les caractéristiques maximum à la création ] #v(2pt) #( ( stats .max .pairs() .map(((key, value)) => [ #text(weight: "bold")[#key] (#value) ]) + (text(fill: theme.ink.transparentize(72%))[Autres (6)],) ).join([, ]) ) ] } } //----- STAGE ----- #let render-stage(stage, breakable: true) = { block( width: 100%, breakable: breakable, inset: creature-stage.inset, radius: creature-stage.radius, stroke: creature-stage.stroke + creature-stage.border, fill: creature-stage.fill, )[ #align(center)[ #text( size: creature-stage.title-size, weight: "bold", fill: theme.blood, )[ #text(size: creature-stage.symbol-size)[ #theme.small-symbol ] #h(creature-stage.symbol-gap) #stage-name(stage.number) #h(creature-stage.symbol-gap) #text(size: creature-stage.symbol-size)[ #theme.small-symbol ] ] ] #v(5pt) #for ability-data in stage.abilities { render-ability( ability-data.type, ability-data.at( "description", default: none, ), name: ability-data.at( "name", default: none, ), ) v(creature-spacing.component) } ] } //----- CREATURE ----- #let render-creature( data, show-fluff: true, show-artwork: true, start-on-recto: true, ) = { if start-on-recto { recto-pagebreak() } assert( data.difficulty >= 1 and data.difficulty <= 5, message: "Origin difficulty must be between 1 and 5: " + data.name, ) show heading: it => { align(center)[#text( size: creature-title.size, weight: creature-title.weight, fill: creature-title.fill, )[#it.body] #v(3pt) #text( size: creature-title.symbol-size, fill: creature-title.symbol-fill, )[ #theme.section-symbol ]] } heading(level: 3, data.name) v(creature-spacing.section) if show-fluff and data.fluff != none [ #fluff( data.fluff.text, data.fluff.author, ) #v(creature-spacing.section) ] if show-artwork and data.image != none [ #align(center)[ #block( radius:creature-image.radius, clip: true, stroke: creature-image.stroke + creature-image.border, inset: creature-image.inset, )[ #image( data.image, height: creature-image.height, ) ] ] #v(creature-spacing.section) ] data.description v(creature-spacing.content) if data.stats != none [ #block(width: 100%, breakable: false)[ #grid( columns: (1fr, auto), align: horizon, spacers.fantasy-label("DIFFICULTÉ", theme-name: "warm"), grid( column-gutter: 0.25em, macros.difficulty-stars(data.difficulty), ), ) #v(creature-spacing.content) #render-stats(data.stats) ] #v(creature-spacing.section) ] for stage in data.stades [ #render-stage(stage) #v(creature-spacing.section) ] }