aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-09-12 10:42:33 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-09-12 10:42:33 +0200
commitce03028ccd575af1dc38b26d23569601d3b5d491 (patch)
treeddb943e743aa2389ea63079e36a0f063d60e0155
parentaadf3043f8647c033cc14ba8a4d5ad01dd9057fb (diff)
downloadtacticians-client-ce03028ccd575af1dc38b26d23569601d3b5d491.zip
tacticians-client-ce03028ccd575af1dc38b26d23569601d3b5d491.tar.bz2
Improves presentation of attributes in battle.
-rw-r--r--src/battle/src/View/Controlled/CharacterCard.elm103
-rw-r--r--src/shared/battle/Battle/Struct/Omnimods.elm11
-rw-r--r--src/shared/battle/Battle/View/Omnimods.elm69
3 files changed, 100 insertions, 83 deletions
diff --git a/src/battle/src/View/Controlled/CharacterCard.elm b/src/battle/src/View/Controlled/CharacterCard.elm
index 6024438..291263c 100644
--- a/src/battle/src/View/Controlled/CharacterCard.elm
+++ b/src/battle/src/View/Controlled/CharacterCard.elm
@@ -281,73 +281,44 @@ get_weapon_field_header is_active weapon =
]
)
-get_weapon_details : (
+get_inactive_weapon_details : (
Battle.Struct.Omnimods.Type ->
Battle.Struct.Omnimods.Type ->
BattleCharacters.Struct.Weapon.Type ->
(Html.Html Struct.Event.Type)
)
-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
- )
+get_inactive_weapon_details omnimods other_wp_omnimods weapon =
+ (Html.div
+ [
+ (Html.Attributes.class "character-card-weapon")
+ ]
+ [
+ (get_weapon_field_header False weapon),
+ (Battle.View.Omnimods.get_user_friendly_html
+ (Battle.Struct.Omnimods.merge
+ (Battle.Struct.Omnimods.merge
+ (Battle.Struct.Omnimods.scale -1 other_wp_omnimods)
omnimods
)
- other_wp_omnimods
+ (BattleCharacters.Struct.Weapon.get_omnimods weapon)
)
)
- 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 : (
+get_active_weapon_details : (
+ Battle.Struct.Omnimods.Type ->
BattleCharacters.Struct.Weapon.Type ->
(Html.Html Struct.Event.Type)
)
-get_weapon_summary weapon =
+get_active_weapon_details omnimods weapon =
(Html.div
[
(Html.Attributes.class "character-card-weapon-summary")
]
[
- (get_weapon_field_header True weapon)
+ (get_weapon_field_header True weapon),
+ (Battle.View.Omnimods.get_user_friendly_html omnimods)
]
)
@@ -437,19 +408,8 @@ get_summary_html char_turn player_ix char =
(get_statuses char)
]
),
- (Battle.View.Omnimods.get_html
- (Battle.Struct.Omnimods.apply_damage_modifier
- (Battle.Struct.Omnimods.get_attribute_mod
- (Battle.Struct.Attributes.encode_category
- Battle.Struct.Attributes.DamageModifier
- )
- omnimods
- )
- omnimods
- )
- ),
- (get_weapon_summary active_weapon),
- (get_weapon_details
+ (get_active_weapon_details omnimods active_weapon),
+ (get_inactive_weapon_details
omnimods
(BattleCharacters.Struct.Weapon.get_omnimods active_weapon)
(BattleCharacters.Struct.Character.get_inactive_weapon
@@ -504,23 +464,8 @@ get_full_html player_ix char =
(get_statuses char)
]
),
- (Battle.View.Omnimods.get_html
- (Battle.Struct.Omnimods.apply_damage_modifier
- (Battle.Struct.Omnimods.get_attribute_mod
- (Battle.Struct.Attributes.encode_category
- Battle.Struct.Attributes.DamageModifier
- )
- omnimods
- )
- omnimods
- )
- ),
- (get_weapon_summary
- (BattleCharacters.Struct.Character.get_active_weapon
- base_char
- )
- ),
- (get_weapon_details
+ (get_active_weapon_details omnimods active_weapon),
+ (get_inactive_weapon_details
omnimods
(BattleCharacters.Struct.Weapon.get_omnimods active_weapon)
(BattleCharacters.Struct.Character.get_inactive_weapon
diff --git a/src/shared/battle/Battle/Struct/Omnimods.elm b/src/shared/battle/Battle/Struct/Omnimods.elm
index 2b3c011..e9c3089 100644
--- a/src/shared/battle/Battle/Struct/Omnimods.elm
+++ b/src/shared/battle/Battle/Struct/Omnimods.elm
@@ -195,9 +195,14 @@ 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
+get_attribute_mod : Battle.Struct.Attributes.Category -> Type -> Int
+get_attribute_mod att omnimods =
+ case
+ (Dict.get
+ (Battle.Struct.Attributes.encode_category att)
+ omnimods.attributes
+ )
+ of
(Just e) -> e
Nothing -> 0
diff --git a/src/shared/battle/Battle/View/Omnimods.elm b/src/shared/battle/Battle/View/Omnimods.elm
index 8d8c4ce..7af5709 100644
--- a/src/shared/battle/Battle/View/Omnimods.elm
+++ b/src/shared/battle/Battle/View/Omnimods.elm
@@ -1,7 +1,8 @@
module Battle.View.Omnimods exposing
(
get_html_with_modifier,
- get_html
+ get_html,
+ get_user_friendly_html
)
-- Elm -------------------------------------------------------------------------
@@ -136,3 +137,69 @@ get_html omnimods =
)
]
)
+
+get_user_friendly_html : (
+ Battle.Struct.Omnimods.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+get_user_friendly_html omnimods =
+ let
+ -- TODO: Add minimal values to omnimods (e.g. +1 to health).
+ scaled_omnimods =
+ (Battle.Struct.Omnimods.apply_damage_modifier
+ (Battle.Struct.Omnimods.get_attribute_mod
+ Battle.Struct.Attributes.DamageModifier
+ omnimods
+ )
+ omnimods
+ )
+ in
+ (Html.div
+ [
+ (Html.Attributes.class "omnimod-listing")
+ ]
+ [
+ (Html.div
+ [
+ (Html.Attributes.class "omnimod-attack-mods")
+ ]
+ (List.map
+ (\(k, v) ->
+ (Battle.View.DamageType.get_html
+ (Battle.Struct.DamageType.decode k)
+ v
+ )
+ )
+ (Battle.Struct.Omnimods.get_attack_mods scaled_omnimods)
+ )
+ ),
+ (Html.div
+ [
+ (Html.Attributes.class "omnimod-defense-mods")
+ ]
+ (List.map
+ (\(k, v) ->
+ (Battle.View.DamageType.get_html
+ (Battle.Struct.DamageType.decode k)
+ v
+ )
+ )
+ (Battle.Struct.Omnimods.get_defense_mods omnimods)
+ )
+ ),
+ (Html.div
+ [
+ (Html.Attributes.class "omnimod-attributes-mods")
+ ]
+ (List.map
+ (\(k, v) ->
+ (Battle.View.Attribute.get_html
+ (Battle.Struct.Attributes.decode_category k)
+ v
+ )
+ )
+ (Battle.Struct.Omnimods.get_attribute_mods omnimods)
+ )
+ )
+ ]
+ )