aboutsummaryrefslogtreecommitdiff
blob: 2eaca27da1720ab83d0843489791e8ebf2912c01 (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
module View.SideBar.TabMenu.Characters exposing (get_html)

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

import Html
import Html.Attributes
import Html.Events

-- Battlemap -------------------------------------------------------------------
import Struct.Character
import Struct.Event
import Struct.Model

--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
get_character_portrait_html : (
      String ->
      Struct.Character.Type ->
      (Html.Html Struct.Event.Type)
   )
get_character_portrait_html viewer_id char =
   (Html.div
      [
         (Html.Attributes.class
            (
               "asset-character-portrait-"
               ++ (Struct.Character.get_portrait_id char)
            )
         ),
         (Html.Attributes.class
            (
               if ((Struct.Character.get_player_id char) == viewer_id)
               then
                  "battlemap-character-ally"
               else
                  "battlemap-character-enemy"
            )
         ),
         (Html.Attributes.class "battlemap-character-portrait")
      ]
      [
      ]
   )

get_character_element_html : (
      String ->
      Struct.Character.Type ->
      (Html.Html Struct.Event.Type)
   )
get_character_element_html viewer_id char =
   (Html.div
      [
         (Html.Attributes.class "battlemap-characters-element"),
         (Html.Attributes.class "clickable"),
         (Html.Events.onClick
            (Struct.Event.CharacterInfoRequested
               (Struct.Character.get_ref char)
            )
         )
      ]
      [
         (get_character_portrait_html viewer_id char),
         (Html.text
            (
               (Struct.Character.get_name char)
               ++ ": "
               ++ (toString (Struct.Character.get_current_health char))
               ++ " HP, "
               ++
               (
                  if (Struct.Character.is_enabled char)
                  then
                     "active"
                  else
                     "inactive"
               )
               ++ " (Player "
               ++ (Struct.Character.get_player_id char)
               ++ ")."
            )
         )
      ]
   )

--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
get_html model =
   (Html.div
      [
         (Html.Attributes.class "battlemap-tabmenu-content"),
         (Html.Attributes.class "battlemap-tabmenu-characters-tab")
      ]
      (List.map
         (get_character_element_html model.player_id)
         (Dict.values model.characters)
      )
   )