From 36c4af70fb3cda46d553306b65d9a73b1d0220fc Mon Sep 17 00:00:00 2001 From: nsensfel Date: Tue, 8 Oct 2019 18:19:38 +0200 Subject: ... --- src/battle/mechanic/condition/blt_cond_heal.erl | 7 +- .../mechanic/skill/btl_skill_static_heal.erl | 137 +++++++++++++ src/battle/mechanic/skill/btl_static_heal.erl | 137 ------------- src/battle/struct/btl_character.erl | 13 +- src/battle/struct/btl_condition.erl | 226 +++++++++++++++++++++ src/shared/struct/shr_condition.erl | 3 +- 6 files changed, 377 insertions(+), 146 deletions(-) create mode 100644 src/battle/mechanic/skill/btl_skill_static_heal.erl delete mode 100644 src/battle/mechanic/skill/btl_static_heal.erl create mode 100644 src/battle/struct/btl_condition.erl 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_skill_static_heal.erl b/src/battle/mechanic/skill/btl_skill_static_heal.erl new file mode 100644 index 0000000..7a9bf35 --- /dev/null +++ b/src/battle/mechanic/skill/btl_skill_static_heal.erl @@ -0,0 +1,137 @@ +-module(btl_skill_static_heal). +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-include("tacticians/skills.hrl") +-include("tacticians/conditions.hrl") + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export +( + [ + cast/5 + ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec cast_logic + ( + non_neg_integer(), + non_neg_integer(), + btl_character_turn_update:type() + ) + -> btl_character_turn_update:type(). +cast_logic (TargetIX, Amount, S0Update) -> + Healing = + btl_condition:new + ( + ?CONDITION_EFFECT_HEAL, + [], + -1, + 1, + {TargetIX, HealAmount} + ), + + {_S1HealindAndUpdate, S1Update} = + btl_cond_heal:apply + ( + Healing, + S0Update + ), + + % TODO: Add a btl_turn_result showing the heal to S1Update. + + S1Update. + +-spec group_cast_logic + ( + list(non_neg_integer()), + non_neg_integer(), + non_neg_integer(), + btl_character_turn_update:type() + ) + -> btl_character_turn_update:type(). +group_cast_logic (TargetIXs, MaxTargets, Amount, S0Update) -> + case (length(TargetIXs) > MaxTargets) of + true -> error({skill, target, TargetIXs}); + false -> ok + end, + + lists:foldl + ( + fun (TargetIX, S1Update) -> + cast_logic(Amount, TargetIX, S1Update) + end, + S0Update, + TargetIXs + ). + +-spec player_cast_logic + ( + non_neg_integer(), + non_neg_integer(), + btl_character_turn_update:type() + ) + -> btl_character_turn_update:type(). +player_cast_logic (TargetIX, Amount, S0Update) -> + Characters = todo, %TODO + TargetRef = todo, %TODO + TargetPlayerIX = todo, %TODO + + % TODO: + % apply `cast_logic(Amount, TargetIX, S1Update)` on all characters whose + % PlayerIX == TargetPlayerIX. + S0Update. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec cast + ( + shr_skill:variant(), + non_neg_integer(), + list(non_neg_integer()), + list(shr_location:type()), + btl_character_turn_update:type() + ) + -> btl_character_turn_update:type(). +cast (?SKILL_VARIANT_ALPHA_0, _UserIX, [TargetIX], _Locations, S0Update) -> + cast_logic(20, TargetIX, S0Update); +cast (?SKILL_VARIANT_ALPHA_1, _UserIX, [TargetIX], _Locations, S0Update) -> + cast_logic(40, TargetIX, S0Update); +cast (?SKILL_VARIANT_ALPHA_2, _UserIX, [TargetIX], _Locations, S0Update) -> + cast_logic(60, TargetIX, S0Update); +cast (?SKILL_VARIANT_ALPHA_3, _UserIX, [TargetIX], _Locations, S0Update) -> + cast_logic(80, TargetIX, S0Update); +cast (?SKILL_VARIANT_ALPHA_4, _UserIX, [TargetIX], _Locations, S0Update) -> + cast_logic(100, TargetIX, S0Update); +cast (?SKILL_VARIANT_PHI_0, _UserIX, TargetIXs, _Locations, S0Update) -> + group_cast_logic(TargetIXs, 2, 20, S0Update); +cast (?SKILL_VARIANT_PHI_1, _UserIX, TargetIXs, _Locations, S0Update) -> + group_cast_logic(TargetIXs, 2, 60, S0Update); +cast (?SKILL_VARIANT_PHI_2, _UserIX, TargetIXs, _Locations, S0Update) -> + group_cast_logic(TargetIXs, 2, 100, S0Update); +cast (?SKILL_VARIANT_PHI_3, _UserIX, TargetIXs, _Locations, S0Update) -> + group_cast_logic(TargetIXs, 4, 20, S0Update); +cast (?SKILL_VARIANT_PHI_4, _UserIX, TargetIXs, _Locations, S0Update) -> + group_cast_logic(TargetIXs, 4, 60, S0Update); +cast (?SKILL_VARIANT_PHI_5, _UserIX, TargetIXs, _Locations, S0Update) -> + group_cast_logic(TargetIXs, 4, 100, S0Update); +cast (?SKILL_VARIANT_PHI_6, _UserIX, TargetIXs, _Locations, S0Update) -> + group_cast_logic(TargetIXs, 8, 20, S0Update); +cast (?SKILL_VARIANT_PHI_7, _UserIX, TargetIXs, _Locations, S0Update) -> + group_cast_logic(TargetIXs, 8, 60, S0Update); +cast (?SKILL_VARIANT_PHI_8, _UserIX, TargetIXs, _Locations, S0Update) -> + group_cast_logic(TargetIXs, 8, 100, S0Update); +cast (?SKILL_VARIANT_PSI_0, _UserIX, [TargetIX], _Locations, S0Update) -> + player_cast_logic(TargetIX, 20, S0Update); +cast (?SKILL_VARIANT_PSI_1, _UserIX, [TargetIX], _Locations, S0Update) -> + player_cast_logic(TargetIX, 40, S0Update); +cast (?SKILL_VARIANT_PSI_2, _UserIX, [TargetIX], _Locations, S0Update) -> + player_cast_logic(TargetIX, 60, S0Update); +cast (?SKILL_VARIANT_PSI_3, _UserIX, [TargetIX], _Locations, S0Update) -> + player_cast_logic(TargetIX, 80, S0Update). diff --git a/src/battle/mechanic/skill/btl_static_heal.erl b/src/battle/mechanic/skill/btl_static_heal.erl deleted file mode 100644 index bb67463..0000000 --- a/src/battle/mechanic/skill/btl_static_heal.erl +++ /dev/null @@ -1,137 +0,0 @@ --module(btl_skill_static_heal). -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --include("tacticians/skills.hrl") --include("tacticians/conditions.hrl") - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --export -( - [ - cast/5 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec cast_logic - ( - non_neg_integer(), - non_neg_integer(), - btl_character_turn_update:type() - ) - -> btl_character_turn_update:type(). -cast_logic (TargetIX, Amount, S0Update) -> - Healing = - btl_condition:new - ( - ?CONDITION_EFFECT_HEAL, - [], - -1, - 1, - {TargetIX, HealAmount} - ), - - {_S1Healing, _HealingUpdates, S1Update} = - btl_cond_heal:apply - ( - Healing, - S0Update - ), - - % TODO: Add a btl_turn_result showing the heal to S1Update. - - S1Update. - --spec group_cast_logic - ( - list(non_neg_integer()), - non_neg_integer(), - non_neg_integer(), - btl_character_turn_update:type() - ) - -> btl_character_turn_update:type(). -group_cast_logic (TargetIXs, MaxTargets, Amount, S0Update) -> - case (length(TargetIXs) > MaxTargets) of - true -> error({skill, target, TargetIXs}); - false -> ok - end, - - lists:foldl - ( - fun (TargetIX, S1Update) -> - cast_logic(Amount, TargetIX, S1Update) - end, - S0Update, - TargetIXs - ). - --spec player_cast_logic - ( - non_neg_integer(), - non_neg_integer(), - btl_character_turn_update:type() - ) - -> btl_character_turn_update:type(). -player_cast_logic (TargetIX, Amount, S0Update) -> - Characters = todo, %TODO - TargetRef = todo, %TODO - TargetPlayerIX = todo, %TODO - - % TODO: - % apply `cast_logic(Amount, TargetIX, S1Update)` on all characters whose - % PlayerIX == TargetPlayerIX. - S0Update. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec cast - ( - shr_skill:variant(), - non_neg_integer(), - list(non_neg_integer()), - list(shr_location:type()), - btl_character_turn_update:type() - ) - -> btl_character_turn_update:type(). -cast (?SKILL_VARIANT_ALPHA_0, _UserIX, [TargetIX], _Locations, S0Update) -> - cast_logic(20, TargetIX, S0Update); -cast (?SKILL_VARIANT_ALPHA_1, _UserIX, [TargetIX], _Locations, S0Update) -> - cast_logic(40, TargetIX, S0Update); -cast (?SKILL_VARIANT_ALPHA_2, _UserIX, [TargetIX], _Locations, S0Update) -> - cast_logic(60, TargetIX, S0Update); -cast (?SKILL_VARIANT_ALPHA_3, _UserIX, [TargetIX], _Locations, S0Update) -> - cast_logic(80, TargetIX, S0Update); -cast (?SKILL_VARIANT_ALPHA_4, _UserIX, [TargetIX], _Locations, S0Update) -> - cast_logic(100, TargetIX, S0Update); -cast (?SKILL_VARIANT_PHI_0, _UserIX, TargetIXs, _Locations, S0Update) -> - group_cast_logic(TargetIXs, 2, 20, S0Update); -cast (?SKILL_VARIANT_PHI_1, _UserIX, TargetIXs, _Locations, S0Update) -> - group_cast_logic(TargetIXs, 2, 60, S0Update); -cast (?SKILL_VARIANT_PHI_2, _UserIX, TargetIXs, _Locations, S0Update) -> - group_cast_logic(TargetIXs, 2, 100, S0Update); -cast (?SKILL_VARIANT_PHI_3, _UserIX, TargetIXs, _Locations, S0Update) -> - group_cast_logic(TargetIXs, 4, 20, S0Update); -cast (?SKILL_VARIANT_PHI_4, _UserIX, TargetIXs, _Locations, S0Update) -> - group_cast_logic(TargetIXs, 4, 60, S0Update); -cast (?SKILL_VARIANT_PHI_5, _UserIX, TargetIXs, _Locations, S0Update) -> - group_cast_logic(TargetIXs, 4, 100, S0Update); -cast (?SKILL_VARIANT_PHI_6, _UserIX, TargetIXs, _Locations, S0Update) -> - group_cast_logic(TargetIXs, 8, 20, S0Update); -cast (?SKILL_VARIANT_PHI_7, _UserIX, TargetIXs, _Locations, S0Update) -> - group_cast_logic(TargetIXs, 8, 60, S0Update); -cast (?SKILL_VARIANT_PHI_8, _UserIX, TargetIXs, _Locations, S0Update) -> - group_cast_logic(TargetIXs, 8, 100, S0Update); -cast (?SKILL_VARIANT_PSI_0, _UserIX, [TargetIX], _Locations, S0Update) -> - player_cast_logic(TargetIX, 20, S0Update); -cast (?SKILL_VARIANT_PSI_1, _UserIX, [TargetIX], _Locations, S0Update) -> - player_cast_logic(TargetIX, 40, S0Update); -cast (?SKILL_VARIANT_PSI_2, _UserIX, [TargetIX], _Locations, S0Update) -> - player_cast_logic(TargetIX, 60, S0Update); -cast (?SKILL_VARIANT_PSI_3, _UserIX, [TargetIX], _Locations, S0Update) -> - player_cast_logic(TargetIX, 80, S0Update). 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() } ). -- cgit v1.2.3-70-g09d2