From 120b0b7f6df0c8978aac9a423cbf8364feac4779 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Sat, 10 Aug 2019 18:23:48 +0200 Subject: Statistics -> Attributes. --- src/shared/battle/Battle/View/Attribute.elm | 259 +++++++++++++++++++++++ src/shared/battle/Battle/View/Help/Attribute.elm | 62 ++++++ src/shared/battle/Battle/View/Help/Statistic.elm | 62 ------ src/shared/battle/Battle/View/Omnimods.elm | 20 +- src/shared/battle/Battle/View/Statistic.elm | 259 ----------------------- 5 files changed, 331 insertions(+), 331 deletions(-) create mode 100644 src/shared/battle/Battle/View/Attribute.elm create mode 100644 src/shared/battle/Battle/View/Help/Attribute.elm delete mode 100644 src/shared/battle/Battle/View/Help/Statistic.elm delete mode 100644 src/shared/battle/Battle/View/Statistic.elm (limited to 'src/shared/battle/Battle/View') diff --git a/src/shared/battle/Battle/View/Attribute.elm b/src/shared/battle/Battle/View/Attribute.elm new file mode 100644 index 0000000..ae2edf3 --- /dev/null +++ b/src/shared/battle/Battle/View/Attribute.elm @@ -0,0 +1,259 @@ +module Battle.View.Attribute exposing + ( + get_html, + get_all_html, + get_all_but_gauges_html, + get_signed_html, + get_all_signed_html, + get_all_but_gauges_signed_html + ) + +-- Elm ------------------------------------------------------------------------- +import Html +import Html.Attributes +import Html.Events + +-- Battle ---------------------------------------------------------------------- +import Battle.Struct.Attributes + +-- Local Module ---------------------------------------------------------------- +import Struct.Event +import Struct.HelpRequest + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : ( + Battle.Struct.Attributes.Category -> + Int -> + (Html.Html Struct.Event.Type) + ) +get_html attribute value = + (Html.div + [ + (Html.Events.onClick + (Struct.Event.RequestedHelp + (Struct.HelpRequest.Attribute attribute) + ) + ) + ] + [ + (Html.div + [ + (Html.Attributes.class "omnimod-icon"), + (Html.Attributes.class + ( + "omnimod-icon-" + ++ (Battle.Struct.Attributes.encode_category attribute) + ) + ) + ] + [ + ] + ), + (Html.div + [ + (Html.Attributes.class "omnimod-value") + ] + [ + (Html.text + ( + if (Battle.Struct.Attributes.is_percent attribute) + then ((String.fromInt value) ++ "%") + else (String.fromInt value) + ) + ) + ] + ) + ] + ) + +get_signed_html : ( + Battle.Struct.Attributes.Category -> + Int -> + (Html.Html Struct.Event.Type) + ) +get_signed_html attribute value = + (Html.div + [ + ( + if (value < 0) + then (Html.Attributes.class "omnimod-negative") + else (Html.Attributes.class "omnimod-positive") + ), + (Html.Events.onClick + (Struct.Event.RequestedHelp + (Struct.HelpRequest.Attribute attribute) + ) + ) + ] + [ + (Html.div + [ + (Html.Attributes.class "omnimod-icon"), + (Html.Attributes.class + ( + "omnimod-icon-" + ++ (Battle.Struct.Attributes.encode_category attribute) + ) + ) + ] + [ + ] + ), + (Html.div + [ + (Html.Attributes.class "omnimod-value") + ] + [ + (Html.text + ( + ( + if (value > 0) + then ("+" ++ (String.fromInt value)) + else (String.fromInt value) + ) + ++ + ( + if (Battle.Struct.Attributes.is_percent attribute) + then "%" + else "" + ) + ) + ) + ] + ) + ] + ) + +get_all_html : ( + Battle.Struct.Attributes.Type -> + (List (Html.Html Struct.Event.Type)) + ) +get_all_html atts = + [ + (get_html + Battle.Struct.Attributes.Dodges + (Battle.Struct.Attributes.get_dodges atts) + ), + (get_html + Battle.Struct.Attributes.Parries + (Battle.Struct.Attributes.get_parries atts) + ), + (get_html + Battle.Struct.Attributes.Accuracy + (Battle.Struct.Attributes.get_accuracy atts) + ), + (get_html + Battle.Struct.Attributes.DoubleHits + (Battle.Struct.Attributes.get_double_hits atts) + ), + (get_html + Battle.Struct.Attributes.CriticalHits + (Battle.Struct.Attributes.get_critical_hits atts) + ), + (get_html + Battle.Struct.Attributes.MaxHealth + (Battle.Struct.Attributes.get_max_health atts) + ), + (get_html + Battle.Struct.Attributes.MovementPoints + (Battle.Struct.Attributes.get_movement_points atts) + ) + ] + +get_all_signed_html : ( + Battle.Struct.Attributes.Type -> + (List (Html.Html Struct.Event.Type)) + ) +get_all_signed_html atts = + [ + (get_signed_html + Battle.Struct.Attributes.Dodges + (Battle.Struct.Attributes.get_dodges atts) + ), + (get_signed_html + Battle.Struct.Attributes.Parries + (Battle.Struct.Attributes.get_parries atts) + ), + (get_signed_html + Battle.Struct.Attributes.Accuracy + (Battle.Struct.Attributes.get_accuracy atts) + ), + (get_signed_html + Battle.Struct.Attributes.DoubleHits + (Battle.Struct.Attributes.get_double_hits atts) + ), + (get_signed_html + Battle.Struct.Attributes.CriticalHits + (Battle.Struct.Attributes.get_critical_hits atts) + ), + (get_signed_html + Battle.Struct.Attributes.MaxHealth + (Battle.Struct.Attributes.get_max_health atts) + ), + (get_signed_html + Battle.Struct.Attributes.MovementPoints + (Battle.Struct.Attributes.get_movement_points atts) + ) + ] + +get_all_but_gauges_html : ( + Battle.Struct.Attributes.Type -> + (List (Html.Html Struct.Event.Type)) + ) +get_all_but_gauges_html atts = + [ + (get_html + Battle.Struct.Attributes.Dodges + (Battle.Struct.Attributes.get_dodges atts) + ), + (get_html + Battle.Struct.Attributes.Parries + (Battle.Struct.Attributes.get_parries atts) + ), + (get_html + Battle.Struct.Attributes.Accuracy + (Battle.Struct.Attributes.get_accuracy atts) + ), + (get_html + Battle.Struct.Attributes.DoubleHits + (Battle.Struct.Attributes.get_double_hits atts) + ), + (get_html + Battle.Struct.Attributes.CriticalHits + (Battle.Struct.Attributes.get_critical_hits atts) + ) + ] + +get_all_but_gauges_signed_html : ( + Battle.Struct.Attributes.Type -> + (List (Html.Html Struct.Event.Type)) + ) +get_all_but_gauges_signed_html atts = + [ + (get_signed_html + Battle.Struct.Attributes.Dodges + (Battle.Struct.Attributes.get_dodges atts) + ), + (get_signed_html + Battle.Struct.Attributes.Parries + (Battle.Struct.Attributes.get_parries atts) + ), + (get_signed_html + Battle.Struct.Attributes.Accuracy + (Battle.Struct.Attributes.get_accuracy atts) + ), + (get_signed_html + Battle.Struct.Attributes.DoubleHits + (Battle.Struct.Attributes.get_double_hits atts) + ), + (get_signed_html + Battle.Struct.Attributes.CriticalHits + (Battle.Struct.Attributes.get_critical_hits atts) + ) + ] diff --git a/src/shared/battle/Battle/View/Help/Attribute.elm b/src/shared/battle/Battle/View/Help/Attribute.elm new file mode 100644 index 0000000..f7bd9e1 --- /dev/null +++ b/src/shared/battle/Battle/View/Help/Attribute.elm @@ -0,0 +1,62 @@ +module Battle.View.Help.Attribute exposing (get_html_contents) + +-- Elm ------------------------------------------------------------------------- +import Html +import Html.Attributes + +-- Battle ---------------------------------------------------------------------- +import Battle.Struct.Attributes +import Battle.Lang.English + +-- Local Module ---------------------------------------------------------------- +import Struct.Event + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_header_html : ( + Battle.Struct.Attributes.Category -> + String -> + (Html.Html Struct.Event.Type) + ) +get_header_html cat name = + (Html.h1 + [] + [ + (Html.div + [(Html.Attributes.class "help-guide-icon")] + [] + ), + (Html.text " "), + (Html.div + [ + (Html.Attributes.class "omnimod-icon"), + (Html.Attributes.class + ( + "omnimod-icon-" + ++ (Battle.Struct.Attributes.encode_category cat) + ) + ) + ] + [ + ] + ), + (Html.text name) + ] + ) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html_contents : ( + Battle.Struct.Attributes.Category -> + (List (Html.Html Struct.Event.Type)) + ) +get_html_contents cat = + let + (name, tooltip) = (Battle.Lang.English.get_attribute_category_help cat) + in + [ + (get_header_html cat name), + tooltip + ] diff --git a/src/shared/battle/Battle/View/Help/Statistic.elm b/src/shared/battle/Battle/View/Help/Statistic.elm deleted file mode 100644 index 0e1f056..0000000 --- a/src/shared/battle/Battle/View/Help/Statistic.elm +++ /dev/null @@ -1,62 +0,0 @@ -module Battle.View.Help.Statistic exposing (get_html_contents) - --- Elm ------------------------------------------------------------------------- -import Html -import Html.Attributes - --- Battle ---------------------------------------------------------------------- -import Battle.Struct.Statistics -import Battle.Lang.English - --- Local Module ---------------------------------------------------------------- -import Struct.Event - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_header_html : ( - Battle.Struct.Statistics.Category -> - String -> - (Html.Html Struct.Event.Type) - ) -get_header_html cat name = - (Html.h1 - [] - [ - (Html.div - [(Html.Attributes.class "help-guide-icon")] - [] - ), - (Html.text " "), - (Html.div - [ - (Html.Attributes.class "omnimod-icon"), - (Html.Attributes.class - ( - "omnimod-icon-" - ++ (Battle.Struct.Statistics.encode_category cat) - ) - ) - ] - [ - ] - ), - (Html.text name) - ] - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html_contents : ( - Battle.Struct.Statistics.Category -> - (List (Html.Html Struct.Event.Type)) - ) -get_html_contents cat = - let - (name, tooltip) = (Battle.Lang.English.get_statistic_category_help cat) - in - [ - (get_header_html cat name), - tooltip - ] diff --git a/src/shared/battle/Battle/View/Omnimods.elm b/src/shared/battle/Battle/View/Omnimods.elm index a41afba..8d8c4ce 100644 --- a/src/shared/battle/Battle/View/Omnimods.elm +++ b/src/shared/battle/Battle/View/Omnimods.elm @@ -14,10 +14,10 @@ import Html.Events -- Battle ---------------------------------------------------------------------- import Battle.Struct.DamageType import Battle.Struct.Omnimods -import Battle.Struct.Statistics +import Battle.Struct.Attributes import Battle.View.DamageType -import Battle.View.Statistic +import Battle.View.Attribute -- Local Module ---------------------------------------------------------------- import Struct.Event @@ -70,16 +70,16 @@ get_html_with_modifier attack_multiplier omnimods = ), (Html.div [ - (Html.Attributes.class "omnimod-statistics-mods") + (Html.Attributes.class "omnimod-attribute-mods") ] (List.map (\(k, v) -> - (Battle.View.Statistic.get_signed_html - (Battle.Struct.Statistics.decode_category k) + (Battle.View.Attribute.get_signed_html + (Battle.Struct.Attributes.decode_category k) v ) ) - (Battle.Struct.Omnimods.get_statistics_mods omnimods) + (Battle.Struct.Omnimods.get_attribute_mods omnimods) ) ) ] @@ -122,16 +122,16 @@ get_html omnimods = ), (Html.div [ - (Html.Attributes.class "omnimod-statistics-mods") + (Html.Attributes.class "omnimod-attributes-mods") ] (List.map (\(k, v) -> - (Battle.View.Statistic.get_signed_html - (Battle.Struct.Statistics.decode_category k) + (Battle.View.Attribute.get_signed_html + (Battle.Struct.Attributes.decode_category k) v ) ) - (Battle.Struct.Omnimods.get_statistics_mods omnimods) + (Battle.Struct.Omnimods.get_attribute_mods omnimods) ) ) ] diff --git a/src/shared/battle/Battle/View/Statistic.elm b/src/shared/battle/Battle/View/Statistic.elm deleted file mode 100644 index 0ced0dc..0000000 --- a/src/shared/battle/Battle/View/Statistic.elm +++ /dev/null @@ -1,259 +0,0 @@ -module Battle.View.Statistic exposing - ( - get_html, - get_all_html, - get_all_but_gauges_html, - get_signed_html, - get_all_signed_html, - get_all_but_gauges_signed_html - ) - --- Elm ------------------------------------------------------------------------- -import Html -import Html.Attributes -import Html.Events - --- Battle ---------------------------------------------------------------------- -import Battle.Struct.Statistics - --- Local Module ---------------------------------------------------------------- -import Struct.Event -import Struct.HelpRequest - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : ( - Battle.Struct.Statistics.Category -> - Int -> - (Html.Html Struct.Event.Type) - ) -get_html statistic value = - (Html.div - [ - (Html.Events.onClick - (Struct.Event.RequestedHelp - (Struct.HelpRequest.Statistic statistic) - ) - ) - ] - [ - (Html.div - [ - (Html.Attributes.class "omnimod-icon"), - (Html.Attributes.class - ( - "omnimod-icon-" - ++ (Battle.Struct.Statistics.encode_category statistic) - ) - ) - ] - [ - ] - ), - (Html.div - [ - (Html.Attributes.class "omnimod-value") - ] - [ - (Html.text - ( - if (Battle.Struct.Statistics.is_percent statistic) - then ((String.fromInt value) ++ "%") - else (String.fromInt value) - ) - ) - ] - ) - ] - ) - -get_signed_html : ( - Battle.Struct.Statistics.Category -> - Int -> - (Html.Html Struct.Event.Type) - ) -get_signed_html statistic value = - (Html.div - [ - ( - if (value < 0) - then (Html.Attributes.class "omnimod-negative") - else (Html.Attributes.class "omnimod-positive") - ), - (Html.Events.onClick - (Struct.Event.RequestedHelp - (Struct.HelpRequest.Statistic statistic) - ) - ) - ] - [ - (Html.div - [ - (Html.Attributes.class "omnimod-icon"), - (Html.Attributes.class - ( - "omnimod-icon-" - ++ (Battle.Struct.Statistics.encode_category statistic) - ) - ) - ] - [ - ] - ), - (Html.div - [ - (Html.Attributes.class "omnimod-value") - ] - [ - (Html.text - ( - ( - if (value > 0) - then ("+" ++ (String.fromInt value)) - else (String.fromInt value) - ) - ++ - ( - if (Battle.Struct.Statistics.is_percent statistic) - then "%" - else "" - ) - ) - ) - ] - ) - ] - ) - -get_all_html : ( - Battle.Struct.Statistics.Type -> - (List (Html.Html Struct.Event.Type)) - ) -get_all_html stats = - [ - (get_html - Battle.Struct.Statistics.Dodges - (Battle.Struct.Statistics.get_dodges stats) - ), - (get_html - Battle.Struct.Statistics.Parries - (Battle.Struct.Statistics.get_parries stats) - ), - (get_html - Battle.Struct.Statistics.Accuracy - (Battle.Struct.Statistics.get_accuracy stats) - ), - (get_html - Battle.Struct.Statistics.DoubleHits - (Battle.Struct.Statistics.get_double_hits stats) - ), - (get_html - Battle.Struct.Statistics.CriticalHits - (Battle.Struct.Statistics.get_critical_hits stats) - ), - (get_html - Battle.Struct.Statistics.MaxHealth - (Battle.Struct.Statistics.get_max_health stats) - ), - (get_html - Battle.Struct.Statistics.MovementPoints - (Battle.Struct.Statistics.get_movement_points stats) - ) - ] - -get_all_signed_html : ( - Battle.Struct.Statistics.Type -> - (List (Html.Html Struct.Event.Type)) - ) -get_all_signed_html stats = - [ - (get_signed_html - Battle.Struct.Statistics.Dodges - (Battle.Struct.Statistics.get_dodges stats) - ), - (get_signed_html - Battle.Struct.Statistics.Parries - (Battle.Struct.Statistics.get_parries stats) - ), - (get_signed_html - Battle.Struct.Statistics.Accuracy - (Battle.Struct.Statistics.get_accuracy stats) - ), - (get_signed_html - Battle.Struct.Statistics.DoubleHits - (Battle.Struct.Statistics.get_double_hits stats) - ), - (get_signed_html - Battle.Struct.Statistics.CriticalHits - (Battle.Struct.Statistics.get_critical_hits stats) - ), - (get_signed_html - Battle.Struct.Statistics.MaxHealth - (Battle.Struct.Statistics.get_max_health stats) - ), - (get_signed_html - Battle.Struct.Statistics.MovementPoints - (Battle.Struct.Statistics.get_movement_points stats) - ) - ] - -get_all_but_gauges_html : ( - Battle.Struct.Statistics.Type -> - (List (Html.Html Struct.Event.Type)) - ) -get_all_but_gauges_html stats = - [ - (get_html - Battle.Struct.Statistics.Dodges - (Battle.Struct.Statistics.get_dodges stats) - ), - (get_html - Battle.Struct.Statistics.Parries - (Battle.Struct.Statistics.get_parries stats) - ), - (get_html - Battle.Struct.Statistics.Accuracy - (Battle.Struct.Statistics.get_accuracy stats) - ), - (get_html - Battle.Struct.Statistics.DoubleHits - (Battle.Struct.Statistics.get_double_hits stats) - ), - (get_html - Battle.Struct.Statistics.CriticalHits - (Battle.Struct.Statistics.get_critical_hits stats) - ) - ] - -get_all_but_gauges_signed_html : ( - Battle.Struct.Statistics.Type -> - (List (Html.Html Struct.Event.Type)) - ) -get_all_but_gauges_signed_html stats = - [ - (get_signed_html - Battle.Struct.Statistics.Dodges - (Battle.Struct.Statistics.get_dodges stats) - ), - (get_signed_html - Battle.Struct.Statistics.Parries - (Battle.Struct.Statistics.get_parries stats) - ), - (get_signed_html - Battle.Struct.Statistics.Accuracy - (Battle.Struct.Statistics.get_accuracy stats) - ), - (get_signed_html - Battle.Struct.Statistics.DoubleHits - (Battle.Struct.Statistics.get_double_hits stats) - ), - (get_signed_html - Battle.Struct.Statistics.CriticalHits - (Battle.Struct.Statistics.get_critical_hits stats) - ) - ] -- cgit v1.2.3-70-g09d2