summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'client/elm/battlemap/src/Shim/Battlemap/Tile.elm')
-rw-r--r--client/elm/battlemap/src/Shim/Battlemap/Tile.elm52
1 files changed, 32 insertions, 20 deletions
diff --git a/client/elm/battlemap/src/Shim/Battlemap/Tile.elm b/client/elm/battlemap/src/Shim/Battlemap/Tile.elm
index 55feb14..4f5b40b 100644
--- a/client/elm/battlemap/src/Shim/Battlemap/Tile.elm
+++ b/client/elm/battlemap/src/Shim/Battlemap/Tile.elm
@@ -3,30 +3,42 @@ module Shim.Battlemap.Tile exposing (generate)
import Array
import List
+import Battlemap.Location
import Battlemap.Direction
import Battlemap.Tile
-from_int : Int -> Battlemap.Tile.Type
-from_int i =
- if (i >= 10)
- then
- {
- floor_level = (i - 10),
- nav_level = Battlemap.Direction.None,
- char_level = (Just (toString (i - 10))),
- mod_level = Nothing
- }
- else
- {
- floor_level = i,
- nav_level = Battlemap.Direction.None,
- char_level = Nothing,
- mod_level = Nothing
- }
+from_int : Int -> Int -> Int -> Battlemap.Tile.Type
+from_int map_width index i =
+ let
+ location =
+ (Battlemap.Location.get_ref
+ {
+ x = (index % map_width),
+ y = (index // map_width)
+ }
+ )
+ in
+ if (i >= 10)
+ then
+ {
+ location = location,
+ floor_level = (i - 10),
+ nav_level = Battlemap.Direction.None,
+ char_level = (Just (toString (i - 10))),
+ mod_level = Nothing
+ }
+ else
+ {
+ location = location,
+ floor_level = i,
+ nav_level = Battlemap.Direction.None,
+ char_level = Nothing,
+ mod_level = Nothing
+ }
-generate : (Array.Array Battlemap.Tile.Type)
-generate =
+generate : Int -> (Array.Array Battlemap.Tile.Type)
+generate map_width =
let
as_int_list =
(
@@ -126,6 +138,6 @@ generate =
++ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
]
)
- as_list = (List.map (from_int) as_int_list)
+ as_list = (List.indexedMap (from_int map_width) as_int_list)
in
(Array.fromList as_list)