summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/battle/mechanic/condition/blt_cond_heal.erl7
-rw-r--r--src/battle/mechanic/skill/btl_skill_static_heal.erl (renamed from src/battle/mechanic/skill/btl_static_heal.erl)2
-rw-r--r--src/battle/struct/btl_character.erl13
-rw-r--r--src/battle/struct/btl_condition.erl226
-rw-r--r--src/shared/struct/shr_condition.erl3
5 files changed, 241 insertions, 10 deletions
diff --git a/src/battle/mechanic/condition/blt_cond_heal.erl b/src/battle/mechanic/condition/blt_cond_heal.erl
index 2479720..e67ae08 100644
--- a/src/battle/mechanic/condition/blt_cond_heal.erl
+++ b/src/battle/mechanic/condition/blt_cond_heal.erl
@@ -26,16 +26,15 @@
btl_character_turn_update:type()
) ->
{
- btl_condition:type(),
- [ataxic:basic()],
+ [{btl_condition:type(), ataxic:basic()}],
btl_character_turn_update:type()
}.
apply (Condition, Update) ->
{TargetIX, Amount} =
- case btl_condition:get_parameter(Condition) of
+ case btl_condition:get_parameters(Condition) of
{StoredTargetIX, StoredAmount} -> {StoredTargetIX, StoredAmount};
Other -> error({condition, parameter, Other})
end,
% TODO
- {Condition, [], Update}.
+ {[{Condition, []}], Update}.
diff --git a/src/battle/mechanic/skill/btl_static_heal.erl b/src/battle/mechanic/skill/btl_skill_static_heal.erl
index bb67463..7a9bf35 100644
--- a/src/battle/mechanic/skill/btl_static_heal.erl
+++ b/src/battle/mechanic/skill/btl_skill_static_heal.erl
@@ -36,7 +36,7 @@ cast_logic (TargetIX, Amount, S0Update) ->
{TargetIX, HealAmount}
),
- {_S1Healing, _HealingUpdates, S1Update} =
+ {_S1HealindAndUpdate, S1Update} =
btl_cond_heal:apply
(
Healing,
diff --git a/src/battle/struct/btl_character.erl b/src/battle/struct/btl_character.erl
index f5f7ee0..de01eb7 100644
--- a/src/battle/struct/btl_character.erl
+++ b/src/battle/struct/btl_character.erl
@@ -23,7 +23,8 @@
current_health :: integer(), %% Negative integers let us reverse attacks.
is_active :: boolean(),
is_defeated :: boolean(),
- base :: shr_character:unresolved()
+ base :: shr_character:unresolved(),
+ conditions :: list(btl_condition:type())
}
).
@@ -37,7 +38,8 @@
current_health :: integer(), %% Negative integers let us reverse attacks.
is_active :: boolean(),
is_defeated :: boolean(),
- base :: shr_character:type()
+ base :: shr_character:type(),
+ conditions :: list(btl_condition:type())
}
).
@@ -61,6 +63,7 @@
get_is_active/1,
get_is_defeated/1,
get_base_character/1,
+ get_conditions/1,
set_rank/2,
set_location/3,
@@ -68,6 +71,7 @@
set_is_active/2,
set_is_defeated/2,
set_base_character/2,
+ set_conditions/2,
ataxia_set_rank/2,
ataxia_set_location/3,
@@ -75,7 +79,9 @@
ataxia_set_is_active/2,
ataxia_set_is_defeated/2,
ataxia_set_base_character/2,
+ ataxia_set_conditions/2,
+ ataxia_set_conditions/3,
ataxia_set_base_character/3,
get_rank_field/0,
@@ -83,7 +89,8 @@
get_is_active_field/0,
get_is_defeated_field/0,
get_location_field/0,
- get_base_character_field/0
+ get_base_character_field/0,
+ get_conditions_field/0
]
).
diff --git a/src/battle/struct/btl_condition.erl b/src/battle/struct/btl_condition.erl
new file mode 100644
index 0000000..2571898
--- /dev/null
+++ b/src/battle/struct/btl_condition.erl
@@ -0,0 +1,226 @@
+-module(btl_condition).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-record
+(
+ btl_cond,
+ {
+ category :: shr_condition:id(),
+ triggers :: ordset:ordset(shr_condition:trigger()),
+ occurrences :: (non_neg_integer() | -1),
+ duration :: (non_neg_integer() | -1),
+ parameters :: tuple()
+ }
+).
+
+-opaque type() :: #btl_cond{}.
+
+-export_type([type/0]).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-export
+(
+ [
+ get_category/1,
+ get_triggers/1,
+ get_remaining_occurrences/1,
+ get_duration/1,
+ get_parameters/1,
+
+ set_triggers/2,
+ set_remaining_occurrences/2,
+ set_duration/2,
+ set_parameters/2,
+
+ ataxia_set_triggers/2,
+ ataxia_set_remaining_occurrences/2,
+ ataxia_set_duration/2,
+ ataxia_set_parameters/2,
+
+ ataxia_set_triggers/3,
+ ataxia_set_parameters/3,
+
+ get_category_field/0,
+ get_triggers_field/0,
+ get_remaining_occurrences_field/0,
+ get_duration_field/0,
+ get_parameters_field/0
+ ]
+).
+
+-export
+(
+ [
+ triggers_on/2
+ ]
+).
+
+-export
+(
+ [
+ encode/1
+ ]
+).
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-spec encode_parameters
+ (
+ shr_condition:id(),
+ tuple()
+ )
+ -> {list({binary(), any()})}.
+encode_parameters (_Category, _Parameters) -> {[]}. % TODO.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+-spec get_category (type()) -> shr_condition:id().
+get_category (Condition) -> Condition#btl_cond.category.
+
+-spec get_triggers (type()) -> ordset:ordset(shr_condition:trigger()).
+get_triggers (Condition) -> Condition#btl_cond.triggers.
+
+-spec get_remaining_occurrences (type()) -> (non_neg_integer() | -1).
+get_remaining_occurrences (Condition) -> Condition#btl_cond.occurrences.
+
+-spec get_duration (type()) -> (non_neg_integer() | -1).
+get_duration (Condition) -> Condition#btl_cond.duration.
+
+-spec get_parameters (type()) -> tuple().
+get_parameters (Condition) -> Condition#btl_cond.parameters.
+
+-spec set_triggers (ordset:ordset(shr_condition:trigger()), type()) -> type().
+set_triggers (Triggers, Condition) -> Condition#btl_cond{ triggers = Triggers }.
+
+-spec set_remaining_occurrences ((non_neg_integer() | -1), type()) -> type().
+set_remaining_occurrences (Value, Condition) ->
+ Condition#btl_cond{ occurrences = Value }.
+
+-spec set_duration ((non_neg_integer() | -1), type()) -> type().
+set_duration (Value, Condition) ->
+ Condition#btl_cond{ duration = Value }.
+
+-spec set_parameters (tuple(), type()) -> type().
+set_parameters (Value, Condition) -> Condition#btl_cond{ parameters = Value }.
+
+-spec ataxia_set_triggers
+ (
+ ordset:ordset(shr_condition:trigger()),
+ type()
+ )
+ -> {type(), ataxic:basic()}.
+ataxia_set_triggers (Triggers, Condition) ->
+ {
+ set_triggers(Triggers, Condition),
+ ataxic:update_field
+ (
+ get_triggers_field(),
+ ataxic:constant(Triggers)
+ )
+ }.
+
+-spec ataxia_set_remaining_occurrences
+ (
+ (non_neg_integer() | -1),
+ type()
+ )
+ -> {type(), ataxic:basic()}.
+ataxia_set_remaining_occurrences (Value, Condition) ->
+ {
+ set_remaining_occurrences(Value, Condition),
+ ataxic:update_field
+ (
+ get_remaining_occurrences_field(),
+ ataxic:constant(Value)
+ )
+ }.
+
+
+-spec ataxia_set_duration
+ (
+ (non_neg_integer() | -1),
+ type()
+ )
+ -> {type(), ataxic:basic()}.
+ataxia_set_duration (Value, Condition) ->
+ {
+ set_duration(Value, Condition),
+ ataxic:update_field
+ (
+ get_duration_field(),
+ ataxic:constant(Value)
+ )
+ }.
+
+-spec ataxia_set_parameters (tuple(), type()) -> {type(), ataxic:basic()}.
+ataxia_set_parameters (Value, Condition) ->
+ {
+ set_parameters(Value, Condition),
+ ataxic:update_field
+ (
+ get_parameters_field(),
+ ataxic:constant(Value)
+ )
+ }.
+
+-spec ataxia_set_triggers
+ (
+ ordset:ordset(shr_condition:trigger()),
+ ataxic:basic(),
+ type()
+ )
+ -> {type(), ataxic:basic()}.
+ataxia_set_triggers (Triggers, Update, Condition) ->
+ {
+ set_triggers(Triggers, Condition),
+ ataxic:update_field
+ (
+ get_triggers_field(),
+ Update
+ )
+ }.
+
+-spec ataxia_set_parameters
+ (
+ tuple(),
+ ataxic:basic(),
+ type()
+ )
+ -> {type(), ataxic:basic()}.
+ataxia_set_parameters (Value, Update, Condition) ->
+ {
+ set_parameters(Value, Condition),
+ ataxic:update_field
+ (
+ get_parameters_field(),
+ Update
+ )
+ }.
+
+-spec triggers_on (shr_condition:trigger(), type()) -> boolean().
+triggers_on (Trigger, Type) ->
+ ordset:is_element(Trigger, Type#btl_cond.triggers).
+
+-spec get_category_field () -> non_neg_integer().
+get_category_field () -> #btl_cond.category.
+
+-spec get_triggers_field () -> non_neg_integer().
+get_triggers_field () -> #btl_cond.triggers.
+
+-spec get_remaining_occurrences_field () -> non_neg_integer().
+get_remaining_occurrences_field () -> #btl_cond.occurrences.
+
+-spec get_duration_field () -> non_neg_integer().
+get_duration_field () -> #btl_cond.duration.
+
+-spec get_parameters_field () -> non_neg_integer().
+get_parameters_field () -> #btl_cond.parameters.
+
+-spec encode (type()) -> {list({binary(), any()})}.
+encode (Condition) -> {[]} % TODO.
diff --git a/src/shared/struct/shr_condition.erl b/src/shared/struct/shr_condition.erl
index ec2493a..cf37531 100644
--- a/src/shared/struct/shr_condition.erl
+++ b/src/shared/struct/shr_condition.erl
@@ -12,8 +12,7 @@
{
id :: id(),
name :: binary(),
- description :: binary(),
- triggers :: ordset:ordset(trigger())
+ description :: binary()
}
).