summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-07-12 17:48:41 +0200
committernsensfel <SpamShield0@noot-noot.org>2018-07-12 17:48:41 +0200
commita132188ccc244a6d802bd1c32fbf196d4cb53cbd (patch)
treebd54e576ea8164d3efc801d9c56420218a74e591
parentb853df7a1c3efef6b84b90fe8c492611564f8b53 (diff)
Got it to load the map (full of "error" tiles).
-rw-r--r--src/battle/btl_shim.erl28
-rw-r--r--src/battle/game-logic/btl_movement.erl12
-rw-r--r--src/battle/game-logic/btl_turn_actions.erl4
-rw-r--r--src/battle/reply/btl_set_map.erl8
-rw-r--r--src/battle/struct/btl_battle.erl8
-rw-r--r--src/battle/struct/btl_character.erl14
-rw-r--r--src/battle/struct/btl_map.erl14
-rw-r--r--src/db/db_node.erl6
-rw-r--r--src/db/struct/db_model.erl19
-rw-r--r--src/map/map_shim.erl2
-rw-r--r--src/map/query/map_load.erl2
-rw-r--r--src/map/reply/map_add_tile.erl14
-rw-r--r--src/map/reply/map_set_map.erl12
-rw-r--r--src/map/struct/map_direction.erl2
-rw-r--r--src/map/struct/map_location.erl4
-rw-r--r--src/map/struct/map_map.erl (renamed from src/map/struct/map_battlemap.erl)13
-rw-r--r--src/map/struct/map_tile.erl2
17 files changed, 88 insertions, 76 deletions
diff --git a/src/battle/btl_shim.erl b/src/battle/btl_shim.erl
index 2964a76..07ec687 100644
--- a/src/battle/btl_shim.erl
+++ b/src/battle/btl_shim.erl
@@ -30,7 +30,7 @@ generate_random_characters
0,
_CharactersPerPlayer,
_TotalCharacterCount,
- _Battlemap,
+ _Map,
_ForbiddenLocations,
Result
) ->
@@ -41,7 +41,7 @@ generate_random_characters
0,
CharactersPerPlayer,
TotalCharacterCount,
- Battlemap,
+ Map,
ForbiddenLocations,
Result
) ->
@@ -51,7 +51,7 @@ generate_random_characters
CharactersPerPlayer,
CharactersPerPlayer,
TotalCharacterCount,
- Battlemap,
+ Map,
ForbiddenLocations,
Result
);
@@ -61,7 +61,7 @@ generate_random_characters
PlayerCharacterCount,
CharactersPerPlayer,
TotalCharacterCount,
- Battlemap,
+ Map,
ForbiddenLocations,
Result
) ->
@@ -70,8 +70,8 @@ generate_random_characters
(
TotalCharacterCount,
MaxPlayerIX,
- btl_map:get_width(Battlemap),
- btl_map:get_height(Battlemap),
+ btl_map:get_width(Map),
+ btl_map:get_height(Map),
ForbiddenLocations
),
Character =
@@ -86,7 +86,7 @@ generate_random_characters
(PlayerCharacterCount - 1),
CharactersPerPlayer,
(TotalCharacterCount + 1),
- Battlemap,
+ Map,
[btl_character:get_location(Character)|ForbiddenLocations],
[Character|Result]
).
@@ -132,11 +132,11 @@ demo_map () ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-spec generate_random_battle () -> btl_battle:type().
generate_random_battle () ->
- %BattlemapWidth = 32, % shr_roll:between(16, 32),
- %BattlemapHeight = 32, %shr_roll:between(16, 32),
- %Battlemap = btl_map:random(0, BattlemapWidth, BattlemapHeight),
- Battlemap = btl_map:from_list(0, 32, 32, demo_map()),
- Characters = generate_random_characters(1, 8, 8, 0, Battlemap, [], []),
+ %MapWidth = 32, % shr_roll:between(16, 32),
+ %MapHeight = 32, %shr_roll:between(16, 32),
+ %Map = btl_map:random(0, MapWidth, MapHeight),
+ Map = btl_map:from_list(0, 32, 32, demo_map()),
+ Characters = generate_random_characters(1, 8, 8, 0, Map, [], []),
PlayersAsList = [btl_player:new(0, 8, <<"0">>), btl_player:new(1, 0, <<"1">>)],
{UsedWeaponIDs, UsedArmorIDs} =
@@ -165,7 +165,7 @@ generate_random_battle () ->
)
end,
sets:new(),
- btl_map:get_tile_class_ids(Battlemap)
+ btl_map:get_tile_class_ids(Map)
),
Battle =
@@ -173,7 +173,7 @@ generate_random_battle () ->
(
<<"0">>,
PlayersAsList,
- Battlemap,
+ Map,
Characters,
sets:to_list(UsedWeaponIDs),
sets:to_list(UsedArmorIDs),
diff --git a/src/battle/game-logic/btl_movement.erl b/src/battle/game-logic/btl_movement.erl
index f78eca1..9acce73 100644
--- a/src/battle/game-logic/btl_movement.erl
+++ b/src/battle/game-logic/btl_movement.erl
@@ -26,11 +26,11 @@
btl_location:type()
)
-> {btl_location:type(), non_neg_integer()}.
-cross (_Battlemap, _ForbiddenLocations, [], Cost, Location) ->
+cross (_Map, _ForbiddenLocations, [], Cost, Location) ->
{Location, Cost};
-cross (Battlemap, ForbiddenLocations, [Step|NextSteps], Cost, Location) ->
+cross (Map, ForbiddenLocations, [Step|NextSteps], Cost, Location) ->
NextLocation = btl_location:apply_direction(Step, Location),
- NextTileClassID = btl_map:get_tile_class_id(NextLocation, Battlemap),
+ NextTileClassID = btl_map:get_tile_class_id(NextLocation, Map),
NextTileID = btl_tile:class_id_to_type_id(NextTileClassID),
NextTile = btl_tile:from_id(NextTileID),
NextCost = (Cost + btl_tile:get_cost(NextTile)),
@@ -46,7 +46,7 @@ cross (Battlemap, ForbiddenLocations, [Step|NextSteps], Cost, Location) ->
IsForbidden = false,
- cross(Battlemap, ForbiddenLocations, NextSteps, NextCost, NextLocation).
+ cross(Map, ForbiddenLocations, NextSteps, NextCost, NextLocation).
-spec cross
(
@@ -56,5 +56,5 @@ cross (Battlemap, ForbiddenLocations, [Step|NextSteps], Cost, Location) ->
btl_location:type()
)
-> {btl_location:type(), non_neg_integer()}.
-cross (Battlemap, ForbiddenLocations, Path, Location) ->
- cross(Battlemap, ForbiddenLocations, Path, 0, Location).
+cross (Map, ForbiddenLocations, Path, Location) ->
+ cross(Map, ForbiddenLocations, Path, 0, Location).
diff --git a/src/battle/game-logic/btl_turn_actions.erl b/src/battle/game-logic/btl_turn_actions.erl
index d46818f..caf2e26 100644
--- a/src/battle/game-logic/btl_turn_actions.erl
+++ b/src/battle/game-logic/btl_turn_actions.erl
@@ -79,7 +79,7 @@ get_path_cost_and_destination (Data, Path) ->
Character = btl_character_turn_data:get_character(Data),
CharacterIX = btl_character_turn_data:get_character_ix(Data),
Battle = btl_character_turn_data:get_battle(Data),
- Battlemap = btl_battle:get_map(Battle),
+ Map = btl_battle:get_map(Battle),
ForbiddenLocations =
array:foldl
@@ -99,7 +99,7 @@ get_path_cost_and_destination (Data, Path) ->
{NewLocation, Cost} =
btl_movement:cross
(
- Battlemap,
+ Map,
ForbiddenLocations,
Path,
btl_character:get_location(Character)
diff --git a/src/battle/reply/btl_set_map.erl b/src/battle/reply/btl_set_map.erl
index c520930..b4025b1 100644
--- a/src/battle/reply/btl_set_map.erl
+++ b/src/battle/reply/btl_set_map.erl
@@ -17,15 +17,15 @@
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-spec generate (btl_map:type()) -> {list(any())}.
-generate (Battlemap) ->
+generate (Map) ->
{
[
{<<"msg">>, <<"set_map">>},
- {<<"w">>, btl_map:get_width(Battlemap)},
- {<<"h">>, btl_map:get_height(Battlemap)},
+ {<<"w">>, btl_map:get_width(Map)},
+ {<<"h">>, btl_map:get_height(Map)},
{
<<"t">>,
- array:sparse_to_list(btl_map:get_tile_class_ids(Battlemap))
+ array:sparse_to_list(btl_map:get_tile_class_ids(Map))
}
]
}.
diff --git a/src/battle/struct/btl_battle.erl b/src/battle/struct/btl_battle.erl
index 97742aa..22c96f6 100644
--- a/src/battle/struct/btl_battle.erl
+++ b/src/battle/struct/btl_battle.erl
@@ -128,10 +128,10 @@ get_encoded_last_turns_effects (Battle) ->
get_all_timelines([], StartingPoint, CurrentPlayerIX, PlayersCount, Players).
-spec set_map (btl_map:type(), type()) -> type().
-set_map (Battlemap, Battle) ->
+set_map (Map, Battle) ->
Battle#battle
{
- map = Battlemap
+ map = Map
}.
-spec set_characters (array:array(btl_character:type()), type()) -> type().
@@ -192,14 +192,14 @@ set_current_player_turn (PlayerTurn, Battle) ->
list(btl_tile:id())
)
-> type().
-new (ID, PlayersAsList, Battlemap, CharactersAsList, UWIDs, UAIDs, UTIDs) ->
+new (ID, PlayersAsList, Map, CharactersAsList, UWIDs, UAIDs, UTIDs) ->
#battle
{
id = ID,
used_weapon_ids = UWIDs,
used_armor_ids = UAIDs,
used_tile_ids = UTIDs,
- map = Battlemap,
+ map = Map,
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_character.erl b/src/battle/struct/btl_character.erl
index d9362ea..3f5c360 100644
--- a/src/battle/struct/btl_character.erl
+++ b/src/battle/struct/btl_character.erl
@@ -89,9 +89,9 @@
list({non_neg_integer(), non_neg_integer()})
)
-> {non_neg_integer(), non_neg_integer()}.
-find_random_location (BattlemapWidth, BattlemapHeight, ForbiddenLocations) ->
- X = shr_roll:between(0, (BattlemapWidth - 1)),
- Y = shr_roll:between(0, (BattlemapHeight - 1)),
+find_random_location (MapWidth, MapHeight, ForbiddenLocations) ->
+ X = shr_roll:between(0, (MapWidth - 1)),
+ Y = shr_roll:between(0, (MapHeight - 1)),
IsForbidden = lists:member({X, Y}, ForbiddenLocations),
@@ -99,8 +99,8 @@ find_random_location (BattlemapWidth, BattlemapHeight, ForbiddenLocations) ->
true ->
find_random_location
(
- BattlemapWidth,
- BattlemapHeight,
+ MapWidth,
+ MapHeight,
ForbiddenLocations
);
@@ -241,9 +241,9 @@ set_statistics (Stats, Char) ->
list({non_neg_integer(), non_neg_integer()})
)
-> type().
-random (ID, PlayerIX, BattlemapWidth, BattlemapHeight, ForbiddenLocations) ->
+random (ID, PlayerIX, MapWidth, MapHeight, ForbiddenLocations) ->
Location =
- find_random_location(BattlemapWidth, BattlemapHeight, ForbiddenLocations),
+ find_random_location(MapWidth, MapHeight, ForbiddenLocations),
WeaponIDs = {shr_weapon:random_id(), shr_weapon:random_id()},
ArmorID = shr_armor:random_id(),
Attributes = shr_attributes:random(),
diff --git a/src/battle/struct/btl_map.erl b/src/battle/struct/btl_map.erl
index ef34833..83cf455 100644
--- a/src/battle/struct/btl_map.erl
+++ b/src/battle/struct/btl_map.erl
@@ -64,21 +64,21 @@ location_to_array_index (ArrayWidth, {X, Y}) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Accessors
-spec get_id (type()) -> id().
-get_id (Battlemap) -> Battlemap#map.id.
+get_id (Map) -> Map#map.id.
-spec get_width (type()) -> integer().
-get_width (Battlemap) -> Battlemap#map.width.
+get_width (Map) -> Map#map.width.
-spec get_height (type()) -> integer().
-get_height (Battlemap) -> Battlemap#map.height.
+get_height (Map) -> Map#map.height.
-spec get_tile_class_ids (type()) -> array:array(btl_tile:class_id()).
-get_tile_class_ids (Battlemap) -> Battlemap#map.tile_class_ids.
+get_tile_class_ids (Map) -> Map#map.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#map.width, Location),
- array:get(TileIX, Battlemap#map.tile_class_ids).
+get_tile_class_id (Location, Map) ->
+ TileIX = location_to_array_index(Map#map.width, Location),
+ array:get(TileIX, Map#map.tile_class_ids).
-spec from_list
(
diff --git a/src/db/db_node.erl b/src/db/db_node.erl
index be295c6..aaf6ae3 100644
--- a/src/db/db_node.erl
+++ b/src/db/db_node.erl
@@ -25,7 +25,9 @@ wait_for_stop () ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-spec start () -> 'ok'.
start () ->
- DB = db_model:new(battle_db, "/tmp/battle_db.mnesia", []),
- db_model:start(DB),
+ Mnesia = db_model:new("/tmp/to_db_node.mnesia", []),
+ db_model:start(Mnesia),
+ db_model:add_db(battle_db, Mnesia),
+ db_model:add_db(map_db, Mnesia),
wait_for_stop(),
ok.
diff --git a/src/db/struct/db_model.erl b/src/db/struct/db_model.erl
index e6ec721..2cd58d4 100644
--- a/src/db/struct/db_model.erl
+++ b/src/db/struct/db_model.erl
@@ -8,7 +8,6 @@
(
db_model,
{
- name :: atom(),
store_file :: string(),
neighbors :: list(node())
}
@@ -24,7 +23,8 @@
-export
(
[
- new/3,
+ new/2,
+ add_db/2,
start/1
]
).
@@ -36,27 +36,34 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--spec new (atom(), string(), list(node())) -> type().
-new (DBName, StorageFile, Neighbors) ->
+-spec new (string(), list(node())) -> type().
+new (StorageFile, Neighbors) ->
#db_model
{
- name = DBName,
store_file = StorageFile,
neighbors = Neighbors
}.
-spec start(type()) -> 'ok'.
start (Model) ->
- DBName = Model#db_model.name,
StorageFile = Model#db_model.store_file,
Neighbors = Model#db_model.neighbors,
ok = application:set_env(mnesia, dir, StorageFile),
+
case mnesia:create_schema([node()|Neighbors]) of
{error, {Name, {already_exists, Name}}} -> ok;
ok -> ok
end,
+
ok = mnesia:start(),
+
+ ok.
+
+-spec add_db (atom(), type()) -> 'ok'.
+add_db (DBName, Model) ->
+ Neighbors = Model#db_model.neighbors,
+
mnesia:create_table
(
DBName,
diff --git a/src/map/map_shim.erl b/src/map/map_shim.erl
index 08034e4..ef23027 100644
--- a/src/map/map_shim.erl
+++ b/src/map/map_shim.erl
@@ -54,6 +54,6 @@ demo_map () ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-spec generate_random_map () -> map_map:type().
generate_random_map () ->
- Map = map_map:from_list(<<"0">>, <<"0">>, 32, 32, demo_map()),
+ Map = map_map:from_list(0, <<"0">>, 32, 32, demo_map()),
Map.
diff --git a/src/map/query/map_load.erl b/src/map/query/map_load.erl
index 0f9c685..8365521 100644
--- a/src/map/query/map_load.erl
+++ b/src/map/query/map_load.erl
@@ -65,7 +65,7 @@ generate_reply (QueryState) ->
Map = QueryState#query_state.map,
SetMap = map_set_map:generate(Map),
- Output = jiffy:encode(SetMap),
+ Output = jiffy:encode([SetMap]),
Output.
diff --git a/src/map/reply/map_add_tile.erl b/src/map/reply/map_add_tile.erl
index 04c4ec2..ab0d80b 100644
--- a/src/map/reply/map_add_tile.erl
+++ b/src/map/reply/map_add_tile.erl
@@ -1,4 +1,4 @@
--module(btl_add_tile).
+-module(map_add_tile).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -16,15 +16,15 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--spec generate (btl_tile:type()) -> {list(any())}.
+-spec generate (map_tile:type()) -> {list(any())}.
generate (Tile) ->
{
[
{<<"msg">>, <<"add_tile">>},
- {<<"id">>, btl_tile:get_id(Tile)},
- {<<"nam">>, btl_tile:get_name(Tile)},
- {<<"ct">>, btl_tile:get_cost(Tile)},
- {<<"rmi">>, btl_tile:get_range_minimum(Tile)},
- {<<"rma">>, btl_tile:get_range_maximum(Tile)}
+ {<<"id">>, map_tile:get_id(Tile)},
+ {<<"nam">>, map_tile:get_name(Tile)},
+ {<<"ct">>, map_tile:get_cost(Tile)},
+ {<<"rmi">>, map_tile:get_range_minimum(Tile)},
+ {<<"rma">>, map_tile:get_range_maximum(Tile)}
]
}.
diff --git a/src/map/reply/map_set_map.erl b/src/map/reply/map_set_map.erl
index 37c6331..336c9b2 100644
--- a/src/map/reply/map_set_map.erl
+++ b/src/map/reply/map_set_map.erl
@@ -1,4 +1,4 @@
--module(btl_set_map).
+-module(map_set_map).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -16,16 +16,16 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--spec generate (btl_battlemap:type()) -> {list(any())}.
-generate (Battlemap) ->
+-spec generate (map_map:type()) -> {list(any())}.
+generate (Map) ->
{
[
{<<"msg">>, <<"set_map">>},
- {<<"w">>, btl_battlemap:get_width(Battlemap)},
- {<<"h">>, btl_battlemap:get_height(Battlemap)},
+ {<<"w">>, map_map:get_width(Map)},
+ {<<"h">>, map_map:get_height(Map)},
{
<<"t">>,
- array:sparse_to_list(btl_battlemap:get_tile_class_ids(Battlemap))
+ array:sparse_to_list(map_map:get_tile_class_ids(Map))
}
]
}.
diff --git a/src/map/struct/map_direction.erl b/src/map/struct/map_direction.erl
index 9fb5a01..bd61b7d 100644
--- a/src/map/struct/map_direction.erl
+++ b/src/map/struct/map_direction.erl
@@ -1,4 +1,4 @@
--module(btl_direction).
+-module(map_direction).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/map/struct/map_location.erl b/src/map/struct/map_location.erl
index 9670cb0..edfb85a 100644
--- a/src/map/struct/map_location.erl
+++ b/src/map/struct/map_location.erl
@@ -1,4 +1,4 @@
--module(btl_location).
+-module(map_location).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -44,7 +44,7 @@ validate ({X, Y}) ->
-spec get_nowhere () -> type().
get_nowhere () -> nowhere.
--spec apply_direction (btl_direction:enum(), type()) -> type().
+-spec apply_direction (map_direction:enum(), type()) -> type().
apply_direction (left, {X, Y}) ->
validate({(X - 1), Y});
apply_direction (right, {X, Y}) ->
diff --git a/src/map/struct/map_battlemap.erl b/src/map/struct/map_map.erl
index 595bcb3..d5a2a7c 100644
--- a/src/map/struct/map_battlemap.erl
+++ b/src/map/struct/map_map.erl
@@ -13,7 +13,7 @@
owner :: binary(),
width :: integer(),
height :: integer(),
- tile_class_ids :: array:array(btl_tile:class_id())
+ tile_class_ids :: array:array(map_tile:class_id())
}
).
@@ -50,7 +50,7 @@
-spec location_to_array_index
(
non_neg_integer(),
- btl_location:type()
+ map_location:type()
)
-> ('error' | non_neg_integer()).
location_to_array_index (ArrayWidth, {X, Y}) ->
@@ -68,16 +68,19 @@ location_to_array_index (ArrayWidth, {X, Y}) ->
-spec get_id (type()) -> id().
get_id (Map) -> Map#map.id.
+-spec get_owner (type()) -> binary().
+get_owner (Map) -> Map#map.owner.
+
-spec get_width (type()) -> integer().
get_width (Map) -> Map#map.width.
-spec get_height (type()) -> integer().
get_height (Map) -> Map#map.height.
--spec get_tile_class_ids (type()) -> array:array(btl_tile:class_id()).
+-spec get_tile_class_ids (type()) -> array:array(map_tile:class_id()).
get_tile_class_ids (Map) -> Map#map.tile_class_ids.
--spec get_tile_class_id (btl_location:type(), type()) -> btl_tile:class_id().
+-spec get_tile_class_id (map_location:type(), type()) -> map_tile:class_id().
get_tile_class_id (Location, Map) ->
TileIX = location_to_array_index(Map#map.width, Location),
array:get(TileIX, Map#map.tile_class_ids).
@@ -92,7 +95,7 @@ get_tile_class_id (Location, Map) ->
)
-> type().
from_list (ID, Owner, Width, Height, List) ->
- TileClassIDs = lists:map(fun btl_tile:class_id_from_int/1, List),
+ TileClassIDs = lists:map(fun map_tile:class_id_from_int/1, List),
#map
{
diff --git a/src/map/struct/map_tile.erl b/src/map/struct/map_tile.erl
index 16e671b..58ef658 100644
--- a/src/map/struct/map_tile.erl
+++ b/src/map/struct/map_tile.erl
@@ -1,4 +1,4 @@
--module(btl_tile).
+-module(map_tile).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%