summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-06-20 15:42:11 +0200
committernsensfel <SpamShield0@noot-noot.org>2018-06-20 15:42:11 +0200
commit33e804883ace6ea717106fb4d07ea0b47385e3ab (patch)
treea2265f1f7b402a6ea758b025303c25382ef491cc /src/battlemap/struct/bm_character.erl
parentc2c6af4ed1fd0c8c9c6220517a2c6b76528193ac (diff)
Allows negative current_health.
Diffstat (limited to 'src/battlemap/struct/bm_character.erl')
-rw-r--r--src/battlemap/struct/bm_character.erl8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/battlemap/struct/bm_character.erl b/src/battlemap/struct/bm_character.erl
index 594f9cd..d3a762c 100644
--- a/src/battlemap/struct/bm_character.erl
+++ b/src/battlemap/struct/bm_character.erl
@@ -19,7 +19,7 @@
weapon_ids :: {sh_weapon:id(), sh_weapon:id()},
armor_id :: sh_armor:id(),
location :: {non_neg_integer(), non_neg_integer()},
- current_health :: non_neg_integer(),
+ current_health :: integer(), %% Negative integers let us reverse attacks.
active :: boolean()
}
).
@@ -134,7 +134,7 @@ get_location (Char) ->
true = get_is_alive(Char),
Char#character.location.
--spec get_current_health (type()) -> non_neg_integer().
+-spec get_current_health (type()) -> integer().
get_current_health (Char) -> Char#character.current_health.
-spec get_is_alive (type()) -> boolean().
@@ -161,11 +161,11 @@ set_location (Location, Char) ->
location = Location
}.
--spec set_current_health (non_neg_integer(), type()) -> type().
+-spec set_current_health (integer(), type()) -> type().
set_current_health (Health, Char) ->
Char#character
{
- current_health = max(0, Health)
+ current_health = Health
}.
-spec set_is_active (boolean(), type()) -> type().