summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-06-22 18:38:15 +0200
committernsensfel <SpamShield0@noot-noot.org>2018-06-22 18:38:15 +0200
commit161c7870644e8c45f741a8f33e149737ae7cdad2 (patch)
treeb111130f8ffc614b8d7ca2f22fc5cc25a1ef1b39
parent1bcde2b23a273c7ff6c5b5ea5346111084e01700 (diff)
Fixes attackers never taking any damage.
-rw-r--r--src/battlemap/game-logic/bm_turn_actions.erl27
-rw-r--r--src/battlemap/struct/bm_attack.erl45
2 files changed, 46 insertions, 26 deletions
diff --git a/src/battlemap/game-logic/bm_turn_actions.erl b/src/battlemap/game-logic/bm_turn_actions.erl
index 7808d1f..87e14aa 100644
--- a/src/battlemap/game-logic/bm_turn_actions.erl
+++ b/src/battlemap/game-logic/bm_turn_actions.erl
@@ -310,7 +310,7 @@ handle_attack (BattleAction, Update) ->
AttackEffects
),
- DBQuery =
+ DBQuery0 =
sh_db_query:update_indexed
(
bm_battle:get_characters_field(),
@@ -324,15 +324,36 @@ handle_attack (BattleAction, Update) ->
]
),
+ DBQuery1 =
+ sh_db_query:update_indexed
+ (
+ bm_battle:get_characters_field(),
+ CharacterIX,
+ [
+ sh_db_query:set_field
+ (
+ bm_character:get_current_health_field(),
+ RemainingAttackerHealth
+ )
+ ]
+ ),
+
S0Update =
bm_character_turn_update:add_to_timeline
(
TimelineItem,
- DBQuery,
+ DBQuery0,
Update
),
- bm_character_turn_update:set_data(S1Data, S0Update).
+ S1Update =
+ bm_character_turn_update:add_to_db
+ (
+ DBQuery1,
+ S0Update
+ ),
+
+ bm_character_turn_update:set_data(S1Data, S1Update).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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
@@ -188,6 +188,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,
DefenderHealth
@@ -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
(