summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2019-11-14 17:05:31 +0100 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2019-11-14 17:05:31 +0100 |
commit | a4bb64f3cc1142e288a7bd270dd94f11f0f9f5b4 (patch) | |
tree | 4c2db27eb40e57c1f24ee80763697cad5decc8e3 /src/battle/mechanic/condition | |
parent | 70964517f6f2d3bc04a999358215ef8b8d5bd63d (diff) |
...
Diffstat (limited to 'src/battle/mechanic/condition')
-rw-r--r-- | src/battle/mechanic/condition/btl_cond_heal.erl | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/src/battle/mechanic/condition/btl_cond_heal.erl b/src/battle/mechanic/condition/btl_cond_heal.erl index d1f6853..e60d1ac 100644 --- a/src/battle/mechanic/condition/btl_cond_heal.erl +++ b/src/battle/mechanic/condition/btl_cond_heal.erl @@ -11,6 +11,8 @@ -export ( [ + encode/1, + get_turn_result_encoding/1, apply/3 ] ). @@ -18,18 +20,62 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec heal_character + ( + non_neg_integer(), + btl_character:type(), + non_neg_integer() + ) + -> + ( + { + non_neg_integer(), + btl_character:type(), + btl_turn_result:type(), + ataxic:basic() + } + | none + ). +heal_character (ActorIX, S0Actor, S0HealingAmount) -> + case btl_character:get_is_alive(S0Actor) of + false -> none; + true -> + CurrentHealth = btl_character:get_current_health(S0Actor), + BaseActor = btl_character:get_base_character(S0Actor), + ActorAttributes = shr_character:get_attributes(BaseActor), + MaxHealth = shr_attributes:get_maximum_health(ActorAttributes), + MaxHealing = (MaxHealth - CurrentHealth), + S1HealingAmount = min(MaxHealing, S0HealingAmount), + {S1Actor, ActorAtaxicUpdate} = + btl_character:ataxia_set_current_health + ( + S0Actor, + (CurrentHealth + S1HealingAmount) + ), + + { + S1HealingAmount, + S1Actor, + btl_turn_result:new_condition + ( + btl_cond_heal, + {ActorIX, S1HealingAmount} + ), + ActorAtaxicUpdate + } + end. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -spec apply ( - shr_condition:context(any(), VolatileDataType), btl_conditions:ref(), - btl_character_turn_update:type() + btl_character_turn_update:type(), + shr_condition:context(any(), VolatileDataType), ) -> {VolatileDataType, btl_character_turn_update:type()}. -apply (S0Context, _SelfRef, S0Update) -> +apply (SelfRef, S0Update, S0Context) -> {_Trigger, _ReadOnlyData, VolatileData} = S0Context, {VolatileData, S0Update}. |