summaryrefslogtreecommitdiff |
diff options
author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2018-12-20 14:44:41 +0100 |
---|---|---|
committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2018-12-20 14:44:41 +0100 |
commit | c69fe90821bba84c70b020a2504fe4ed63072158 (patch) | |
tree | ebb40443b25c0c03014d51625b5d7b692a622cd2 /src/battle/struct | |
parent | 71a4a4195292bef8f48e8a533f2d31bc4a53ac2e (diff) |
...
Diffstat (limited to 'src/battle/struct')
-rw-r--r-- | src/battle/struct/btl_battle.erl | 18 | ||||
-rw-r--r-- | src/battle/struct/btl_pending_battle.erl | 84 |
2 files changed, 93 insertions, 9 deletions
diff --git a/src/battle/struct/btl_battle.erl b/src/battle/struct/btl_battle.erl index dec7fd7..5cc7bc3 100644 --- a/src/battle/struct/btl_battle.erl +++ b/src/battle/struct/btl_battle.erl @@ -10,9 +10,9 @@ battle, { id :: id(), - used_armor_ids :: list(shr_armor:id()), - used_weapon_ids :: list(shr_weapon:id()), - used_tile_ids :: list(shr_tile:class_id()), + used_armor_ids :: ordsets:ordset(shr_armor:id()), + used_weapon_ids :: ordsets:ordset(shr_weapon:id()), + used_tile_ids :: ordsets:ordset(shr_tile:class_id()), map :: btl_map:type(), characters :: array:array(btl_character:type()), players :: array:array(btl_player:type()), @@ -86,13 +86,13 @@ get_all_timelines (Result, CurrentIndex, EndPoint, ArraySize, Players) -> -spec get_id (type()) -> id(). get_id (Battle) -> Battle#battle.id. --spec get_used_weapon_ids (type()) -> list(shr_weapon:id()). +-spec get_used_weapon_ids (type()) -> ordsets:ordset(shr_weapon:id()). get_used_weapon_ids (Battle) -> Battle#battle.used_weapon_ids. --spec get_used_armor_ids (type()) -> list(shr_armor:id()). +-spec get_used_armor_ids (type()) -> ordsets:ordset(shr_armor:id()). get_used_armor_ids (Battle) -> Battle#battle.used_armor_ids. --spec get_used_tile_ids (type()) -> list(shr_tile:class_id()). +-spec get_used_tile_ids (type()) -> ordsets:ordset(shr_tile:class_id()). get_used_tile_ids (Battle) -> Battle#battle.used_tile_ids. -spec get_map (type()) -> btl_map:type(). @@ -187,9 +187,9 @@ set_current_player_turn (PlayerTurn, Battle) -> list(btl_player:type()), btl_map:type(), list(btl_character:type()), - list(shr_weapon:id()), - list(shr_armor:id()), - list(shr_tile:class_id()) + ordsets:ordset(shr_weapon:id()), + ordsets:ordset(shr_armor:id()), + ordsets:ordset(shr_tile:class_id()) ) -> type(). new (ID, PlayersAsList, Map, CharactersAsList, UWIDs, UAIDs, UTIDs) -> diff --git a/src/battle/struct/btl_pending_battle.erl b/src/battle/struct/btl_pending_battle.erl new file mode 100644 index 0000000..6e21f79 --- /dev/null +++ b/src/battle/struct/btl_pending_battle.erl @@ -0,0 +1,84 @@ +-module(btl_pending_battle). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-type id() :: binary(). + +-record +( + pending_battle, + { + id :: id(), + free_slots :: non_neg_integer(), + battle :: btl_battle:type() + } +). + +-opaque type() :: #pending_battle{}. + +-export_type([type/0, id/0]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% Accessors +-export +( + [ + get_id/1, + get_battle/1, + get_free_slots/1, + + set_battle/2, + set_free_slots/2, + + get_battle_field/0, + get_free_slots_field/0 + ] +). + +-export +( + [ + new/3 + ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec new (id(), non_neg_integer(), btl_battle:type()) -> type(). +new (ID, FreeSlots, Battle) -> + #pending_battle + { + id = ID, + free_slots = FreeSlots, + battle = Battle + }. + +%%%% Accessors +-spec get_id (type()) -> id(). +get_id (PBattle) -> PBattle#pending_battle.id. + +-spec get_battle (type()) -> btl_battle:type(). +get_battle (PBattle) -> PBattle#pending_battle.battle. + +-spec get_free_slots (type()) -> non_neg_integer(). +get_free_slots (PBattle) -> PBattle#pending_battle.free_slots. + +-spec set_battle (btl_battle:type(), type()) -> type(). +set_battle (Battle, PBattle) -> PBattle#pending_battle{ battle = Battle }. + +-spec set_free_slots (non_neg_integer(), type()) -> type(). +set_free_slots (Val, PBattle) -> PBattle#pending_battle{ free_slots = Val }. + +-spec get_battle_field () -> non_neg_integer(). +get_battle_field () -> #pending_battle.battle. + +-spec get_free_slots_field () -> non_neg_integer(). +get_free_slots_field () -> #pending_battle.free_slots. |