Skip to content

Commit

Permalink
Implemented wall generators.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodiologist committed Feb 18, 2024
1 parent 6d9fa90 commit 2495ced
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 15 deletions.
39 changes: 39 additions & 0 deletions simalq/tile/scenery.hy
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,45 @@

:flavor "Where do video games get all their crates from? There must be entire warehouses full of 'em, am I right?")

;; --------------------------------------------------------------
;; * Wall generators
;; --------------------------------------------------------------

(defclass WallGenerator [Scenery]
(setv
blocks-move T
; Surprisingly, but per IQ, wall generators aren't diagonal
; blockers.
direction None)

(defmeth hook-player-bump [origin]
(doc f"Creates a line of walls to the {@direction.name}, stopping at the first nonempty square. The wall generator itself then reverts to a normal wall.")
(@generate)
True)
(defmeth hook-player-shot []
"As when bumped."
(@generate))

(defmeth generate []
(for [p (ray @pos @direction Inf)]
(when (at p)
(break))
(Tile.make p "wall"))
(@replace "wall"))

(setv flavor "Ever wondered where all those walls come from?"))

(do-mac
(import simalq.geometry [Direction])
`(do ~@(lfor
[direction iq-ix] [
[Direction.N 190] [Direction.E 193]
[Direction.S 191] [Direction.W 192]]
:setv c (get Direction.arrows direction)
`(deftile ~f"{c}|" ~f"a wall generator ({direction.name})" WallGenerator
:iq-ix ~iq-ix
:direction (. Direction ~(hy.models.Symbol direction.abbr))))))

;; --------------------------------------------------------------
;; * Fountains
;; --------------------------------------------------------------
Expand Down
4 changes: 0 additions & 4 deletions simalq/tile/unimplemented.hy
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
[184 "giant_ant"]
[185 "dark_brain"]
[187 "magical_mirror"]
[190 "wall_generator_north"]
[191 "wall_generator_south"]
[192 "wall_generator_west"]
[193 "wall_generator_east"]
[195 "dragon_egg"]
[196 "wyrm"]
[197 "dragon"]
Expand Down
28 changes: 17 additions & 11 deletions tests/test_item.hy
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,10 @@
(init [
:width 30 :height 1
:tiles [
"pile of gold" "treasure chest" "key"
"phase trigger" "phasing wall (in phase)" "cracked wall" "orc"]])
"pile of gold" "wall generator (west)"
"treasure chest" "key"
"phase trigger" "phasing wall (in phase)"
"cracked wall" "orc"]])
(defn remote [x]
(use-item "wand of remote action" [x 0]))
(setv G.rules.reality-bubble-size 20)
Expand All @@ -674,27 +676,31 @@
; Pick up gold.
(remote 1)
(assert (= G.score 100))
; Trigger a wall generator.
(remote 2)
(assert-at [1 0] "wall")
(assert-at [2 0] "wall")
; Try to unlock a chest.
(set-square [2 0] "treasure chest" "pile of gold")
(cant (remote 2) "It's locked, and you're keyless at the moment.")
(set-square [3 0] "treasure chest" "pile of gold")
(cant (remote 3) "It's locked, and you're keyless at the moment.")
; Get a key, unlock it, and get the gold.
(remote 3)
(remote 4)
(assert (= G.player.keys 1))
(assert (= G.score 150))
(remote 2)
(remote 3)
(assert (= G.player.keys 0))
(assert (= G.score 150))
(remote 2)
(remote 3)
(assert (= G.score 250))
; Hit a phase trigger.
(remote 4)
(assert-at [5 0] "phasing wall (out of phase)")
(remote 5)
(assert-at [6 0] "phasing wall (out of phase)")

; Things that wands of remote action can't do include:
; - Break a cracked wall
(cant (remote 6) nothing)
; - Attack a monster
(cant (remote 7) nothing)
; - Attack a monster
(cant (remote 8) nothing)
; - Affect an empty square
(cant (remote 15) nothing)
; - Pick up a key when you're already full.
Expand Down
21 changes: 21 additions & 0 deletions tests/test_scenery.hy
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,27 @@
(assert-at 'E "wall"))


(defn test-wall-generator []
(init [
:map "
. →|. . o . . .
@ →|. . . . . ."])
(setv G.rules.reality-bubble-size 2)

; Wall generators aren't limited by the reality bubble.
(wk 'E)
(assert-textmap "
. →|. . o . . .
@ ██████████████")
; They can be triggered with an arrow. And they're stopped by any
; nonempty tile; monsters are unhurt.
(cant (wk 'NE) "That diagonal is blocked by a neighbor.")
(shoot 'NE)
(assert-textmap "
. ██████o . . .
@ ██████████████"))


(defn test-fountains []
(init [
:poison-intensity (f/ 1 5)
Expand Down

0 comments on commit 2495ced

Please sign in to comment.