summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-06-15 15:54:42 +0200
committernsensfel <SpamShield0@noot-noot.org>2018-06-15 15:54:42 +0200
commit705d2b61926b90aa2906dd717edd1a2286a36b96 (patch)
treeb9bee2d8b288c71d78514967c9bab3835fd7d6c9 /src/battlemap
parent9552d3330793d48d196c1b07e69638168c776413 (diff)
Uses the existing tiles to make a demo map.
Diffstat (limited to 'src/battlemap')
-rw-r--r--src/battlemap/bm_shim.erl43
-rw-r--r--src/battlemap/struct/bm_battlemap.erl22
-rw-r--r--src/battlemap/struct/bm_tile.erl14
3 files changed, 71 insertions, 8 deletions
diff --git a/src/battlemap/bm_shim.erl b/src/battlemap/bm_shim.erl
index ee11290..6920c24 100644
--- a/src/battlemap/bm_shim.erl
+++ b/src/battlemap/bm_shim.erl
@@ -90,15 +90,52 @@ generate_random_characters
[bm_character:get_location(Character)|ForbiddenLocations],
[Character|Result]
).
+-spec demo_map () -> list(non_neg_integer()).
+demo_map () ->
+ [
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 2,
+ 2, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 2,
+ 2, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 2,
+ 2, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 0, 0, 0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, 0, 0, 0, 2, 0, 1, 0, 0, 0, 1, 2,
+ 2, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 4, 3, 3, 5, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 2,
+ 2, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0,11, 7, 7,10, 0, 1, 0, 0, 0, 2, 0, 1, 0, 0, 0, 0, 1, 1, 2,
+ 2, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 2,
+ 2, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 2,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
+ ].
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-spec generate_random_battle () -> bm_battle:type().
generate_random_battle () ->
- BattlemapWidth = sh_roll:between(16, 32),
- BattlemapHeight = sh_roll:between(16, 32),
- Battlemap = bm_battlemap:random(0, BattlemapWidth, BattlemapHeight),
+ %BattlemapWidth = 32, % sh_roll:between(16, 32),
+ %BattlemapHeight = 32, %sh_roll:between(16, 32),
+ %Battlemap = bm_battlemap:random(0, BattlemapWidth, BattlemapHeight),
+ Battlemap = bm_battlemap:from_list(0, 32, 32, demo_map()),
Characters = generate_random_characters(1, 8, 8, 0, Battlemap, [], []),
PlayersAsList = [bm_player:new(<<"0">>), bm_player:new(<<"1">>)],
diff --git a/src/battlemap/struct/bm_battlemap.erl b/src/battlemap/struct/bm_battlemap.erl
index c3eabb0..6c9fbf9 100644
--- a/src/battlemap/struct/bm_battlemap.erl
+++ b/src/battlemap/struct/bm_battlemap.erl
@@ -38,7 +38,8 @@
-export
(
[
- random/3
+ random/3,
+ from_list/4
]
).
@@ -119,3 +120,22 @@ random (ID, Width, Height) ->
height = Height,
tile_ids = array:from_list(TileIDs)
}.
+
+-spec from_list
+ (
+ non_neg_integer(),
+ non_neg_integer(),
+ non_neg_integer(),
+ list(non_neg_integer())
+ )
+ -> type().
+from_list (ID, Width, Height, List) ->
+ TileIDs = lists:map(fun bm_tile:id_from_int/1, List),
+
+ #battlemap
+ {
+ id = list_to_binary(integer_to_list(ID)),
+ width = Width,
+ height = Height,
+ tile_ids = array:from_list(TileIDs)
+ }.
diff --git a/src/battlemap/struct/bm_tile.erl b/src/battlemap/struct/bm_tile.erl
index c1dd448..ce04898 100644
--- a/src/battlemap/struct/bm_tile.erl
+++ b/src/battlemap/struct/bm_tile.erl
@@ -21,7 +21,8 @@
-export
(
[
- random_id/0
+ random_id/0,
+ id_from_int/1
]
).
@@ -37,11 +38,16 @@ cost_when_oob () -> 255.
-spec get_cost (id()) -> non_neg_integer().
get_cost (N) ->
- if
- (N =< 200) -> (N + 8);
- true -> cost_when_oob()
+ case N of
+ 0 -> 6;
+ 1 -> 12;
+ 2 -> 24;
+ _ -> cost_when_oob()
end.
-spec random_id () -> id().
random_id () ->
sh_roll:between(0, 15).
+
+-spec id_from_int (non_neg_integer()) -> id().
+id_from_int (I) -> I.