From 35f562a53f2ff3b498b8158be6ee739429f36c4b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 24 Mar 2021 21:04:50 +0100 Subject: [PATCH] fix damage calculation, again scale_number was messing with the hp --- src/volcano.c | 3 ++- src/volcano.test.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/volcano.c b/src/volcano.c index 7df53b62c..9649efa5b 100644 --- a/src/volcano.c +++ b/src/volcano.c @@ -119,8 +119,9 @@ int volcano_damage(unit* u, const char* dice) } } } + total = u->hp - total; scale_number(u, u->number - dead); - u->hp -= total; + u->hp = total; return dead; } diff --git a/src/volcano.test.c b/src/volcano.test.c index 358dccd02..7fe8f653d 100644 --- a/src/volcano.test.c +++ b/src/volcano.test.c @@ -47,6 +47,8 @@ static void test_volcano_damage(CuTest* tc) { u = test_create_unit(test_create_faction(), test_create_plain(0, 0)); scale_number(u, 100); u->hp = u->number * 20; + CuAssertIntEquals(tc, 0, volcano_damage(u, "0")); + CuAssertIntEquals(tc, u->number * 20, u->hp); CuAssertIntEquals(tc, 0, volcano_damage(u, "10")); CuAssertIntEquals(tc, u->number * 10, u->hp); CuAssertIntEquals(tc, 0, volcano_damage(u, "d9"));