summaryrefslogtreecommitdiff
blob: 2d8b42c6aac6beec2534155ec60744f39c72cf11 (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
module Update.DirectionRequest exposing (apply_to)

import Dict

import Battlemap.Direction
import Battlemap.Navigator.Move

import Model

apply_to : Model.Type -> Battlemap.Direction.Type -> Model.Type
apply_to model dir =
   case (model.selection, model.navigator) of
      (Nothing, _) -> model
      (_ , Nothing) -> model
      ((Just char_id), (Just nav)) ->
         let
            (new_bmap, new_nav) =
               (Battlemap.Navigator.Move.to
                  model.battlemap
                  nav
                  dir
                  (Dict.values model.characters)
               )
         in
            {model |
               battlemap = new_bmap,
               navigator = (Just new_nav)
            }