summaryrefslogtreecommitdiff |
diff options
-rw-r--r-- | src/battle/mechanic/action/btl_action_attack.erl | 6 | ||||
-rw-r--r-- | src/battle/mechanic/action/btl_action_move.erl | 8 | ||||
-rw-r--r-- | src/battle/mechanic/action/btl_action_switch_weapons.erl | 8 | ||||
-rw-r--r-- | src/battle/mechanic/action/btl_action_use_skill.erl | 8 | ||||
-rw-r--r-- | src/battle/mechanic/btl_victory_progression.erl | 6 | ||||
-rw-r--r-- | src/battle/mechanic/condition/btl_cond_heal.erl | 14 | ||||
-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 | ||||
-rw-r--r-- | src/bounty/bnt_join_battle.erl | 2 |
11 files changed, 59 insertions, 75 deletions
diff --git a/src/battle/mechanic/action/btl_action_attack.erl b/src/battle/mechanic/action/btl_action_attack.erl index ea7857a..8ddd119 100644 --- a/src/battle/mechanic/action/btl_action_attack.erl +++ b/src/battle/mechanic/action/btl_action_attack.erl @@ -61,7 +61,7 @@ apply_mirror_conditions end, {S1VolatileContext, S1Update} = - btl_condition:apply_to_character + btl_conditions:apply_to_character ( ActorIX, OwnTriggerName, @@ -71,7 +71,7 @@ apply_mirror_conditions ), {S2VolatileContext, S2Update} = - btl_condition:apply_to_character + btl_conditions:apply_to_character ( TargetIX, OtherTriggerName, @@ -81,7 +81,7 @@ apply_mirror_conditions ), {S3VolatileContext, S3Update} = - btl_condition:apply_to_battle + btl_conditions:apply_to_battle ( GlobalTriggerName, ReadOnlyContext, diff --git a/src/battle/mechanic/action/btl_action_move.erl b/src/battle/mechanic/action/btl_action_move.erl index 756ebca..9bbbf7a 100644 --- a/src/battle/mechanic/action/btl_action_move.erl +++ b/src/battle/mechanic/action/btl_action_move.erl @@ -462,7 +462,7 @@ handle (Action, S0Update) -> S0Path = btl_action:get_path(Action), {{S1MovementPoints, S1Path}, S2Update} = - btl_condition:apply_to_character + btl_conditions:apply_to_character ( ActorIX, ?CONDITION_TRIGGER_ABOUT_TO_MOVE, @@ -472,7 +472,7 @@ handle (Action, S0Update) -> ), {{S2MovementPoints, S2Path}, S3Update} = - btl_condition:apply_to_battle + btl_conditions:apply_to_battle ( ?CONDITION_TRIGGER_A_CHARACTER_IS_ABOUT_TO_MOVE, Action, @@ -503,7 +503,7 @@ handle (Action, S0Update) -> commit_move(ActorIX, S1Actor, S4Update, HandledPath, NewLocation), {_V0Nothing, S5Update} = - btl_condition:apply_to_character + btl_conditions:apply_to_character ( ActorIX, ?CONDITION_TRIGGER_HAS_MOVED, @@ -513,7 +513,7 @@ handle (Action, S0Update) -> ), {_V1Nothing, S6Update} = - btl_condition:apply_to_character + btl_conditions:apply_to_character ( ActorIX, ?CONDITION_TRIGGER_A_CHARACTER_HAS_MOVED, diff --git a/src/battle/mechanic/action/btl_action_switch_weapons.erl b/src/battle/mechanic/action/btl_action_switch_weapons.erl index 693c258..3d1035d 100644 --- a/src/battle/mechanic/action/btl_action_switch_weapons.erl +++ b/src/battle/mechanic/action/btl_action_switch_weapons.erl @@ -34,7 +34,7 @@ handle (Action, S0Update) -> S0PerformSwitch = true, {S1PerformSwitch, S1Update} = - btl_condition:apply_to_character + btl_conditions:apply_to_character ( ActorIX, ?CONDITION_TRIGGER_ABOUT_TO_SWITCH_WEAPONS, @@ -44,7 +44,7 @@ handle (Action, S0Update) -> ), {S2PerformSwitch, S2Update} = - btl_condition:apply_to_battle + btl_conditions:apply_to_battle ( ?CONDITION_TRIGGER_A_CHARACTER_IS_ABOUT_TO_SWITCH_WEAPONS, Action, @@ -96,7 +96,7 @@ handle (Action, S0Update) -> ), {_V0Nothing, S5Update} = - btl_condition:apply_to_character + btl_conditions:apply_to_character ( ActorIX, ?CONDITION_TRIGGER_HAS_SWITCHED_WEAPONS, @@ -106,7 +106,7 @@ handle (Action, S0Update) -> ), {_V1Nothing, S6Update} = - btl_condition:apply_to_battle + btl_conditions:apply_to_battle ( ?CONDITION_TRIGGER_A_CHARACTER_HAS_SWITCHED_WEAPONS, Action, diff --git a/src/battle/mechanic/action/btl_action_use_skill.erl b/src/battle/mechanic/action/btl_action_use_skill.erl index 154d7db..1501539 100644 --- a/src/battle/mechanic/action/btl_action_use_skill.erl +++ b/src/battle/mechanic/action/btl_action_use_skill.erl @@ -79,7 +79,7 @@ cast_skill (Action, S0Update) -> ), {none, S3Update} = - btl_condition:apply_to_character + btl_conditions:apply_to_character ( ActorIX, ?CONDITION_TRIGGER_HAS_USED_THEIR_SKILL, @@ -89,7 +89,7 @@ cast_skill (Action, S0Update) -> ), {none, S3Update} = - btl_condition:apply_to_battle + btl_conditions:apply_to_battle ( ?CONDITION_TRIGGER_A_CHARACTER_HAS_USED_THEIR_SKILL, Action, @@ -115,7 +115,7 @@ handle (S0Action, S0Update) -> S0PerformAction = true, {{S1Action, S1PerformAction}, S1Update} = - btl_condition:apply_to_character + btl_conditions:apply_to_character ( ActorIX, ?CONDITION_TRIGGER_ABOUT_TO_USE_THEIR_SKILL, @@ -125,7 +125,7 @@ handle (S0Action, S0Update) -> ), {{S2Action, S2PerformAction}, S2Update} = - btl_condition:apply_to_battle + btl_conditions:apply_to_battle ( ?CONDITION_TRIGGER_A_CHARACTER_IS_ABOUT_TO_USE_THEIR_SKILL, none, diff --git a/src/battle/mechanic/btl_victory_progression.erl b/src/battle/mechanic/btl_victory_progression.erl index 45a6e89..1959731 100644 --- a/src/battle/mechanic/btl_victory_progression.erl +++ b/src/battle/mechanic/btl_victory_progression.erl @@ -114,7 +114,7 @@ handle_player_defeat (PlayerIX, S0Update) -> ), {_V3Nothing, S3Update} = - btl_condition:apply_to_battle + btl_conditions:apply_to_battle ( ?CONDITION_TRIGGER_PLAYER_DEFEAT, PlayerIX, @@ -135,7 +135,7 @@ handle_player_defeat (PlayerIX, S0Update) -> -> btl_character_turn_update:type(). handle_character_loss (ActorIX, S0Update) -> {_V0Nothing, S1Update} = - btl_condition:apply_to_character + btl_conditions:apply_to_character ( ActorIX, ?CONDITION_TRIGGER_HAS_DIED, @@ -145,7 +145,7 @@ handle_character_loss (ActorIX, S0Update) -> ), {_V1Nothing, S2Update} = - btl_condition:apply_to_battle + btl_conditions:apply_to_battle ( ?CONDITION_TRIGGER_A_CHARACTER_HAS_DIED, ActorIX, diff --git a/src/battle/mechanic/condition/btl_cond_heal.erl b/src/battle/mechanic/condition/btl_cond_heal.erl index fd3d94f..c677d32 100644 --- a/src/battle/mechanic/condition/btl_cond_heal.erl +++ b/src/battle/mechanic/condition/btl_cond_heal.erl @@ -11,7 +11,7 @@ -export ( [ - apply/4 + apply/3 ] ). @@ -25,15 +25,11 @@ -spec apply ( shr_condition:context(any(), VolatileDataType), - btl_condition:ref(), - btl_condition:type(), + btl_conditions:ref(), btl_character_turn_update:type() - ) -> - { - VolatileDataType, - btl_character_turn_update:type() - }. -apply (S0Context, _SelfRef, _S0Condition, S0Update) -> + ) + -> {VolatileDataType, btl_character_turn_update:type()}. +apply (S0Context, _SelfRef, S0Update) -> {_Trigger, _ReadOnlyData, VolatileData} = S0Context, {VolatileData, S0Update, none}. 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}) -> { diff --git a/src/bounty/bnt_join_battle.erl b/src/bounty/bnt_join_battle.erl index 4e6f7fe..3fccccc 100644 --- a/src/bounty/bnt_join_battle.erl +++ b/src/bounty/bnt_join_battle.erl @@ -90,7 +90,7 @@ create_character (PlayerIX, RosterChar, Map, ForbiddenLocations) -> optional, Location, ResolvedBaseChar, - btl_condition:new_collection() + btl_conditions:new() ), btl_character:to_unresolved(Result). |