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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
module Struct.Armor exposing
(
Type,
Ref,
Category(..),
new,
get_id,
get_name,
get_category,
get_resistance_to,
get_image_id,
apply_to_attributes
)
-- Battlemap -------------------------------------------------------------------
import Struct.Attributes
import Struct.Weapon
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
--------------------------------------------------------------------------------
type alias Type =
{
id : Int,
name : String,
category : Category,
coef : Float
}
type alias Ref = Int
type Category =
Kinetic
| Leather
| Chain
| Plate
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
new : Int -> String -> Category -> Float -> Type
new id name category coef =
{
id = id,
name = name,
category = category,
coef = coef
}
get_id : Type -> Ref
get_id ar = ar.id
get_name : Type -> String
get_name ar = ar.name
get_category : Type -> String
get_category ar = ar.name
get_image_id : Type -> String
get_image_id ar = (toString ar.id)
get_resistance_to : Struct.Weapon.DamageType -> Type -> Int
get_resistance_to dmg_type ar =
(ceiling
(
ar.coef
*
(toFloat
(
case (dmg_type, ar.category) of
(Struct.Weapon.Slash, Kinetic) -> 0
(Struct.Weapon.Slash, Leather) -> 5
(Struct.Weapon.Slash, Chain) -> 10
(Struct.Weapon.Slash, Plate) -> 10
(Struct.Weapon.Blunt, Kinetic) -> 10
(Struct.Weapon.Blunt, Leather) -> 5
(Struct.Weapon.Blunt, Chain) -> 5
(Struct.Weapon.Blunt, Plate) -> 5
(Struct.Weapon.Pierce, Kinetic) -> 5
(Struct.Weapon.Pierce, Leather) -> 5
(Struct.Weapon.Pierce, Chain) -> 5
(Struct.Weapon.Pierce, Plate) -> 10
)
)
)
)
apply_to_attributes : Type -> Struct.Attributes.Type -> Struct.Attributes.Type
apply_to_attributes ar atts =
let
impact = (ceiling (-20.0 * ar.coef))
in
case ar.category of
Kinetic -> (Struct.Attributes.mod_mind impact atts)
Leather -> (Struct.Attributes.mod_dexterity impact atts)
Chain ->
(Struct.Attributes.mod_dexterity
impact
(Struct.Attributes.mod_speed impact atts)
)
Plate ->
(Struct.Attributes.mod_dexterity
impact
(Struct.Attributes.mod_speed
impact
(Struct.Attributes.mod_strength impact atts)
)
)
|