This commit is contained in:
2026-06-23 20:07:53 -05:00
parent 2ea2ce0212
commit cbbe522fb1
5 changed files with 143 additions and 9 deletions
+11
View File
@@ -79,6 +79,12 @@ pub(crate) enum Action {
/// Add `n` to the player's gem count (negative subtracts; the count is
/// clamped at 0). Zero time cost. Applied to `GameState::player_gems`.
AddGems(i64),
/// Give (`true`) or take (`false`) the named key color from the player.
///
/// Color must be one of `"blue"`, `"green"`, `"cyan"`, `"red"`, `"purple"`,
/// `"orange"`, `"yellow"`, `"white"`. An unrecognized name is logged and
/// ignored. Zero time cost. Applied to `GameState::player_keys`.
SetKey(String, bool),
/// Remove the source object from the board. Zero time cost. Used by grab
/// things (e.g. gems) to despawn themselves from their `grab()` hook.
Die,
@@ -191,6 +197,11 @@ pub(crate) fn action_to_map(action: &Action) -> rhai::Map {
m.insert("type".into(), ds("AddGems"));
m.insert("n".into(), Dynamic::from(*n));
}
Action::SetKey(color, present) => {
m.insert("type".into(), ds("SetKey"));
m.insert("color".into(), Dynamic::from(color.clone()));
m.insert("present".into(), Dynamic::from(*present));
}
Action::Die => {
m.insert("type".into(), ds("Die"));
}