summaryrefslogtreecommitdiff |
diff options
-rw-r--r-- | src/map-editor/src/View/SelectableTile.elm | 54 | ||||
-rw-r--r-- | src/roster-editor/src/View/Omnimods.elm | 181 | ||||
-rw-r--r-- | src/shared/battle/Battle/Struct/Attributes.elm | 11 | ||||
-rw-r--r-- | src/shared/battle/Battle/Struct/Statistics.elm | 12 | ||||
-rw-r--r-- | src/shared/battle/Battle/View/Attribute.elm | 181 | ||||
-rw-r--r-- | src/shared/battle/Battle/View/DamageType.elm | 131 | ||||
-rw-r--r-- | src/shared/battle/Battle/View/Gauge.elm | 75 | ||||
-rw-r--r-- | src/shared/battle/Battle/View/Statistic.elm | 246 |
8 files changed, 710 insertions, 181 deletions
diff --git a/src/map-editor/src/View/SelectableTile.elm b/src/map-editor/src/View/SelectableTile.elm new file mode 100644 index 0000000..79acef5 --- /dev/null +++ b/src/map-editor/src/View/SelectableTile.elm @@ -0,0 +1,54 @@ +module View.SelectableTile exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Html +import Html.Attributes +import Html.Events + +-- Battle Map ------------------------------------------------------------------ +import BattleMap.Struct.TileInstance +import BattleMap.Struct.Location + +import BattleMap.View.Tile + +-- Local Module ---------------------------------------------------------------- +import Constants.UI +import Constants.IO + +import Struct.Event +import Struct.Toolbox + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +get_html : ( + Bool -> + Struct.Toolbox.Type -> + BattleMap.Struct.TileInstance.Type -> + (Html.Html Struct.Event.Type) + ) +get_html display_cost tb tile = + let + tile_loc = (BattleMap.Struct.TileInstance.get_location tile) + in + (BattleMap.View.Tile.get_html_with_extra + display_cost + [ + ( + if (Struct.Toolbox.is_selected tile_loc tb) + then (Html.Attributes.class "tile-selected") + else (Html.Attributes.class "") + ), + ( + if (Struct.Toolbox.is_square_corner tile_loc tb) + then (Html.Attributes.class "tile-square-corner") + else (Html.Attributes.class "") + ) + ] + tile + ) diff --git a/src/roster-editor/src/View/Omnimods.elm b/src/roster-editor/src/View/Omnimods.elm deleted file mode 100644 index d1ae7b7..0000000 --- a/src/roster-editor/src/View/Omnimods.elm +++ /dev/null @@ -1,181 +0,0 @@ -module View.Omnimods exposing - ( - get_html_with_modifier, - get_html - ) - --- Elm ------------------------------------------------------------------------- -import List - -import Html -import Html.Attributes -import Html.Events - --- Battle ---------------------------------------------------------------------- -import Battle.Struct.Omnimods - --- Local Module ---------------------------------------------------------------- -import Struct.Event - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_mod_html : (String, Int) -> (Html.Html Struct.Event.Type) -get_mod_html mod = - let - (category, value) = mod - in - (Html.div - [ - (Html.Attributes.class "info-card-mod") - ] - [ - (Html.div - [ - (Html.Attributes.class "omnimod-icon"), - (Html.Attributes.class ("omnimod-icon-" ++ category)), - ( - if (value < 0) - then (Html.Attributes.class "omnimod-icon-negative") - else (Html.Attributes.class "omnimod-icon-positive") - ) - ] - [ - ] - ), - (Html.text (String.fromInt value)) - ] - ) - -get_multiplied_mod_html : Float -> (String, Int) -> (Html.Html Struct.Event.Type) -get_multiplied_mod_html multiplier mod = - let - (category, value) = mod - in - (Html.div - [ - (Html.Attributes.class "character-card-mod") - ] - [ - (Html.div - [ - (Html.Attributes.class "omnimod-icon"), - (Html.Attributes.class ("omnimod-icon-" ++ category)), - ( - if (value < 0) - then (Html.Attributes.class "omnimod-icon-negative") - else (Html.Attributes.class "omnimod-icon-positive") - ) - ] - [ - ] - ), - (Html.text - ( - (String.fromInt value) - ++ " (" - ++(String.fromInt (ceiling ((toFloat value) * multiplier))) - ++ ")" - ) - ) - ] - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html_with_modifier : ( - Float -> - Battle.Struct.Omnimods.Type -> - (Html.Html Struct.Event.Type) - ) -get_html_with_modifier attack_multiplier omnimods = - (Html.div - [ - (Html.Attributes.class "omnimod-listing") - ] - [ - (Html.div - [ - (Html.Attributes.class "omnimod-attack-mods") - ] - (List.map - (get_multiplied_mod_html attack_multiplier) - (Battle.Struct.Omnimods.get_attack_mods omnimods) - ) - ), - (Html.div - [ - (Html.Attributes.class "omnimod-defense-mods") - ] - (List.map - (get_mod_html) - (Battle.Struct.Omnimods.get_defense_mods omnimods) - ) - ), - (Html.div - [ - (Html.Attributes.class "omnimod-attribute-mods") - ] - (List.map - (get_mod_html) - (Battle.Struct.Omnimods.get_attributes_mods omnimods) - ) - ), - (Html.div - [ - (Html.Attributes.class "omnimod-statistics-mods") - ] - (List.map - (get_mod_html) - (Battle.Struct.Omnimods.get_statistics_mods omnimods) - ) - ) - ] - ) - -get_html : Battle.Struct.Omnimods.Type -> (Html.Html Struct.Event.Type) -get_html omnimods = - (Html.div - [ - (Html.Attributes.class "omnimod-listing") - ] - [ - (Html.div - [ - (Html.Attributes.class "omnimod-attack-mods") - ] - (List.map - (get_mod_html) - (Battle.Struct.Omnimods.get_attack_mods omnimods) - ) - ), - (Html.div - [ - (Html.Attributes.class "omnimod-defense-mods") - ] - (List.map - (get_mod_html) - (Battle.Struct.Omnimods.get_defense_mods omnimods) - ) - ), - (Html.div - [ - (Html.Attributes.class "omnimod-attribute-mods") - ] - (List.map - (get_mod_html) - (Battle.Struct.Omnimods.get_attributes_mods omnimods) - ) - ), - (Html.div - [ - (Html.Attributes.class "omnimod-statistics-mods") - ] - (List.map - (get_mod_html) - (Battle.Struct.Omnimods.get_statistics_mods omnimods) - ) - ) - ] - ) diff --git a/src/shared/battle/Battle/Struct/Attributes.elm b/src/shared/battle/Battle/Struct/Attributes.elm index ee12dbd..6f6fe10 100644 --- a/src/shared/battle/Battle/Struct/Attributes.elm +++ b/src/shared/battle/Battle/Struct/Attributes.elm @@ -18,6 +18,7 @@ module Battle.Struct.Attributes exposing get, new, decode_category, + encode_category, default ) @@ -167,3 +168,13 @@ decode_category str = "min" -> Mind "spe" -> Speed _ -> Strength + +encode_category : Category -> string +encode_category cat = + case cat of + Constitution -> "con" + Dexterity -> "dex" + Intelligence -> "int" + Mind -> "min" + Speed -> "spe" + Strength -> "str" diff --git a/src/shared/battle/Battle/Struct/Statistics.elm b/src/shared/battle/Battle/Struct/Statistics.elm index e21b4f6..43bd27d 100644 --- a/src/shared/battle/Battle/Struct/Statistics.elm +++ b/src/shared/battle/Battle/Struct/Statistics.elm @@ -11,6 +11,7 @@ module Battle.Struct.Statistics exposing get_critical_hits, get_damage_modifier, decode_category, + encode_category, mod, new_raw ) @@ -208,3 +209,14 @@ decode_category str = "accu" -> Accuracy "dhit" -> DoubleHits _ -> 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" 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) + ) + ] diff --git a/src/shared/battle/Battle/View/DamageType.elm b/src/shared/battle/Battle/View/DamageType.elm new file mode 100644 index 0000000..0a76092 --- /dev/null +++ b/src/shared/battle/Battle/View/DamageType.elm @@ -0,0 +1,131 @@ +module Battle.View.DamageType exposing + ( + get_html, + get_signed_html + ) + +-- Elm ------------------------------------------------------------------------- +import Html +import Html.DamageTypes + +import List + +-- Battle ---------------------------------------------------------------------- +import Battle.Struct.DamageType + +-- Local Module ---------------------------------------------------------------- +import Struct.Event +import Struct.HelpRequest + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : ( + Battle.Struct.DamageType.Type -> + Int -> + (List (Html.Html Struct.Event.Type)) + ) +get_html damage_type value = + (Html.div + [ + (Html.Events.onClick + (Struct.Event.RequestedHelp + (Struct.HelpRequest.DamageType damage_type) + ) + ) + ] + [ + (Html.div + [ + (Html.DamageTypes.class "omnimod-icon"), + (Html.DamageTypes.class + ( + "omnimod-icon-" + ++ (Battle.Struct.DamageType.encode damage_type) + ) + ), + ] + [ + ] + ), + (Html.div + [ + (Html.DamageTypes.class "omnimod-value") + ] + [ + (Html.text (String.FromInt value)) + ] + ) + ] + ) + +get_signed_html : ( + Battle.Struct.DamageType.Type -> + Int -> + (Html.Html Struct.Event.Type) + ) +get_signed_html damage_type value = + (Html.div + [ + ( + if (value < 0) + then (Html.DamageTypes.class "omnimod-negative") + else (Html.DamageTypes.class "omnimod-positive") + ), + (Html.Events.onClick + (Struct.Event.RequestedHelp + (Struct.HelpRequest.DamageType damage_type) + ) + ) + ] + [ + (Html.div + [ + (Html.DamageTypes.class "omnimod-icon"), + (Html.DamageTypes.class + ( + "omnimod-icon-" + ++ (Battle.Struct.DamageType.encode damage_type) + ) + ), + ] + [ + ] + ), + (Html.div + [ + (Html.DamageTypes.class "omnimod-value") + ] + [ + (Html.text + ( + ( + if (value < 0) + then "-" + else "+" + ) + ++ (String.FromInt value) + ) + ) + ] + ) + ] + ) + +get_all_html : ( + (List Battle.Struct.DamageTypes.Type) -> + (List (Html.Html Struct.Event.Type)) + ) +get_all_html damage_types = + (List.map (get_html) damage_types) + +get_all_signed_html : ( + (List Battle.Struct.DamageTypes.Type) -> + (List (Html.Html Struct.Event.Type)) + ) +get_all_signed_html damage_types = + (List.map (get_signed_html) damage_types) diff --git a/src/shared/battle/Battle/View/Gauge.elm b/src/shared/battle/Battle/View/Gauge.elm new file mode 100644 index 0000000..29a97a0 --- /dev/null +++ b/src/shared/battle/Battle/View/Gauge.elm @@ -0,0 +1,75 @@ +module Battle.View.Gauge exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Html +import Html.Attributes + +-- Local Module ---------------------------------------------------------------- +import Struct.Event + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_text_div : ( + String -> + List (Html.Attribute Struct.Event.Type) -> + (Html.Html Struct.Event.Type) + ) +get_text_div text extra_txt_attr = + (Html.div + ( + [(Html.Attributes.class "gauge-text")] + ++ extra_txt_attr + ) + [ + (Html.text text) + ] + ) + +get_bar_div : ( + Float -> + List (Html.Attribute Struct.Event.Type) -> + (Html.Html Struct.Event.Type) + ) +get_bar_div percent extra_bar_attr = + (Html.div + ( + [ + (Html.Attributes.style + "width" + ((String.fromFloat percent) ++ "%") + ), + (Html.Attributes.class + "gauge-bar" + ) + ] + ++ + extra_bar_attr + ) + [ + ] + ) + + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : ( + String -> + Float -> + List (Html.Attribute Struct.Event.Type) -> + List (Html.Attribute Struct.Event.Type) -> + List (Html.Attribute Struct.Event.Type) -> + (Html.Html Struct.Event.Type) + ) +get_html text percent extra_div_attr extra_bar_attr extra_txt_attr = + (Html.div + ( + [(Html.Attributes.class "gauge")] + ++ extra_div_attr + ) + [ + (get_text_div text extra_txt_attr), + (get_bar_div percent extra_bar_attr) + ] + ) diff --git a/src/shared/battle/Battle/View/Statistic.elm b/src/shared/battle/Battle/View/Statistic.elm new file mode 100644 index 0000000..4e2e91a --- /dev/null +++ b/src/shared/battle/Battle/View/Statistic.elm @@ -0,0 +1,246 @@ +module Battle.View.Statistic exposing + ( + get_html, + get_all_html, + get_signed_html, + get_all_signed_html + ) + +-- Elm ------------------------------------------------------------------------- +import Html +import Html.Statistics + +-- Battle ---------------------------------------------------------------------- +import Battle.Struct.Statistic + +-- Local Module ---------------------------------------------------------------- +import Struct.Event +import Struct.HelpRequest + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : ( + Battle.Struct.Statistic.Category -> + Int -> + (List (Html.Html Struct.Event.Type)) + ) +get_html statistic value = + (Html.div + [ + (Html.Events.onClick + (Struct.Event.RequestedHelp + (Struct.HelpRequest.Statistic statistic) + ) + ) + ] + [ + (Html.div + [ + (Html.Statistics.class "omnimod-icon"), + (Html.Statistics.class + ( + "omnimod-icon-" + ++ (Battle.Struct.Statistic.encode_category statistic) + ) + ), + ] + [ + ] + ), + (Html.div + [ + (Html.Statistics.class "omnimod-value") + ] + [ + (Html.text ((String.FromInt value) ++ "%")) + ] + ) + ] + ) + +get_signed_html : ( + Battle.Struct.Statistic.Category -> + Int -> + (Html.Html Struct.Event.Type) + ) +get_signed_html statistic value = + (Html.div + [ + ( + if (value < 0) + then (Html.Statistics.class "omnimod-negative") + else (Html.Statistics.class "omnimod-positive") + ), + (Html.Events.onClick + (Struct.Event.RequestedHelp + (Struct.HelpRequest.Statistic statistic) + ) + ) + ] + [ + (Html.div + [ + (Html.Statistics.class "omnimod-icon"), + (Html.Statistics.class + ( + "omnimod-icon-" + ++ (Battle.Struct.Statistic.encode_category statistic) + ) + ), + ] + [ + ] + ), + (Html.div + [ + (Html.Statistics.class "omnimod-value") + ] + [ + (Html.text + ( + ( + if (value < 0) + then "-" + else "+" + ) + ++ (String.FromInt value) + ++ "%" + ) + ) + ] + ) + ] + ) + +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) + ) + ] |