aboutsummaryrefslogtreecommitdiff
blob: 2ff5bf4dbfe42df64cec0c82331edab09303d8ec (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
157
module View.SubMenu.Status exposing (get_html)

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

import Html
import Html.Attributes

-- Struct.Battlemap -------------------------------------------------------------------
import Struct.Battlemap
import Struct.Character
import Struct.Error
import Struct.Event
import Struct.Location
import Struct.Model
import Struct.Statistics
import Struct.Tile
import Struct.UI

import View.SubMenu.Status.CharacterInfo
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
get_char_info_html : (
      Struct.Model.Type ->
      Struct.Character.Ref ->
      (Html.Html Struct.Event.Type)
   )
get_char_info_html model char_ref =
   case (Dict.get char_ref model.characters) of
      Nothing -> (Html.text "Error: Unknown character selected.")
      (Just char) ->
         (Html.text
            (
               "Focusing "
               ++ char.name
               ++ " (Player "
               ++ (Struct.Character.get_player_id char)
               ++ "): "
               ++
               (toString
                  (Struct.Statistics.get_movement_points
                     (Struct.Character.get_statistics char)
                  )
               )
               ++ " movement points; "
               ++ "???"
               ++ " attack range. Health: "
               ++ (toString (Struct.Character.get_current_health char))
               ++ "/"
               ++
               (toString
                  (Struct.Statistics.get_max_health
                     (Struct.Character.get_statistics char)
                  )
               )
            )
         )

get_error_html : Struct.Error.Type -> (Html.Html Struct.Event.Type)
get_error_html err =
   (Html.div
      [
         (Html.Attributes.class "battlemap-tabmenu-error-message")
      ]
      [
         (Html.text (Struct.Error.to_string err))
      ]
   )

get_tile_info_html : (
      Struct.Model.Type ->
      Struct.Location.Type ->
      (Html.Html Struct.Event.Type)
   )
get_tile_info_html model loc =
   case (Struct.Battlemap.try_getting_tile_at model.battlemap loc) of
      (Just tile) ->
         (Html.div
            [
               (Html.Attributes.class
                  "battlemap-tabmenu-tile-info-tab"
               )
            ]
            [
               (Html.div
                  [
                     (Html.Attributes.class "battlemap-tile-icon"),
                     (Html.Attributes.class "battlemap-tiled"),
                     (Html.Attributes.class
                        (
                           "asset-tile-"
                           ++
                           (Struct.Tile.get_icon_id tile)
                        )
                     )
                  ]
                  [
                  ]
               ),
               (Html.div
                  [
                  ]
                  [
                     (Html.text
                        (
                           "Focusing tile ("
                           ++ (toString loc.x)
                           ++ ", "
                           ++ (toString loc.y)
                           ++ "). {ID = "
                           ++ (Struct.Tile.get_icon_id tile)
                           ++ ", cost = "
                           ++ (toString (Struct.Tile.get_cost tile))
                           ++ "}."
                        )
                     )
                  ]
               )
            ]
         )

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

--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
get_html model =
   (Html.div
      [
         (Html.Attributes.class "battlemap-footer-tabmenu-content"),
         (Html.Attributes.class "battlemap-footer-tabmenu-content-status")
      ]
      [
         (case (Struct.UI.get_previous_action model.ui) of
            (Just (Struct.UI.SelectedLocation loc)) ->
               (get_tile_info_html
                  model
                  (Struct.Location.from_ref loc)
               )

            (Just (Struct.UI.SelectedCharacter target_char)) ->
               case (Dict.get target_char model.characters) of
                  (Just char) ->
                     (View.SubMenu.Status.CharacterInfo.get_html
                        model
                        char
                     )

                  _ -> (Html.text "Error: Unknown character selected.")

            _ ->
               (Html.text "Double-click on a character to control it.")
         )
      ]
   )