# ============================================================
# The Handcrafter — Rank ladder render (numeric -> letter map)
# ============================================================
# Renders the 13-tier Handcrafter rank ladder as a compact tellraw, with the
# player's CURRENT rank (ec.bc_rank, internal 0..12) called out by letter. Mirrors
# guild_cards/bc/letter's numeric->letter map exactly:
#   0 ?  · 1 G · 2 F · 3 E · 4 D · 5 C · 6 B · 7 A · 8 S · 9 SS · 10 SSS · 11 X · 12 V
# X = Mastercrafter (special-title ID 14); V = hidden Hand of the Maker (ID 16).
# Read-only on ec.bc_rank. Run as @s = the player. Pure tellraw helper.

tellraw @s [{text:"  Rank Ladder",color:"#E8C9A0",bold:true}]

# Row 1: ? G F E D C B A (ranks 0..7) — bright once the player is at rank 1+.
execute if score @s ec.bc_rank matches 0 run tellraw @s [{text:"   ? ",color:"gold",bold:true},{text:"G F E D C B A",color:"dark_gray"}]
execute if score @s ec.bc_rank matches 1.. run tellraw @s [{text:"   ? G F E D C B A",color:"#C49A6C"}]

# Row 2: S SS SSS X V (ranks 8..12) — dim until the player crosses into the S band.
execute unless score @s ec.bc_rank matches 8.. run tellraw @s [{text:"   S SS SSS X V",color:"dark_gray"}]
execute if score @s ec.bc_rank matches 8.. run tellraw @s [{text:"   S SS SSS X V",color:"#E8C9A0"}]

# CURRENT-RANK callout (the highlight) — bc/letter writes the exact letter to
# storage evercraft:guild_cards bc.letter; the macro prints "You are rank <L>".
function evercraft:guild_cards/bc/letter
function evercraft:handcrafter/book/render_ladder_macro with storage evercraft:guild_cards bc
