aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2019-09-11 17:07:23 +0200
committernsensfel <SpamShield0@noot-noot.org>2019-09-11 17:07:23 +0200
commit6a294ff0ed9c69be2c49aa18a1589ef0a4be83f6 (patch)
tree604bf0da5f07756a37e9aee63c4313ddddb4e532
parent75dfc9fcc6c119bbea63414fad8d754a1ea513a9 (diff)
downloadtacticians-client-6a294ff0ed9c69be2c49aa18a1589ef0a4be83f6.zip
tacticians-client-6a294ff0ed9c69be2c49aa18a1589ef0a4be83f6.tar.bz2
...
-rw-r--r--src/battle/src/View/Controlled/CharacterCard.elm64
-rw-r--r--src/shared/battle/Battle/Struct/Attributes.elm.m4 (renamed from src/shared/battle/Battle/Struct/Attributes.elm)32
-rw-r--r--src/shared/battle/Battle/Struct/Omnimods.elm18
3 files changed, 84 insertions, 30 deletions
diff --git a/src/battle/src/View/Controlled/CharacterCard.elm b/src/battle/src/View/Controlled/CharacterCard.elm
index 8857fbf..a48c631 100644
--- a/src/battle/src/View/Controlled/CharacterCard.elm
+++ b/src/battle/src/View/Controlled/CharacterCard.elm
@@ -283,27 +283,59 @@ get_weapon_field_header is_active weapon =
get_weapon_details : (
Battle.Struct.Omnimods.Type ->
+ Battle.Struct.Omnimods.Type ->
BattleCharacters.Struct.Weapon.Type ->
(Html.Html Struct.Event.Type)
)
-get_weapon_details other_wp_omnimods weapon =
- (Html.div
- [
- (Html.Attributes.class "character-card-weapon")
- ]
- [
- (get_weapon_field_header False weapon),
- (Battle.View.Omnimods.get_html
- (Battle.Struct.Omnimods.merge
- (Battle.Struct.Omnimods.scale
- -1
- other_wp_omnimods
+get_weapon_details omnimods other_wp_omnimods weapon =
+ let
+ other_wp_omnimods_scaled =
+ (Battle.Struct.Omnimods.scale
+ -1
+ (Battle.Struct.Omnimods.apply_damage_modifier
+ (Battle.Struct.Omnimods.get_attribute_mod
+ (Battle.Struct.Attributes.encode_category
+ Battle.Struct.Attributes.DamageModifier
+ )
+ omnimods
)
- (BattleCharacters.Struct.Weapon.get_omnimods weapon)
+ other_wp_omnimods
)
)
- ]
- )
+ omnimods_without_other_wp =
+ (Battle.Struct.Omnimods.merge
+ (Battle.Struct.Omnimods.scale -1 other_wp_omnimods)
+ omnimods
+ )
+ this_wp_omnimods = (BattleCharacters.Struct.Weapon.get_omnimods weapon)
+ omnimods_with_this_wp =
+ (Battle.Struct.Omnimods.merge
+ omnimods_without_other_wp
+ this_wp_omnimods
+ )
+ in
+ (Html.div
+ [
+ (Html.Attributes.class "character-card-weapon")
+ ]
+ [
+ (get_weapon_field_header False weapon),
+ (Battle.View.Omnimods.get_html
+ (Battle.Struct.Omnimods.merge
+ other_wp_omnimods_scaled
+ (Battle.Struct.Omnimods.apply_damage_modifier
+ (Battle.Struct.Omnimods.get_attribute_mod
+ (Battle.Struct.Attributes.encode_category
+ Battle.Struct.Attributes.DamageModifier
+ )
+ omnimods_with_this_wp
+ )
+ this_wp_omnimods
+ )
+ )
+ )
+ ]
+ )
get_weapon_summary : (
BattleCharacters.Struct.Weapon.Type ->
@@ -410,6 +442,7 @@ get_summary_html char_turn player_ix char =
),
(get_weapon_summary active_weapon),
(get_weapon_details
+ omnimods
(BattleCharacters.Struct.Weapon.get_omnimods active_weapon)
(BattleCharacters.Struct.Character.get_inactive_weapon
base_char
@@ -472,6 +505,7 @@ get_full_html player_ix char =
)
),
(get_weapon_details
+ omnimods
(BattleCharacters.Struct.Weapon.get_omnimods active_weapon)
(BattleCharacters.Struct.Character.get_inactive_weapon
base_char
diff --git a/src/shared/battle/Battle/Struct/Attributes.elm b/src/shared/battle/Battle/Struct/Attributes.elm.m4
index bb6c06e..d008618 100644
--- a/src/shared/battle/Battle/Struct/Attributes.elm
+++ b/src/shared/battle/Battle/Struct/Attributes.elm.m4
@@ -168,29 +168,31 @@ default =
damage_modifier = 0
}
+m4_include(__MAKEFILE_DATA_DIR/names.m4.conf)
+
decode_category : String -> Category
decode_category str =
case str of
- "mheal" -> MaxHealth
- "mpts" -> MovementPoints
- "dodg" -> Dodges
- "pary" -> Parries
- "accu" -> Accuracy
- "dhit" -> DoubleHits
- "dmgm" -> DamageModifier
+ "__SN_MAX_HEALTH" -> MaxHealth
+ "__SN_MOVEMENT_POINTS" -> MovementPoints
+ "__SN_DODGE" -> Dodges
+ "__SN_PARRY" -> Parries
+ "__SN_ACCURACY" -> Accuracy
+ "__SN_DOUBLE_HITS" -> DoubleHits
+ "__SN_DAMAGE_MODIFIER" -> DamageModifier
_ -> CriticalHits
encode_category : Category -> String
encode_category cat =
case cat of
- MaxHealth -> "mheal"
- MovementPoints -> "mpts"
- Dodges -> "dodg"
- Parries -> "pary"
- Accuracy -> "accu"
- DoubleHits -> "dhit"
- CriticalHits -> "crit"
- DamageModifier -> "dmgm"
+ MaxHealth -> "__SN_MAX_HEALTH"
+ MovementPoints -> "__SN_MOVEMENT_POINTS"
+ Dodges -> "__SN_DODGE"
+ Parries -> "__SN_PARRY"
+ Accuracy -> "__SN_ACCURACY"
+ DoubleHits -> "__SN_DOUBLE_HITS"
+ CriticalHits -> "__SN_CRITICAL_HIT"
+ DamageModifier -> "__SN_DAMAGE_MODIFIER"
is_percent : Category -> Bool
is_percent cat = ((cat /= MaxHealth) && (cat /= MovementPoints))
diff --git a/src/shared/battle/Battle/Struct/Omnimods.elm b/src/shared/battle/Battle/Struct/Omnimods.elm
index 7a61153..2b3c011 100644
--- a/src/shared/battle/Battle/Struct/Omnimods.elm
+++ b/src/shared/battle/Battle/Struct/Omnimods.elm
@@ -8,9 +8,11 @@ module Battle.Struct.Omnimods exposing
get_attack_damage,
get_damage_sum,
get_attribute_mods,
+ get_attribute_mod,
get_attack_mods,
get_defense_mods,
get_all_mods,
+ apply_damage_modifier,
scale,
decoder
)
@@ -174,6 +176,16 @@ get_attack_damage dmg_modifier atk_omni def_omni =
atk_omni.attack
)
+apply_damage_modifier : Int -> Type -> Type
+apply_damage_modifier damage_modifier omnimods =
+ {omnimods |
+ attack =
+ (Dict.map
+ (scale_dict_value ((toFloat damage_modifier) / 100.0))
+ omnimods.attack
+ )
+ }
+
scale : Float -> Type -> Type
scale multiplier omnimods =
{omnimods |
@@ -183,6 +195,12 @@ scale multiplier omnimods =
(Dict.map (scale_dict_value multiplier) omnimods.defense)
}
+get_attribute_mod : String -> Type -> Int
+get_attribute_mod att_name omnimods =
+ case (Dict.get att_name omnimods.attributes) of
+ (Just e) -> e
+ Nothing -> 0
+
get_attribute_mods : Type -> (List (String, Int))
get_attribute_mods omnimods = (Dict.toList omnimods.attributes)