Skip to content

Commit 7f7f74e

Browse files
committed
Implemented archmagi.
1 parent 975d169 commit 7f7f74e

File tree

5 files changed

+71
-15
lines changed

5 files changed

+71
-15
lines changed

simalq/color.hy

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
flash-label 'white
4747
flash-player-damaged 'red
48+
flash-player-hit-by-special-attack 'orange
4849
flash-player-shot-mundane 'blue
4950
flash-player-shot-magic 'purple
5051

simalq/tile/monster.hy

+21
Original file line numberDiff line numberDiff line change
@@ -705,3 +705,24 @@
705705
:damage-shot 10
706706
707707
:flavor "A wretched organic structure, fashioned from fiendish flesh. It twists about to aim its toothy maw, from which it belches flame. It's immobile, but dark magics make it almost invulnerable… almost.")
708+
709+
710+
(deftile "W " "an archmage" Approacher
711+
:iq-ix 163
712+
:destruction-points 75
713+
714+
:damage-melee 2
715+
:damage-shot 12
716+
:sees-invisible T
717+
718+
:act (meth []
719+
(doc (.format "Disenchant — If it's not adjacent but has line of effect to you, the monster removes the first beneficial status effect that you have from the following list: {}. Otherwise, it behaves per `Approach`."
720+
(.join ", " (gfor e (StatusEffect.disenchantable) e.name))))
721+
(if (and
722+
(not (adjacent? @pos G.player.pos))
723+
(@try-to-attack-player :dry-run T)
724+
(StatusEffect.disenchant-player))
725+
(.animate-hit G.player @ " " :special-color? T)
726+
(@approach)))
727+
728+
:flavor "A professor emeritus whose killer instincts have been honed by decades of publishing and not perishing. His canny eye can detect the least visible academic politics, and his mastery of grant-review panels has bought him the reagents for powerful spells. But even with the best health insurance in the land, he's found that aging has taken its toll: he can no longer cane the young folk with the vigor of his early years.")

simalq/tile/player.hy

+21-14
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,8 @@
6363
(* G.rules.artifact-shield-factor amount)))))
6464

6565
(when animate
66-
(flash-map
67-
@pos
68-
colors.flash-player-damaged
69-
(+
70-
(if (and attacker attacker.pos)
71-
(ray @pos
72-
(dir-to @pos attacker.pos)
73-
(dist @pos attacker.pos))
74-
#())
75-
(if (.player-has? StatusEffect.Ivln)
76-
#()
77-
#(@pos)))
78-
{@pos (if (> amount 99) "OW" (format amount "2"))}
79-
:flash-time-s .2))
66+
(@animate-hit attacker :show-ivln? F
67+
:label (if (> amount 99) "OW" (format amount "2"))))
8068

8169
(setv hp-was @hp)
8270
(unless (.player-has? StatusEffect.Ivln)
@@ -90,6 +78,25 @@
9078
:destroy (meth []
9179
(raise (GameOverException 'dead)))
9280

81+
:!animate-hit (meth [attacker label [special-color? F] [show-ivln? T]]
82+
"Use `flash-map` to indicate that the player's been hit."
83+
(flash-map
84+
@pos
85+
(if special-color?
86+
colors.flash-player-hit-by-special-attack
87+
colors.flash-player-damaged)
88+
(+
89+
(if (and attacker attacker.pos)
90+
(ray @pos
91+
(dir-to @pos attacker.pos)
92+
(dist @pos attacker.pos))
93+
#())
94+
(if (and (not show-ivln?) (.player-has? StatusEffect.Ivln))
95+
#()
96+
#(@pos)))
97+
{@pos label}
98+
:flash-time-s .2))
99+
93100
:flavor "People who've met Tris and Argonn separately are sometimes surprised to learn that they're siblings. They don't look much alike.")
94101

95102
(setv Player (get Tile.types "Princess Triskaidecagonn XIII"))

simalq/tile/unimplemented.hy

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
[154 "wand_of_flame"]
3636
[158 "ring_of_protection"]
3737
[159 "amulet_of_poisonous_touch"]
38-
[163 "archmage"]
3938
[164 "cyclops"]
4039
[165 "dark_prince"]
4140
[166 "blind_mage"]

tests/test_monster.hy

+28
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
(import
44
fractions [Fraction :as f/]
55
tests.lib [init assert-at assert-full-name assert-hp wait set-square wk shoot mv-player use-item top]
6+
simalq.util [StatusEffect]
67
simalq.geometry [Direction Pos ray at burst]
78
simalq.game-state [G])
89
(setv T True F False)
@@ -721,3 +722,30 @@
721722
(use-item "wand of death" 0 0)
722723
(assert-at 'NE 'floor)
723724
(assert (= G.score 150)))
725+
726+
727+
(defn test-archmage []
728+
(init [:tiles [
729+
"archmage"
730+
'floor
731+
"cloak of invisibility"
732+
"cloak of invisibility"]])
733+
734+
(mv-player 2 0)
735+
(assert (= G.player.hp 100))
736+
; The shot of an archmage can disenchant, in which case it does no
737+
; damage.
738+
(wk 'E)
739+
(assert (not (.player-has? StatusEffect.Ivis)))
740+
(assert (= G.player.hp 100))
741+
; Without disenchantment, it does 12 damage.
742+
(wait)
743+
(assert (= G.player.hp 88))
744+
; The melee attack of an archmage always does 2 damage and never
745+
; disenchants.
746+
(set-square [1 0])
747+
(wk 'E)
748+
(set-square 'E "archmage")
749+
(wait)
750+
(assert (.player-has? StatusEffect.Ivis))
751+
(assert (= G.player.hp 86)))

0 commit comments

Comments
 (0)