summaryrefslogtreecommitdiff
blob: 75cab27ccdcbedca7a00a280928bd9711a48cd9b (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
-module(statistics).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-record
(
   statistics,
   {
      movement_points,
      health,
      dodges,
      parries,
      damage_min,
      damage_max,
      accuracy,
      double_hits,
      critical_hits
   }
).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Accessors
-export
(
   [
      get_movement_points/1,
      get_health/1,
      get_dodges/1,
      get_parries/1,
      get_damage_min/1,
      get_damage_max/1,
      get_accuracy/1,
      get_double_hits/1,
      get_critical_hits/1
   ]
).

-export
(
   [
      calc_for/2
   ]
).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Accessors
get_movement_points (Stats) -> Stats#statistics.movement_points.
get_health (Stats) -> Stats#statistics.health.
get_dodges (Stats) -> Stats#statistics.dodges.
get_parries (Stats) -> Stats#statistics.parries.
get_damage_min (Stats) -> Stats#statistics.damage_min.
get_damage_max (Stats) -> Stats#statistics.damage_max.
get_accuracy (Stats) -> Stats#statistics.accuracy.
get_double_hits (Stats) -> Stats#statistics.double_hits.
get_critical_hits (Stats) -> Stats#statistics.critical_hits.

calc_for (Att, Wp) ->
   #statistics
   {
      movement_points =
         trunc(math:ceil(math:pow(attributes:get_speed(Att), 1.8) / 20)),
      health =
         trunc(math:ceil(math:pow(attributes:get_constitution(Att), 1.8) / 20)),
      dodges =
         min(75, max(5, trunc(math:ceil(math:pow(4,
            (
               lists:sum
               (
                  [
                     attributes:get_dexterity(Att),
                     attributes:get_mind(Att),
                     attributes:get_speed(Att)
                  ]
               )
               / 3
            )))))),
      parries =
         min(75, trunc(math:ceil(math:pow(4,
            (
               lists:sum
               (
                  [
                     attributes:get_dexterity(Att),
                     attributes:get_speed(Att),
                     attributes:get_strength(Att)
                  ]
               )
               / 3
            ))))),
      damage_min = 0,
      damage_max = 100,
      accuracy = min(75, max(5, trunc(math:ceil(30 * math:log((x + 5) / 4))))),
      double_hits =
         min(100, trunc(math:ceil(
            math:pow(attributes:get_speed(Att), 2.5)
            / 1000
         ))),
      critical_hits =
         min(100, trunc(math:ceil(
            math:pow(attributes:get_intelligence(Att), 2.5)
            / 1000
        )))
   }.