| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2018-05-31 16:36:11 +0200 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2018-05-31 16:36:11 +0200 | 
| commit | b1cf443357cc8fbb641c4e0f6004bac08ddc2c15 (patch) | |
| tree | f253d60b4888cfdcf795669c6273569d9a396c28 /src/battlemap | |
| parent | bc537c67fc80538c7919ba0d41e4a733cba27e87 (diff) | |
Preparing to add Armors (w/ stats, this time).
Diffstat (limited to 'src/battlemap')
| -rw-r--r-- | src/battlemap/src/Data/Armors.elm | 77 | ||||
| -rw-r--r-- | src/battlemap/src/Struct/Armor.elm | 85 | ||||
| -rw-r--r-- | src/battlemap/src/Struct/Character.elm | 4 | ||||
| -rw-r--r-- | src/battlemap/src/View/Gauge.elm | 1 | 
4 files changed, 160 insertions, 7 deletions
| diff --git a/src/battlemap/src/Data/Armors.elm b/src/battlemap/src/Data/Armors.elm new file mode 100644 index 0000000..ca95fa8 --- /dev/null +++ b/src/battlemap/src/Data/Armors.elm @@ -0,0 +1,77 @@ +module Data.Armors exposing (generate_dict, none) +-- Elm ------------------------------------------------------------------------- +import Dict + +-- Battlemap ------------------------------------------------------------------- +import Struct.Armor + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +dataset : (List (Struct.Armor.Ref, Struct.Armor.Type)) +dataset = +   [ +      -- TODO: have those in separate text files, and put them here only at +      -- compilation. +      ( +         0, +         (Struct.Armor.new +            0 +            "None" +            Struct.Armor.Leather +            0.0 +         ) +      ), +      ( +         1, +         (Struct.Armor.new +            1 +            "Morrigan's Pity" +            Struct.Armor.Kinetic +            5.0 +         ) +      ), +      ( +         2, +         (Struct.Armor.new +            1 +            "Last Night's Hunt" +            Struct.Armor.Leather +            5.0 +         ) +      ), +      ( +         3, +         (Struct.Armor.new +            1 +            "Garden Fence" +            Struct.Armor.Chain +            5.0 +         ) +      ), +      ( +         4, +         (Struct.Armor.new +            1 +            "Bits of Wall" +            Struct.Armor.Plate +            5.0 +         ) +      ) +   ] + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +generate_dict : (Dict.Dict Struct.Armor.Ref Struct.Armor.Type) +generate_dict = (Dict.fromList dataset) + +-- If it's not found. +none : (Struct.Armor.Type) +none = +   (Struct.Armor.new +      0 +      "None" +      Struct.Armor.Leather +      0.0 +   ) diff --git a/src/battlemap/src/Struct/Armor.elm b/src/battlemap/src/Struct/Armor.elm index c62b0c7..92d68f7 100644 --- a/src/battlemap/src/Struct/Armor.elm +++ b/src/battlemap/src/Struct/Armor.elm @@ -2,23 +2,39 @@ module Struct.Armor exposing     (        Type,        Ref, +      Category(..),        new, -      get_id +      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 +      id : Int, +      name : String, +      category : Category, +      coef : Float     }  type alias Ref = Int +type Category = +   Kinetic +   | Leather +   | Chain +   | Plate +  --------------------------------------------------------------------------------  -- LOCAL -----------------------------------------------------------------------  -------------------------------------------------------------------------------- @@ -26,11 +42,70 @@ type alias Ref = Int  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  -------------------------------------------------------------------------------- -new : Int -> Type -new id = +new : Int -> String -> Category -> Float -> Type +new id name category coef =     { -      id = id +      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 +         * +         ( +            case (dmg_type, ar.category) of +               (Struct.Weapon.Slash, Kinetic) -> 0.0 +               (Struct.Weapon.Slash, Leather) -> 0.5 +               (Struct.Weapon.Slash, Chain) -> 1.0 +               (Struct.Weapon.Slash, Plate) -> 1.0 +               (Struct.Weapon.Blunt, Kinetic) -> 1.0 +               (Struct.Weapon.Blunt, Leather) -> 0.5 +               (Struct.Weapon.Blunt, Chain) -> 0.5 +               (Struct.Weapon.Blunt, Plate) -> 0.5 +               (Struct.Weapon.Pierce, Kinetic) -> 0.5 +               (Struct.Weapon.Pierce, Leather) -> 0.5 +               (Struct.Weapon.Pierce, Chain) -> 0.5 +               (Struct.Weapon.Pierce, Plate) -> 1.0 +         ) +      ) +   ) + +apply_to_attributes : Type -> Struct.Attributes.Type -> Struct.Attributes.Type +apply_to_attributes ar atts = +   case ar.category of +      Kinetic -> atts +      Leather -> atts +      Chain -> +         (Struct.Attributes.mod_dexterity +            -10 +            (Struct.Attributes.mod_speed -10 atts) +         ) + +      Plate -> +         (Struct.Attributes.mod_dexterity +            -10 +            (Struct.Attributes.mod_speed +               -10 +               (Struct.Attributes.mod_strength +                  -10 +                  atts +               ) +            ) +         ) diff --git a/src/battlemap/src/Struct/Character.elm b/src/battlemap/src/Struct/Character.elm index 630befd..7406af7 100644 --- a/src/battlemap/src/Struct/Character.elm +++ b/src/battlemap/src/Struct/Character.elm @@ -28,6 +28,8 @@ import Json.Decode  import Json.Decode.Pipeline  -- Battlemap ------------------------------------------------------------------- +import Data.Armors +  import Struct.Armor  import Struct.Attributes  import Struct.Location @@ -97,7 +99,7 @@ finish_decoding get_weapon add_char =           player_id = add_char.pla,           enabled = add_char.ena,           weapons = weapon_set, -         armor = (Struct.Armor.new (add_char.ix % 2)) +         armor = (Data.Armors.none)        }  -------------------------------------------------------------------------------- diff --git a/src/battlemap/src/View/Gauge.elm b/src/battlemap/src/View/Gauge.elm index 86fcef2..a4c5974 100644 --- a/src/battlemap/src/View/Gauge.elm +++ b/src/battlemap/src/View/Gauge.elm @@ -6,7 +6,6 @@ import Html.Attributes  -- Battlemap -------------------------------------------------------------------  import Struct.Event -import Struct.Model  --------------------------------------------------------------------------------  -- LOCAL ----------------------------------------------------------------------- | 


