Skip to content

Commit d13e923

Browse files
committed
Implemented magical keys.
1 parent 097b2fb commit d13e923

File tree

4 files changed

+51
-4
lines changed

4 files changed

+51
-4
lines changed

simalq/tile/item.hy

+12
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,18 @@
327327
f"Protects you (for {@duration} more turns) from harmful status effects and disenchantment.")
328328
:flavor "Also known as a ring of anti-anti-magic. Fortunately, anti-anti-anti-magic traps are still in dungeon R&D.")
329329
330+
(deftile "" "a magical key" StatusEffectItem
331+
:color 'purple
332+
:iq-ix 183
333+
:acquirement-points 100
334+
335+
:effect StatusEffect.MKey
336+
:duration 12
337+
338+
:help (meth []
339+
f"Grants you a magical key for {@duration} more turns. In this state, you can open scenery objects that would require a key without actually using one. Furthermore, you can open metal doors, and bumping into a one-way door turns it into a normal door (even if its direction is such that you could normally enter it).")
340+
:flavor "A huge key blinged out with a nearly-as-huge finely cut amethyst. It's so powerful that within a few moments of being activated by your body heat, it opens itself, leaving only a shiny dust that has too many heavy metals to be useful as glitter.")
341+
330342
;; --------------------------------------------------------------
331343
;; * Usables
332344
;; --------------------------------------------------------------

simalq/tile/scenery.hy

+14-3
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,10 @@
205205
f"replace the tile with {(. Tile types [@result-when-opened] name-with-article)}."
206206
"destroy the tile.")))
207207

208-
(unless G.player.keys
209-
(raise (CommandError "It's locked, and you're keyless at the moment.")))
210-
(-= G.player.keys 1)
208+
(unless (.player-has? StatusEffect.MKey)
209+
(unless G.player.keys
210+
(raise (CommandError "It's locked, and you're keyless at the moment.")))
211+
(-= G.player.keys 1))
211212
(if @result-when-opened
212213
(@replace @result-when-opened)
213214
(@rm-from-map))
@@ -270,6 +271,11 @@
270271

271272
:blocks-move T
272273

274+
:hook-player-bump (meth [origin]
275+
(when (.player-has? StatusEffect.MKey)
276+
(@rm-from-map)
277+
T))
278+
273279
:flavor "This massive slab of steel will certainly not be opened with a sad little bargain-basement skeleton key. Your best bet is looking for a remote switch of some kind.")
274280

275281
(deftile "+|" "a metal-door control" Scenery
@@ -309,6 +315,11 @@
309315
direction None
310316
color #('brown 'red))
311317

318+
(defmeth hook-player-bump [origin]
319+
(when (.player-has? StatusEffect.MKey)
320+
(@replace "door")
321+
T))
322+
312323
(defmeth hook-player-walk-from [target]
313324
(doc f"Only allows you to walk {@direction.name}.")
314325
(unless (= (+ @pos @direction) target)

simalq/tile/unimplemented.hy

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
[178 "magical_barrier_generator"]
3939
[179 "magical_barrier_east"]
4040
[180 "magical_barrier_north"]
41-
[183 "magical_key"]
4241
[184 "giant_ant"]
4342
[185 "dark_brain"]
4443
[187 "magical_mirror"]

tests/test_item.hy

+25
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,31 @@
353353
(check 88 F T))
354354

355355

356+
(defn test-magical-key []
357+
358+
(setv becomes {
359+
'floor 'floor
360+
"locked door" "door"
361+
"door" "door"
362+
"locked disappearing door" 'floor
363+
"closed portcullis" "closed portcullis"
364+
; The portcullis will open, but then close again after we walk
365+
; through it.
366+
"treasure chest" 'floor
367+
"one-way door (east)" "door"
368+
"one-way door (north)" "door"
369+
"metal door" 'floor})
370+
(init [:tiles [
371+
"magical key" "magical key"
372+
#* (.keys becomes)
373+
'floor "wall"]])
374+
375+
(wk 'E 19)
376+
(cant (wk 'E) "Your way is blocked.")
377+
(for [[i result] (enumerate (.values becomes))]
378+
(assert-at [(+ i 3) 0] result)))
379+
380+
356381
(defn test-inventory []
357382
(init [:tiles [
358383
"wand of shielding" "wall-making wand"

0 commit comments

Comments
 (0)