- commit
- 68543081ff6b75d8c677efe5e57d8424db178d2b
- parent
- 41275417806b970637afb2b06761bef9fc7f0c5c
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2024-10-05 22:51
fix: die on 0 health
Diffstat
| M | monster.go | 2 | +- |
| M | player.go | 2 | +- |
2 files changed, 2 insertions, 2 deletions
diff --git a/monster.go b/monster.go
@@ -51,7 +51,7 @@ func (monster *Monster) run() {
51 51
52 52 func (monster *Monster) TakeDamage(attack float64) {
53 53 amount := attack * attack / (attack + monster.Defense)
54 -1 if amount > monster.Health {
-1 54 if amount >= monster.Health {
55 55 monster.quit <- true
56 56 delete(monster.Game.Monsters, monster)
57 57 monster.Game.addToPile(monster.Pos, RandomItem(), 1)
diff --git a/player.go b/player.go
@@ -43,7 +43,7 @@ func (player *Player) Flush() {
43 43
44 44 func (player *Player) TakeDamage(attack float64) {
45 45 amount := uint(math.Round(attack * attack / (attack + player.Defense)))
46 -1 if amount > player.Health {
-1 46 if amount >= player.Health {
47 47 player.Game.removePlayer(player)
48 48 } else {
49 49 player.Health -= amount