summaryrefslogtreecommitdiff
blob: 3067bcbf8e3701f487dbb98fd31bd6f5871e6fe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
module BattleMap.View.TileInfo exposing (get_html)

-- Elm -------------------------------------------------------------------------
import Dict

import Html
import Html.Attributes

-- Shared ----------------------------------------------------------------------
import Util.Html

-- Battle ----------------------------------------------------------------------
import Battle.Struct.Omnimods

import Battle.View.Omnimods

-- Battle Map ------------------------------------------------------------------
import BattleMap.Struct.Location
import BattleMap.Struct.Map
import BattleMap.Struct.Tile
import BattleMap.Struct.TileInstance

import BattleMap.View.Tile

-- Local Module ----------------------------------------------------------------
import Constants.Movement

import Struct.Event
import Struct.Model

--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
get_icon : (BattleMap.Struct.TileInstance.Type -> (Html.Html Struct.Event.Type))
get_icon tile_instance =
   (Html.div
      [
         (Html.Attributes.class "tile-card-icon"),
         (Html.Attributes.class "info-card-picture"),
         (Html.Attributes.class
            (
               "tile-variant-"
               ++
               (String.fromInt
                  (BattleMap.Struct.TileInstance.get_local_variant_ix
                     tile_instance
                  )
               )
            )
         )
      ]
      (BattleMap.View.Tile.get_content_html tile_instance)
   )

get_name : BattleMap.Struct.Tile.Type -> (Html.Html Struct.Event.Type)
get_name tile =
   (Html.div
      [
         (Html.Attributes.class "info-card-name"),
         (Html.Attributes.class "info-card-text-field"),
         (Html.Attributes.class "tile-card-name")
      ]
      [
         (Html.text
            (BattleMap.Struct.Tile.get_name tile)
         )
      ]
   )

get_cost : BattleMap.Struct.TileInstance.Type -> (Html.Html Struct.Event.Type)
get_cost tile_inst =
   let
      cost = (BattleMap.Struct.TileInstance.get_cost tile_inst)
      text =
         if (cost > Constants.Movement.max_points)
         then "Obstructed"
         else ("Cost: " ++ (String.fromInt cost))
   in
      (Html.div
         [
            (Html.Attributes.class "info-card-text-field"),
            (Html.Attributes.class "tile-card-cost")
         ]
         [
            (Html.text text)
         ]
      )

get_location : (
      BattleMap.Struct.TileInstance.Type ->
      (Html.Html Struct.Event.Type)
   )
get_location tile_inst =
   let tile_location = (BattleMap.Struct.TileInstance.get_location tile_inst) in
      (Html.div
         [
            (Html.Attributes.class "info-card-text-field"),
            (Html.Attributes.class "tile-card-location")
         ]
         [
            (Html.text
               (
                  "{x: "
                  ++ (String.fromInt tile_location.x)
                  ++ "; y: "
                  ++ (String.fromInt tile_location.y)
                  ++ "}"
               )
            )
         ]
      )

--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_html : (
      BattleMap.Struct.DataSet.Type ->
      BattleMap.Struct.Location.Ref ->
      BattleMap.Struct.Map.Type ->
      (Html.Html Struct.Event.Type)
   )
get_html dataset loc_ref map =
   let loc = (BattleMap.Struct.Location.from_ref loc_ref) in
      case (BattleMap.Struct.Map.maybe_get_tile_at loc map) of
         (Just tile_instance) ->
            let
               tile_data =
                  (BattleMap.Struct.DataSet.get_tile
                     (BattleMap.Struct.TileInstance.get_class_id tile_instance)
                  )
            in
               (Html.div
                  [
                     (Html.Attributes.class "info-card"),
                     (Html.Attributes.class "tile-card")
                  ]
                  [
                     (get_name dataset tile_data),
                     (Html.div
                        [
                           (Html.Attributes.class "info-card-top"),
                           (Html.Attributes.class "tile-card-top")
                        ]
                        [
                           (get_icon tile_instance),
                           (get_location tile_instance),
                           (get_cost tile_instance)
                        ]
                     ),
                     (Battle.View.Omnimods.get_signed_html
                        (BattleMap.Struct.Tile.get_omnimods tile_data)
                     )
                  ]
               )

         Nothing -> (Html.text "Error: Unknown tile location selected.")