aboutsummaryrefslogtreecommitdiff
blob: 9cdfc1f596d255862dbc812f24597b65c762cd70 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
module Battlemap.Navigator exposing
   (
      Type,
      new,
      get_current_location,
      get_remaining_points,
      get_range_markers,
      add_step
   )

import Dict

import Battlemap.Location

import Battlemap.Navigator.Path
import Battlemap.Navigator.RangeIndicator

--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
--------------------------------------------------------------------------------
type alias Type =
   {
      starting_location: Battlemap.Location.Type,
      movement_dist: Int,
      attack_dist: Int,
      path: Battlemap.Navigator.Path.Type,
      range_indicators:
         (Dict.Dict
            Battlemap.Location.Ref
            Battlemap.Navigator.RangeIndicator.Type
         )
   }

--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------


--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------

new : (
      Battlemap.Location.Type ->
      Int ->
      Int ->
      (Battlemap.Location.Type -> Bool) -> Type
   )
new start_loc mov_dist atk_dist can_cross_fun =
   {
      starting_location = start_loc,
      movement_dist = mov_dist,
      attack_dist = atk_dist,
      path = (Battlemap.Navigator.Path.new start_loc mov_dist),
      range_indicators =
         (Battlemap.Navigator.RangeIndicator.generate
            start_loc
            mov_dist
            atk_dist
            (can_cross_fun)
         )
   }

get_current_location : Type -> Battlemap.Location.Type
get_current_location navigator =
   (Battlemap.Navigator.Path.get_current_location navigator.path)

get_remaining_points : Type -> Int
get_remaining_points navigator =
   (Battlemap.Navigator.Path.get_remaining_points navigator.path)

get_range_markers : (
      Type ->
      (List
         (Battlemap.Location.Ref, Battlemap.Navigator.RangeIndicator.Type)
      )
   )
get_range_markers navigator = (Dict.toList navigator.range_indicators)

add_step : (
      Type ->
      Battlemap.Direction.Type ->
      (Battlemap.Location.Type -> Bool) ->
      (Maybe Type)
   )
add_step navigator dir can_cross =
   case
      (Battlemap.Navigator.Path.follow_direction
         can_cross
         (Just navigator.path)
         dir
      )
   of
      (Just path) -> (Just {navigator | path = path}
      Nothing -> Nothing