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 /src/map/struct/map_battlemap.erl
parentb853df7a1c3efef6b84b90fe8c492611564f8b53 (diff)
Got it to load the map (full of "error" tiles).
Diffstat (limited to 'src/map/struct/map_battlemap.erl')
-rw-r--r--src/map/struct/map_battlemap.erl104
1 files changed, 0 insertions, 104 deletions
diff --git a/src/map/struct/map_battlemap.erl b/src/map/struct/map_battlemap.erl
deleted file mode 100644
index 595bcb3..0000000
--- a/src/map/struct/map_battlemap.erl
+++ /dev/null
@@ -1,104 +0,0 @@
--module(map_map).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--type id() :: binary().
-
--record
-(
- map,
- {
- id :: id(),
- owner :: binary(),
- width :: integer(),
- height :: integer(),
- tile_class_ids :: array:array(btl_tile:class_id())
- }
-).
-
--opaque type() :: #map{}.
-
--export_type([type/0, id/0]).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%% Accessors
--export
-(
- [
- get_id/1,
- get_owner/1,
- get_width/1,
- get_height/1,
- get_tile_class_ids/1,
- get_tile_class_id/2
- ]
-).
-
--export
-(
- [
- from_list/5
- ]
-).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% 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 (Map) -> Map#map.id.
-
--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()).
-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, Map) ->
- TileIX = location_to_array_index(Map#map.width, Location),
- array:get(TileIX, Map#map.tile_class_ids).
-
--spec from_list
- (
- non_neg_integer(),
- binary(),
- non_neg_integer(),
- non_neg_integer(),
- list(non_neg_integer())
- )
- -> type().
-from_list (ID, Owner, Width, Height, List) ->
- TileClassIDs = lists:map(fun btl_tile:class_id_from_int/1, List),
-
- #map
- {
- id = list_to_binary(integer_to_list(ID)),
- owner = Owner,
- width = Width,
- height = Height,
- tile_class_ids = array:from_list(TileClassIDs)
- }.