Skip to content

Commit

Permalink
Implemented one-shot damaging traps.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodiologist committed Jan 21, 2024
1 parent 5ab1b3e commit 789ae27
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
29 changes: 23 additions & 6 deletions simalq/tile/scenery.hy
Original file line number Diff line number Diff line change
Expand Up @@ -630,16 +630,33 @@
:flavor "The special thing about this wall is that it can be destroyed by wallfall traps of the corresponding type.\n\nWhat's the deal with monster closets? Monsters are proud of who they are, am I right? I'll be here all week.")
(deftile "<>" "a fixed damaging trap" Trap
(defclass DamagingTrap [Trap]
(setv trap-damage 5)
(setv one-shot? F)
(defmeth hook-player-walked-into []
(doc (+ f"Does {@trap-damage} damage." (if @one-shot?
" Then, the tile is destroyed."
"")))
(.damage G.player @trap-damage DamageType.Trap)
(when @one-shot?
(@rm-from-map))))
(deftile "<>" "a fixed damaging trap" DamagingTrap
:color 'red
:iq-ix 35 ; damage-causing trap
:hook-player-walked-into (meth []
(doc f"Does {trap-damage} damage.")
(.damage G.player trap-damage DamageType.Trap))
:flavor "A dense assortment of pointy, painful objects that can penetrate the toughest footwear.")
(setv trap-damage 5)
(deftile "<>" "a one-shot damaging trap" DamagingTrap
:color 'dark-orange
:iq-ix 199 ; random-damage trap
:one-shot? T
:flavor "A tiny hole in the floor that shoots a ball bearing in your eye with uncanny accuracy. Fortunately, it has only one shot.")
(deftile "<>" "a paralysis trap" Trap
:color 'purple
Expand Down
1 change: 0 additions & 1 deletion simalq/tile/unimplemented.hy
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
[196 "wyrm"]
[197 "dragon"]
[198 "wand_of_remote_action"]
[199 "random_damage_trap"]
[201 "weakness_trap"]
[202 "rotation_trap"]
[203 "krogg"]
Expand Down
10 changes: 8 additions & 2 deletions tests/test_scenery.hy
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@

(defn test-damaging-trap []
(init
[:tiles ["fixed damaging trap"]])
[:tiles ["fixed damaging trap" "one-shot damaging trap"]])

(assert (= G.player.hp 100))
; Step on the trap, taking 5 damage.
Expand All @@ -557,7 +557,13 @@
; trap remains.
(wait)
(assert (= G.player.hp 95))
(assert-at 'here ['player "fixed damaging trap"]))
(assert-at 'here ['player "fixed damaging trap"])
; The other kind of damaging trap is destroyed after being triggered
; once.
(assert-at 'E "one-shot damaging trap")
(wk 'E)
(assert (= G.player.hp 90))
(assert-at 'here 'player))


(defn test-paralysis-trap []
Expand Down

0 comments on commit 789ae27

Please sign in to comment.