summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2018-01-23 12:52:28 +0100 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2018-01-23 12:52:28 +0100 |
commit | 1c5640a56a14623c0c92233a22403c1a05d1b492 (patch) | |
tree | 07ebd8742f26fc2b3784a128515ac3faa2434e4e | |
parent | 0af4f6c8a558c1cd7affac35fb0583c74cd1c103 (diff) |
Adds client side stats calc.
-rw-r--r-- | src/battlemap/src/Struct/Attributes.elm | 6 | ||||
-rw-r--r-- | src/battlemap/src/Struct/Character.elm | 1 | ||||
-rw-r--r-- | src/battlemap/src/Struct/Statistics.elm | 98 |
3 files changed, 89 insertions, 16 deletions
diff --git a/src/battlemap/src/Struct/Attributes.elm b/src/battlemap/src/Struct/Attributes.elm index bacd414..c632684 100644 --- a/src/battlemap/src/Struct/Attributes.elm +++ b/src/battlemap/src/Struct/Attributes.elm @@ -40,13 +40,13 @@ get_intelligence : Type -> Int get_intelligence t = t.intelligence get_mind : Type -> Int -get_mind = t.mind +get_mind t = t.mind get_speed : Type -> Int -get_speed = t.speed +get_speed t = t.speed get_strength : Type -> Int -get_strength = t.strength +get_strength t = t.strength new : ( Int -> -- constitution diff --git a/src/battlemap/src/Struct/Character.elm b/src/battlemap/src/Struct/Character.elm index 3f340d7..dc64c97 100644 --- a/src/battlemap/src/Struct/Character.elm +++ b/src/battlemap/src/Struct/Character.elm @@ -20,6 +20,7 @@ module Struct.Character exposing -- Battlemap ------------------------------------------------------------------- import Struct.Attributes import Struct.Location +import Struct.Statistics -------------------------------------------------------------------------------- -- TYPES ----------------------------------------------------------------------- diff --git a/src/battlemap/src/Struct/Statistics.elm b/src/battlemap/src/Struct/Statistics.elm index b1690a5..fa59bb5 100644 --- a/src/battlemap/src/Struct/Statistics.elm +++ b/src/battlemap/src/Struct/Statistics.elm @@ -13,6 +13,12 @@ module Struct.Statistics exposing new ) +-- Elm ------------------------------------------------------------------------- +import List + +-- Battlemap ------------------------------------------------------------------- +import Struct.Attributes + -------------------------------------------------------------------------------- -- TYPES ----------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -32,6 +38,30 @@ type alias Type = -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- +average : (Int List) -> 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)) + +sudden_squared_growth : Int -> Int +sudden_squared_growth v = (float_to_int (((toFloat 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))) + +already_high_slow_growth : Int -> Int +already_high_slow_growth v = + (float_to_int + (30.0 * (logBase 10.0 (((toFloat v) + 5.0)/4.0))) + ) -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- @@ -46,34 +76,76 @@ get_dodges : Type -> Int get_dodges t = t.dodges get_parries : Type -> Int -get_parries = t.parries +get_parries t = t.parries get_damage_min : Type -> Int -get_damage_min = t.damage_min +get_damage_min t = t.damage_min get_damage_max : Type -> Int -get_damage_max = t.damage_max +get_damage_max t = t.damage_max get_accuracy : Type -> Int -get_accuracy = t.accuracy +get_accuracy t = t.accuracy get_double_hits : Type -> Int -get_double_hits = t.double_hits +get_double_hits t = t.double_hits get_critical_hits : Type -> Int -get_critical_hits = t.critical_hits +get_critical_hits t = t.critical_hits new : ( Struct.Attributes.Type -> Struct.Weapon.Type -> Type ) -new con dex int min spe str = +new att wp = { - constitution = con, - dexterity = dex, - intelligence = int, - mind = min, - speed = spe, - strength = str + movement_points = + (gentle_squared_growth (Struct.Attributes.get_speed att)), + max_health = + (gentle_squared_growth (Struct.Attributes.get_constitution att)), + dodges = + (clamp + 5 + 75 + (sudden_exp_growth_f + (average + [ + (Struct.Attributes.get_dexterity att), + (Struct.Attributes.get_mind att), + (Struct.Attributes.get_speed att) + ] + ) + ) + ), + parries = + (clamp + 0 + 75 + (sudden_exp_growth_f + (average + [ + (Struct.Attributes.get_dexterity att), + (Struct.Attributes.get_speed att), + (Struct.Attributes.get_strength att) + ] + ) + ) + ), + damage_min = 0, + damage_max = 100, + accuracy = + (already_high_slow_growth (Struct.Attributes.get_dexterity att)), + double_hits = + (clamp + 0 + 100 + (sudden_squared_growth (Struct.Attributes.get_speed att)) + ), + critical_hits = + (clamp + 0 + 100 + (sudden_squared_growth (Struct.Attributes.get_intelligence att)) + ) } |