| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'src/battle/struct/btl_map.erl')
| -rw-r--r-- | src/battle/struct/btl_map.erl | 31 | 
1 files changed, 19 insertions, 12 deletions
| diff --git a/src/battle/struct/btl_map.erl b/src/battle/struct/btl_map.erl index c784bca..157382d 100644 --- a/src/battle/struct/btl_map.erl +++ b/src/battle/struct/btl_map.erl @@ -3,13 +3,10 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --type id() :: binary(). -  -record  (     map,     { -      id :: id(),        width :: integer(),        height :: integer(),        tile_ids :: array:array(shr_tile:instance()) @@ -18,7 +15,7 @@  -opaque type() :: #map{}. --export_type([type/0, id/0]). +-export_type([type/0]).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -27,7 +24,6 @@  -export  (     [ -      get_id/1,        get_width/1,        get_height/1,        get_tile_instances/1, @@ -38,7 +34,8 @@  -export  (     [ -      from_list/4 +      from_list/3, +      from_array/3     ]  ). @@ -63,9 +60,6 @@ location_to_array_index (ArrayWidth, {X, Y}) ->  %% 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. @@ -84,17 +78,30 @@ get_tile_instance (Location, Map) ->     (        non_neg_integer(),        non_neg_integer(), -      non_neg_integer(),        list(list(non_neg_integer()))     )     -> type(). -from_list (ID, Width, Height, List) -> +from_list (Width, Height, List) ->     TileInstances = lists:map(fun shr_tile:instance_from_ints/1, List),     #map     { -      id = list_to_binary(integer_to_list(ID)),        width = Width,        height = Height,        tile_ids = array:from_list(TileInstances)     }. + +-spec from_array +   ( +      non_neg_integer(), +      non_neg_integer(), +      array:array(shr_tile:instance()) +   ) +   -> type(). +from_array (Width, Height, TileInstances) -> +   #map +   { +      width = Width, +      height = Height, +      tile_ids = TileInstances +   }. | 


