- commit
- b1859bef6759d291135d8355f6f54308c1af6f95
- parent
- 817901d5e3c990f8e1b2cee52965abe4e8c92f78
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2024-10-05 07:36
implement defense
Diffstat
| M | monster.go | 3 | ++- |
| M | player.go | 4 | ++-- |
2 files changed, 4 insertions, 3 deletions
diff --git a/monster.go b/monster.go
@@ -73,7 +73,8 @@ func (monster *Monster) run() {
73 73 }
74 74 }
75 75
76 -1 func (monster *Monster) TakeDamage(amount float64) {
-1 76 func (monster *Monster) TakeDamage(attack float64) {
-1 77 amount := attack * (1 - monster.Defense/(monster.Defense+100))
77 78 if amount > monster.Health {
78 79 monster.quit <- true
79 80 delete(monster.Game.Monsters, monster)
diff --git a/player.go b/player.go
@@ -42,8 +42,8 @@ func (player *Player) Flush() {
42 42 }
43 43 }
44 44
45 -1 func (player *Player) TakeDamage(rawAmount float64) {
46 -1 amount := uint(math.Round(rawAmount))
-1 45 func (player *Player) TakeDamage(attack float64) {
-1 46 amount := uint(math.Round(attack * (1 - player.Defense/(player.Defense+100))))
47 47 if amount > player.Health {
48 48 player.quit <- true
49 49 } else {