From 586409be1f98355a3bd7e99fb6afcbbf94fafc69 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Fri, 26 Jan 2024 15:25:59 -0500 Subject: [PATCH] Added a method `StatusEffect.add`. --- simalq/main.hy | 6 +++--- simalq/tile/item.hy | 13 +++++-------- simalq/tile/scenery.hy | 6 ++---- simalq/util.hy | 3 +++ 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/simalq/main.hy b/simalq/main.hy index 65009e9..db7415e 100644 --- a/simalq/main.hy +++ b/simalq/main.hy @@ -107,9 +107,9 @@ (.damage G.player G.rules.poison-emitter-damage DamageType.Poison))) ; Tick down status effects. - (for [se (list G.player.status-effects)] - (when (get G.player.status-effects se) - (-= (get G.player.status-effects se) 1))) + (for [se StatusEffect] + (when (.player-has? se) + (.add se -1))) ; Tick down the time limit. (when G.time-left diff --git a/simalq/tile/item.hy b/simalq/tile/item.hy index ec38951..c0d9e94 100644 --- a/simalq/tile/item.hy +++ b/simalq/tile/item.hy @@ -249,17 +249,14 @@ (defmeth pick-up [] (doc (@help)) - (+= - (get G.player.status-effects - (getattr StatusEffect (str @effect))) - @duration))) + (.add @effect @duration))) (deftile "! " "an amulet of invulnerability" StatusEffectItem :color 'dark-yellow :iq-ix 26 :acquirement-points 100 - :effect 'Ivln + :effect StatusEffect.Ivln :duration 20 :help (meth [] @@ -271,7 +268,7 @@ :iq-ix 151 :acquirement-points 150 - :effect 'Pass + :effect StatusEffect.Pass :duration 20 :help (meth [] @@ -283,7 +280,7 @@ :iq-ix 34 :acquirement-points 100 - :effect 'Fast + :effect StatusEffect.Fast :duration 10 :help (meth [] @@ -295,7 +292,7 @@ :iq-ix 25 :acquirement-points 100 - :effect 'Ivis + :effect StatusEffect.Ivis :duration 25 :help (meth [] diff --git a/simalq/tile/scenery.hy b/simalq/tile/scenery.hy index 053bf17..68f43a6 100644 --- a/simalq/tile/scenery.hy +++ b/simalq/tile/scenery.hy @@ -705,8 +705,7 @@ :hook-player-walked-into (meth [] (doc f"Paralyzes you for {G.rules.paralysis-duration} turns. While you're paralyzed, waiting is the only action you can take.") - (+= (get G.player.status-effects StatusEffect.Para) - G.rules.paralysis-duration)) + (.add StatusEffect.Para G.rules.paralysis-duration)) :flavor "A magical field that causes you to vividly remember something embarrassing that you did as a teenager, forcing you to briefly freeze in horror. The problem with being royalty is that awkward adolescent moments all too easily become international incidents.") @@ -717,8 +716,7 @@ :blocks-move F :blocks-monster T :hook-player-walked-into (meth [] (doc f"The tile is destroyed, but you're paralyzed for {G.rules.paralysis-duration} turns.") - (+= (get G.player.status-effects StatusEffect.Para) - G.rules.paralysis-duration) + (.add StatusEffect.Para G.rules.paralysis-duration) (@rm-from-map)) :flavor "This spiderweb is the size of a really big spiderweb. Until Idok cleans up the dungeon properly, you'll have to tediously carve your way through the webs with your sword. Got any recommendations for a good smitemaster?") diff --git a/simalq/util.hy b/simalq/util.hy index 75c5077..3162af5 100644 --- a/simalq/util.hy +++ b/simalq/util.hy @@ -139,6 +139,9 @@ "Does the player have this status effect?" (bool (get G.player.status-effects @))) + (defmeth add [duration] + (+= (get G.player.status-effects @) duration)) + (defmeth bad? [] (in @ [StatusEffect.Para StatusEffect.Weak])))