summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'client/elm/battlemap/src/Shim')
-rw-r--r-- | client/elm/battlemap/src/Shim/Battlemap.elm | 2 | ||||
-rw-r--r-- | client/elm/battlemap/src/Shim/Battlemap/Tile.elm | 52 | ||||
-rw-r--r-- | client/elm/battlemap/src/Shim/Model.elm | 5 |
3 files changed, 35 insertions, 24 deletions
diff --git a/client/elm/battlemap/src/Shim/Battlemap.elm b/client/elm/battlemap/src/Shim/Battlemap.elm index 2f795e1..f35cb67 100644 --- a/client/elm/battlemap/src/Shim/Battlemap.elm +++ b/client/elm/battlemap/src/Shim/Battlemap.elm @@ -7,5 +7,5 @@ generate = { width = 32, height = 32, - content = (Shim.Battlemap.Tile.generate) + content = (Shim.Battlemap.Tile.generate 32) } 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) diff --git a/client/elm/battlemap/src/Shim/Model.elm b/client/elm/battlemap/src/Shim/Model.elm index 3d6cc5a..03c2450 100644 --- a/client/elm/battlemap/src/Shim/Model.elm +++ b/client/elm/battlemap/src/Shim/Model.elm @@ -10,8 +10,8 @@ import Shim.Battlemap generate = { state = Model.Default, + selection = Nothing, battlemap = (Shim.Battlemap.generate), - navigator = Nothing, characters = (Dict.insert "2" @@ -49,6 +49,5 @@ generate = Dict.empty ) ) - ), - range_indicator = Dict.empty + ) } |