aboutsummaryrefslogtreecommitdiff
blob: c4cd30126d72d281531d37337b36bf18c3741168 (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
module ElmModule.Update exposing (update)

-- Elm -------------------------------------------------------------------------

-- Battlemap -------------------------------------------------------------------
import Struct.Event
import Struct.Error
import Struct.UI
import Struct.Model

import Update.ChangeScale
import Update.EndTurn
import Update.HandleServerReply
import Update.RequestDirection
import Update.SelectCharacter
import Update.SelectTab
import Update.SelectTile
import Update.SendLoadBattlemapRequest
import Update.SwitchTeam

import Send.LoadBattlemap

update : (
      Struct.Event.Type ->
      Struct.Model.Type ->
      (Struct.Model.Type, (Cmd Struct.Event.Type))
   )
update event model =
   let
      new_model = (Struct.Model.clear_error model)
   in
   case event of
      (Struct.Event.DirectionRequested d) ->
         (Update.RequestDirection.apply_to new_model d)

      (Struct.Event.TileSelected loc) ->
         (Update.SelectTile.apply_to new_model loc)

      (Struct.Event.CharacterSelected char_id) ->
         (Update.SelectCharacter.apply_to new_model char_id)

      Struct.Event.TurnEnded ->
         (Update.EndTurn.apply_to new_model)

      (Struct.Event.ScaleChangeRequested mod) ->
         (Update.ChangeScale.apply_to new_model mod)

      (Struct.Event.TabSelected tab) ->
         (Update.SelectTab.apply_to new_model tab)

      Struct.Event.DebugTeamSwitchRequest ->
         (Update.SwitchTeam.apply_to new_model)

      (Struct.Event.DebugLoadBattlemapRequest) ->
         (Update.SendLoadBattlemapRequest.apply_to new_model)

      (Struct.Event.ServerReplied result) ->
         (Update.HandleServerReply.apply_to model result)