summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/battle/Battle/Struct/Statistics.elm')
-rw-r--r--src/shared/battle/Battle/Struct/Statistics.elm146
1 files changed, 41 insertions, 105 deletions
diff --git a/src/shared/battle/Battle/Struct/Statistics.elm b/src/shared/battle/Battle/Struct/Statistics.elm
index 9847f1c..74eea8d 100644
--- a/src/shared/battle/Battle/Struct/Statistics.elm
+++ b/src/shared/battle/Battle/Struct/Statistics.elm
@@ -10,19 +10,17 @@ module Battle.Struct.Statistics exposing
get_double_hits,
get_critical_hits,
get_damage_modifier,
+ get_damage_multiplier,
decode_category,
encode_category,
mod,
- new_raw,
+ default,
is_percent
)
-- Elm -------------------------------------------------------------------------
import List
--- Battle ----------------------------------------------------------------------
-import Battle.Struct.Attributes
-
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
--------------------------------------------------------------------------------
@@ -34,6 +32,7 @@ type Category =
| Accuracy
| DoubleHits
| CriticalHits
+ | DamageModifier
type alias Type =
{
@@ -44,120 +43,71 @@ type alias Type =
accuracy : Int,
double_hits : Int,
critical_hits : Int,
- damage_modifier : Float
+ damage_modifier : Int
}
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-average : (List Int) -> Float
-average l = ((toFloat (List.sum l)) / (toFloat (List.length l)))
-
-float_to_int : Float -> Int
-float_to_int f =
- (ceiling f)
-
-gentle_squared_growth : Int -> Int
-gentle_squared_growth v = (float_to_int (((toFloat v)^1.8)/20.0))
-
-gentle_squared_growth_f : Float -> Int
-gentle_squared_growth_f v = (float_to_int ((v^1.8)/20.0))
-
-sudden_squared_growth : Int -> Int
-sudden_squared_growth v = (float_to_int (((toFloat v)^2.5)/1000.0))
-
-sudden_squared_growth_f : Float -> Int
-sudden_squared_growth_f v = (float_to_int ((v^2.5)/1000.0))
-
-sudden_exp_growth : Int -> Int
-sudden_exp_growth v = (float_to_int (4.0^((toFloat v)/25.0)))
-
-sudden_exp_growth_f : Float -> Int
-sudden_exp_growth_f f = (float_to_int (4.0^(f/25.0)))
-
-damage_base_mod : Float -> Float
-damage_base_mod str = ((((str + 10) * 4)^1.5)/3000.0)
-
-make_movement_points_safe : Int -> Int
-make_movement_points_safe val = (clamp 0 200 val)
-
-make_max_health_safe : Int -> Int
-make_max_health_safe val = (max 1 val)
-
-make_dodges_safe : Int -> Int
-make_dodges_safe val = (clamp 0 100 val)
-
-make_parries_safe : Int -> Int
-make_parries_safe val = (clamp 0 75 val)
-
-make_accuracy_safe : Int -> Int
-make_accuracy_safe val = (clamp 0 100 val)
-
-make_double_hits_safe : Int -> Int
-make_double_hits_safe val = (clamp 0 100 val)
-
-make_critical_hits_safe : Int -> Int
-make_critical_hits_safe val = (clamp 0 100 val)
-
mod_movement_points : Int -> Type -> Type
mod_movement_points v t =
{t |
- movement_points = (make_movement_points_safe (t.movement_points + v))
+ movement_points = (t.movement_points + v)
}
mod_max_health : Int -> Type -> Type
mod_max_health v t =
{t |
- max_health = (make_max_health_safe (t.max_health + v))
+ max_health = (t.max_health + v)
}
mod_dodges : Int -> Type -> Type
-mod_dodges v t = {t | dodges = (make_dodges_safe (t.dodges + v))}
+mod_dodges v t = {t | dodges = (t.dodges + v)}
mod_parries : Int -> Type -> Type
-mod_parries v t = {t | parries = (make_parries_safe (t.parries + v))}
+mod_parries v t = {t | parries = (t.parries + v)}
mod_accuracy : Int -> Type -> Type
-mod_accuracy v t = {t | accuracy = (make_accuracy_safe (t.accuracy + v))}
+mod_accuracy v t = {t | accuracy = (t.accuracy + v)}
mod_double_hits : Int -> Type -> Type
-mod_double_hits v t =
- {t |
- double_hits = (make_double_hits_safe (t.double_hits + v))
- }
+mod_double_hits v t = {t | double_hits = (t.double_hits + v)}
mod_critical_hits : Int -> Type -> Type
-mod_critical_hits v t =
- {t |
- critical_hits = (make_critical_hits_safe (t.critical_hits + v))
- }
+mod_critical_hits v t = {t | critical_hits = (t.critical_hits + v)}
+
+mod_damage_modifier : Int -> Type -> Type
+mod_damage_modifier v t = {t | damage_modifier = (t.damage_modifier + v)}
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_movement_points : Type -> Int
-get_movement_points t = t.movement_points
+get_movement_points t = (max 0 t.movement_points)
get_max_health : Type -> Int
-get_max_health t = t.max_health
+get_max_health t = (max 1 t.max_health)
get_dodges : Type -> Int
-get_dodges t = t.dodges
+get_dodges t = (max 0 t.dodges)
get_parries : Type -> Int
-get_parries t = t.parries
+get_parries t = (max 0 t.parries)
get_accuracy : Type -> Int
-get_accuracy t = t.accuracy
+get_accuracy t = (max 0 t.accuracy)
get_double_hits : Type -> Int
-get_double_hits t = t.double_hits
+get_double_hits t = (max 0 t.double_hits)
get_critical_hits : Type -> Int
-get_critical_hits t = t.critical_hits
+get_critical_hits t = (max 0 t.critical_hits)
-get_damage_modifier : Type -> Float
-get_damage_modifier t = t.damage_modifier
+get_damage_modifier : Type -> Int
+get_damage_modifier t = (max 0 t.damage_modifier)
+
+get_damage_multiplier : Type -> Float
+get_damage_multiplier t = ((toFloat (max 0 t.damage_modifier)) / 100.0)
mod : Category -> Int -> Type -> Type
mod cat v t =
@@ -169,36 +119,20 @@ mod cat v t =
Accuracy -> (mod_accuracy v t)
DoubleHits -> (mod_double_hits v t)
CriticalHits -> (mod_critical_hits v t)
+ DamageModifier -> (mod_damage_modifier v t)
-new_raw : (Battle.Struct.Attributes.Type -> Type)
-new_raw att =
- let
- constitution = (Battle.Struct.Attributes.get_effective_constitution att)
- dexterity = (Battle.Struct.Attributes.get_effective_dexterity att)
- intelligence = (Battle.Struct.Attributes.get_effective_intelligence att)
- mind = (Battle.Struct.Attributes.get_effective_mind att)
- speed = (Battle.Struct.Attributes.get_effective_speed att)
- strength = (Battle.Struct.Attributes.get_effective_strength att)
- in
- {
- movement_points =
- (gentle_squared_growth_f
- (average [mind, constitution, constitution, speed, speed, speed])
- ),
- max_health =
- (gentle_squared_growth_f
- (average [constitution, constitution, constitution, mind])
- ),
- dodges = (sudden_exp_growth_f (average [dexterity, mind, speed])),
- parries =
- (sudden_exp_growth_f
- (average [dexterity, intelligence, speed, strength])
- ),
- accuracy = (sudden_squared_growth dexterity),
- double_hits = (sudden_squared_growth_f (average [mind, speed])),
- critical_hits = (sudden_squared_growth intelligence),
- damage_modifier = (damage_base_mod (toFloat strength))
- }
+default : Type
+default =
+ {
+ movement_points = 0,
+ max_health = 1,
+ dodges = 0,
+ parries = 0,
+ accuracy = 0,
+ double_hits = 0,
+ critical_hits = 0,
+ damage_modifier = 0
+ }
decode_category : String -> Category
decode_category str =
@@ -209,6 +143,7 @@ decode_category str =
"pary" -> Parries
"accu" -> Accuracy
"dhit" -> DoubleHits
+ "dmgm" -> DamageModifier
_ -> CriticalHits
encode_category : Category -> String
@@ -221,6 +156,7 @@ encode_category cat =
Accuracy -> "accu"
DoubleHits -> "dhit"
CriticalHits -> "crit"
+ DamageModifier -> "dmgm"
is_percent : Category -> Bool
is_percent cat = ((cat /= MaxHealth) && (cat /= MovementPoints))