From 33e57128d48a012533c42635f52037fcdedd4c56 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Tue, 26 Sep 2017 19:13:04 +0200 Subject: Range indicators are now clickable. --- client/elm/battlemap/src/Shim/Battlemap/Tile.elm | 52 +++++++++++++++--------- 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'client/elm/battlemap/src/Shim/Battlemap') 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) -- cgit v1.2.3-70-g09d2