summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/battle/struct/btl_condition.erl')
-rw-r--r--src/battle/struct/btl_condition.erl28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/battle/struct/btl_condition.erl b/src/battle/struct/btl_condition.erl
index 4697a3c..2954c13 100644
--- a/src/battle/struct/btl_condition.erl
+++ b/src/battle/struct/btl_condition.erl
@@ -132,7 +132,8 @@
(
[
triggers_on/2,
- apply/3
+ apply/3,
+ recursive_apply/3
]
).
@@ -303,7 +304,7 @@ get_parameters_field () -> #btl_cond.parameters.
(
type(),
trigger(),
- btl_character_turn_update()
+ btl_character_turn_update:type()
)
-> {trigger(), btl_character_turn_update:type()}.
apply (S0Condition, S0Trigger, S0Update) ->
@@ -324,5 +325,28 @@ apply (S0Condition, S0Trigger, S0Update) ->
end.
+-spec recursive_apply
+ (
+ list(type()),
+ trigger(),
+ btl_character_turn_update:type()
+ )
+ -> {trigger(), btl_character_turn_update:type()}.
+recursive_apply (Conditions, S0Trigger, S0Update) ->
+ [LastTrigger, LastUpdate] =
+ lists:foldl
+ (
+ fun (Condition, Parameters) ->
+ {NextTrigger, NextUpdate} =
+ erlang:apply(btl_condition, apply, [Condition|Parameters]),
+
+ [NextTrigger, NextUpdate]
+ end,
+ [S0Trigger, S0Update],
+ Conditions
+ ),
+
+ {LastTrigger, LastUpdate}.
+
-spec encode (type()) -> {list({binary(), any()})}.
encode (Condition) -> {[]} % TODO.