| summaryrefslogtreecommitdiff | 
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-10-22 21:36:18 +0200 | 
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-10-22 21:36:18 +0200 | 
| commit | 240b60a2a747d073eb001dd92450fd19b91902e9 (patch) | |
| tree | 68bc25f78f764da3edb25865a037833d20a548d8 /src/battle | |
| parent | 3391371f9979f374e5cb3243e1f71500c6115f90 (diff) | |
...
Diffstat (limited to 'src/battle')
| -rw-r--r-- | src/battle/mechanic/action/btl_action_attack.erl | 16 | ||||
| -rw-r--r-- | src/battle/struct/btl_battle.erl | 3 | ||||
| -rw-r--r-- | src/battle/struct/btl_condition.erl | 114 | 
3 files changed, 55 insertions, 78 deletions
| diff --git a/src/battle/mechanic/action/btl_action_attack.erl b/src/battle/mechanic/action/btl_action_attack.erl index c6cd270..26e1190 100644 --- a/src/battle/mechanic/action/btl_action_attack.erl +++ b/src/battle/mechanic/action/btl_action_attack.erl @@ -296,7 +296,7 @@ handle_end_of_attack (Action, S0Update) ->           ?CONDITION_TRIGGER_END_OF_OTHER_ATTACK,           ?CONDITION_TRIGGER_END_OF_ANY_ATTACK,           Action, -         none, +         {Action, none},           S0Update        ), @@ -323,7 +323,7 @@ handle_end_of_attack (Action, S0Update) ->                    ?CONDITION_TRIGGER_MAY_HAVE_KILLED,                    ?CONDITION_TRIGGER_ANY_POSSIBLE_KILL,                    Action, -                  none, +                  {Action, none},                    S2Update                 ), @@ -342,7 +342,7 @@ handle_end_of_attack (Action, S0Update) ->                    ?CONDITION_TRIGGER_MAY_HAVE_KILLED,                    ?CONDITION_TRIGGER_ANY_POSSIBLE_KILL,                    Action, -                  none, +                  {Action, none},                    S3Update                 ), @@ -390,7 +390,7 @@ commit_luck_change (Character, NewLuck, S0Update) ->        btl_player:ataxia_set_luck(NewLuck, S0Player),     {S1Battle, BattleAtaxicUpdate} = -      btl_battle:set_player +      btl_battle:ataxia_set_player        (           PlayerIX,           S1Player, @@ -399,7 +399,7 @@ commit_luck_change (Character, NewLuck, S0Update) ->        ),     S1Update = -      btl_character_turn_update:set_battle +      btl_character_turn_update:ataxia_set_battle        (           S1Battle,           BattleAtaxicUpdate, @@ -574,7 +574,7 @@ commit_hit        ),     {S1Battle, BattleAtaxicUpdate1} = -      btl_battle:set_character +      btl_battle:ataxia_set_character        (           TargetIX,           S1Target, @@ -1112,8 +1112,8 @@ handle_hit (AttackCategory, S0Sequence, Action, S0Update) ->        btl_character_turn_update:type()     )     -> btl_character_turn_update:type(). -handle_attack_sequence ([], Action, Update) -> -   {Action, Update}; +handle_attack_sequence ([], _Action, Update) -> +   Update;  handle_attack_sequence ([AttackCategory|S0NextElements], Action, S0Update) ->     {S1NextElements, S1Update} =        handle_hit(AttackCategory, S0NextElements, Action, S0Update), diff --git a/src/battle/struct/btl_battle.erl b/src/battle/struct/btl_battle.erl index b1f88ac..460e2c4 100644 --- a/src/battle/struct/btl_battle.erl +++ b/src/battle/struct/btl_battle.erl @@ -636,5 +636,6 @@ new (Map) ->        map = Map,        characters = EmptyDict,        players = EmptyDict, -      current_player_turn = btl_player_turn:new(0, 0) +      current_player_turn = btl_player_turn:new(0, 0), +      conditions = btl_condition:new_collection()     }. diff --git a/src/battle/struct/btl_condition.erl b/src/battle/struct/btl_condition.erl index 60b329a..546c38b 100644 --- a/src/battle/struct/btl_condition.erl +++ b/src/battle/struct/btl_condition.erl @@ -24,8 +24,6 @@     {        category :: shr_condition:id(),        triggers :: ordsets:ordset(shr_condition:trigger()), -      occurrences :: (non_neg_integer() | -1), -      duration :: (non_neg_integer() | -1),        parameters :: tuple()     }  ). @@ -43,18 +41,12 @@     [        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, @@ -62,9 +54,10 @@        get_category_field/0,        get_triggers_field/0, -      get_remaining_occurrences_field/0, -      get_duration_field/0, -      get_parameters_field/0 +      get_parameters_field/0, + +      new/3, +      new_collection/0     ]  ). @@ -73,7 +66,8 @@     [        ataxia_apply_trigger/3,        apply_to_character/5, -      apply_to_battle/4 +      apply_to_battle/4, +      update_from_reference/3     ]  ). @@ -133,33 +127,18 @@ update_actions_to_ataxic_update (Updates) ->  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -  -spec get_category (type()) -> shr_condition:id().  get_category (Condition) -> Condition#btl_cond.category.  -spec get_triggers (type()) -> ordsets: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 (ordsets: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 }. @@ -179,39 +158,6 @@ ataxia_set_triggers (Triggers, Condition) ->        )     }. --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) ->     { @@ -267,12 +213,6 @@ 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. @@ -311,7 +251,12 @@ ataxia_apply_trigger (Context, S0Update, Conditions) ->                 UpdateActions              }           ) -> -            Module = shr_condition_selector:get_module(get_category(Condition)), +            Module = +               shr_condition:get_module +               ( +                  shr_condition:from_id(Condition#btl_cond.category) +               ), +              {NextVolatileData, NextUpdate, UpdateAction} =                 erlang:apply                 ( @@ -444,8 +389,8 @@ apply_to_battle     UpdatedBattleConditions =        ataxic:apply_basic_to        ( -         btl_battle:get_conditions(S1Battle), -         BattleConditionsAtaxicUpdate +         BattleConditionsAtaxicUpdate, +         btl_battle:get_conditions(S1Battle)        ),     {S2Battle, BattleAtaxicUpdate} = @@ -461,5 +406,36 @@ apply_to_battle     {S1VolatileContext, S1Update}. +-spec update_from_reference +   ( +      ref(), +      update_action(), +      btl_character_turn_update:type() +   ) +   -> btl_character_turn_update:type(). +update_from_reference ({battle, _CondIX}, _UpdateAction, Update) -> +   Update; % TODO +update_from_reference ({char, _CharIX, _CondIX}, _UpdateAction, Update) -> +   Update. % TODO + +-spec new +   ( +      shr_condition:id(), +      ordsets:ordset(shr_condition:trigger()), +      tuple() +   ) +   -> type(). +new (CondID, Triggers, Params) -> +   #btl_cond +   { +      category = CondID, +      triggers = Triggers, +      parameters = Params +   }. + +-spec new_collection () -> collection(). +new_collection () -> orddict:new(). + +  -spec encode (type()) -> {list({binary(), any()})}.  encode (Condition) -> {[]}. % TODO | 


