| summaryrefslogtreecommitdiff | 
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-10-08 23:35:55 +0200 | 
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-10-08 23:35:55 +0200 | 
| commit | 6ef631761688ae94126ddd544b23849fd12ed041 (patch) | |
| tree | 6b8a73158c8d96071eb646f9f8266a9b1db386b8 /src/battle | |
| parent | ab495fba74091a9b69919f117e9be7de0ebe5959 (diff) | |
...
Diffstat (limited to 'src/battle')
| -rw-r--r-- | src/battle/mechanic/condition/blt_cond_heal.erl | 108 | ||||
| -rw-r--r-- | src/battle/struct/btl_condition.erl | 76 | 
2 files changed, 181 insertions, 3 deletions
| diff --git a/src/battle/mechanic/condition/blt_cond_heal.erl b/src/battle/mechanic/condition/blt_cond_heal.erl index e67ae08..edb01fd 100644 --- a/src/battle/mechanic/condition/blt_cond_heal.erl +++ b/src/battle/mechanic/condition/blt_cond_heal.erl @@ -9,27 +9,131 @@  -export  (     [ -      apply/2 +      apply/3     ]  ).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec apply_to_character +   ( +      btl_condition:type(), +      btl_character:type() +   ) +   -> +   { +      btl_condition:type(), +      btl_condition:update_order(), +      [{btl_character:type(), ataxic:basic()}] +   }. +apply_to_character (Condition, S0Character) -> +   {_, Amount} = btl_condition:get_parameters(Condition), + +   case btl_character:get_is_alive(S0Character) of +      false -> {Condition, btl_condition:do_nothing(), []}; +      true -> +         RemainingUses = btl_condition:get_remaining_uses(Condition), +         CurrentHealth = btl_character:get_current_health(S0Character), +         MaxHealth = +            shr_attributes:get_health +            ( +               shr_character:get_attributes +               j( +                  btl_character:get_base_character(S0Character) +               ) +            ), + +         UpdatedHealth = min(MaxHealth, (CurrentHealth + Amount)), +         UpdatedRemainingUses = + +         {S1Character, CharacterUpdate} = +            btl_character:ataxia_set_current_health(UpdatedHealth, S0Character), + +         if +            (RemainingUses == -1) -> +               { +                  Condition, +                  btl_condition:do_nothing(), +                  [{S1Character, CharacterUpdate}] +               }; + +            (RemainingUses == 1) -> +               { +                  btl_condition:set_remaining_uses +                  ( +                     UpdatedRemainingUses, +                     Condition +                  ), +                  btl_condition:remove(), +                  [{S1Character, CharacterUpdate}] +               }; + +            (RemainingUses == 0) -> +               { +                  Condition, +                  btl_condition:remove(), +                  [{S1Character, CharacterUpdate}] +               }; + +            true -> +               {UpdatedCondition, ConditionUpdate} = +                  btl_condition:ataxia_set_remaining_uses +                  ( +                     UpdatedRemainingUses, +                     Condition +                  ), +               { +                  UpdatedCondition, +                  btl_condition:update(ConditionUpdate), +                  [{S1Character, CharacterUpdate}] +               } +         end +   end.  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  -spec apply     ( +      btl_condition:trigger(), +      tuple(),        btl_condition:type(),        btl_character_turn_update:type()     ) ->     {        [{btl_condition:type(), ataxic:basic()}], +      tuple(),        btl_character_turn_update:type()     }. -apply (Condition, Update) -> +apply(?CONDITION_TRIGGER_START_OF_PLAYER_TURN, {PlayerIX}, Condition, Update) -> +apply(?CONDITION_TRIGGER_END_OF_PLAYER_TURN, {PlayerIX}, Condition, Update) -> +apply +( +   ?CONDITION_TRIGGER_START_OF_CHARACTER_TURN, +   {CharacterIX}, +   Condition, +   Update +) -> +apply +( +   ?CONDITION_TRIGGER_END_OF_CHARACTER_TURN, +   {CharacterIX}, +   Condition, +   Update +) -> +apply +( +   ?CONDITION_TRIGGER_END_OF_CHARACTER_TURN, +   {CharacterIX}, +   Condition, +   Update +) -> + +   Trigger, +   Parameters, +   Condition, +   Update) ->     {TargetIX, Amount} =        case btl_condition:get_parameters(Condition) of           {StoredTargetIX, StoredAmount} -> {StoredTargetIX, StoredAmount}; diff --git a/src/battle/struct/btl_condition.erl b/src/battle/struct/btl_condition.erl index 2571898..1f8228f 100644 --- a/src/battle/struct/btl_condition.erl +++ b/src/battle/struct/btl_condition.erl @@ -3,6 +3,80 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-include("tacticians/conditions.hrl"). + +-type trigger() :: +   ( +      { +         ( +            ?CONDITION_TRIGGER_START_OF_PLAYER_TURN +            | ?CONDITION_TRIGGER_END_OF_PLAYER_TURN +         ), +         non_neg_integer() +      } + +      | +         { +            ( +               ?CONDITION_TRIGGER_START_OF_CHARACTER_TURN +               | ?CONDITION_TRIGGER_END_OF_CHARACTER_TURN +               | ?CONDITION_WEAPON_SWITCH +               | ?CONDITION_TRIGGER_SKILL_USE +               | ?CONDITION_TRIGGER_DEATH +            ), +            non_neg_integer() +         } + +      | +         { +            ( +               ?CONDITION_TRIGGER_START_OF_OWN_ATTACK +               | ?CONDITION_TRIGGER_END_OF_OWN_ATTACK +               | ?CONDITION_TRIGGER_START_OF_OWN_HIT +               | ?CONDITION_TRIGGER_END_OF_OWN_HIT +               | ?CONDITION_TRIGGER_OWN_DODGE +               | ?CONDITION_TRIGGER_OWN_CRITICAL +               | ?CONDITION_TRIGGER_OWN_DOUBLE_HIT +               | ?CONDITION_TRIGGER_OWN_DAMAGE +               | ?CONDITION_TRIGGER_START_OF_TARGET_ATTACK +               | ?CONDITION_TRIGGER_END_OF_TARGET_ATTACK +               | ?CONDITION_TRIGGER_START_OF_TARGET_HIT +               | ?CONDITION_TRIGGER_END_OF_TARGET_HIT +               | ?CONDITION_TRIGGER_TARGET_DODGE +               | ?CONDITION_TRIGGER_TARGET_CRITICAL +               | ?CONDITION_TRIGGER_TARGET_DOUBLE_HIT +               | ?CONDITION_TRIGGER_TARGET_DAMAGE +            ), +            { +               non_neg_integer(), +               btl_character:type(), +               non_neg_integer(), +               btl_character:type(), +            } +         } + +      | +         { +            ( +               ?CONDITION_TRIGGER_START_OF_MOVEMENT +               | ?CONDITION_TRIGGER_END_OF_MOVEMENT +            ), +            { +               non_neg_integer(), +               list(shr_direction:type()) +            } +         } + +      | +         { +            ( +               ?CONDITION_TRIGGER_START_OF_BATTLE +               | ?CONDITION_TRIGGER_END_OF_BATTLE +            ), +            none +         } +   ). +  -record  (     btl_cond, @@ -17,7 +91,7 @@  -opaque type() :: #btl_cond{}. --export_type([type/0]). +-export_type([type/0, trigger/0]).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 


