Skip to content

Commit d696db6

Browse files
committed
Implemented wands of remote action.
1 parent 5c02f03 commit d696db6

File tree

6 files changed

+80
-1
lines changed

6 files changed

+80
-1
lines changed

simalq/color.hy

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
'steel-blue [(/ 1 4) (/ 1 2) (/ 3 4)]
2828
'pale-green [(/ 7 8) 1 (/ 7 8)]
2929
'moss-green [(/ 1 2) (/ 3 4) (/ 1 2)]
30+
'medium-green [0 (/ 1 2) 0]
3031
'dark-green [0 (/ 1 4) 0]
3132
'lime [0 1 0]})
3233

simalq/tile/__init__.hy

+5
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@
184184
"Called when the player tries to walk towards this tile. Return
185185
true to end her turn."
186186
None)
187+
(defmeth hook-remote-action []
188+
"Called when the player tries to use a wand of remote action on
189+
this tile. Return true to end her turn (which you should do if and
190+
only if there was an effect on the game state)."
191+
None)
187192
(defmeth hook-player-walk-from [target]
188193
"Called when the player is about to walk from a square containing
189194
this tile. The hook shouldn't change the game state, but it can

simalq/tile/item.hy

+19
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
(@rm-from-map))
3434
(defmeth pick-up [])
3535

36+
(defmeth hook-remote-action []
37+
(@hook-player-walk-to None)
38+
(@hook-player-walked-into)
39+
T)
40+
3641
(defmeth info-bullets [#* extra] [
3742
(@dod "Pickup effect" 'pick-up)
3843
#* extra
@@ -492,6 +497,20 @@
492497
493498
:flavor "Clean out the cobwebs and have yourself some barbecued goblin.")
494499
500+
(deftile "/ " "a wand of remote action" Usable
501+
:color 'medium-green
502+
:iq-ix 198
503+
:acquirement-points 50
504+
505+
:use (meth [target]
506+
"Performs an action on the topmost applicable tile on the square. Scenery that has a special effect when bumped, such as phase triggers, can be activated, and items can be picked up."
507+
(for [tile (at target)]
508+
(when (.hook-remote-action tile)
509+
(return)))
510+
(raise (CommandError "There isn't anything you can affect there.")))
511+
512+
:flavor "This wand bears an uncanny resemblance to a grabber arm, and is nearly as useful. Many a wizard has used one to eat tortilla chips from across the room. Now this power is yours.")
513+
495514
;; --------------------------------------------------------------
496515
;; ** Bombs
497516
;; --------------------------------------------------------------

simalq/tile/scenery.hy

+11
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
protects-vs-poison-air F
3535
emits-poison-air F)
3636

37+
(defmeth hook-remote-action []
38+
"Called when the player tries to use a wand of remote action on
39+
this tile. Return true to end her turn (which you should do if and
40+
only if there was an effect on the game state)."
41+
(@hook-player-bump None))
42+
3743
(defmeth info-bullets [#* extra]
3844
(setv blocks-monster (or @blocks-monster @blocks-move))
3945
(.info-bullets (super)
@@ -388,6 +394,9 @@
388394
:blocks-player-shots F
389395
:immune #(DamageType.Poison DamageType.Fire DamageType.DeathMagic)
390396

397+
:hook-remote-action (meth []
398+
None)
399+
391400
:flavor "I think this dungeon might not be up to code.")
392401

393402

@@ -407,6 +416,8 @@
407416
propagating a chain reaction.")
408417
(@breakdown)
409418
True)
419+
(defmeth hook-remote-action []
420+
None)
410421

411422
(defmeth hook-player-shot []
412423
"As when bumped."

simalq/tile/unimplemented.hy

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
[195 "dragon_egg"]
5252
[196 "wyrm"]
5353
[197 "dragon"]
54-
[198 "wand_of_remote_action"]
5554
[202 "rotation_trap"]
5655
[203 "krogg"]
5756
[204 "vampire"]

tests/test_item.hy

+44
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,50 @@
578578
(assert-hp [6 0] 10))
579579

580580

581+
(defn test-wand-remote-action []
582+
(init [
583+
:width 30 :height 1
584+
:tiles [
585+
"pile of gold" "treasure chest" "key"
586+
"phase trigger" "phasing wall (in phase)" "cracked wall" "orc"]])
587+
(defn remote [x]
588+
(use-item "wand of remote action" x 0))
589+
(setv G.rules.reality-bubble-size 20)
590+
(setv nothing "There isn't anything you can affect there.")
591+
592+
; Wands of remote action can do lots of things.
593+
; Pick up gold.
594+
(remote 1)
595+
(assert (= G.score 100))
596+
; Try to unlock a chest.
597+
(set-square [2 0] "treasure chest" "pile of gold")
598+
(cant (remote 2) "It's locked, and you're keyless at the moment.")
599+
; Get a key, unlock it, and get the gold.
600+
(remote 3)
601+
(assert (= G.player.keys 1))
602+
(assert (= G.score 150))
603+
(remote 2)
604+
(assert (= G.player.keys 0))
605+
(assert (= G.score 150))
606+
(remote 2)
607+
(assert (= G.score 250))
608+
; Hit a phase trigger.
609+
(remote 4)
610+
(assert-at [5 0] "phasing wall (out of phase)")
611+
612+
; Things that wands of remote action can't do include:
613+
; - Break a cracked wall
614+
(cant (remote 6) nothing)
615+
; - Attack a monster
616+
(cant (remote 7) nothing)
617+
; - Affect an empty square
618+
(cant (remote 15) nothing)
619+
; - Pick up a key when you're already full.
620+
(setv G.player.keys G.rules.max-keys)
621+
(set-square 'E "key")
622+
(cant (remote 1) "Your keyring has no room for another key."))
623+
624+
581625
(defn test-fire-bomb []
582626
"Put some orcs in a line and check how much damage is done to each."
583627

0 commit comments

Comments
 (0)