summaryrefslogtreecommitdiff |
diff options
author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-10-20 20:59:34 +0200 |
---|---|---|
committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-10-20 20:59:34 +0200 |
commit | 08fab636c981574a703baffad9ebb52ff4308f17 (patch) | |
tree | 6fd3742f4b374fb948ecd017be88e5923dc9d611 /src/battle/mechanic/btl_actions_management.erl | |
parent | 4aaf3670c0ff4bc46092e909bb450b6336417ed9 (diff) |
...
Diffstat (limited to 'src/battle/mechanic/btl_actions_management.erl')
-rw-r--r-- | src/battle/mechanic/btl_actions_management.erl | 64 |
1 files changed, 15 insertions, 49 deletions
diff --git a/src/battle/mechanic/btl_actions_management.erl b/src/battle/mechanic/btl_actions_management.erl index 050ab4e..d7b85c5 100644 --- a/src/battle/mechanic/btl_actions_management.erl +++ b/src/battle/mechanic/btl_actions_management.erl @@ -9,65 +9,31 @@ -export ( [ - handle/2 + handle/1 ] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec perform_action - ( - btl_action:type(), - btl_character:type(), - btl_character_turn_update:type() - ) - -> - ( - {ok, btl_character_turn_update:type()} - | {events, list(btl_action:type()), btl_character_turn_update:type()} - ). -perform_action (Action, Character, Update) -> - case btl_action:get_category(Action) of - move -> btl_action_move:handle(Action, Character, Update); - attack -> btl_action_attack:handle(Action, Character, Update); - switch_weapon -> - btl_action_switch_weapon:handle(Action, Character, Update) - end. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec handle - ( - list(btl_action:type()), - btl_character_turn_update:type() - ) - -> btl_character_turn_update:type(). -handle ([], Update) -> Update; -handle ([BattleAction|FutureBattleActions], S0Update) -> - case btl_action:get_actor_index(BattleAction) of - -1 -> handle(FutureBattleActions, S0Update); - CharacterIX -> - S0Battle = btl_character_turn_update:get_battle(S0Update), - {Character, S1Battle} = - btl_battle:get_resolved_character(CharacterIX, S0Battle), - - S1Update = btl_character_turn_update:set_battle(S1Battle, S0Update), +-spec handle (btl_character_turn_update:type()) -> +btl_character_turn_update:type(). +handle (S0Update) -> + case btl_character_turn_update:pop_next_action(S0Update) of + none -> S0Update; + {ok, S1Update, Action} -> + S2Update = + case btl_action:get_category(Action) of + move -> btl_action_move:handle(Action, S1Update); + attack -> btl_action_attack:handle(Action, S1Update); + switch_weapon -> + btl_action_switch_weapon:handle(Action, S1Update) + end, - case btl_character:get_is_alive(Character) of - false -> handle(FutureBattleActions, S1Update); - true -> - case perform_action(BattleAction, Character, S1Update) of - {ok, S2Update} -> - handle(FutureBattleActions, S2Update); - {events, NewEvents, S2Update} -> - handle - ( - (NewEvents ++ FutureBattleActions), - S2Update - ) - end - end + handle(S2Update) end. |