blob: 272163e662fff3f42be2b8e6303f27d0be275c22 (
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
|
module Update.CharacterTurn.ToggleTarget exposing (apply_to_ref)
-- Local Module ----------------------------------------------------------------
import Struct.CharacterTurn
import Struct.Event
import Struct.Model
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
can_target_character : (
Struct.Model.Type ->
Struct.Character.Type ->
Bool
)
can_target_character model target =
(
(Struct.Character.is_alive target)
&&
(
case
(Struct.CharacterTurn.maybe_get_navigator
model.char_turn
)
of
(Just nav) ->
case
(Struct.Navigator.maybe_get_path_to
(BattleMap.Struct.Location.get_ref
(Struct.Character.get_location target)
)
nav
)
of
(Just _) -> True
_ -> False
_ ->
False
)
)
attack_character : (
Struct.Model.Type ->
Int ->
Struct.Character.Type ->
Struct.Model.Type
)
attack_character model target_char_id target_char =
{model |
char_turn =
(Struct.CharacterTurn.set_target
(Just target_char_id)
model.char_turn
),
ui =
(Struct.UI.reset_displayed_nav
(Struct.UI.reset_displayed_tab
(Struct.UI.set_previous_action Nothing model.ui)
)
)
}
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
apply_to : Struct.Model.Type -> (Struct.Model.Type, (Cmd Struct.Event.Type))
apply_to model =
(
{model |
char_turn = (Struct.CharacterTurn.new)
},
Cmd.none
)
|