summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2018-06-18 18:35:53 +0200 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2018-06-18 18:35:53 +0200 |
commit | b251f5165ea3530747657b522773c4a8f44b16fa (patch) | |
tree | 68d830acec3fe8c171429ac903a16944ed31120c /src/battlemap/struct/bm_battlemap.erl | |
parent | a174bc2cc95b94c0b7d786e764c48de72206d7c5 (diff) |
Separates tiles from their icon images IDs.
The client has yet to be updated to support the new exchanges.
Diffstat (limited to 'src/battlemap/struct/bm_battlemap.erl')
-rw-r--r-- | src/battlemap/struct/bm_battlemap.erl | 61 |
1 files changed, 10 insertions, 51 deletions
diff --git a/src/battlemap/struct/bm_battlemap.erl b/src/battlemap/struct/bm_battlemap.erl index 6c9fbf9..77d3041 100644 --- a/src/battlemap/struct/bm_battlemap.erl +++ b/src/battlemap/struct/bm_battlemap.erl @@ -12,7 +12,7 @@ id :: id(), width :: integer(), height :: integer(), - tile_ids :: array:array(bm_tile:id()) + tile_class_ids :: array:array(bm_tile:class_id()) } ). @@ -30,15 +30,14 @@ get_id/1, get_width/1, get_height/1, - get_tile_ids/1, - get_tile_id/2 + get_tile_class_ids/1, + get_tile_class_id/2 ] ). -export ( [ - random/3, from_list/4 ] ). @@ -46,27 +45,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec generate_random_tile_ids - ( - bm_tile:id(), - list(bm_tile:id()), - non_neg_integer(), - non_neg_integer(), - non_neg_integer() - ) - -> list(bm_tile:id()). -generate_random_tile_ids (_PreviousTileID, Result, _X, 0, _Width) -> - Result; -generate_random_tile_ids (PreviousTileID, Result, 0, Y, Width) -> - generate_random_tile_ids(PreviousTileID, Result, Width, (Y - 1), Width); -generate_random_tile_ids (PreviousTileID, Result, X, Y, Width) -> - NewTile = - case sh_roll:percentage() of - N when (N >= 10) -> PreviousTileID; - _ -> bm_tile:random_id() - end, - generate_random_tile_ids(NewTile, [NewTile|Result], (X - 1), Y, Width). - -spec location_to_array_index ( non_neg_integer(), @@ -94,32 +72,13 @@ get_width (Battlemap) -> Battlemap#battlemap.width. -spec get_height (type()) -> integer(). get_height (Battlemap) -> Battlemap#battlemap.height. --spec get_tile_ids (type()) -> array:array(bm_tile:id()). -get_tile_ids (Battlemap) -> Battlemap#battlemap.tile_ids. +-spec get_tile_class_ids (type()) -> array:array(bm_tile:class_id()). +get_tile_class_ids (Battlemap) -> Battlemap#battlemap.tile_class_ids. --spec get_tile_id (bm_location:type(), type()) -> bm_tile:id(). -get_tile_id (Location, Battlemap) -> +-spec get_tile_class_id (bm_location:type(), type()) -> bm_tile:class_id(). +get_tile_class_id (Location, Battlemap) -> TileIX = location_to_array_index(Battlemap#battlemap.width, Location), - array:get(TileIX, Battlemap#battlemap.tile_ids). - --spec random - ( - non_neg_integer(), - non_neg_integer(), - non_neg_integer() - ) - -> type(). -random (ID, Width, Height) -> - InitialTile = bm_tile:random_id(), - TileIDs = generate_random_tile_ids(InitialTile, [], Width, Height, Width), - - #battlemap - { - id = list_to_binary(integer_to_list(ID)), - width = Width, - height = Height, - tile_ids = array:from_list(TileIDs) - }. + array:get(TileIX, Battlemap#battlemap.tile_class_ids). -spec from_list ( @@ -130,12 +89,12 @@ random (ID, Width, Height) -> ) -> type(). from_list (ID, Width, Height, List) -> - TileIDs = lists:map(fun bm_tile:id_from_int/1, List), + TileClassIDs = lists:map(fun bm_tile:class_id_from_int/1, List), #battlemap { id = list_to_binary(integer_to_list(ID)), width = Width, height = Height, - tile_ids = array:from_list(TileIDs) + tile_class_ids = array:from_list(TileClassIDs) }. |