blob: 719d25962cda174c4303bc097373eb96614fd1e5 (
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 Update exposing (..)
import Model exposing (Model, model)
import Battlemap exposing (apply_to_all_tiles)
import Battlemap.Direction exposing (Direction)
import Battlemap.Navigator as Nr exposing (go, reset_navigation)
import Dict as Dt exposing (get)
import Character exposing (CharacterRef)
type Msg =
DirectionRequest Direction
| SelectCharacter CharacterRef
update : Msg -> Model -> Model
update msg model =
case msg of
(DirectionRequest d) ->
(case model.selection of
Nothing ->
model
(Just char_id) ->
(case model.navigator of
Nothing -> model
(Just nav) ->
let
(new_bmap, new_nav) =
(Nr.go
model.battlemap
nav
d
)
in
{model |
battlemap = new_bmap,
navigator = (Just new_nav)
}
)
)
(SelectCharacter char_id) ->
{model |
selection = (Just char_id),
battlemap =
(apply_to_all_tiles
model.battlemap
(reset_navigation)
),
navigator =
(case (Dt.get char_id model.characters) of
Nothing -> Nothing
(Just char) ->
(Just (Nr.new_navigator {x = char.x, y = char.y}))
)
}
--_ -> model
|