From edc44d0860c9f9b1c192499137aa3489f8324412 Mon Sep 17 00:00:00 2001 From: hyperpolymath <6759885+hyperpolymath@users.noreply.github.com> Date: Mon, 18 May 2026 18:07:22 +0100 Subject: [PATCH] fix(affine): migrate record literals to #{ } (affinescript#218) affinescript#218 (merged): bare { = block, records use #{ }. Migrated all expression-position record literals in PlayerHP.affine including nested inline records (hp:/iframes:/knockback:/player: value records, the Player/UpdateResult constructions, and the if-expr velocity/kb records). Blocks (fn bodies, if/else, { 1 }/{ 0 - 1 }) left unchanged. Diff hand-verified; parses clean under the new compiler. Refs hyperpolymath/affinescript#218 Co-Authored-By: Claude Opus 4.7 (1M context) --- src/app/combat/PlayerHP.affine | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/app/combat/PlayerHP.affine b/src/app/combat/PlayerHP.affine index 929a379a..fbe822fc 100644 --- a/src/app/combat/PlayerHP.affine +++ b/src/app/combat/PlayerHP.affine @@ -75,10 +75,10 @@ fn max(a: Int, b: Int) -> Int { // CON is a 0-200 scaling factor; baseline 100 → 1000 (= 100.0 HP in tenths). fn make(con: Int) -> Player { let max_hp = 800 + 2 * con; - { - hp: { current: max_hp, max: max_hp }, - iframes: { remaining_ms: 0 }, - knockback: { vel_x: 0, vel_y: 0, remaining_ms: 0 } + #{ + hp: #{ current: max_hp, max: max_hp }, + iframes: #{ remaining_ms: 0 }, + knockback: #{ vel_x: 0, vel_y: 0, remaining_ms: 0 } } } @@ -97,10 +97,10 @@ fn take_damage(p: Player, amount: Int, source: Pos, player: Pos) -> Player { } else { let new_current = max(0, p.hp.current - amount); let direction = if player.x >= source.x { 1 } else { 0 - 1 }; - { - hp: { current: new_current, max: p.hp.max }, - iframes: { remaining_ms: iframe_duration_ms() }, - knockback: { + #{ + hp: #{ current: new_current, max: p.hp.max }, + iframes: #{ remaining_ms: iframe_duration_ms() }, + knockback: #{ vel_x: direction * knockback_speed(), vel_y: knockback_pop_y(), remaining_ms: knockback_duration_ms() @@ -121,19 +121,19 @@ fn update(p: Player, dt_ms: Int) -> UpdateResult { 0 }; let emit_velocity = if p.knockback.remaining_ms > 0 { - { x: p.knockback.vel_x, y: p.knockback.vel_y } + #{ x: p.knockback.vel_x, y: p.knockback.vel_y } } else { - { x: 0, y: 0 } + #{ x: 0, y: 0 } }; let new_kb = if new_kb_remaining <= 0 { - { vel_x: 0, vel_y: 0, remaining_ms: 0 } + #{ vel_x: 0, vel_y: 0, remaining_ms: 0 } } else { - { vel_x: p.knockback.vel_x, vel_y: p.knockback.vel_y, remaining_ms: new_kb_remaining } + #{ vel_x: p.knockback.vel_x, vel_y: p.knockback.vel_y, remaining_ms: new_kb_remaining } }; - { - player: { + #{ + player: #{ hp: p.hp, - iframes: { remaining_ms: new_iframe }, + iframes: #{ remaining_ms: new_iframe }, knockback: new_kb }, velocity: emit_velocity