summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2018-02-27 14:16:16 +0100 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2018-02-27 14:16:16 +0100 |
commit | 292022649270d36c8ab0c813e4d7e07f3e067231 (patch) | |
tree | 8e25f8c3e5db7f6bae7001d405f24e29115750f3 /src/struct/battlemap.erl | |
parent | be9a65dd6d24ca8e7006c0b8825a3fa46419e201 (diff) |
Starting to specify types everywhere...
Diffstat (limited to 'src/struct/battlemap.erl')
-rw-r--r-- | src/struct/battlemap.erl | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/struct/battlemap.erl b/src/struct/battlemap.erl index 733f76c..76f8fd4 100644 --- a/src/struct/battlemap.erl +++ b/src/struct/battlemap.erl @@ -3,17 +3,23 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-opaque id() :: binary(). + -record ( battlemap, { - id, - width, - height, - tile_ids + id :: id(), + width :: integer(), + height :: integer(), + tile_ids :: array:array(tile:id()) } ). +-opaque struct() :: #battlemap{}. + +-export_type([struct/0, id/0]). + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -38,6 +44,15 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec generate_random_tile_ids + ( + tile:id(), + list(tile:id()), + non_neg_integer(), + non_neg_integer(), + non_neg_integer() + ) + -> list(tile:id()). generate_random_tile_ids (_PreviousTileID, Result, _X, 0, _Width) -> Result; generate_random_tile_ids (PreviousTileID, Result, 0, Y, Width) -> @@ -54,11 +69,19 @@ generate_random_tile_ids (PreviousTileID, Result, X, Y, Width) -> %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% Accessors +-spec get_id (struct()) -> id(). get_id (Battlemap) -> Battlemap#battlemap.id. + +-spec get_width (struct()) -> integer(). get_width (Battlemap) -> Battlemap#battlemap.width. + +-spec get_height (struct()) -> integer(). get_height (Battlemap) -> Battlemap#battlemap.height. + +-spec get_tile_ids (struct()) -> array:array(tile:id()). get_tile_ids (Battlemap) -> Battlemap#battlemap.tile_ids. +-spec random (id(), non_neg_integer(), non_neg_integer()) -> struct(). random (ID, Width, Height) -> InitialTile = tile:random_id(), TileIDs = generate_random_tile_ids(InitialTile, [], Width, Height, Width), |