aboutsummaryrefslogtreecommitdiff
blob: 6a95aa938857b73170a3a2593190ad2b40d38dbd (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
module View.Footer exposing (get_html)

-- Elm -------------------------------------------------------------------------
import Html
import Html.Attributes
import Html.Events

-- Struct.Battlemap -------------------------------------------------------------------
import Struct.Character
import Struct.CharacterTurn
import Struct.Event
import Struct.Model
import Struct.Navigator
import Struct.Statistics

import Util.Html

--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
attack_button : (Html.Html Struct.Event.Type)
attack_button =
   (Html.button
      [ (Html.Events.onClick Struct.Event.AttackWithoutMovingRequest) ]
      [ (Html.text "Attack Without Moving") ]
   )

end_turn_button : (Html.Html Struct.Event.Type)
end_turn_button =
   (Html.button
      [ (Html.Events.onClick Struct.Event.TurnEnded) ]
      [ (Html.text "End Turn") ]
   )

inventory_button : (Html.Html Struct.Event.Type)
inventory_button =
   (Html.button
      [ (Html.Events.onClick Struct.Event.WeaponSwitchRequest) ]
      [ (Html.text "Switch Weapon") ]
   )

get_navigator_info : (
      Struct.Model.Type ->
      Struct.Character.Type ->
      String
   )
get_navigator_info model char =
   case
      (Struct.CharacterTurn.try_getting_navigator model.char_turn)
   of
      (Just nav) ->
         (
            (toString (Struct.Navigator.get_remaining_points nav))
            ++ "/"
            ++
            (toString
               (Struct.Statistics.get_movement_points
                  (Struct.Character.get_statistics char)
               )
            )
            ++ " movement points remaining"
         )

      _ ->
         "[Error: Character selected yet navigator undefined.]"

get_curr_char_info_htmls : (
      Struct.Model.Type ->
      Struct.Character.Type ->
      (List (Html.Html Struct.Event.Type))
   )
get_curr_char_info_htmls model char =
   case
      (Struct.CharacterTurn.get_state model.char_turn)
   of
      Struct.CharacterTurn.SelectedCharacter ->
         [
            (Html.text
               (
                  "Controlling "
                  ++ char.name
                  ++ ". Move ("
                  ++ (get_navigator_info model char)
                  ++ "), "
               )
            ),
            (attack_button),
            (Html.text ", or "),
            (inventory_button)
         ]

      Struct.CharacterTurn.MovedCharacter ->
         [
            (Html.text
               (
                  "Controlling "
                  ++ char.name
                  ++ ". Moved. Select a target, or "
               )
            ),
            (end_turn_button)
         ]

      Struct.CharacterTurn.ChoseTarget ->
         [
            (Html.text
               (
                  "Controlling "
                  ++ char.name
                  ++ ". Moved. Chose a target. Click on "
               )
            ),
            (end_turn_button),
            (Html.text "to end turn.")
         ]

      _ ->
         [
            (Html.text
               (
                  "Error: CharacterTurn structure in an inconsistent state:"
                  ++ " Has an active character yet the 'state' is not any of"
                  ++ " those expected in such cases."
               )
            )
         ]

--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
get_html model =
   case
      (Struct.CharacterTurn.try_getting_active_character model.char_turn)
   of
      (Just char) ->
         (Html.div
            [(Html.Attributes.class "battlemap-footer")]
            (get_curr_char_info_htmls model char)
         )

      Nothing -> (Util.Html.nothing)