summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/battle')
-rw-r--r-- | src/battle/mechanic/condition/btl_cond_heal.erl | 52 | ||||
-rw-r--r-- | src/battle/struct/btl_conditions.erl | 10 |
2 files changed, 51 insertions, 11 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}. diff --git a/src/battle/struct/btl_conditions.erl b/src/battle/struct/btl_conditions.erl index 564f559..76f80ea 100644 --- a/src/battle/struct/btl_conditions.erl +++ b/src/battle/struct/btl_conditions.erl @@ -52,7 +52,8 @@ [ type/0, ref/0, - visibility/0 + visibility/0, + single/0 ] ). @@ -140,13 +141,6 @@ apply_trigger (Context, IXtoRef, S0Update, RelevantIndices, Conditions) -> Module, apply, [ - % TODO: - % Provide Ref instead of Condition. This ensures that - % the condition will use its most up-to-date status - % and, more importantly, will not overwrite changes - % made to itself by previous conditions. - % This comes at the cost of an additional Condition - % lookup, but whatever. IXtoRef(IX), CurrentUpdate, {Trigger, ReadOnlyData, CurrentVolatileData} |