summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2019-10-09 17:31:49 +0200 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2019-10-09 17:31:49 +0200 |
commit | 85b4344b0aa478ae0a206ba4f0fb9b2e4f14106e (patch) | |
tree | 84103d02e420f32c778b008b3638079cc1eee2ba /src/battle/struct | |
parent | 64cab0e171ab13ced4c36ea40bff393d5093e075 (diff) |
Still trying stuff out...
Diffstat (limited to 'src/battle/struct')
-rw-r--r-- | src/battle/struct/btl_condition.erl | 28 |
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. |