add_gems -> alter_gems

This commit is contained in:
2026-07-07 23:58:51 -05:00
parent 23b5bf2afb
commit e43dae54a8
7 changed files with 18 additions and 18 deletions
+2 -2
View File
@@ -70,7 +70,7 @@ pub struct GameState {
/// The game-global player state (health, gems, keys) — see [`Player`]. Not
/// per-board: it persists across board transitions, unlike the per-board
/// position in [`Board::player`](crate::board::Board::player). Scripts mutate
/// it via `add_gems`/`alter_health`/`set_key` and read a snapshot of it.
/// it via `alter_gems`/`alter_health`/`set_key` and read a snapshot of it.
pub player: PlayerRef,
}
@@ -477,7 +477,7 @@ impl GameState {
return;
}
// Fire the grab hook and resolve it immediately so the grabbed thing's
// die()/add_gems() apply now — no player+object overlap survives this call.
// die()/alter_gems() apply now — no player+object overlap survives this call.
if let Some(id) = grabbed {
self.scripts.run_grab(id);
self.resolve();
+3 -3
View File
@@ -28,7 +28,7 @@
//! `move(dir)`, `delay(secs)`, `now()`, `set_tile(n)`, `log(msg)`, `say(msg)`,
//! `set_fg(fg)`, `set_bg(bg)`, `set_color(fg, bg)`, `set_tag(target, tag, present)`,
//! `send(target_id, fn_name [, arg])`, `teleport(x, y)`, `push(x, y, dir)`,
//! `shift([[x, y], …])`, `add_gems(n)`, `alter_health(dh)`, `set_key(color, present)`, `die()`
//! `shift([[x, y], …])`, `alter_gems(n)`, `alter_health(dh)`, `set_key(color, present)`, `die()`
use crate::action::{Action, BoardAction, ScrollLine, SendArg, MOVE_COST};
use crate::game::SAY_DURATION;
@@ -377,9 +377,9 @@ fn register_write_api(engine: &mut Engine, board: BoardRef) {
emit(&b, source_of(&ctx), Action::SetTile(tile as u32));
});
// add_gems(n): change the player's gem count (negative subtracts; clamped at 0).
// alter_gems(n): change the player's gem count (negative subtracts; clamped at 0).
let b = board.clone();
engine.register_fn("add_gems", move |ctx: NativeCallContext, n: i64| {
engine.register_fn("alter_gems", move |ctx: NativeCallContext, n: i64| {
emit(&b, source_of(&ctx), Action::AddGems(n));
});
+1 -1
View File
@@ -4,6 +4,6 @@
// player) fires this `grab()` hook instead of blocking. We bump the player's gem
// count and remove ourselves from the board.
fn grab(me) {
add_gems(1);
alter_gems(1);
die();
}