| summaryrefslogtreecommitdiff | 
diff options
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | include/tacticians/conditions.hrl | 8 | ||||
| -rw-r--r-- | src/battle/mechanic/action/btl_action_switch_weapons.erl (renamed from src/battle/mechanic/action/btl_action_switch_weapon.erl) | 2 | ||||
| -rw-r--r-- | src/battle/mechanic/action/btl_action_use_skill.erl (renamed from src/battle/mechanic/action/btl_action_skill.erl) | 14 | ||||
| -rw-r--r-- | src/battle/mechanic/btl_actions_management.erl | 6 | ||||
| -rw-r--r-- | src/battle/mechanic/skill/btl_skill_static_heal.erl | 8 | ||||
| -rw-r--r-- | src/battle/struct/btl_action.erl | 132 | ||||
| -rw-r--r-- | src/battle/struct/btl_character_turn_request.erl | 89 | ||||
| -rw-r--r-- | src/battle/struct/btl_condition.erl | 63 | 
9 files changed, 166 insertions, 159 deletions
| @@ -113,7 +113,7 @@ run_db_node: build  	$(ERL_EXEC) $(ERL_NAME_VS_SNAME) db_node -run db_node start  run_query_node: build $(YAWS_CONFIG_FILE) -	$(YAWS_EXEC) --conf $(YAWS_CONFIG_FILE)  +	$(YAWS_EXEC) --conf $(YAWS_CONFIG_FILE)  clean:  	# Preprocessor @@ -152,6 +152,7 @@ $(PREPROCESSED_FILES): %: %.m4 .PHONY  $(OPTIONAL_DIRS): %:  	mkdir -p $@ +# [TODO][IMPORTANT] Handle 'include' directives.  $(ERL_BIN_FILES): $(BIN_DIR)/%.beam: $(SRC_DIR)/%.erl  	mkdir -p $(dir $@)  	$(ERLC_EXEC) -o $(dir $@) $< diff --git a/include/tacticians/conditions.hrl b/include/tacticians/conditions.hrl index cc27972..3558732 100644 --- a/include/tacticians/conditions.hrl +++ b/include/tacticians/conditions.hrl @@ -54,8 +54,8 @@  -define(CONDITION_TRIGGER_HAS_SWITCHED_WEAPONS, hsw).  -define(CONDITION_TRIGGER_A_CHARACTER_HAS_SWITCHED_WEAPONS, achsw). --define(CONDITION_TRIGGER_ABOUT_TO_CAST_SKILL, atcs). --define(CONDITION_TRIGGER_A_CHARACTER_IS_ABOUT_TO_CAST_SKILL, aciatcs). +-define(CONDITION_TRIGGER_ABOUT_TO_USE_THEIR_SKILL, atcs). +-define(CONDITION_TRIGGER_A_CHARACTER_IS_ABOUT_TO_USE_THEIR_SKILL, aciatcs). --define(CONDITION_TRIGGER_HAS_CAST_SKILL, hcs). --define(CONDITION_TRIGGER_A_CHARACTER_HAS_CAST_SKILL, achcs). +-define(CONDITION_TRIGGER_HAS_USED_THEIR_SKILL, hcs). +-define(CONDITION_TRIGGER_A_CHARACTER_HAS_USED_THEIR_SKILL, achcs). diff --git a/src/battle/mechanic/action/btl_action_switch_weapon.erl b/src/battle/mechanic/action/btl_action_switch_weapons.erl index 10348bc..693c258 100644 --- a/src/battle/mechanic/action/btl_action_switch_weapon.erl +++ b/src/battle/mechanic/action/btl_action_switch_weapons.erl @@ -1,4 +1,4 @@ --module(btl_action_switch_weapon). +-module(btl_action_switch_weapons).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/battle/mechanic/action/btl_action_skill.erl b/src/battle/mechanic/action/btl_action_use_skill.erl index 7e6579b..154d7db 100644 --- a/src/battle/mechanic/action/btl_action_skill.erl +++ b/src/battle/mechanic/action/btl_action_use_skill.erl @@ -1,4 +1,4 @@ --module(btl_action_skill). +-module(btl_action_use_skill).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -22,7 +22,7 @@        non_neg_integer(),        btl_character_turn_update:type()     ) -   -> btl_character_turn_update:type(). +   -> {btl_character_turn_update:type(), shr_skill:type()}.  pay_for_cast (ActorIX, S0Update) ->     S0Battle = btl_character_turn_update:get_battle(S0Update),     S0Actor = btl_battle:get_character(ActorIX, S0Battle), @@ -51,7 +51,7 @@ pay_for_cast (ActorIX, S0Update) ->        ),     S1Update = -      btl_character_turn:ataxia_set_battle +      btl_character_turn_update:ataxia_set_battle        (           S1Battle,           BattleAtaxiaUpdate, @@ -82,7 +82,7 @@ cast_skill (Action, S0Update) ->        btl_condition:apply_to_character        (           ActorIX, -         ?CONDITION_TRIGGER_HAS_CAST_SKILL, +         ?CONDITION_TRIGGER_HAS_USED_THEIR_SKILL,           Action,           none,           S2Update @@ -91,7 +91,7 @@ cast_skill (Action, S0Update) ->     {none, S3Update} =        btl_condition:apply_to_battle        ( -         ?CONDITION_TRIGGER_A_CHARACTER_HAS_CAST_SKILL, +         ?CONDITION_TRIGGER_A_CHARACTER_HAS_USED_THEIR_SKILL,           Action,           none,           S2Update @@ -118,7 +118,7 @@ handle (S0Action, S0Update) ->        btl_condition:apply_to_character        (           ActorIX, -         ?CONDITION_TRIGGER_ABOUT_TO_CAST_SKILL, +         ?CONDITION_TRIGGER_ABOUT_TO_USE_THEIR_SKILL,           none,           {S0Action, S0PerformAction},           S0Update @@ -127,7 +127,7 @@ handle (S0Action, S0Update) ->     {{S2Action, S2PerformAction}, S2Update} =        btl_condition:apply_to_battle        ( -         ?CONDITION_TRIGGER_A_CHARACTER_IS_ABOUT_TO_CAST_SKILL, +         ?CONDITION_TRIGGER_A_CHARACTER_IS_ABOUT_TO_USE_THEIR_SKILL,           none,           {S1Action, S1PerformAction},           S1Update diff --git a/src/battle/mechanic/btl_actions_management.erl b/src/battle/mechanic/btl_actions_management.erl index a3f9365..6305de7 100644 --- a/src/battle/mechanic/btl_actions_management.erl +++ b/src/battle/mechanic/btl_actions_management.erl @@ -30,9 +30,9 @@ handle (S0Update) ->              case btl_action:get_category(Action) of                 move -> btl_action_move:handle(Action, S1Update);                 attack -> btl_action_attack:handle(Action, S1Update); -               skill -> btl_action_skill:handle(Action, S1Update); -               switch_weapon -> -                  btl_action_switch_weapon:handle(Action, S1Update) +               skill -> btl_action_use_skill:handle(Action, S1Update); +               switch_weapons -> +                  btl_action_switch_weapons:handle(Action, S1Update)              end,           handle(S2Update) diff --git a/src/battle/mechanic/skill/btl_skill_static_heal.erl b/src/battle/mechanic/skill/btl_skill_static_heal.erl index b1b7018..90d3154 100644 --- a/src/battle/mechanic/skill/btl_skill_static_heal.erl +++ b/src/battle/mechanic/skill/btl_skill_static_heal.erl @@ -10,7 +10,7 @@  -export  (     [ -      cast/5 +      cast/3     ]  ). @@ -24,11 +24,9 @@  -spec cast     (        shr_skill:type(), -      non_neg_integer(), -      list(non_neg_integer()), -      list(shr_location:type()), +      btl_action:type(),        btl_character_turn_update:type()     )     -> btl_character_turn_update:type(). -cast (_Skill, _UserIX, _TargetIXs, _Locations, S0Update) -> +cast (_Skill, _Action, S0Update) ->     S0Update. diff --git a/src/battle/struct/btl_action.erl b/src/battle/struct/btl_action.erl index 7feb986..71a9636 100644 --- a/src/battle/struct/btl_action.erl +++ b/src/battle/struct/btl_action.erl @@ -3,6 +3,19 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-define(CATEGORY_FIELD, <<"cat">>). +-define(CATEGORY_MOVE, <<"mov">>). +-define(CATEGORY_ATTACK, <<"atk">>). +-define(CATEGORY_SWITCH_WEAPONS, <<"swp">>). +-define(CATEGORY_USE_SKILL, <<"skl">>). + +-define(MOVE_PATH_FIELD, <<"pat">>). + +-define(ATTACK_TARGET_FIELD, <<"tar">>). + +-define(USE_SKILL_TARGETS_FIELD, <<"tar">>). +-define(USE_SKILL_LOCATIONS_FIELD, <<"loc">>). +  -record  (     move, @@ -15,7 +28,7 @@  -record  ( -   switch_weapon, +   switch_weapons,     {        actor_ix :: non_neg_integer()     } @@ -44,7 +57,7 @@  -type category() ::     (        'move' -      | 'switch_weapon' +      | 'switch_weapons'        | 'attack'        | 'skill'        | 'nothing' @@ -53,7 +66,7 @@  -opaque type() ::     (        #move{} -      | #switch_weapon{} +      | #switch_weapons{}        | #attack{}        | #skill{}     ). @@ -67,10 +80,6 @@  (     [        from_map_marker/3, -      maybe_decode_move/2, -      maybe_decode_weapon_switch/2, -      maybe_decode_attack/2, -      maybe_decode_skill/2,        can_follow/2     ]  ). @@ -99,79 +108,63 @@     ]  ). -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export +( +   [ +      decode/2 +   ] +).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec maybe_decode_move -   ( -      non_neg_integer(), -      list(shr_direction:type()) -   ) -   -> ({ok, type()} | none). -maybe_decode_move (_CharacterIX, []) -> none; -maybe_decode_move (CharacterIX, PathInBinary) -> -   Path = lists:map(fun shr_direction:decode/1, PathInBinary), +-spec decode (binary(), non_neg_integer(), map()) -> type(). +decode (?CATEGORY_MOVE, ActorIX, Map) -> +   EncodedPath = map:get(?MOVE_PATH_FIELD, Map), +   Path = lists:map(fun shr_direction:decode/1, EncodedPath), +   #move     { -      ok, -      #move -      { -         actor_ix = CharacterIX, -         path = Path, -         movement_points = -1 -      } -   }. +      actor_ix = ActorIX, +      path = Path, +      movement_points = -1 +   }; +decode (?CATEGORY_ATTACK, ActorIX, Map) -> +   TargetIX = map:get(?ATTACK_TARGET_FIELD, Map), --spec maybe_decode_attack -   ( -      non_neg_integer(), -      integer() -   ) -   -> ({ok, type()} | none). -maybe_decode_attack (_CharacterIX, TargetIX) when (TargetIX < 0) -> none; -maybe_decode_attack (CharacterIX, TargetIX) -> +   #attack     { -      ok, -      #attack -      { -         actor_ix = CharacterIX, -         target_ix = TargetIX, -         is_opportunistic = false -      } -   }. +      actor_ix = ActorIX, +      target_ix = TargetIX, +      is_opportunistic = false +   }; +decode (?CATEGORY_SWITCH_WEAPONS, ActorIX, _Map) -> +   #switch_weapons +   { +      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), +   Locations = lists:map(fun shr_location:decode/1, EncodedLocations), --spec maybe_decode_weapon_switch -   ( -      non_neg_integer(), -      boolean() -   ) -   -> ({ok, type()} | none). -maybe_decode_weapon_switch (_CharacterIX, false) -> none; -maybe_decode_weapon_switch (CharacterIX, true) -> -   {ok, #switch_weapon{ actor_ix = CharacterIX }}. - --spec maybe_decode_skill (non_neg_integer(), any()) -> ({ok, type()} | none). -maybe_decode_skill (_CharacterIX, what) -> none; -maybe_decode_skill (CharacterIX, _) -> -   % TODO +   #skill     { -      ok, -      #skill -      { -         actor_ix = CharacterIX -      } +      actor_ix = ActorIX, +      targets = Targets, +      locations = Locations     }. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  -spec can_follow (category(), category()) -> boolean().  can_follow (nothing, attack) -> true; -can_follow (nothing, switch_weapon) -> true; +can_follow (nothing, switch_weapons) -> true;  can_follow (nothing, move) -> true;  can_follow (nothing, skill) -> true; -can_follow (move, switch_weapon) -> true; +can_follow (move, switch_weapons) -> true;  can_follow (move, attack) -> true;  can_follow (move, skill) -> true;  can_follow (_, _) -> false. @@ -206,8 +199,8 @@ get_actor_index (Action) when is_record(Action, attack) ->     Action#attack.actor_ix;  get_actor_index (Action) when is_record(Action, move) ->     Action#move.actor_ix; -get_actor_index (Action) when is_record(Action, switch_weapon) -> -   Action#switch_weapon.actor_ix; +get_actor_index (Action) when is_record(Action, switch_weapons) -> +   Action#switch_weapons.actor_ix;  get_actor_index (Action) when is_record(Action, skill) ->     Action#skill.actor_ix;  get_actor_index (_) -> @@ -274,9 +267,12 @@ new_skill (ActorIX, Targets, Locations) ->  -spec get_category (type()) -> category().  get_category (Action) when is_record(Action, attack) -> attack;  get_category (Action) when is_record(Action, move) -> move; -get_category (Action) when is_record(Action, switch_weapon) -> switch_weapon; +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). +  -spec from_map_marker     (        non_neg_integer(), diff --git a/src/battle/struct/btl_character_turn_request.erl b/src/battle/struct/btl_character_turn_request.erl index 3596b4b..9f5747f 100644 --- a/src/battle/struct/btl_character_turn_request.erl +++ b/src/battle/struct/btl_character_turn_request.erl @@ -5,10 +5,6 @@  -define(BATTLE_ID_FIELD, <<"bid">>).  -define(CHAR_IX_FIELD, <<"cix">>).  -define(ACTIONS_FIELD, <<"act">>). --define(ACTIONS_MOVE_FIELD, <<"mov">>). --define(ACTIONS_WEAPON_SWITCH_FIELD, <<"wps">>). --define(ACTIONS_SKILL_FIELD, <<"skl">>). --define(ACTIONS_ATTACK_FIELD, <<"tar">>).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -53,58 +49,28 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec decode_actions (non_neg_integer(), map()) -> list(btl_action:type()). -decode_actions (CharacterIX, Act) -> -   S0Result = [], -   S1Result = -      case -         btl_action:maybe_decode_move -         ( -            CharacterIX, -            maps:get(?ACTIONS_MOVE_FIELD, Act) -         ) -      of -         {ok, Move} -> [Move|S0Result]; -         none -> S0Result -      end, - -   S2Result = -      case -         btl_action:maybe_decode_attack -         ( -            CharacterIX, -            maps:get(?ACTIONS_ATTACK_FIELD, Act) -         ) -      of -         {ok, Atk} -> [Atk|S1Result]; -         none -> S1Result -      end, - -   S3Result = -      case -         btl_action:maybe_decode_weapon_switch -         ( -            CharacterIX, -            maps:get(?ACTIONS_WEAPON_SWITCH_FIELD, Act) -         ) -      of -         {ok, Wps} -> [Wps|S2Result]; -         none -> S2Result -      end, - -   S4Result = -      case -         btl_action:maybe_decode_skill -         ( -            CharacterIX, -            maps:get(?ACTIONS_SKILL_FIELD, Act) -         ) -      of -         {ok, Skill} -> [Skill|S3Result]; -         none -> S3Result -      end, - -   lists:reverse(S4Result). +-spec validate_actions (list(btl_action:type())) -> ok. +validate_actions (Actions) -> +   {AreValid, _LastAction} = +      lists:foldl +      ( +         fun (Action, {CurrentResult, PrevAction}) -> +            { +               case CurrentResult of +                  false -> false; +                  true -> btl_action:can_follow(PrevAction, Action) +               end, +               Action +            } +         end, +         {true, nothing}, +         Actions +      ), + +   case AreValid of +      false -> error({actions, Actions}); +      true -> ok +   end.  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -113,7 +79,16 @@ decode_actions (CharacterIX, Act) ->  decode (Map) ->     CharacterIX = maps:get(?CHAR_IX_FIELD, Map),     EncodedActions = maps:get(?ACTIONS_FIELD, Map), -   Actions = decode_actions(CharacterIX, EncodedActions), +   Actions = +      lists:map +      ( +         fun (EncodedAction) -> +            btl_action:decode(CharacterIX, EncodedAction) +         end, +         EncodedActions +      ), + +   validate_actions(Actions),     #type     { diff --git a/src/battle/struct/btl_condition.erl b/src/battle/struct/btl_condition.erl index 695830b..ee582d9 100644 --- a/src/battle/struct/btl_condition.erl +++ b/src/battle/struct/btl_condition.erl @@ -5,6 +5,13 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  -include("tacticians/conditions.hrl"). +-type visibility() :: +   ( +      none +      | {limited, ordsets:ordsets(non_neg_integer())} % PlayerIXs +      | all +   ). +  -type update_action() ::     (        none @@ -24,14 +31,15 @@     {        category :: shr_condition:id(),        triggers :: ordsets:ordset(shr_condition:trigger()), -      parameters :: tuple() +      parameters :: tuple(), +      visibility :: visibility()     }  ).  -opaque type() :: #btl_cond{}.  -opaque collection() :: orddict:orddict(non_neg_integer(), type()). --export_type([type/0, ref/0, collection/0, update_action/0]). +-export_type([type/0, ref/0, visibility/0, collection/0, update_action/0]).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -42,21 +50,26 @@        get_category/1,        get_triggers/1,        get_parameters/1, +      get_visibility/1, -      set_triggers/2, -      set_parameters/2, +      set_visibility/2, +      ataxia_set_visibility/2, +      set_triggers/2,        ataxia_set_triggers/2, -      ataxia_set_parameters/2, -        ataxia_set_triggers/3, + +      set_parameters/2, +      ataxia_set_parameters/2,        ataxia_set_parameters/3, +        get_category_field/0,        get_triggers_field/0,        get_parameters_field/0, +      get_visibility_field/0, -      new/3, +      new/4,        new_collection/0     ]  ). @@ -74,8 +87,7 @@  -export  (     [ -      encode/1, -      encode_collection/1 +      encode_collection_for/2     ]  ).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -437,8 +449,33 @@ new (CondID, Triggers, Params) ->  -spec new_collection () -> collection().  new_collection () -> orddict:new(). --spec encode (type()) -> {list({binary(), any()})}. -encode (Condition) -> {[]}. % TODO +-spec encode +   ( +      non_neg_integer(), +      type() +   ) +   -> list({binary(), any()}). +encode (IX, Condition) -> todo. % TODO --spec encode_collection (collection()) -> {list({binary(), any()})}. -encode_collection (Conditions) -> {[]}. % TODO +-spec encode_collection_for +   ( +      non_neg_integer(), +      collection() +   ) +   -> list({binary(), any()}). +encode_collection_for (PlayerIX, Conditions) -> +   lists:filtermap +   ( +      fun ({IX, Condition}) -> +         case Condition#btl_cond.visibility of +            none -> false; +            any -> encode(IX, Condition); +            {limited, AllowedPlayerIXs} -> +               case ordsets:is_element(PlayerIX, AllowedPlayerIXs) of +                  false -> false; +                  true -> {true, encode(IX, Condition)} +               end +         end +      end, +      orddict:to_list(Conditions) +   ). | 


