summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-10-20 20:59:34 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-10-20 20:59:34 +0200
commit08fab636c981574a703baffad9ebb52ff4308f17 (patch)
tree6fd3742f4b374fb948ecd017be88e5923dc9d611 /src/battle/struct
parent4aaf3670c0ff4bc46092e909bb450b6336417ed9 (diff)
...
Diffstat (limited to 'src/battle/struct')
-rw-r--r--src/battle/struct/btl_character_turn_update.erl32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/battle/struct/btl_character_turn_update.erl b/src/battle/struct/btl_character_turn_update.erl
index 304f19d..e0d94f1 100644
--- a/src/battle/struct/btl_character_turn_update.erl
+++ b/src/battle/struct/btl_character_turn_update.erl
@@ -10,7 +10,8 @@
battle :: btl_battle:type(),
character_ix :: non_neg_integer(),
reversed_battle_updates :: list(ataxic:basic()),
- timeline :: list(any())
+ timeline :: list(any()),
+ actions :: list(btl_action:type())
}
).
@@ -31,10 +32,13 @@
get_character_ix/1,
get_battle_update/1,
get_timeline/1,
+ pop_next_action/1,
set_battle/2,
ataxia_set_battle/3,
+ add_actions/3,
+
add_to_timeline/2
]
).
@@ -53,7 +57,8 @@ new (Battle, CharacterIX) ->
battle = Battle,
character_ix = CharacterIX,
reversed_battle_updates = [],
- timeline = []
+ timeline = [],
+ actions = []
}.
-spec get_battle (type()) -> btl_battle:type().
@@ -62,6 +67,18 @@ get_battle (Data) -> Data#type.battle.
-spec get_character_ix (type()) -> non_neg_integer().
get_character_ix (Data) -> Data#type.character_ix.
+-spec pop_next_action (type()) -> ({ok, type(), btl_action:type()} | none).
+pop_next_action (Data) ->
+ case Data#type.actions of
+ [] -> none;
+ [Result|NextActions] ->
+ {
+ ok,
+ Data#type { actions = NextActions },
+ Result
+ }
+ end.
+
-spec set_battle (btl_battle:type(), type()) -> type().
set_battle (Battle, Data) -> Data#type { battle = Battle }.
@@ -79,6 +96,17 @@ ataxia_set_battle (Battle, BattleUpdate, Data) ->
reversed_battle_updates = [BattleUpdate|Data#type.reversed_battle_updates]
}.
+-spec add_actions (boolean(), list(btl_action:type()), type()) -> type().
+add_actions (IsPrefix, Actions, Data) ->
+ Data#type
+ {
+ actions =
+ case IsPrefix of
+ true -> (Actions ++ Data#type.actions);
+ false -> (Data#type.actions ++ Actions)
+ end
+ }.
+
-spec add_to_timeline (btl_turn_result:type(), type()) -> type().
add_to_timeline (Item, Data) ->
Data#type