summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/battle-map/BattleMap')
-rw-r--r--src/shared/battle-map/BattleMap/Struct/Direction.elm58
-rw-r--r--src/shared/battle-map/BattleMap/Struct/Location.elm70
-rw-r--r--src/shared/battle-map/BattleMap/Struct/Map.elm206
-rw-r--r--src/shared/battle-map/BattleMap/Struct/Tile.elm77
-rw-r--r--src/shared/battle-map/BattleMap/Struct/TileInstance.elm249
-rw-r--r--src/shared/battle-map/BattleMap/View/Tile.elm242
6 files changed, 902 insertions, 0 deletions
diff --git a/src/shared/battle-map/BattleMap/Struct/Direction.elm b/src/shared/battle-map/BattleMap/Struct/Direction.elm
new file mode 100644
index 0000000..4620e29
--- /dev/null
+++ b/src/shared/battle-map/BattleMap/Struct/Direction.elm
@@ -0,0 +1,58 @@
+module BattleMap.Struct.Direction exposing
+(
+ Type(..),
+ opposite_of,
+ to_string,
+ decoder
+)
+
+-- Elm -------------------------------------------------------------------------
+import Json.Decode
+
+-- Battle Map ------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type Type =
+ None
+ | Left
+ | Right
+ | Up
+ | Down
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+from_string : String -> Type
+from_string str =
+ case str of
+ "R" -> Right
+ "L" -> Left
+ "U" -> Up
+ "D" -> Down
+ _ -> None
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+opposite_of : Type -> Type
+opposite_of d =
+ case d of
+ Left -> Right
+ Right -> Left
+ Up -> Down
+ Down -> Up
+ None -> None
+
+to_string : Type -> String
+to_string dir =
+ case dir of
+ Right -> "R"
+ Left -> "L"
+ Up -> "U"
+ Down -> "D"
+ None -> "N"
+
+decoder : (Json.Decode.Decoder Type)
+decoder = (Json.Decode.map (from_string) Json.Decode.string)
diff --git a/src/shared/battle-map/BattleMap/Struct/Location.elm b/src/shared/battle-map/BattleMap/Struct/Location.elm
new file mode 100644
index 0000000..3443150
--- /dev/null
+++ b/src/shared/battle-map/BattleMap/Struct/Location.elm
@@ -0,0 +1,70 @@
+module BattleMap.Struct.Location exposing (..)
+
+-- Elm -------------------------------------------------------------------------
+import Json.Decode
+import Json.Decode.Pipeline
+
+import Json.Encode
+
+-- Battle Map ------------------------------------------------------------------
+import BattleMap.Struct.Direction
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type alias Type =
+ {
+ x : Int,
+ y : Int
+ }
+
+type alias Ref = (Int, Int)
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+neighbor : BattleMap.Struct.Direction.Type -> Type -> Type
+neighbor dir loc =
+ case dir of
+ BattleMap.Struct.Direction.Right -> {loc | x = (loc.x + 1)}
+ BattleMap.Struct.Direction.Left -> {loc | x = (loc.x - 1)}
+ BattleMap.Struct.Direction.Up -> {loc | y = (loc.y - 1)}
+ BattleMap.Struct.Direction.Down -> {loc | y = (loc.y + 1)}
+ BattleMap.Struct.Direction.None -> loc
+
+get_ref : Type -> Ref
+get_ref l =
+ (l.x, l.y)
+
+from_ref : Ref -> Type
+from_ref (x, y) =
+ {x = x, y = y}
+
+dist : Type -> Type -> Int
+dist loc_a loc_b =
+ (
+ (abs (loc_a.x - loc_b.x))
+ +
+ (abs (loc_a.y - loc_b.y))
+ )
+
+decoder : (Json.Decode.Decoder Type)
+decoder =
+ (Json.Decode.succeed
+ Type
+ |> (Json.Decode.Pipeline.required "x" Json.Decode.int)
+ |> (Json.Decode.Pipeline.required "y" Json.Decode.int)
+ )
+
+encode : Type -> Json.Encode.Value
+encode loc =
+ (Json.Encode.object
+ [
+ ( "x", (Json.Encode.int loc.x) ),
+ ( "y", (Json.Encode.int loc.y) )
+ ]
+ )
diff --git a/src/shared/battle-map/BattleMap/Struct/Map.elm b/src/shared/battle-map/BattleMap/Struct/Map.elm
new file mode 100644
index 0000000..aa166d4
--- /dev/null
+++ b/src/shared/battle-map/BattleMap/Struct/Map.elm
@@ -0,0 +1,206 @@
+module BattleMap.Struct.Map exposing
+ (
+ Type,
+ decoder,
+ empty,
+ get_height,
+ get_markers,
+ get_movement_cost_function,
+ get_omnimods_at,
+ get_tiles,
+ get_width,
+ new,
+ set_tile_to,
+ solve_tiles,
+ try_getting_tile_at
+ )
+
+-- Elm -------------------------------------------------------------------------
+import Array
+
+import Dict
+
+import Json.Decode
+
+-- Battle ----------------------------------------------------------------------
+import Battle.Struct.Omnimods
+
+-- Battle Map ------------------------------------------------------------------
+import BattleMap.Struct.Location
+import BattleMap.Struct.MapMarker
+import BattleMap.Struct.Tile
+import BattleMap.Struct.TileInstance
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type alias Type =
+ {
+ width : Int,
+ height : Int,
+ content : (Array.Array BattleMap.Struct.TileInstance.Type),
+ markers : (Dict.Dict String BattleMap.Struct.MapMarker.Type)
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+location_to_index : BattleMap.Struct.Location.Type -> Type -> Int
+location_to_index loc map =
+ ((loc.y * map.width) + loc.x)
+
+has_location : BattleMap.Struct.Location.Type -> Type -> Bool
+has_location loc map =
+ (
+ (loc.x >= 0)
+ && (loc.y >= 0)
+ && (loc.x < map.width)
+ && (loc.y < map.height)
+ )
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_width : Type -> Int
+get_width map = map.width
+
+get_height : Type -> Int
+get_height map = map.height
+
+get_tiles : Type -> (Array.Array BattleMap.Struct.TileInstance.Type)
+get_tiles map = map.content
+
+get_markers : Type -> (Dict.Dict String BattleMap.Struct.MapMarker.Type)
+get_markers map = map.markers
+
+set_tile_to : BattleMap.Struct.Location.Type -> BattleMap.Struct.TileInstance.Type -> Type -> Type
+set_tile_to loc tile_inst map =
+ {map |
+ content = (Array.set (location_to_index loc map) tile_inst map.content)
+ }
+
+empty : Type
+empty =
+ {
+ width = 0,
+ height = 0,
+ content = (Array.empty),
+ markers = (Dict.empty)
+ }
+
+new : Int -> Int -> (List BattleMap.Struct.TileInstance.Type) -> Type
+new width height tiles =
+ {
+ width = width,
+ height = height,
+ content = (Array.fromList tiles),
+ markers = (Dict.empty)
+ }
+
+try_getting_tile_at : (
+ BattleMap.Struct.Location.Type ->
+ Type ->
+ (Maybe BattleMap.Struct.TileInstance.Type)
+ )
+try_getting_tile_at loc map =
+ if (has_location loc map)
+ then (Array.get (location_to_index loc map) map.content)
+ else Nothing
+
+solve_tiles : (
+ (Dict.Dict BattleMap.Struct.Tile.Ref BattleMap.Struct.Tile.Type) ->
+ Type ->
+ Type
+ )
+solve_tiles tiles map =
+ {map |
+ content =
+ (Array.map
+ (BattleMap.Struct.TileInstance.solve tiles) map.content
+ )
+ }
+
+get_omnimods_at : (
+ BattleMap.Struct.Location.Type ->
+ (Dict.Dict BattleMap.Struct.Tile.Ref BattleMap.Struct.Tile.Type) ->
+ Type ->
+ Battle.Struct.Omnimods.Type
+ )
+get_omnimods_at loc tiles_solver map =
+ case (try_getting_tile_at loc map) of
+ Nothing -> (Battle.Struct.Omnimods.none)
+ (Just tile_inst) ->
+ case
+ (Dict.get
+ (BattleMap.Struct.TileInstance.get_class_id tile_inst)
+ tiles_solver
+ )
+ of
+ Nothing -> (Battle.Struct.Omnimods.none)
+ (Just tile) -> (BattleMap.Struct.Tile.get_omnimods tile)
+
+decoder : (Json.Decode.Decoder Type)
+decoder =
+ (Json.Decode.andThen
+ (\width ->
+ (Json.Decode.map4
+ Type
+ (Json.Decode.field "w" Json.Decode.int)
+ (Json.Decode.field "h" Json.Decode.int)
+ (Json.Decode.field
+ "t"
+ (Json.Decode.map
+ (Array.indexedMap
+ (BattleMap.Struct.TileInstance.set_location_from_index
+ width
+ )
+ )
+ (Json.Decode.array (BattleMap.Struct.TileInstance.decoder))
+ )
+ )
+ (Json.Decode.field
+ "m"
+ (Json.Decode.map
+ (Dict.fromList)
+ (Json.Decode.keyValuePairs
+ (BattleMap.Struct.MapMarker.decoder)
+ )
+ )
+ )
+ )
+ )
+ (Json.Decode.field "w" Json.Decode.int)
+ )
+
+get_movement_cost_function : (
+ Type ->
+ BattleMap.Struct.Location.Type ->
+ (List BattleMap.Struct.Character.Type) ->
+ BattleMap.Struct.Location.Type ->
+ Int
+ )
+get_movement_cost_function bmap start_loc char_list loc =
+ if (has_location loc bmap)
+ then
+ case (Array.get (location_to_index loc bmap) bmap.content) of
+ (Just tile) ->
+ if
+ (List.any
+ (
+ \c ->
+ (
+ ((BattleMap.Struct.Character.get_location c) == loc)
+ && (loc /= start_loc)
+ && (BattleMap.Struct.Character.is_alive c)
+ )
+ )
+ char_list
+ )
+ then
+ Constants.Movement.cost_when_occupied_tile
+ else
+ (BattleMap.Struct.TileInstance.get_cost tile)
+
+ Nothing -> Constants.Movement.cost_when_out_of_bounds
+ else
+ Constants.Movement.cost_when_out_of_bounds
diff --git a/src/shared/battle-map/BattleMap/Struct/Tile.elm b/src/shared/battle-map/BattleMap/Struct/Tile.elm
new file mode 100644
index 0000000..9145b44
--- /dev/null
+++ b/src/shared/battle-map/BattleMap/Struct/Tile.elm
@@ -0,0 +1,77 @@
+module BattleMap.Struct.Tile exposing
+ (
+ Ref,
+ VariantID,
+ FamilyID,
+ Type,
+ get_id,
+ get_name,
+ get_cost,
+ get_omnimods,
+ get_family,
+ decoder
+ )
+
+-- Elm -------------------------------------------------------------------------
+import Dict
+
+import Json.Decode
+import Json.Decode.Pipeline
+
+-- Battle ----------------------------------------------------------------------
+import Battle.Struct.Omnimods
+
+-- Local Module ----------------------------------------------------------------
+import Constants.UI
+import Constants.Movement
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type alias Ref = String
+type alias VariantID = String
+type alias FamilyID = String
+
+type alias Type =
+ {
+ id : Ref,
+ name : String,
+ crossing_cost : Int,
+ family : FamilyID,
+ depth : Int,
+ omnimods : Battle.Struct.Omnimods.Type
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_id : Type -> Ref
+get_id tile = tile.id
+
+get_cost : Type -> Int
+get_cost tile = tile.crossing_cost
+
+get_name : Type -> String
+get_name tile = tile.name
+
+get_family : Type -> FamilyID
+get_family tile = tile.family
+
+get_omnimods : Type -> Battle.Struct.Omnimods.Type
+get_omnimods t = t.omnimods
+
+decoder : (Json.Decode.Decoder Type)
+decoder =
+ (Json.Decode.succeed
+ Type
+ |> (Json.Decode.Pipeline.required "id" Json.Decode.string)
+ |> (Json.Decode.Pipeline.required "nam" Json.Decode.string)
+ |> (Json.Decode.Pipeline.required "ct" Json.Decode.int)
+ |> (Json.Decode.Pipeline.required "fa" Json.Decode.string)
+ |> (Json.Decode.Pipeline.required "de" Json.Decode.int)
+ |> (Json.Decode.Pipeline.required "omni" Battle.Struct.Omnimods.decoder)
+ )
diff --git a/src/shared/battle-map/BattleMap/Struct/TileInstance.elm b/src/shared/battle-map/BattleMap/Struct/TileInstance.elm
new file mode 100644
index 0000000..8c39371
--- /dev/null
+++ b/src/shared/battle-map/BattleMap/Struct/TileInstance.elm
@@ -0,0 +1,249 @@
+module BattleMap.Struct.TileInstance exposing
+ (
+ Type,
+ Border,
+ clone,
+ get_location,
+ get_class_id,
+ get_family,
+ get_cost,
+ default,
+ set_borders,
+ get_borders,
+ new_border,
+ get_variant_id,
+ get_border_variant_id,
+ get_border_class_id,
+ get_local_variant_ix,
+ error,
+ solve,
+ set_location_from_index,
+ decoder,
+ encode
+ )
+
+-- Elm -------------------------------------------------------------------------
+import Dict
+
+import Json.Encode
+
+import Json.Decode
+import Json.Decode.Pipeline
+
+-- Battle Map ------------------------------------------------------------------
+import BattleMap.Struct.Tile
+import BattleMap.Struct.Location
+
+-- Local -----------------------------------------------------------------------
+import Constants.UI
+import Constants.Movement
+
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type alias Type =
+ {
+ location : BattleMap.Struct.Location.Type,
+ crossing_cost : Int,
+ family : BattleMap.Struct.Tile.FamilyID,
+ class_id : BattleMap.Struct.Tile.Ref,
+ variant_id : BattleMap.Struct.Tile.VariantID,
+ triggers : (List String),
+ borders : (List Border)
+ }
+
+type alias Border =
+ {
+ class_id : BattleMap.Struct.Tile.Ref,
+ variant_id : BattleMap.Struct.Tile.VariantID
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+noise_function : Int -> Int -> Int -> Int
+noise_function a b c =
+ (round (radians (toFloat ((a + 1) * 2 + (b + 1) * 3 + c))))
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+clone : BattleMap.Struct.Location.Type -> Type -> Type
+clone loc inst = {inst | location = loc}
+
+new_border : BattleMap.Struct.Tile.Ref -> BattleMap.Struct.Tile.VariantID -> Border
+new_border class_id variant_id =
+ {
+ class_id = class_id,
+ variant_id = variant_id
+ }
+
+default : BattleMap.Struct.Tile.Type -> Type
+default tile =
+ {
+ location = {x = 0, y = 0},
+ class_id = (Struct.Tile.get_id tile),
+ variant_id = "0",
+ crossing_cost = (Struct.Tile.get_cost tile),
+ family = (Struct.Tile.get_family tile),
+ triggers = [],
+ borders = []
+ }
+
+error : Int -> Int -> Type
+error x y =
+ {
+ location = {x = x, y = y},
+ class_id = "0",
+ variant_id = "0",
+ family = "0",
+ crossing_cost = Constants.Movement.cost_when_out_of_bounds,
+ triggers = [],
+ borders = []
+ }
+
+get_class_id : Type -> BattleMap.Struct.Tile.Ref
+get_class_id inst = inst.class_id
+
+get_cost : Type -> Int
+get_cost inst = inst.crossing_cost
+
+get_location : Type -> BattleMap.Struct.Location.Type
+get_location inst = inst.location
+
+get_family : Type -> BattleMap.Struct.Tile.FamilyID
+get_family inst = inst.family
+
+set_borders : (List Border) -> Type -> Type
+set_borders borders tile_inst = {tile_inst | borders = borders}
+
+get_borders : Type -> (List Border)
+get_borders tile_inst = tile_inst.borders
+
+get_variant_id : Type -> BattleMap.Struct.Tile.VariantID
+get_variant_id tile_inst = tile_inst.variant_id
+
+get_border_variant_id : Border -> BattleMap.Struct.Tile.VariantID
+get_border_variant_id tile_border = tile_border.variant_id
+
+get_local_variant_ix : Type -> Int
+get_local_variant_ix tile_inst =
+ (modBy
+ Constants.UI.local_variants_per_tile
+ (noise_function
+ tile_inst.location.x
+ tile_inst.location.y
+ tile_inst.crossing_cost
+ )
+ )
+
+solve : (
+ (Dict.Dict BattleMap.Struct.Tile.Ref BattleMap.Struct.Tile.Type) ->
+ Type ->
+ Type
+ )
+solve tiles tile_inst =
+ case (Dict.get tile_inst.class_id tiles) of
+ (Just tile) ->
+ {tile_inst |
+ crossing_cost = (Struct.Tile.get_cost tile),
+ family = (Struct.Tile.get_family tile)
+ }
+
+ Nothing ->
+ {tile_inst |
+ crossing_cost = -1,
+ family = "-1"
+ }
+
+
+list_to_borders : (
+ (List String) ->
+ (List Border) ->
+ (List Border)
+ )
+list_to_borders list borders =
+ case list of
+ (a :: (b :: c)) ->
+ (list_to_borders
+ c
+ ({ class_id = a, variant_id = b } :: borders)
+ )
+ _ -> (List.reverse borders)
+
+decoder : (Json.Decode.Decoder Type)
+decoder =
+ (Json.Decode.andThen
+ (\tile_data ->
+ case tile_data of
+ (tile_id :: (variant_id :: borders)) ->
+ (Json.Decode.succeed
+ Type
+ |> (Json.Decode.Pipeline.hardcoded {x = 0, y = 0}) -- Location
+ |> (Json.Decode.Pipeline.hardcoded 0) -- Crossing Cost
+ |> (Json.Decode.Pipeline.hardcoded "") -- Family
+ |> (Json.Decode.Pipeline.hardcoded tile_id)
+ |> (Json.Decode.Pipeline.hardcoded variant_id)
+ |>
+ (Json.Decode.Pipeline.required
+ "t"
+ (Json.Decode.list (Json.Decode.string))
+ )
+ |>
+ (Json.Decode.Pipeline.hardcoded
+ (list_to_borders borders [])
+ )
+ )
+ _ -> (Json.Decode.succeed (error 0 0))
+ )
+ (Json.Decode.field "b" (Json.Decode.list (Json.Decode.string)))
+ )
+
+get_border_class_id : Border -> BattleMap.Struct.Tile.Ref
+get_border_class_id tile_border = tile_border.class_id
+
+set_location_from_index : Int -> Int -> Type -> Type
+set_location_from_index map_width index tile_inst =
+ {tile_inst |
+ location =
+ {
+ x = (modBy map_width index),
+ y = (index // map_width)
+ }
+ }
+
+encode : Type -> Json.Encode.Value
+encode tile_inst =
+ (Json.Encode.object
+ [
+ (
+ "b",
+ (Json.Encode.list
+ (Json.Encode.string)
+ (
+ tile_inst.class_id
+ ::
+ (
+ tile_inst.variant_id
+ ::
+ (List.concatMap
+ (\border ->
+ [
+ border.class_id,
+ border.variant_id
+ ]
+ )
+ tile_inst.borders
+ )
+ )
+ )
+ )
+ ),
+ (
+ "t",
+ (Json.Encode.list (Json.Encode.string) tile_inst.triggers)
+ )
+ ]
+ )
+
diff --git a/src/shared/battle-map/BattleMap/View/Tile.elm b/src/shared/battle-map/BattleMap/View/Tile.elm
new file mode 100644
index 0000000..6039ff4
--- /dev/null
+++ b/src/shared/battle-map/BattleMap/View/Tile.elm
@@ -0,0 +1,242 @@
+module BattleMap.View.Tile exposing (get_html, get_html_extra, get_content_html)
+
+-- Elm -------------------------------------------------------------------------
+import Html
+import Html.Attributes
+import Html.Events
+
+-- Battle Map ------------------------------------------------------------------
+import Constants.UI
+import Constants.IO
+
+import BattleMap.Struct.Location
+import BattleMap.Struct.TileInstance
+
+-- Local -----------------------------------------------------------------------
+import Struct.Event
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_layer_html : (
+ Int ->
+ BattleMap.Struct.TileInstance.Border ->
+ (Html.Html Struct.Event.Type)
+ )
+get_layer_html index border =
+ (Html.div
+ [
+ (Html.Attributes.class ("tile-icon-f-" ++ (String.fromInt index))),
+ (Html.Attributes.style
+ "background-image"
+ (
+ "url("
+ ++ Constants.IO.tile_assets_url
+ ++ (BattleMap.Struct.TileInstance.get_border_class_id border)
+ ++ "-f-"
+ ++ (BattleMap.Struct.TileInstance.get_border_variant_id border)
+ ++ ".svg)"
+ )
+ )
+ ]
+ []
+ )
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_content_html : (
+ BattleMap.Struct.TileInstance.Type ->
+ (List (Html.Html Struct.Event.Type))
+ )
+get_content_html tile =
+ (
+ (Html.div
+ [
+ (Html.Attributes.class "tile-icon-bg"),
+ (Html.Attributes.style
+ "background-image"
+ (
+ "url("
+ ++ Constants.IO.tile_assets_url
+ ++ (BattleMap.Struct.TileInstance.get_class_id tile)
+ ++ "-bg.svg)"
+ )
+ )
+ ]
+ []
+ )
+ (Html.div
+ [
+ (Html.Attributes.class "tile-icon-bg"),
+ (Html.Attributes.style
+ "background-image"
+ (
+ "url("
+ ++ Constants.IO.tile_assets_url
+ ++ (BattleMap.Struct.TileInstance.get_class_id tile)
+ ++ "-bg.svg)"
+ )
+ )
+ ]
+ []
+ )
+ ::
+ (
+ (Html.div
+ [
+ (Html.Attributes.class "tile-icon-dt"),
+ (Html.Attributes.style
+ "background-image"
+ (
+ "url("
+ ++ Constants.IO.tile_assets_url
+ ++ (BattleMap.Struct.TileInstance.get_class_id tile)
+ ++ "-v-"
+ ++ (BattleMap.Struct.TileInstance.get_variant_id tile)
+ ++ ".svg)"
+ )
+ )
+ ]
+ []
+ )
+ ::
+ (List.indexedMap
+ (get_layer_html)
+ (BattleMap.Struct.TileInstance.get_borders tile)
+ )
+ )
+ )
+
+get_html : (
+ Bool ->
+ BattleMap.Struct.TileInstance.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+get_html display_cost tile =
+ let tile_loc = (BattleMap.Struct.TileInstance.get_location tile) in
+ (Html.div
+ [
+ (Html.Attributes.class "tile-icon"),
+ (Html.Attributes.class "tiled"),
+ (Html.Attributes.class
+ (
+ "tile-variant-"
+ ++
+ (String.fromInt
+ (BattleMap.Struct.TileInstance.get_local_variant_ix tile)
+ )
+ )
+ ),
+ (Html.Attributes.class "clickable"),
+ (Html.Events.onClick
+ (Struct.Event.TileSelected
+ (BattleMap.Struct.Location.get_ref tile_loc)
+ )
+ ),
+ (Html.Attributes.style
+ "top"
+ (
+ (String.fromInt (tile_loc.y * Constants.UI.tile_size))
+ ++ "px"
+ )
+ ),
+ (Html.Attributes.style
+ "left"
+ (
+ (String.fromInt (tile_loc.x * Constants.UI.tile_size))
+ ++ "px"
+ )
+ )
+ ]
+ (
+ if (display_cost)
+ then
+ (
+ (Html.div
+ [
+ (Html.Attributes.class "tile-icon-cost")
+ ]
+ [
+ (Html.text
+ (String.fromInt
+ (BattleMap.Struct.TileInstance.get_cost tile)
+ )
+ )
+ ]
+ )
+ :: (get_content_html tile)
+ )
+ else (get_content_html tile)
+ )
+ )
+
+get_html_with_extra : (
+ Bool ->
+ (List Html.Attributes.Attribute) ->
+ BattleMap.Struct.TileInstance.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+get_html_with_extra display_cost extra_classes tile =
+ let tile_loc = (BattleMap.Struct.TileInstance.get_location tile) in
+ (Html.div
+ (
+ extra_classes
+ ++
+ [
+ (Html.Attributes.class "tile-icon"),
+ (Html.Attributes.class "tiled"),
+ (Html.Attributes.class
+ (
+ "tile-variant-"
+ ++
+ (String.fromInt
+ (BattleMap.Struct.TileInstance.get_local_variant_ix
+ tile
+ )
+ )
+ )
+ ),
+ (Html.Attributes.class "clickable"),
+ (Html.Events.onClick
+ (Struct.Event.TileSelected
+ (BattleMap.Struct.Location.get_ref tile_loc)
+ )
+ ),
+ (Html.Attributes.style
+ "top"
+ (
+ (String.fromInt (tile_loc.y * Constants.UI.tile_size))
+ ++ "px"
+ )
+ ),
+ (Html.Attributes.style
+ "left"
+ (
+ (String.fromInt (tile_loc.x * Constants.UI.tile_size))
+ ++ "px"
+ )
+ )
+ ]
+ )
+ (
+ if (display_cost)
+ then
+ (
+ (Html.div
+ [
+ (Html.Attributes.class "tile-icon-cost")
+ ]
+ [
+ (Html.text
+ (String.fromInt
+ (BattleMap.Struct.TileInstance.get_cost tile)
+ )
+ )
+ ]
+ )
+ :: (get_content_html tile)
+ )
+ else (get_content_html tile)
+ )
+ )