summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/battle/Battle/Struct')
-rw-r--r--src/shared/battle/Battle/Struct/Attributes.elm204
-rw-r--r--src/shared/battle/Battle/Struct/Omnimods.elm33
-rw-r--r--src/shared/battle/Battle/Struct/Statistics.elm146
3 files changed, 43 insertions, 340 deletions
diff --git a/src/shared/battle/Battle/Struct/Attributes.elm b/src/shared/battle/Battle/Struct/Attributes.elm
deleted file mode 100644
index 9d83bef..0000000
--- a/src/shared/battle/Battle/Struct/Attributes.elm
+++ /dev/null
@@ -1,204 +0,0 @@
-module Battle.Struct.Attributes exposing
- (
- Type,
- Category(..),
- get_constitution,
- get_dexterity,
- get_intelligence,
- get_mind,
- get_speed,
- get_strength,
- get_effective_constitution,
- get_effective_dexterity,
- get_effective_intelligence,
- get_effective_mind,
- get_effective_speed,
- get_effective_strength,
- mod_constitution,
- mod_dexterity,
- mod_intelligence,
- mod_mind,
- mod_speed,
- mod_strength,
- mod,
- get,
- new,
- decode_category,
- encode_category,
- default
- )
-
---------------------------------------------------------------------------------
--- TYPES -----------------------------------------------------------------------
---------------------------------------------------------------------------------
-type Category =
- Constitution
- | Dexterity
- | Intelligence
- | Mind
- | Speed
- | Strength
-
-type alias Type =
- {
- constitution : Int,
- dexterity : Int,
- intelligence : Int,
- mind : Int,
- speed : Int,
- strength : Int
- }
-
---------------------------------------------------------------------------------
--- LOCAL -----------------------------------------------------------------------
---------------------------------------------------------------------------------
-get_within_range : Int -> Int -> Int -> Int
-get_within_range vmin vmax v = (min vmax (max vmin v))
-
-get_within_att_range : Int -> Int
-get_within_att_range v = (get_within_range 0 100 v)
-
---------------------------------------------------------------------------------
--- EXPORTED --------------------------------------------------------------------
---------------------------------------------------------------------------------
-get_constitution : Type -> Int
-get_constitution t = t.constitution
-
-get_dexterity : Type -> Int
-get_dexterity t = t.dexterity
-
-get_intelligence : Type -> Int
-get_intelligence t = t.intelligence
-
-get_mind : Type -> Int
-get_mind t = t.mind
-
-get_speed : Type -> Int
-get_speed t = t.speed
-
-get_strength : Type -> Int
-get_strength t = t.strength
-
-get_effective_constitution : Type -> Int
-get_effective_constitution t = (get_within_att_range t.constitution)
-
-get_effective_dexterity : Type -> Int
-get_effective_dexterity t = (get_within_att_range t.dexterity)
-
-get_effective_intelligence : Type -> Int
-get_effective_intelligence t = (get_within_att_range t.intelligence)
-
-get_effective_mind : Type -> Int
-get_effective_mind t = (get_within_att_range t.mind)
-
-get_effective_speed : Type -> Int
-get_effective_speed t = (get_within_att_range t.speed)
-
-get_effective_strength : Type -> Int
-get_effective_strength t = (get_within_att_range t.strength)
-
-mod_constitution : Int -> Type -> Type
-mod_constitution i t =
- {t |
- constitution = (i + t.constitution)
- }
-
-mod_dexterity : Int -> Type -> Type
-mod_dexterity i t =
- {t |
- dexterity = (i + t.dexterity)
- }
-
-mod_intelligence : Int -> Type -> Type
-mod_intelligence i t =
- {t |
- intelligence = (i + t.intelligence)
- }
-
-mod_mind : Int -> Type -> Type
-mod_mind i t =
- {t |
- mind = (i + t.mind)
- }
-
-mod_speed : Int -> Type -> Type
-mod_speed i t =
- {t |
- speed = (i + t.speed)
- }
-
-mod_strength : Int -> Type -> Type
-mod_strength i t =
- {t |
- strength = (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 -> Type -> Int
-get cat t =
- case cat of
- Constitution -> (get_constitution t)
- Dexterity -> (get_dexterity t)
- Intelligence -> (get_intelligence t)
- Mind -> (get_mind t)
- Speed -> (get_speed t)
- Strength -> (get_strength t)
-
-new : (
- Int -> -- constitution
- Int -> -- dexterity
- Int -> -- intelligence
- Int -> -- mind
- Int -> -- speed
- Int -> -- strength
- Type
- )
-new con dex int min spe str =
- {
- constitution = con,
- dexterity = dex,
- intelligence = int,
- mind = min,
- speed = spe,
- strength = str
- }
-
-default : Type
-default =
- {
- constitution = 50,
- dexterity = 50,
- intelligence = 50,
- mind = 50,
- speed = 50,
- strength = 50
- }
-
-decode_category : String -> Category
-decode_category str =
- case str of
- "con" -> Constitution
- "dex" -> Dexterity
- "int" -> Intelligence
- "min" -> Mind
- "spe" -> Speed
- _ -> Strength
-
-encode_category : Category -> String
-encode_category cat =
- case cat of
- Constitution -> "con"
- Dexterity -> "dex"
- Intelligence -> "int"
- Mind -> "min"
- Speed -> "spe"
- Strength -> "str"
diff --git a/src/shared/battle/Battle/Struct/Omnimods.elm b/src/shared/battle/Battle/Struct/Omnimods.elm
index fd0088b..92bf636 100644
--- a/src/shared/battle/Battle/Struct/Omnimods.elm
+++ b/src/shared/battle/Battle/Struct/Omnimods.elm
@@ -4,11 +4,9 @@ module Battle.Struct.Omnimods exposing
new,
merge,
none,
- apply_to_attributes,
apply_to_statistics,
get_attack_damage,
get_damage_sum,
- get_attributes_mods,
get_statistics_mods,
get_attack_mods,
get_defense_mods,
@@ -24,7 +22,6 @@ import Json.Decode
import Json.Decode.Pipeline
-- Battle ----------------------------------------------------------------------
-import Battle.Struct.Attributes
import Battle.Struct.Statistics
import Battle.Struct.DamageType
@@ -33,7 +30,6 @@ import Battle.Struct.DamageType
--------------------------------------------------------------------------------
type alias Type =
{
- attributes : (Dict.Dict String Int),
statistics : (Dict.Dict String Int),
attack : (Dict.Dict String Int),
defense : (Dict.Dict String Int)
@@ -88,7 +84,6 @@ decoder : (Json.Decode.Decoder Type)
decoder =
(Json.Decode.succeed
Type
- |> (Json.Decode.Pipeline.required "attm" generic_mods_decoder)
|> (Json.Decode.Pipeline.required "stam" generic_mods_decoder)
|> (Json.Decode.Pipeline.required "atkm" generic_mods_decoder)
|> (Json.Decode.Pipeline.required "defm" generic_mods_decoder)
@@ -98,12 +93,10 @@ new : (
(List (String, Int)) ->
(List (String, Int)) ->
(List (String, Int)) ->
- (List (String, Int)) ->
Type
)
-new attribute_mods statistic_mods attack_mods defense_mods =
+new statistic_mods attack_mods defense_mods =
{
- attributes = (Dict.fromList attribute_mods),
statistics = (Dict.fromList statistic_mods),
attack = (Dict.fromList attack_mods),
defense = (Dict.fromList defense_mods)
@@ -112,7 +105,6 @@ new attribute_mods statistic_mods attack_mods defense_mods =
none : Type
none =
{
- attributes = (Dict.empty),
statistics = (Dict.empty),
attack = (Dict.empty),
defense = (Dict.empty)
@@ -121,27 +113,11 @@ none =
merge : Type -> Type -> Type
merge omni_a omni_b =
{
- attributes = (merge_mods omni_a.attributes omni_b.attributes),
statistics = (merge_mods omni_a.statistics omni_b.statistics),
attack = (merge_mods omni_a.attack omni_b.attack),
defense = (merge_mods omni_a.defense omni_b.defense)
}
-apply_to_attributes : (
- Type ->
- Battle.Struct.Attributes.Type
- -> Battle.Struct.Attributes.Type
- )
-apply_to_attributes omnimods attributes =
- (Dict.foldl
- (
- (Battle.Struct.Attributes.decode_category)
- >> (Battle.Struct.Attributes.mod)
- )
- attributes
- omnimods.attributes
- )
-
apply_to_statistics : (
Type ->
Battle.Struct.Statistics.Type ->
@@ -201,16 +177,12 @@ get_attack_damage dmg_modifier atk_omni def_omni =
scale : Float -> Type -> Type
scale multiplier omnimods =
{omnimods |
- attributes = (Dict.map (scale_dict_value multiplier) omnimods.attributes),
statistics = (Dict.map (scale_dict_value multiplier) omnimods.statistics),
attack = (Dict.map (scale_dict_value multiplier) omnimods.attack),
defense =
(Dict.map (scale_dict_value multiplier) omnimods.defense)
}
-get_attributes_mods : Type -> (List (String, Int))
-get_attributes_mods omnimods = (Dict.toList omnimods.attributes)
-
get_statistics_mods : Type -> (List (String, Int))
get_statistics_mods omnimods = (Dict.toList omnimods.statistics)
@@ -223,8 +195,7 @@ get_defense_mods omnimods = (Dict.toList omnimods.defense)
get_all_mods : Type -> (List (String, Int))
get_all_mods omnimods =
(
- (get_attributes_mods omnimods)
- ++ (get_statistics_mods omnimods)
+ (get_statistics_mods omnimods)
++ (get_attack_mods omnimods)
++ (get_defense_mods omnimods)
)
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))