Skip to content

Commit

Permalink
Implemented wands of remote action.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodiologist committed Feb 14, 2024
1 parent 5c02f03 commit d696db6
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 1 deletion.
1 change: 1 addition & 0 deletions simalq/color.hy
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
'steel-blue [(/ 1 4) (/ 1 2) (/ 3 4)]
'pale-green [(/ 7 8) 1 (/ 7 8)]
'moss-green [(/ 1 2) (/ 3 4) (/ 1 2)]
'medium-green [0 (/ 1 2) 0]
'dark-green [0 (/ 1 4) 0]
'lime [0 1 0]})

Expand Down
5 changes: 5 additions & 0 deletions simalq/tile/__init__.hy
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@
"Called when the player tries to walk towards this tile. Return
true to end her turn."
None)
(defmeth hook-remote-action []
"Called when the player tries to use a wand of remote action on
this tile. Return true to end her turn (which you should do if and
only if there was an effect on the game state)."
None)
(defmeth hook-player-walk-from [target]
"Called when the player is about to walk from a square containing
this tile. The hook shouldn't change the game state, but it can
Expand Down
19 changes: 19 additions & 0 deletions simalq/tile/item.hy
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
(@rm-from-map))
(defmeth pick-up [])

(defmeth hook-remote-action []
(@hook-player-walk-to None)
(@hook-player-walked-into)
T)

(defmeth info-bullets [#* extra] [
(@dod "Pickup effect" 'pick-up)
#* extra
Expand Down Expand Up @@ -492,6 +497,20 @@
:flavor "Clean out the cobwebs and have yourself some barbecued goblin.")
(deftile "/ " "a wand of remote action" Usable
:color 'medium-green
:iq-ix 198
:acquirement-points 50
:use (meth [target]
"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."
(for [tile (at target)]
(when (.hook-remote-action tile)
(return)))
(raise (CommandError "There isn't anything you can affect there.")))
: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.")
;; --------------------------------------------------------------
;; ** Bombs
;; --------------------------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions simalq/tile/scenery.hy
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
protects-vs-poison-air F
emits-poison-air F)

(defmeth hook-remote-action []
"Called when the player tries to use a wand of remote action on
this tile. Return true to end her turn (which you should do if and
only if there was an effect on the game state)."
(@hook-player-bump None))

(defmeth info-bullets [#* extra]
(setv blocks-monster (or @blocks-monster @blocks-move))
(.info-bullets (super)
Expand Down Expand Up @@ -388,6 +394,9 @@
:blocks-player-shots F
:immune #(DamageType.Poison DamageType.Fire DamageType.DeathMagic)

:hook-remote-action (meth []
None)

:flavor "I think this dungeon might not be up to code.")


Expand All @@ -407,6 +416,8 @@
propagating a chain reaction.")
(@breakdown)
True)
(defmeth hook-remote-action []
None)

(defmeth hook-player-shot []
"As when bumped."
Expand Down
1 change: 0 additions & 1 deletion simalq/tile/unimplemented.hy
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
[195 "dragon_egg"]
[196 "wyrm"]
[197 "dragon"]
[198 "wand_of_remote_action"]
[202 "rotation_trap"]
[203 "krogg"]
[204 "vampire"]
Expand Down
44 changes: 44 additions & 0 deletions tests/test_item.hy
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,50 @@
(assert-hp [6 0] 10))


(defn test-wand-remote-action []
(init [
:width 30 :height 1
:tiles [
"pile of gold" "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)
(setv nothing "There isn't anything you can affect there.")

; Wands of remote action can do lots of things.
; Pick up gold.
(remote 1)
(assert (= G.score 100))
; 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.")
; Get a key, unlock it, and get the gold.
(remote 3)
(assert (= G.player.keys 1))
(assert (= G.score 150))
(remote 2)
(assert (= G.player.keys 0))
(assert (= G.score 150))
(remote 2)
(assert (= G.score 250))
; Hit a phase trigger.
(remote 4)
(assert-at [5 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)
; - Affect an empty square
(cant (remote 15) nothing)
; - Pick up a key when you're already full.
(setv G.player.keys G.rules.max-keys)
(set-square 'E "key")
(cant (remote 1) "Your keyring has no room for another key."))


(defn test-fire-bomb []
"Put some orcs in a line and check how much damage is done to each."

Expand Down

0 comments on commit d696db6

Please sign in to comment.