From 1aaac5158dd4b0de9e73ea362a7cb2134730f8af Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Fri, 15 Dec 2023 16:24:27 -0500 Subject: [PATCH] Converted `replace-tile` to a method `Tile.replace`. --- simalq/tile/__init__.hy | 11 +++++------ simalq/tile/scenery.hy | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/simalq/tile/__init__.hy b/simalq/tile/__init__.hy index 907a0bd..2d03558 100644 --- a/simalq/tile/__init__.hy +++ b/simalq/tile/__init__.hy @@ -92,6 +92,11 @@ (.insert (at pos) 0 @) (object.__setattr__ @ "pos" pos)) + (defmeth replace [new-stem] + (setv + (get (at @pos) (.index (at @pos) @)) + ((get Tile.types new-stem) :pos @pos))) + ; The below variables and methods may be overridden by subclasses. (setv @@ -233,12 +238,6 @@ cls) -(defn replace-tile [old new-stem] - (setv - (get (at old.pos) (.index (at old.pos) old)) - ((get Tile.types new-stem) :pos old.pos))) - - (defclass Actor [Tile] "A kind of tile (typically a monster) that gets to do something each turn that it's in the reality bubble." diff --git a/simalq/tile/scenery.hy b/simalq/tile/scenery.hy index 3c85d7a..0b25b1d 100644 --- a/simalq/tile/scenery.hy +++ b/simalq/tile/scenery.hy @@ -5,7 +5,7 @@ simalq.color :as color simalq.util [CommandError DamageType next-in-cycle StatusEffect] simalq.geometry [Pos Direction pos+ at burst dist dir-to] - simalq.tile [Tile EachTurner Damageable deftile replace-tile] + simalq.tile [Tile EachTurner Damageable deftile] simalq.game-state [G]) (setv T True F False) @@ -166,7 +166,7 @@ (raise (CommandError "It's locked, and you're keyless at the moment."))) (-= G.player.keys 1) (if @result-when-opened - (replace-tile @ @result-when-opened) + (@replace @result-when-opened) (@rm-from-map)) True))