aboutsummaryrefslogtreecommitdiff
blob: 6f1e10d40d6487711ff56e6fb1acbda45800531b (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
module View.Controlled 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 "Select Target") ]
   )

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_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 ->
         [
            (attack_button),
            (inventory_button)
         ]

      Struct.CharacterTurn.MovedCharacter ->
         [
            (end_turn_button)
         ]

      Struct.CharacterTurn.ChoseTarget ->
         [
            (end_turn_button)
         ]

      _ ->
         [
            (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-controlled")]
            (get_curr_char_info_htmls model char)
         )

      Nothing -> (Util.Html.nothing)