From b6fa3b730fe0c4249e714545ca88d2729c815a9b Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Sun, 17 Mar 2019 00:55:26 +0100 Subject: ... --- src/shared/battle/Battle/View/Attribute.elm | 181 ++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 src/shared/battle/Battle/View/Attribute.elm (limited to 'src/shared/battle/Battle/View/Attribute.elm') diff --git a/src/shared/battle/Battle/View/Attribute.elm b/src/shared/battle/Battle/View/Attribute.elm new file mode 100644 index 0000000..abf71c3 --- /dev/null +++ b/src/shared/battle/Battle/View/Attribute.elm @@ -0,0 +1,181 @@ +module Battle.View.Attribute exposing + ( + get_html, + get_all_html, + get_signed_html, + get_all_signed_html + ) + +-- Elm ------------------------------------------------------------------------- +import Html +import Html.Attributes + +-- Battle ---------------------------------------------------------------------- +import Battle.Struct.Attribute + +-- Local Module ---------------------------------------------------------------- +import Struct.Event +import Struct.HelpRequest + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : ( + Battle.Struct.Attribute.Category -> + Int -> + (List (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.Attribute.encode_category attribute) + ) + ), + ] + [ + ] + ), + (Html.div + [ + (Html.Attributes.class "omnimod-value") + ] + [ + (Html.text (String.FromInt value)) + ] + ) + ] + ) + +get_signed_html : ( + Battle.Struct.Attribute.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.Attribute.encode_category attribute) + ) + ), + ] + [ + ] + ), + (Html.div + [ + (Html.Attributes.class "omnimod-value") + ] + [ + (Html.text + ( + ( + if (value < 0) + then "-" + else "+" + ) + ++ (String.FromInt value) + ) + ) + ] + ) + ] + ) + +get_all_html : ( + Battle.Struct.Attributes.Type -> + (List (Html.Html Struct.Event.Type)) + ) +get_all_html atts = + [ + (get_html + Battle.Struct.Attributes.Constitution + (Battle.Struct.Attributes.get_constitution atts) + ), + (get_html + Battle.Struct.Attributes.Strength + (Battle.Struct.Attributes.get_strength atts) + ), + (get_html + Battle.Struct.Attributes.Dexterity + (Battle.Struct.Attributes.get_dexterity atts) + ), + (get_html + Battle.Struct.Attributes.Speed + (Battle.Struct.Attributes.get_speed atts) + ), + (get_html + Battle.Struct.Attributes.Intelligence + (Battle.Struct.Attributes.get_intelligence atts) + ), + (get_html + Battle.Struct.Attributes.Mind + (Battle.Struct.Attributes.get_mind 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.Constitution + (Battle.Struct.Attributes.get_constitution atts) + ), + (get_signed_html + Battle.Struct.Attributes.Strength + (Battle.Struct.Attributes.get_strength atts) + ), + (get_signed_html + Battle.Struct.Attributes.Dexterity + (Battle.Struct.Attributes.get_dexterity atts) + ), + (get_signed_html + Battle.Struct.Attributes.Speed + (Battle.Struct.Attributes.get_speed atts) + ), + (get_signed_html + Battle.Struct.Attributes.Intelligence + (Battle.Struct.Attributes.get_intelligence atts) + ), + (get_signed_html + Battle.Struct.Attributes.Mind + (Battle.Struct.Attributes.get_mind atts) + ) + ] -- cgit v1.2.3-70-g09d2