summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tacticians/conditions.hrl.m44
-rw-r--r--src/battle/mechanic/condition/blt_cond_heal.erl108
-rw-r--r--src/battle/struct/btl_condition.erl76
-rw-r--r--src/shared/struct/shr_condition.erl4
4 files changed, 187 insertions, 5 deletions
diff --git a/include/tacticians/conditions.hrl.m4 b/include/tacticians/conditions.hrl.m4
index 8dee61c..e4f2c34 100644
--- a/include/tacticians/conditions.hrl.m4
+++ b/include/tacticians/conditions.hrl.m4
@@ -25,7 +25,9 @@ m4_include(__MAKEFILE_DATA_DIR/condition/trigger.m4.conf)
-define(CONDITION_TRIGGER_TARGET_DOUBLE_HIT, __COND_TRIG_TARGET_DOUBLE_HIT).
-define(CONDITION_TRIGGER_TARGET_DAMAGE, __COND_TRIG_TARGET_DAMAGE).
--define(CONDITION_TRIGGER_MOVEMENT, __COND_TRIG_MOVEMENT).
+-define(CONDITION_TRIGGER_START_OF_MOVEMENT, __COND_TRIG_START_OF_MOVEMENT).
+-define(CONDITION_TRIGGER_END_OF_MOVEMENT, __COND_TRIG_END_OF_MOVEMENT).
+
-define(CONDITION_TRIGGER_WEAPON_SWITCH, __COND_TRIG_WEAPON_SWITCH).
-define(CONDITION_TRIGGER_SKILL_USE, __COND_TRIG_SKILL_USE).
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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/shared/struct/shr_condition.erl b/src/shared/struct/shr_condition.erl
index cf37531..6d75167 100644
--- a/src/shared/struct/shr_condition.erl
+++ b/src/shared/struct/shr_condition.erl
@@ -12,7 +12,9 @@
{
id :: id(),
name :: binary(),
- description :: binary()
+ description :: binary(),
+ % can it be removed or stolen? Not ranks, for example.
+ is_transferable :: boolean()
}
).