summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2018-08-04 10:21:51 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2018-08-04 10:21:51 +0200
commitb49e7e895b941ae8b5331ccb1d0868afbd8e5516 (patch)
tree62bf2640dc3122b46bf36a624ea6b9dca8dc28e5 /src/map/struct/map_map.erl
parent586c75d06f0e6102c997f56f0c64777417413122 (diff)
Lets the user save their map.
Diffstat (limited to 'src/map/struct/map_map.erl')
-rw-r--r--src/map/struct/map_map.erl39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/map/struct/map_map.erl b/src/map/struct/map_map.erl
index 3c25034..46e501f 100644
--- a/src/map/struct/map_map.erl
+++ b/src/map/struct/map_map.erl
@@ -40,7 +40,17 @@
-export
(
[
- from_list/5
+ get_width_field/0,
+ get_height_field/0,
+ get_tile_instances_field/0
+ ]
+).
+
+-export
+(
+ [
+ from_list/5,
+ update_from_list/4
]
).
@@ -85,6 +95,15 @@ get_tile_instance (Location, Map) ->
TileIX = location_to_array_index(Map#map.width, Location),
array:get(TileIX, Map#map.tile_instances).
+-spec get_width_field () -> non_neg_integer().
+get_width_field () -> #map.width.
+
+-spec get_height_field () -> non_neg_integer().
+get_height_field () -> #map.height.
+
+-spec get_tile_instances_field () -> non_neg_integer().
+get_tile_instances_field () -> #map.tile_instances.
+
-spec from_list
(
non_neg_integer(),
@@ -105,3 +124,21 @@ from_list (ID, Owner, Width, Height, List) ->
height = Height,
tile_instances = array:from_list(TileInstances)
}.
+
+-spec update_from_list
+ (
+ type(),
+ non_neg_integer(),
+ non_neg_integer(),
+ list(list(non_neg_integer()))
+ )
+ -> type().
+update_from_list (Map, Width, Height, List) ->
+ TileInstances = lists:map(fun map_tile:instance_from_ints/1, List),
+
+ Map#map
+ {
+ width = Width,
+ height = Height,
+ tile_instances = array:from_list(TileInstances)
+ }.