Skip to content

Commit 2495ced

Browse files
committed
Implemented wall generators.
1 parent 6d9fa90 commit 2495ced

File tree

4 files changed

+77
-15
lines changed

4 files changed

+77
-15
lines changed

simalq/tile/scenery.hy

+39
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,45 @@
565565

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

568+
;; --------------------------------------------------------------
569+
;; * Wall generators
570+
;; --------------------------------------------------------------
571+
572+
(defclass WallGenerator [Scenery]
573+
(setv
574+
blocks-move T
575+
; Surprisingly, but per IQ, wall generators aren't diagonal
576+
; blockers.
577+
direction None)
578+
579+
(defmeth hook-player-bump [origin]
580+
(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.")
581+
(@generate)
582+
True)
583+
(defmeth hook-player-shot []
584+
"As when bumped."
585+
(@generate))
586+
587+
(defmeth generate []
588+
(for [p (ray @pos @direction Inf)]
589+
(when (at p)
590+
(break))
591+
(Tile.make p "wall"))
592+
(@replace "wall"))
593+
594+
(setv flavor "Ever wondered where all those walls come from?"))
595+
596+
(do-mac
597+
(import simalq.geometry [Direction])
598+
`(do ~@(lfor
599+
[direction iq-ix] [
600+
[Direction.N 190] [Direction.E 193]
601+
[Direction.S 191] [Direction.W 192]]
602+
:setv c (get Direction.arrows direction)
603+
`(deftile ~f"{c}|" ~f"a wall generator ({direction.name})" WallGenerator
604+
:iq-ix ~iq-ix
605+
:direction (. Direction ~(hy.models.Symbol direction.abbr))))))
606+
568607
;; --------------------------------------------------------------
569608
;; * Fountains
570609
;; --------------------------------------------------------------

simalq/tile/unimplemented.hy

-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@
3636
[184 "giant_ant"]
3737
[185 "dark_brain"]
3838
[187 "magical_mirror"]
39-
[190 "wall_generator_north"]
40-
[191 "wall_generator_south"]
41-
[192 "wall_generator_west"]
42-
[193 "wall_generator_east"]
4339
[195 "dragon_egg"]
4440
[196 "wyrm"]
4541
[197 "dragon"]

tests/test_item.hy

+17-11
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,10 @@
663663
(init [
664664
:width 30 :height 1
665665
:tiles [
666-
"pile of gold" "treasure chest" "key"
667-
"phase trigger" "phasing wall (in phase)" "cracked wall" "orc"]])
666+
"pile of gold" "wall generator (west)"
667+
"treasure chest" "key"
668+
"phase trigger" "phasing wall (in phase)"
669+
"cracked wall" "orc"]])
668670
(defn remote [x]
669671
(use-item "wand of remote action" [x 0]))
670672
(setv G.rules.reality-bubble-size 20)
@@ -674,27 +676,31 @@
674676
; Pick up gold.
675677
(remote 1)
676678
(assert (= G.score 100))
679+
; Trigger a wall generator.
680+
(remote 2)
681+
(assert-at [1 0] "wall")
682+
(assert-at [2 0] "wall")
677683
; Try to unlock a chest.
678-
(set-square [2 0] "treasure chest" "pile of gold")
679-
(cant (remote 2) "It's locked, and you're keyless at the moment.")
684+
(set-square [3 0] "treasure chest" "pile of gold")
685+
(cant (remote 3) "It's locked, and you're keyless at the moment.")
680686
; Get a key, unlock it, and get the gold.
681-
(remote 3)
687+
(remote 4)
682688
(assert (= G.player.keys 1))
683689
(assert (= G.score 150))
684-
(remote 2)
690+
(remote 3)
685691
(assert (= G.player.keys 0))
686692
(assert (= G.score 150))
687-
(remote 2)
693+
(remote 3)
688694
(assert (= G.score 250))
689695
; Hit a phase trigger.
690-
(remote 4)
691-
(assert-at [5 0] "phasing wall (out of phase)")
696+
(remote 5)
697+
(assert-at [6 0] "phasing wall (out of phase)")
692698

693699
; Things that wands of remote action can't do include:
694700
; - Break a cracked wall
695-
(cant (remote 6) nothing)
696-
; - Attack a monster
697701
(cant (remote 7) nothing)
702+
; - Attack a monster
703+
(cant (remote 8) nothing)
698704
; - Affect an empty square
699705
(cant (remote 15) nothing)
700706
; - Pick up a key when you're already full.

tests/test_scenery.hy

+21
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,27 @@
376376
(assert-at 'E "wall"))
377377

378378

379+
(defn test-wall-generator []
380+
(init [
381+
:map "
382+
. →|. . o . . .
383+
@ →|. . . . . ."])
384+
(setv G.rules.reality-bubble-size 2)
385+
386+
; Wall generators aren't limited by the reality bubble.
387+
(wk 'E)
388+
(assert-textmap "
389+
. →|. . o . . .
390+
@ ██████████████")
391+
; They can be triggered with an arrow. And they're stopped by any
392+
; nonempty tile; monsters are unhurt.
393+
(cant (wk 'NE) "That diagonal is blocked by a neighbor.")
394+
(shoot 'NE)
395+
(assert-textmap "
396+
. ██████o . . .
397+
@ ██████████████"))
398+
399+
379400
(defn test-fountains []
380401
(init [
381402
:poison-intensity (f/ 1 5)

0 commit comments

Comments
 (0)