From 161c7870644e8c45f741a8f33e149737ae7cdad2 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Fri, 22 Jun 2018 18:38:15 +0200 Subject: Fixes attackers never taking any damage. --- src/battlemap/struct/bm_attack.erl | 45 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'src/battlemap/struct') diff --git a/src/battlemap/struct/bm_attack.erl b/src/battlemap/struct/bm_attack.erl index ce3af53..a8f97de 100644 --- a/src/battlemap/struct/bm_attack.erl +++ b/src/battlemap/struct/bm_attack.erl @@ -187,6 +187,18 @@ apply_to_healths ) -> {nothing, AttackerHealth, DefenderHealth}; apply_to_healths +( + _Attack, + AttackerHealth, + DefenderHealth +) +when +( + (AttackerHealth =< 0) + or (DefenderHealth =< 0) +) -> + {nothing, AttackerHealth, DefenderHealth}; +apply_to_healths ( Attack, AttackerHealth, @@ -200,17 +212,11 @@ when ) -> Damage = Attack#attack.damage, - case AttackerHealth of - N when (N =< 0) -> - {nothing, AttackerHealth, DefenderHealth}; - - _ -> - { - Attack, - AttackerHealth, - (DefenderHealth - Damage) - } - end; + { + Attack, + AttackerHealth, + (DefenderHealth - Damage) + }; apply_to_healths ( Attack, @@ -228,18 +234,11 @@ when ) -> Damage = Attack#attack.damage, - %% This actually allows you to parry the counter of a dead character. - case DefenderHealth of - N when (N =< 0) -> - {nothing, AttackerHealth, DefenderHealth}; - - _ -> - { - Attack, - (AttackerHealth - Damage), - DefenderHealth - } - end. + { + Attack, + (AttackerHealth - Damage), + DefenderHealth + }. -spec get_sequence ( -- cgit v1.2.3-70-g09d2