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

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

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

import Update.AttackWithoutMoving
import Update.ChangeScale
import Update.DisplayCharacterInfo
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 Update.SwitchWeapon

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.AttackWithoutMovingRequest ->
         (Update.AttackWithoutMoving.apply_to new_model)

      (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.CharacterInfoRequested char_id) ->
         (Update.DisplayCharacterInfo.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)

      Struct.Event.WeaponSwitchRequest ->
         (Update.SwitchWeapon.apply_to new_model)