aboutsummaryrefslogtreecommitdiff
blob: 437d118675a7efb5b3989bc5ef159f553610b067 (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
module Model exposing
   (
      Type,
      CharacterSelection,
      State(..),
      get_state,
      invalidate,
      reset,
      clear_error
   )

import Dict

import Battlemap
import Battlemap.Navigator
import Battlemap.Location
import Battlemap.Tile
import Battlemap.RangeIndicator

import Error

import Character

type alias CharacterSelection =
   {
      character: Character.Ref,
      navigator: Battlemap.Navigator.Type,
      range_indicator:
         (Dict.Dict
            Battlemap.Location.Ref
            Battlemap.RangeIndicator.Type
         )
   }

type State =
   Default
   | MovingCharacterWithButtons
   | MovingCharacterWithClick
   | FocusingTile

type alias Type =
   {
      state: State,
      battlemap: Battlemap.Type,
      characters: (Dict.Dict Character.Ref Character.Type),
      error: (Maybe Error.Type),
      selection: (Maybe CharacterSelection)
   }

get_state : Type -> State
get_state model = model.state

reset : Type -> Type
reset model =
   {model |
      state = Default,
      selection = Nothing,
      error = Nothing,
      battlemap =
         (Battlemap.apply_to_all_tiles
            model.battlemap
            (Battlemap.Tile.reset)
         )
   }

invalidate : Type -> Error.Type -> Type
invalidate model err = {model | error = (Just err)}

clear_error : Type -> Type
clear_error model = {model | error = Nothing}