summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2019-03-15 18:41:39 +0100
committernsensfel <SpamShield0@noot-noot.org>2019-03-15 18:41:39 +0100
commit8103bf80277b759bb9c3b1e032612721f132f256 (patch)
treea1b1858483281e61a0dcb9cb42fb6df38214c06a /src/shared/battle
parent6678cfe464ed9ee595f4f3dd7398dec1416454c9 (diff)
[Broken] Got 'battle' to compile again.
Diffstat (limited to 'src/shared/battle')
-rw-r--r--src/shared/battle/Battle/Struct/Omnimods.elm62
1 files changed, 56 insertions, 6 deletions
diff --git a/src/shared/battle/Battle/Struct/Omnimods.elm b/src/shared/battle/Battle/Struct/Omnimods.elm
index 46843b2..fd0088b 100644
--- a/src/shared/battle/Battle/Struct/Omnimods.elm
+++ b/src/shared/battle/Battle/Struct/Omnimods.elm
@@ -3,6 +3,7 @@ module Battle.Struct.Omnimods exposing
Type,
new,
merge,
+ none,
apply_to_attributes,
apply_to_statistics,
get_attack_damage,
@@ -11,6 +12,8 @@ module Battle.Struct.Omnimods exposing
get_statistics_mods,
get_attack_mods,
get_defense_mods,
+ get_all_mods,
+ scale,
decoder
)
@@ -47,7 +50,7 @@ type alias GenericMod =
generic_mods_decoder : (Json.Decode.Decoder (Dict.Dict String Int))
generic_mods_decoder =
(Json.Decode.map
- (Dict.fromList)
+ ((Dict.fromList) >> (Dict.remove "none"))
(Json.Decode.list
(Json.Decode.map
(\gm -> (gm.t, gm.v))
@@ -75,6 +78,9 @@ merge_mods a_mods b_mods =
(Dict.empty)
)
+scale_dict_value : Float -> String -> Int -> Int
+scale_dict_value modifier entry_name value =
+ (ceiling ((toFloat value) * modifier))
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
@@ -103,6 +109,15 @@ new attribute_mods statistic_mods attack_mods defense_mods =
defense = (Dict.fromList defense_mods)
}
+none : Type
+none =
+ {
+ attributes = (Dict.empty),
+ statistics = (Dict.empty),
+ attack = (Dict.empty),
+ defense = (Dict.empty)
+ }
+
merge : Type -> Type -> Type
merge omni_a omni_b =
{
@@ -112,18 +127,32 @@ merge omni_a omni_b =
defense = (merge_mods omni_a.defense omni_b.defense)
}
-apply_to_attributes : Type -> Battle.Struct.Attributes.Type -> Battle.Struct.Attributes.Type
+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))
+ (
+ (Battle.Struct.Attributes.decode_category)
+ >> (Battle.Struct.Attributes.mod)
+ )
attributes
omnimods.attributes
)
-apply_to_statistics : Type -> Battle.Struct.Statistics.Type -> Battle.Struct.Statistics.Type
+apply_to_statistics : (
+ Type ->
+ Battle.Struct.Statistics.Type ->
+ Battle.Struct.Statistics.Type
+ )
apply_to_statistics omnimods statistics =
(Dict.foldl
- ((Battle.Struct.Statistics.decode_category) >> (Battle.Struct.Statistics.mod))
+ (
+ (Battle.Struct.Statistics.decode_category)
+ >> (Battle.Struct.Statistics.mod)
+ )
statistics
omnimods.statistics
)
@@ -139,7 +168,9 @@ get_attack_damage dmg_modifier atk_omni def_omni =
(
case
(Dict.get
- (Battle.Struct.DamageType.encode Battle.Struct.DamageType.Base)
+ (Battle.Struct.DamageType.encode
+ Battle.Struct.DamageType.Base
+ )
def_omni.defense
)
of
@@ -167,6 +198,16 @@ get_attack_damage dmg_modifier atk_omni def_omni =
atk_omni.attack
)
+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)
@@ -178,3 +219,12 @@ get_attack_mods omnimods = (Dict.toList omnimods.attack)
get_defense_mods : Type -> (List (String, Int))
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_attack_mods omnimods)
+ ++ (get_defense_mods omnimods)
+ )