| summaryrefslogtreecommitdiff | 
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-11-02 20:19:57 +0100 | 
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-11-02 20:19:57 +0100 | 
| commit | 2ad88173a0bf967e483fdb785e0dda31d50e9009 (patch) | |
| tree | 24984a23d797827e29263d0261853e2232eff5f3 /src/battle/struct | |
| parent | d6efe72291a12284536340d047f43737cbfd3b0b (diff) | |
...
Diffstat (limited to 'src/battle/struct')
| -rw-r--r-- | src/battle/struct/btl_action.erl | 10 | ||||
| -rw-r--r-- | src/battle/struct/btl_battle.erl | 12 | ||||
| -rw-r--r-- | src/battle/struct/btl_character.erl | 50 | ||||
| -rw-r--r-- | src/battle/struct/btl_conditions.erl | 10 | 
4 files changed, 35 insertions, 47 deletions
| diff --git a/src/battle/struct/btl_action.erl b/src/battle/struct/btl_action.erl index 71a9636..f51da34 100644 --- a/src/battle/struct/btl_action.erl +++ b/src/battle/struct/btl_action.erl @@ -120,7 +120,7 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  -spec decode (binary(), non_neg_integer(), map()) -> type().  decode (?CATEGORY_MOVE, ActorIX, Map) -> -   EncodedPath = map:get(?MOVE_PATH_FIELD, Map), +   EncodedPath = maps:get(?MOVE_PATH_FIELD, Map),     Path = lists:map(fun shr_direction:decode/1, EncodedPath),     #move @@ -130,7 +130,7 @@ decode (?CATEGORY_MOVE, ActorIX, Map) ->        movement_points = -1     };  decode (?CATEGORY_ATTACK, ActorIX, Map) -> -   TargetIX = map:get(?ATTACK_TARGET_FIELD, Map), +   TargetIX = maps:get(?ATTACK_TARGET_FIELD, Map),     #attack     { @@ -144,8 +144,8 @@ decode (?CATEGORY_SWITCH_WEAPONS, ActorIX, _Map) ->        actor_ix = ActorIX     };  decode (?CATEGORY_USE_SKILL, ActorIX, Map) -> -   Targets = map:get(?USE_SKILL_TARGETS_FIELD, Map), -   EncodedLocations = map:get(?USE_SKILL_LOCATIONS_FIELD, Map), +   Targets = maps:get(?USE_SKILL_TARGETS_FIELD, Map), +   EncodedLocations = maps:get(?USE_SKILL_LOCATIONS_FIELD, Map),     Locations = lists:map(fun shr_location:decode/1, EncodedLocations),     #skill @@ -271,7 +271,7 @@ get_category (Action) when is_record(Action, switch_weapons) -> switch_weapons;  get_category (Action) when is_record(Action, skill) -> skill.  -spec decode (non_neg_integer(), map()) -> type(). -decode (ActorIX, Map) -> decode(map:get(?CATEGORY_FIELD), ActorIX, Map). +decode (ActorIX, Map) -> decode(maps:get(?CATEGORY_FIELD, Map), ActorIX, Map).  -spec from_map_marker     ( diff --git a/src/battle/struct/btl_battle.erl b/src/battle/struct/btl_battle.erl index 460e2c4..09298e6 100644 --- a/src/battle/struct/btl_battle.erl +++ b/src/battle/struct/btl_battle.erl @@ -15,7 +15,7 @@        characters :: orddict:orddict(non_neg_integer(), btl_character:either()),        players :: orddict:orddict(non_neg_integer(), btl_player:type()),        current_player_turn :: btl_player_turn:type(), -      conditions :: btl_condition:collection() +      conditions :: btl_conditions:type()     }  ). @@ -586,16 +586,16 @@ ataxia_set_current_player_turn (PlayerTurn, PlayerTurnUpdate, Battle) ->  -spec get_conditions_field() -> non_neg_integer().  get_conditions_field () -> #battle.conditions. --spec get_conditions (type()) -> btl_condition:collection(). +-spec get_conditions (type()) -> btl_conditions:type().  get_conditions (#battle{ conditions = R }) -> R. --spec set_conditions (btl_condition:collection(), type()) -> type(). +-spec set_conditions (btl_conditions:type(), type()) -> type().  set_conditions (Conditions, Battle) ->     Battle#battle{ conditions = Conditions }.  -spec ataxia_set_conditions     ( -      btl_condition:collection(), +      btl_conditions:type(),        ataxic:basic(),        type()     ) @@ -612,7 +612,7 @@ ataxia_set_conditions (Conditions, Update, Battle) ->  -spec ataxia_set_conditions     ( -      btl_condition:collection(), +      btl_conditions:type(),        type()     )     -> {type(), ataxic:basic()}. @@ -637,5 +637,5 @@ new (Map) ->        characters = EmptyDict,        players = EmptyDict,        current_player_turn = btl_player_turn:new(0, 0), -      conditions = btl_condition:new_collection() +      conditions = btl_conditions:new()     }. diff --git a/src/battle/struct/btl_character.erl b/src/battle/struct/btl_character.erl index 422ee7d..30dac93 100644 --- a/src/battle/struct/btl_character.erl +++ b/src/battle/struct/btl_character.erl @@ -27,7 +27,7 @@        is_active :: boolean(),        is_defeated :: boolean(),        base :: shr_character:unresolved(), -      conditions :: btl_condition:collection() +      conditions :: btl_conditions:type()     }  ). @@ -43,7 +43,7 @@        is_active :: boolean(),        is_defeated :: boolean(),        base :: shr_character:type(), -      conditions :: btl_condition:collection() +      conditions :: btl_conditions:type()     }  ). @@ -109,7 +109,7 @@        resolve/2,        is_unresolved/1,        to_unresolved/1, -      encode/1 +      encode/2     ]  ). @@ -197,8 +197,8 @@ get_base_character (#btl_char{ base = R }) -> R;  get_base_character (#btl_char_ref{ base = R }) -> R.  -spec get_conditions -   (type()) -> btl_condition:collection(); -   (unresolved()) -> btl_condition:collection(). +   (type()) -> btl_conditions:type(); +   (unresolved()) -> btl_conditions:type().  get_conditions (#btl_char{ conditions = R }) -> R;  get_conditions (#btl_char_ref{ conditions = R }) -> R. @@ -457,16 +457,8 @@ ataxia_set_base_character (NewBaseCharacter, Char) ->     ).  -spec set_conditions -   ( -      btl_condition:collection(), -      type() -   ) -   -> type(); -   ( -      btl_condition:collection(), -      unresolved() -   ) -   -> unresolved(). +   (btl_conditions:type(), type()) -> type(); +   (btl_conditions:type(), unresolved()) -> unresolved().  set_conditions (Conditions, Char) when is_record(Char, btl_char) ->     Char#btl_char{ conditions = Conditions };  set_conditions (Conditions, Char) when is_record(Char, btl_char_ref) -> @@ -475,13 +467,13 @@ set_conditions (Conditions, Char) when is_record(Char, btl_char_ref) ->  -spec ataxia_set_conditions     ( -      btl_condition:collection(), +      btl_conditions:type(),        ataxic:basic(),        type()     )     -> {type(), ataxic:basic()};     ( -      btl_condition:collection(), +      btl_conditions:type(),        ataxic:basic(),        unresolved()     ) -> {unresolved(), ataxic:basic()}. @@ -496,16 +488,8 @@ ataxia_set_conditions (Conditions, Update, Char) ->     }.  -spec ataxia_set_conditions -   ( -      btl_condition:collection(), -      type() -   ) -   -> {type(), ataxic:basic()}; -   ( -      btl_condition:collection(), -      unresolved() -   ) -   -> {unresolved(), ataxic:basic()}. +   (btl_conditions:type(), type()) -> {type(), ataxic:basic()}; +   (btl_conditions:type(), unresolved()) -> {unresolved(), ataxic:basic()}.  ataxia_set_conditions (Conditions, Char) ->     ataxia_set_conditions     ( @@ -521,7 +505,7 @@ ataxia_set_conditions (Conditions, Char) ->        rank(),        shr_location:type(),        shr_character:type(), -      btl_condition:collection() +      btl_conditions:type()     )     -> type().  new @@ -599,8 +583,8 @@ get_base_character_field () -> #btl_char_ref.base.  -spec get_conditions_field() -> non_neg_integer().  get_conditions_field () -> #btl_char_ref.conditions. --spec encode (unresolved()) -> {list({binary(), any()})}. -encode (CharRef) -> +-spec encode (non_neg_integer(), unresolved()) -> {list({binary(), any()})}. +encode (RequestingPlayerIX, CharRef) ->     {        [           {?PLAYER_IX_FIELD, CharRef#btl_char_ref.player_ix}, @@ -613,7 +597,11 @@ encode (CharRef) ->           {?BASE_CHAR_FIELD, shr_character:encode(CharRef#btl_char_ref.base)},           {              ?CONDITIONS_FIELD, -            btl_condition:encode_collection(CharRef#btl_char_ref.conditions) +            btl_conditions:encode +            ( +               RequestingPlayerIX, +               CharRef#btl_char_ref.conditions +            )           }        ]     }. diff --git a/src/battle/struct/btl_conditions.erl b/src/battle/struct/btl_conditions.erl index c984437..d9703fb 100644 --- a/src/battle/struct/btl_conditions.erl +++ b/src/battle/struct/btl_conditions.erl @@ -8,7 +8,7 @@  -type visibility() ::     (        none -      | {limited, ordsets:ordsets(non_neg_integer())} % PlayerIXs +      | {limited, ordsets:ordset(non_neg_integer())} % PlayerIXs        | all     ). @@ -40,7 +40,7 @@           orddict:orddict           (              shr_condition:trigger(), -            ordset:ordset(non_neg_integer()) +            ordsets:ordset(non_neg_integer())           )     }  ). @@ -201,7 +201,7 @@ encode_single (IX, Condition) ->     Module =        shr_condition:get_module        ( -         shr_conditon:from_id(Condition#btl_cond.category) +         shr_condition:from_id(Condition#btl_cond.category)        ),     EncodedParameters = @@ -678,7 +678,7 @@ add (CondID, Triggers, Params, Visibility, Conditions) ->        ),     UpdatedFromTrigger = -      ordset:fold +      ordsets:fold        (           fun (Trigger, FromTrigger) ->              orddict:update @@ -755,7 +755,7 @@ ataxia_add (CondID, Triggers, Params, Visibility, Conditions) ->        ),     {UpdatedFromTrigger, FromTriggerAtaxicUpdateList} = -      ordset:fold +      ordsets:fold        (           fun (Trigger, {FromTrigger, FromTriggerUpdates}) ->              { | 


