Skip to content

Commit fbeec50

Browse files
committed
Implemented weakness traps.
1 parent 20532e7 commit fbeec50

File tree

5 files changed

+57
-5
lines changed

5 files changed

+57
-5
lines changed

simalq/game_state.hy

+3
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@
160160
; How much damage the player does with her sword normally.
161161
player-melee-damage-artifact 3
162162
; How much with the relevant artifact.
163+
player-melee-damage-weakness-reduction 1
164+
; How much the player's sword damage is reduced by while she's
165+
; weak.
163166
player-shot-damage-base 1
164167
; How much damage the player does with her bow normally.
165168
player-shot-damage-artifact 2

simalq/tile/scenery.hy

+11
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,17 @@
764764
765765
:flavor "This spiderweb is the size of a really big spiderweb. Until Idok cleans up the dungeon properly, you'll have to tediously carve your way through the webs with your sword. Got any recommendations for a good smitemaster?")
766766
767+
(deftile "<>" "a weakness trap" Trap
768+
:color 'magenta
769+
:iq-ix 201
770+
771+
:!duration 12
772+
:hook-player-walked-into (meth []
773+
(doc f"Makes you weak for {@duration} more turns, reducing the damage of your sword strikes by {G.rules.player-melee-damage-weakness-reduction}.")
774+
(.add StatusEffect.Weak @duration))
775+
776+
:flavor "This complex gadget swiftly adorns Tris with impractical hyperfeminine attire, including a frilly pink dress and stiletto heels. It will take more than that to extinguish Tris's indomitable tomboyish fighting spirit; still, the new duds make fighting a bit awkward. Fortunately, these are all disposable fast-fashion items made solely for the 'Gram #ootd, and will disintegrate in moments.")
777+
767778
(deftile "<>" "an anti-magic trap" Trap
768779
:color 'blue
769780
:iq-ix 169

simalq/tile/unimplemented.hy

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
[196 "wyrm"]
5656
[197 "dragon"]
5757
[198 "wand_of_remote_action"]
58-
[201 "weakness_trap"]
5958
[202 "rotation_trap"]
6059
[203 "krogg"]
6160
[204 "vampire"]

simalq/util.hy

+7-3
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,13 @@
9393

9494
(defn player-melee-damage []
9595
"Return how much damage the player does with her sword."
96-
(if (get G.player.artifacts "Holy Sword")
97-
G.rules.player-melee-damage-artifact
98-
G.rules.player-melee-damage-base))
96+
(-
97+
(if (get G.player.artifacts "Holy Sword")
98+
G.rules.player-melee-damage-artifact
99+
G.rules.player-melee-damage-base)
100+
(if (.player-has? StatusEffect.Weak)
101+
G.rules.player-melee-damage-weakness-reduction
102+
0)))
99103

100104
(defn player-shot-damage [magic]
101105
"Return how much damage the player does with her bow."

tests/test_scenery.hy

+36-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
(import
55
fractions [Fraction :as f/]
66
pytest
7-
tests.lib [init init-boot-camp locate assert-at assert-full-name assert-textmap set-square mv-player assert-player-at wk wait shoot use-item use-cport]
7+
tests.lib [init init-boot-camp locate assert-at assert-hp assert-full-name assert-textmap set-square mv-player assert-player-at wk wait shoot use-item use-cport]
88
simalq.util [GameOverException StatusEffect]
99
simalq.geometry [at Pos]
1010
simalq.game-state [G]
@@ -657,6 +657,41 @@
657657
(assert (= (get G.player.status-effects StatusEffect.Para) 2)))
658658

659659

660+
(defn test-weakness-trap []
661+
662+
(init
663+
[:tiles ["weakness trap" ["orc" :hp 10]]])
664+
; Get weakened.
665+
(wk 'E)
666+
; The weakness trap is still there.
667+
(assert-at 'here 'player "weakness trap")
668+
; Hit the orc. While Tris is weak, her sword does only 1 damage.
669+
(assert-hp 'E 10)
670+
(wk 'E)
671+
(assert-hp 'E 9)
672+
; Arrows are unaffected; they still do 1 damage.
673+
(shoot 'E)
674+
(assert-hp 'E 8)
675+
; Likewise, magic arrows still do 3 damage.
676+
(setv G.player.magic-arrows 1)
677+
(shoot 'E)
678+
(assert-hp 'E 5)
679+
680+
; In IQ, the result of being weak while having the Holy Sword
681+
; depends on the order in which you get these effects. This is
682+
; undocumented and probably a bug. In SQ, the two effects cancel out
683+
; (making your sword do 2 damage), regardless of order.
684+
(for [reverse? [F T]]
685+
(setv ts ["Holy Sword" "weakness trap"])
686+
(when reverse?
687+
(setv ts (reversed ts)))
688+
(init [
689+
:height 1
690+
:tiles [#* ts ["orc" :hp 10]]])
691+
(wk 'E 3)
692+
(assert-hp 'E 8)))
693+
694+
660695
(defn test-anti-magic-trap []
661696

662697
(init [:tiles [

0 commit comments

Comments
 (0)