| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2018-08-29 18:02:41 +0200 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2018-08-29 18:02:41 +0200 | 
| commit | 236ab8b21b9daa751a25c140609ea5bb253bf87e (patch) | |
| tree | a5652939810126c6022c8869136b229dfa2eb2ea /src/battle | |
| parent | 7ac984d3f88f8cf0352830fabaadce362b4271d5 (diff) | |
Starting to update structures to use omnimods...
Diffstat (limited to 'src/battle')
| -rw-r--r-- | src/battle/src/Struct/Armor.elm | 121 | ||||
| -rw-r--r-- | src/battle/src/Struct/Attributes.elm | 65 | ||||
| -rw-r--r-- | src/battle/src/Struct/Character.elm | 8 | ||||
| -rw-r--r-- | src/battle/src/Struct/DamageType.elm | 55 | ||||
| -rw-r--r-- | src/battle/src/Struct/Omnimods.elm | 50 | ||||
| -rw-r--r-- | src/battle/src/Struct/Statistics.elm | 166 | 
6 files changed, 266 insertions, 199 deletions
| diff --git a/src/battle/src/Struct/Armor.elm b/src/battle/src/Struct/Armor.elm index 04a0428..a086dee 100644 --- a/src/battle/src/Struct/Armor.elm +++ b/src/battle/src/Struct/Armor.elm @@ -2,16 +2,12 @@ module Struct.Armor exposing     (        Type,        Ref, -      Category(..),        new,        get_id,        get_name, -      get_category, -      get_resistance_to,        get_image_id,        decoder, -      none, -      apply_to_attributes +      none     )  -- Elm ------------------------------------------------------------------------- @@ -25,59 +21,26 @@ import Struct.Weapon  --------------------------------------------------------------------------------  -- TYPES -----------------------------------------------------------------------  -------------------------------------------------------------------------------- -type alias PartiallyDecoded = -   { -      id : Int, -      nam : String, -      ct : String, -      cf : Float -   } -  type alias Type =     {        id : Int, -      name : String, -      category : Category, -      coef : Float +      name : String     }  type alias Ref = Int -type Category = -   Kinetic -   | Leather -   | Chain -   | Plate -  --------------------------------------------------------------------------------  -- LOCAL -----------------------------------------------------------------------  -------------------------------------------------------------------------------- -finish_decoding : PartiallyDecoded -> Type -finish_decoding add_armor = -   { -      id = add_armor.id, -      name = add_armor.nam, -      category = -         ( -            case add_armor.ct of -               "k" -> Kinetic -               "c" -> Chain -               "p" -> Plate -               _   -> Leather -         ), -      coef = add_armor.cf -   }  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  -------------------------------------------------------------------------------- -new : Int -> String -> Category -> Float -> Type -new id name category coef = +new : Int -> String -> Type +new id name =     {        id = id, -      name = name, -      category = category, -      coef = coef +      name = name     }  get_id : Type -> Ref @@ -86,73 +49,9 @@ 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 -         * -         ( -            case (dmg_type, ar.category) of -               (Struct.Weapon.Slash, Kinetic) -> 0.0 -               (Struct.Weapon.Slash, Leather) -> 20.0 -               (Struct.Weapon.Slash, Chain) -> 30.0 -               (Struct.Weapon.Slash, Plate) -> 30.0 -               (Struct.Weapon.Blunt, Kinetic) -> 30.0 -               (Struct.Weapon.Blunt, Leather) -> 20.0 -               (Struct.Weapon.Blunt, Chain) -> 20.0 -               (Struct.Weapon.Blunt, Plate) -> 20.0 -               (Struct.Weapon.Pierce, Kinetic) -> 20.0 -               (Struct.Weapon.Pierce, Leather) -> 20.0 -               (Struct.Weapon.Pierce, Chain) -> 20.0 -               (Struct.Weapon.Pierce, Plate) -> 30.0 -         ) -      ) -   ) - -apply_to_attributes : Type -> Struct.Attributes.Type -> Struct.Attributes.Type -apply_to_attributes ar atts = -   let -      impact = (-1 * (ceiling (20.0 * ar.coef))) -      half_impact = (-1 * (ceiling (10.0 * ar.coef))) -   in -      case ar.category of -         Kinetic -> (Struct.Attributes.mod_mind impact atts) -         Leather -> -            (Struct.Attributes.mod_constitution -               half_impact -               (Struct.Attributes.mod_dexterity -                  half_impact -                  atts -               ) -            ) - -         Chain -> -            (Struct.Attributes.mod_constitution -               half_impact -               (Struct.Attributes.mod_dexterity -                  half_impact -                  (Struct.Attributes.mod_speed impact atts) -               ) -            ) - -         Plate -> -            (Struct.Attributes.mod_constitution -               half_impact -               (Struct.Attributes.mod_dexterity -                  half_impact -                  (Struct.Attributes.mod_speed -                     impact -                     (Struct.Attributes.mod_strength impact atts) -                  ) -               ) -            )  decoder : (Json.Decode.Decoder Type)  decoder = @@ -162,16 +61,8 @@ decoder =           PartiallyDecoded           |> (Json.Decode.Pipeline.required "id" Json.Decode.int)           |> (Json.Decode.Pipeline.required "nam" Json.Decode.string) -         |> (Json.Decode.Pipeline.required "ct" Json.Decode.string) -         |> (Json.Decode.Pipeline.required "cf" Json.Decode.float)        )     )  none : Type -none = -   (new -      0 -      "None" -      Leather -      0.0 -   ) +none = (new 0 "None") diff --git a/src/battle/src/Struct/Attributes.elm b/src/battle/src/Struct/Attributes.elm index 50b4ad4..89fd1f1 100644 --- a/src/battle/src/Struct/Attributes.elm +++ b/src/battle/src/Struct/Attributes.elm @@ -1,6 +1,7 @@  module Struct.Attributes exposing     (        Type, +      Category(..),        get_constitution,        get_dexterity,        get_intelligence, @@ -13,8 +14,11 @@ module Struct.Attributes exposing        mod_mind,        mod_speed,        mod_strength, +      mod, +      get,        new, -      decoder +      decode_category, +      default     )  -- Elm ------------------------------------------------------------------------- @@ -26,6 +30,14 @@ import Json.Decode.Pipeline  --------------------------------------------------------------------------------  -- TYPES -----------------------------------------------------------------------  -------------------------------------------------------------------------------- +type Category = +   Constitution +   | Dexterity +   | Intelligence +   | Mind +   | Speed +   | Strength +  type alias Type =     {        constitution : Int, @@ -102,6 +114,26 @@ mod_strength i t =        strength = (get_within_att_range (i + t.strength))     } +mod : Category -> Int -> Type -> Type +mod cat i t = +   case cat of +      Constitution -> (mod_constitution i t) +      Dexterity -> (mod_dexterity i t) +      Intelligence -> (mod_intelligence i t) +      Mind -> (mod_mind i t) +      Speed -> (mod_speed i t) +      Strength -> (mod_strength i t) + +get : Category -> Int -> Type -> Type +get cat i t = +   case cat of +      Constitution -> (get_constitution i t) +      Dexterity -> (get_dexterity i t) +      Intelligence -> (get_intelligence i t) +      Mind -> (get_mind i t) +      Speed -> (get_speed i t) +      Strength -> (get_strength i t) +  new : (        Int -> -- constitution        Int -> -- dexterity @@ -121,14 +153,23 @@ new con dex int min spe str =        strength = str     } -decoder : (Json.Decode.Decoder Type) -decoder = -   (Json.Decode.Pipeline.decode -      Type -      |> (Json.Decode.Pipeline.required "con" Json.Decode.int) -      |> (Json.Decode.Pipeline.required "dex" Json.Decode.int) -      |> (Json.Decode.Pipeline.required "int" Json.Decode.int) -      |> (Json.Decode.Pipeline.required "min" Json.Decode.int) -      |> (Json.Decode.Pipeline.required "spe" Json.Decode.int) -      |> (Json.Decode.Pipeline.required "str" Json.Decode.int) -   ) +default : Type +default = +   { +      constitution = 50, +      dexterity = 50, +      intelligence = 50, +      mind = 50, +      speed = 50, +      strength = 50 +   } + +decode_category : String -> Type +decode_category str = +   case str of +      "con" -> Constitution +      "dex" -> Dexterity +      "int" -> Intelligence +      "min" -> Mind +      "spe" -> Speed +      _ -> Strength diff --git a/src/battle/src/Struct/Character.elm b/src/battle/src/Struct/Character.elm index f854b44..30001e5 100644 --- a/src/battle/src/Struct/Character.elm +++ b/src/battle/src/Struct/Character.elm @@ -36,6 +36,7 @@ import Json.Decode.Pipeline  import Struct.Armor  import Struct.Attributes  import Struct.Location +import Struct.Omnimods  import Struct.Statistics  import Struct.Weapon  import Struct.WeaponSet @@ -55,10 +56,10 @@ type alias PartiallyDecoded =        pla : Int,        ena : Bool,        dea : Bool, -      att : Struct.Attributes.Type,        awp : Int,        swp : Int, -      ar : Int +      ar : Int, +      omni : Struct.Omnimods.Type     }  type Rank = @@ -81,7 +82,8 @@ type alias Type =        attributes : Struct.Attributes.Type,        statistics : Struct.Statistics.Type,        weapons : Struct.WeaponSet.Type, -      armor : Struct.Armor.Type +      armor : Struct.Armor.Type, +      permanent_omnimods : Struct.Omnimods.Type     }  -------------------------------------------------------------------------------- diff --git a/src/battle/src/Struct/DamageType.elm b/src/battle/src/Struct/DamageType.elm new file mode 100644 index 0000000..2b16e75 --- /dev/null +++ b/src/battle/src/Struct/DamageType.elm @@ -0,0 +1,55 @@ +module Struct.DamageType exposing +   ( +      Type(..), +      encode, +      decode, +      to_string +   ) + +-- Elm ------------------------------------------------------------------------- + +-- Map ------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- TYPES ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +type Type = +   Base +   | Slash +   | Blunt +   | Pierce +   | None + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +decode : String -> Type +decode str = +   case str of +      "bse" -> Base +      "slh" -> Slash +      "pie" -> Pierce +      "blu" -> Blunt +      _ -> None + +encode : Type -> String +encode t = +   case str of +      Base -> "bse" +      Slash -> "slh" +      Pierce -> "pie" +      Blunt -> "blu" +      None  -> "non" + +to_string : Type -> String +to_string t = +   case str of +      Base -> "Base" +      Slash -> "Slash" +      Pierce -> "Piercing" +      Blunt -> "Bludgeoning" +      None  -> "ERROR" diff --git a/src/battle/src/Struct/Omnimods.elm b/src/battle/src/Struct/Omnimods.elm new file mode 100644 index 0000000..5c7085a --- /dev/null +++ b/src/battle/src/Struct/Omnimods.elm @@ -0,0 +1,50 @@ +module Struct.Omnimods exposing +   ( +      Type, +      new, +      merge, +      apply_to_attributes, +      apply_to_statistics, +      get_attack_damage, +      decode +   ) + +-- Elm ------------------------------------------------------------------------- +import Json.Decode +import Json.Decode.Pipeline + +-- Map ------------------------------------------------------------------- +import Struct.Attributes +import Struct.Statistics +import Struct.DamageType + +-------------------------------------------------------------------------------- +-- TYPES ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +type alias Type = +   { +      attributes : (Dict.Dict Struct.Attributes.Category Int), +      statistics : (Dict.Dict Struct.Statistics.Category Int), +      attack : (Dict.Dict Struct.DamageType.Type Int), +      defense : (Dict.Dict Struct.DamageType.Type Int) +   } + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +decoder : (Json.Decode.Decoder Type) +decoder = +   (Json.Decode.map +      (finish_decoding) +      (Json.Decode.Pipeline.decode +         PartiallyDecoded +         |> (Json.Decode.Pipeline.required "id" Json.Decode.int) +         |> (Json.Decode.Pipeline.required "nam" Json.Decode.string) +         |> (Json.Decode.Pipeline.required "ct" Json.Decode.string) +         |> (Json.Decode.Pipeline.required "cf" Json.Decode.float) +      ) +   ) diff --git a/src/battle/src/Struct/Statistics.elm b/src/battle/src/Struct/Statistics.elm index aa3de39..834cb31 100644 --- a/src/battle/src/Struct/Statistics.elm +++ b/src/battle/src/Struct/Statistics.elm @@ -1,41 +1,47 @@  module Struct.Statistics exposing     (        Type, +      Category(..),        get_movement_points,        get_max_health,        get_dodges,        get_parries, -      get_damage_min, -      get_damage_max,        get_accuracy,        get_double_hits,        get_critical_hits, +      get_damage_modifier, +      decode_category,        new     )  -- Elm -------------------------------------------------------------------------  import List --- Map ------------------------------------------------------------------- +-- Battle ----------------------------------------------------------------------  import Struct.Attributes -import Struct.Armor -import Struct.Weapon -import Struct.WeaponSet  --------------------------------------------------------------------------------  -- TYPES -----------------------------------------------------------------------  -------------------------------------------------------------------------------- +type Category = +   MovementPoints +   | MaxHealth +   | Dodges +   | Parries +   | Accuracy +   | DoubleHits +   | CriticalHits +  type alias Type =     {        movement_points : Int,        max_health : Int,        dodges : Int,        parries : Int, -      damage_min : Int, -      damage_max : Int,        accuracy : Int,        double_hits : Int, -      critical_hits : Int +      critical_hits : Int, +      damage_modifier : Float     }  -------------------------------------------------------------------------------- @@ -66,18 +72,62 @@ 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 2.718281828459 (((toFloat v) + 5.0)/4.0))) -   ) -  damage_base_mod : Float -> Float  damage_base_mod str = (((str^1.8)/2000.0) - 0.75) -apply_damage_base_mod : Float -> Float -> Int -apply_damage_base_mod bmod dmg = -   (max 0 (float_to_int (dmg + (bmod * dmg)))) +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)) +   } + +mod_max_health : Int -> Type -> Type +mod_max_health v t = +   {t | +      max_health = (make_max_health_safe (t.max_health + v)) +   } + +mod_dodges : Int -> Type -> Type +mod_dodges v t = {t | dodges = (make_dodges_safe (t.dodges + v))} + +mod_parries : Int -> Type -> Type +mod_parries v t = {t | parries = (make_parries_safe (t.parries + v))} + +mod_accuracy : Int -> Type -> Type +mod_accuracy v t = {t | accuracy = (make_accuracy_safe (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_critical_hits : Int -> Type -> Type +mod_critical_hits v t = +   {t | +      critical_hits = (make_critical_hits_safe (t.critical_hits + v)) +   }  --------------------------------------------------------------------------------  -- EXPORTED -------------------------------------------------------------------- @@ -109,27 +159,18 @@ get_double_hits t = t.double_hits  get_critical_hits : Type -> Int  get_critical_hits t = t.critical_hits -new : ( -      Struct.Attributes.Type -> -      Struct.WeaponSet.Type -> -      Struct.Armor.Type -> -      Type -   ) -new att wp_set ar = +get_damage_modifier : Type -> Float +get_damage_modifier t = t.damage_modifier + +new_raw : (Struct.Attributes.Type -> Type) +new_raw att =     let -      active_weapon = (Struct.WeaponSet.get_active_weapon wp_set) -      actual_att = -         (Struct.Armor.apply_to_attributes -            ar -            (Struct.Weapon.apply_to_attributes active_weapon att) -         ) -      constitution = (Struct.Attributes.get_constitution actual_att) -      dexterity = (Struct.Attributes.get_dexterity actual_att) -      intelligence = (Struct.Attributes.get_intelligence actual_att) -      mind = (Struct.Attributes.get_mind actual_att) -      speed = (Struct.Attributes.get_speed actual_att) -      strength = (Struct.Attributes.get_strength actual_att) -      dmg_bmod = (damage_base_mod (toFloat strength)) +      constitution = (Struct.Attributes.get_constitution att) +      dexterity = (Struct.Attributes.get_dexterity att) +      intelligence = (Struct.Attributes.get_intelligence att) +      mind = (Struct.Attributes.get_mind att) +      speed = (Struct.Attributes.get_speed att) +      strength = (Struct.Attributes.get_strength att)     in        {           movement_points = @@ -140,37 +181,24 @@ new att wp_set ar =              (gentle_squared_growth_f                 (average [constitution, constitution, constitution, mind])              ), -         dodges = -            (clamp -               0 -               100 -               (sudden_exp_growth_f -                  (average -                     [dexterity, mind, speed] -                  ) -               ) -            ), +         dodges = (sudden_exp_growth_f (average [dexterity, mind, speed])),           parries = -            (clamp -               0 -               75 -               (sudden_exp_growth_f -                  (average [dexterity, intelligence, speed, strength]) -               ) -            ), -         damage_min = -            (apply_damage_base_mod -               dmg_bmod -               (toFloat (Struct.Weapon.get_min_damage active_weapon)) -            ), -         damage_max = -            (apply_damage_base_mod -               dmg_bmod -               (toFloat (Struct.Weapon.get_max_damage active_weapon)) +            (sudden_exp_growth_f +               (average [dexterity, intelligence, speed, strength])              ),           accuracy = (sudden_squared_growth dexterity), -         double_hits = -            (clamp 0 100 (sudden_squared_growth_f (average [mind, speed]))), -         critical_hits = -            (clamp 0 100 (sudden_squared_growth intelligence)) -   } +         double_hits = (sudden_squared_growth_f (average [mind, speed])), +         critical_hits = (sudden_squared_growth intelligence), +         damage_modifier = (damage_base_mod (toFloat strength)) +      } + +decode_category : String -> Type +decode_category str = +   case str of +      "mheal" -> MaxHealth +      "mpts" -> MovementPoints +      "dodg" -> Dodges +      "pary" -> Parries +      "accu" -> Accuracy +      "dhit" -> DoubleHits +      _  -> CriticalHits | 


