summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/battle/struct')
-rw-r--r--src/battle/struct/btl_battle.erl20
-rw-r--r--src/battle/struct/btl_battlemap.erl100
2 files changed, 10 insertions, 110 deletions
diff --git a/src/battle/struct/btl_battle.erl b/src/battle/struct/btl_battle.erl
index dd68b42..97742aa 100644
--- a/src/battle/struct/btl_battle.erl
+++ b/src/battle/struct/btl_battle.erl
@@ -13,7 +13,7 @@
used_armor_ids :: list(shr_armor:id()),
used_weapon_ids :: list(shr_weapon:id()),
used_tile_ids :: list(btl_tile:id()),
- battlemap :: btl_battlemap:type(),
+ map :: btl_map:type(),
characters :: array:array(btl_character:type()),
players :: array:array(btl_player:type()),
current_player_turn :: btl_player_turn:type()
@@ -35,7 +35,7 @@
get_used_weapon_ids/1,
get_used_armor_ids/1,
get_used_tile_ids/1,
- get_battlemap/1,
+ get_map/1,
get_characters/1,
get_character/2,
get_players/1,
@@ -43,7 +43,7 @@
get_current_player_turn/1,
get_encoded_last_turns_effects/1,
- set_battlemap/2,
+ set_map/2,
set_characters/2,
set_character/3,
set_players/2,
@@ -95,8 +95,8 @@ get_used_armor_ids (Battle) -> Battle#battle.used_armor_ids.
-spec get_used_tile_ids (type()) -> list(btl_tile:id()).
get_used_tile_ids (Battle) -> Battle#battle.used_tile_ids.
--spec get_battlemap (type()) -> btl_battlemap:type().
-get_battlemap (Battle) -> Battle#battle.battlemap.
+-spec get_map (type()) -> btl_map:type().
+get_map (Battle) -> Battle#battle.map.
-spec get_characters (type()) -> array:array(btl_character:type()).
get_characters (Battle) -> Battle#battle.characters.
@@ -127,11 +127,11 @@ get_encoded_last_turns_effects (Battle) ->
StartingPoint = ((CurrentPlayerIX + 1) rem PlayersCount),
get_all_timelines([], StartingPoint, CurrentPlayerIX, PlayersCount, Players).
--spec set_battlemap (btl_battlemap:type(), type()) -> type().
-set_battlemap (Battlemap, Battle) ->
+-spec set_map (btl_map:type(), type()) -> type().
+set_map (Battlemap, Battle) ->
Battle#battle
{
- battlemap = Battlemap
+ map = Battlemap
}.
-spec set_characters (array:array(btl_character:type()), type()) -> type().
@@ -185,7 +185,7 @@ set_current_player_turn (PlayerTurn, Battle) ->
(
id(),
list(btl_player:type()),
- btl_battlemap:type(),
+ btl_map:type(),
list(btl_character:type()),
list(shr_weapon:id()),
list(shr_armor:id()),
@@ -199,7 +199,7 @@ new (ID, PlayersAsList, Battlemap, CharactersAsList, UWIDs, UAIDs, UTIDs) ->
used_weapon_ids = UWIDs,
used_armor_ids = UAIDs,
used_tile_ids = UTIDs,
- battlemap = Battlemap,
+ map = Battlemap,
characters = array:from_list(CharactersAsList),
players = array:from_list(PlayersAsList),
current_player_turn = btl_player_turn:new(0, 0)
diff --git a/src/battle/struct/btl_battlemap.erl b/src/battle/struct/btl_battlemap.erl
deleted file mode 100644
index 886e2a9..0000000
--- a/src/battle/struct/btl_battlemap.erl
+++ /dev/null
@@ -1,100 +0,0 @@
--module(btl_battlemap).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--type id() :: binary().
-
--record
-(
- battlemap,
- {
- id :: id(),
- width :: integer(),
- height :: integer(),
- tile_class_ids :: array:array(btl_tile:class_id())
- }
-).
-
--opaque type() :: #battlemap{}.
-
--export_type([type/0, id/0]).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%% Accessors
--export
-(
- [
- get_id/1,
- get_width/1,
- get_height/1,
- get_tile_class_ids/1,
- get_tile_class_id/2
- ]
-).
-
--export
-(
- [
- from_list/4
- ]
-).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--spec location_to_array_index
- (
- non_neg_integer(),
- btl_location:type()
- )
- -> ('error' | non_neg_integer()).
-location_to_array_index (ArrayWidth, {X, Y}) ->
- if
- (X < 0) -> error;
- (Y < 0) -> error;
- (X >= ArrayWidth) -> error;
- true -> ((Y * ArrayWidth) + X)
- end.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%% Accessors
--spec get_id (type()) -> id().
-get_id (Battlemap) -> Battlemap#battlemap.id.
-
--spec get_width (type()) -> integer().
-get_width (Battlemap) -> Battlemap#battlemap.width.
-
--spec get_height (type()) -> integer().
-get_height (Battlemap) -> Battlemap#battlemap.height.
-
--spec get_tile_class_ids (type()) -> array:array(btl_tile:class_id()).
-get_tile_class_ids (Battlemap) -> Battlemap#battlemap.tile_class_ids.
-
--spec get_tile_class_id (btl_location:type(), type()) -> btl_tile:class_id().
-get_tile_class_id (Location, Battlemap) ->
- TileIX = location_to_array_index(Battlemap#battlemap.width, Location),
- array:get(TileIX, Battlemap#battlemap.tile_class_ids).
-
--spec from_list
- (
- non_neg_integer(),
- non_neg_integer(),
- non_neg_integer(),
- list(non_neg_integer())
- )
- -> type().
-from_list (ID, Width, Height, List) ->
- TileClassIDs = lists:map(fun btl_tile:class_id_from_int/1, List),
-
- #battlemap
- {
- id = list_to_binary(integer_to_list(ID)),
- width = Width,
- height = Height,
- tile_class_ids = array:from_list(TileClassIDs)
- }.