From 4905bb9d6322c14034ef3278f67917cf09aae8be Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Wed, 4 Mar 2020 14:38:49 +0100 Subject: ... --- src/battle/src/Struct/Character.elm | 47 +++++------ src/battle/src/Struct/HelpRequest.elm | 1 - src/battle/src/View/Controlled/CharacterCard.elm | 66 ++++++++------- src/battle/src/View/Map/Character.elm | 24 +----- src/battle/src/View/MessageBoard/Help.elm | 4 - src/battle/src/View/MessageBoard/Help/Rank.elm | 97 ---------------------- src/battle/www/index.html | 2 +- src/login/www/index.html | 2 +- src/main-menu/www/index.html | 2 +- src/map-editor/www/index.html | 2 +- src/roster-editor/www/index.html | 2 +- .../BattleCharacters/Struct/StatusIndicator.elm | 44 ++++++++++ 12 files changed, 105 insertions(+), 188 deletions(-) delete mode 100644 src/battle/src/View/MessageBoard/Help/Rank.elm create mode 100644 src/shared/battle-characters/BattleCharacters/Struct/StatusIndicator.elm diff --git a/src/battle/src/Struct/Character.elm b/src/battle/src/Struct/Character.elm index 6cdbaab..254f6a2 100644 --- a/src/battle/src/Struct/Character.elm +++ b/src/battle/src/Struct/Character.elm @@ -1,14 +1,14 @@ module Struct.Character exposing ( Type, - Rank(..), Unresolved, get_index, get_player_index, - get_rank, get_current_health, get_sane_current_health, set_current_health, + get_current_skill_points, + set_current_skill_points, get_location, set_location, dirty_set_location, @@ -43,6 +43,7 @@ import Battle.Struct.Attributes -- Battle Characters ----------------------------------------------------------- import BattleCharacters.Struct.Character import BattleCharacters.Struct.Equipment +import BattleCharacters.Struct.StatusIndicator import BattleCharacters.Struct.Weapon -- Battle Map ------------------------------------------------------------------ @@ -51,17 +52,13 @@ import BattleMap.Struct.Location -------------------------------------------------------------------------------- -- TYPES ----------------------------------------------------------------------- -------------------------------------------------------------------------------- -type Rank = - Optional - | Target - | Commander - type alias Type = { ix : Int, - rank : Rank, location : BattleMap.Struct.Location.Type, health : Int, + skill_points : Int, + status_indicators : (List BattleCharacters.Struct.StatusIndicator.Type), player_ix : Int, enabled : Bool, defeated : Bool, @@ -72,9 +69,10 @@ type alias Type = type alias Unresolved = { ix : Int, - rank : Rank, location : BattleMap.Struct.Location.Type, health : Int, + skill_points : Int, + status_indicators : (List BattleCharacters.Struct.StatusIndicator.Type), player_ix : Int, enabled : Bool, defeated : Bool, @@ -84,13 +82,6 @@ type alias Unresolved = -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- -str_to_rank : String -> Rank -str_to_rank str = - case str of - "t" -> Target - "c" -> Commander - _ -> Optional - fix_health : Int -> Type -> Type fix_health previous_max_health char = let @@ -142,9 +133,6 @@ get_melee_attack_range c = get_index : Type -> Int get_index c = c.ix -get_rank : Type -> Rank -get_rank c = c.rank - get_player_index : Type -> Int get_player_index c = c.player_ix @@ -157,6 +145,12 @@ get_sane_current_health c = (max 0 c.health) set_current_health : Int -> Type -> Type set_current_health health c = {c | health = health} +get_current_skill_points : Type -> Int +get_current_skill_points c = c.skill_points + +set_current_skill_points : Int -> Type -> Type +set_current_skill_points skill_points c = {c | skill_points = skill_points} + get_location : Type -> BattleMap.Struct.Location.Type get_location t = t.location @@ -293,16 +287,14 @@ decoder = (Json.Decode.succeed Unresolved |> (Json.Decode.Pipeline.required "ix" Json.Decode.int) + |> (Json.Decode.Pipeline.required "lc" BattleMap.Struct.Location.decoder) + |> (Json.Decode.Pipeline.required "hea" Json.Decode.int) + |> (Json.Decode.Pipeline.required "sp" Json.Decode.int) |> (Json.Decode.Pipeline.required - "rnk" - (Json.Decode.map - (str_to_rank) - (Json.Decode.string) - ) + "sti" + (Json.Decode.list (BattleCharacters.Struct.StatusIndicator.decoder)) ) - |> (Json.Decode.Pipeline.required "lc" BattleMap.Struct.Location.decoder) - |> (Json.Decode.Pipeline.required "hea" Json.Decode.int) |> (Json.Decode.Pipeline.required "pla" Json.Decode.int) |> (Json.Decode.Pipeline.required "ena" Json.Decode.bool) |> (Json.Decode.Pipeline.required "dea" Json.Decode.bool) @@ -325,10 +317,11 @@ resolve : ( resolve location_omnimod_resolver equipment_resolver ref = { ix = ref.ix, - rank = ref.rank, location = ref.location, health = ref.health, + skill_points = ref.skill_points, player_ix = ref.player_ix, + status_indicators = ref.status_indicators, enabled = ref.enabled, defeated = ref.defeated, base = diff --git a/src/battle/src/Struct/HelpRequest.elm b/src/battle/src/Struct/HelpRequest.elm index 7df06cb..03eb63f 100644 --- a/src/battle/src/Struct/HelpRequest.elm +++ b/src/battle/src/Struct/HelpRequest.elm @@ -14,6 +14,5 @@ import Struct.Character -------------------------------------------------------------------------------- type Type = None - | Rank Struct.Character.Rank | Attribute Battle.Struct.Attributes.Category | DamageType Battle.Struct.DamageType.Type diff --git a/src/battle/src/View/Controlled/CharacterCard.elm b/src/battle/src/View/Controlled/CharacterCard.elm index 2fea74c..45e58d9 100644 --- a/src/battle/src/View/Controlled/CharacterCard.elm +++ b/src/battle/src/View/Controlled/CharacterCard.elm @@ -28,6 +28,7 @@ import Battle.View.DamageType import BattleCharacters.Struct.Armor import BattleCharacters.Struct.Character import BattleCharacters.Struct.Equipment +import BattleCharacters.Struct.Skill import BattleCharacters.Struct.Weapon -- Local Module ---------------------------------------------------------------- @@ -58,10 +59,7 @@ get_name base_char = ] ) -get_health_bar : ( - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) +get_health_bar : Struct.Character.Type -> (Html.Html Struct.Event.Type) get_health_bar char = let current = (Struct.Character.get_sane_current_health char) @@ -90,31 +88,37 @@ get_health_bar char = [] ) -get_rank_status : Struct.Character.Rank -> (Html.Html Struct.Event.Type) -get_rank_status rank = - (Html.div - [ - (Html.Attributes.class "character-card-status"), - (Html.Attributes.class "clickable"), - (Html.Events.onClick - (Struct.Event.RequestedHelp (Struct.HelpRequest.Rank rank)) - ), - (Html.Attributes.class - ( - case rank of - Struct.Character.Commander -> - "character-card-commander-status" - - Struct.Character.Target -> - "character-card-target-status" - - Struct.Character.Optional -> "" +get_skill_points_bar : Struct.Character.Type -> (Html.Html Struct.Event.Type) +get_skill_points_bar char = + let + current = (Struct.Character.get_current_skill_points char) + max = + (BattleCharacters.Struct.Skill.get_reserve + (BattleCharacters.Struct.Equipment.get_skill + (BattleCharacters.Struct.Character.get_equipment + (Struct.Character.get_base_character char) + ) ) ) - ] - [ - ] - ) + in + (Battle.View.Gauge.get_html + ("SP: " ++ (String.fromInt current) ++ "/" ++ (String.fromInt max)) + (100.0 * ((toFloat current)/(toFloat max))) + [ + (Html.Attributes.class "character-card-skill-points"), + (Html.Attributes.class "clickable") + -- TODO: Clicking should display help about skill points. +-- (Html.Events.onClick +-- (Struct.Event.RequestedHelp +-- (Struct.HelpRequest.Attribute +-- Battle.Struct.Attributes.SkillPoints +-- ) +-- ) +-- ) + ] + [] + [] + ) get_statuses : Struct.Character.Type -> (Html.Html Struct.Event.Type) get_statuses char = @@ -123,11 +127,6 @@ get_statuses char = (Html.Attributes.class "character-card-statuses") ] [ - ( - case (Struct.Character.get_rank char) of - Struct.Character.Optional -> (Util.Html.nothing) - other -> (get_rank_status other) - ) ] ) @@ -357,6 +356,7 @@ get_minimal_html player_ix char = ), (get_health_bar char), (get_inactive_movement_bar char), + (get_skill_points_bar char), (get_statuses char) ] ) @@ -405,6 +405,7 @@ get_summary_html char_turn player_ix char = ), (get_health_bar char), (get_movement_bar char_turn char), + (get_skill_points_bar char), (get_statuses char) ] ), @@ -461,6 +462,7 @@ get_full_html player_ix char = ), (get_health_bar char), (get_inactive_movement_bar char), + (get_skill_points_bar char), (get_statuses char) ] ), diff --git a/src/battle/src/View/Map/Character.elm b/src/battle/src/View/Map/Character.elm index b1442b1..1afffeb 100644 --- a/src/battle/src/View/Map/Character.elm +++ b/src/battle/src/View/Map/Character.elm @@ -79,28 +79,8 @@ get_head_html char = get_banner_html : Struct.Character.Type -> (Html.Html Struct.Event.Type) get_banner_html char = - case (Struct.Character.get_rank char) of - Struct.Character.Commander -> - (Html.div - [ - (Html.Attributes.class "character-icon-banner"), - (Html.Attributes.class "asset-character-icon-commander-banner") - ] - [ - ] - ) - - Struct.Character.Target -> - (Html.div - [ - (Html.Attributes.class "character-icon-banner"), - (Html.Attributes.class "asset-character-icon-target-banner") - ] - [ - ] - ) - - _ -> (Util.Html.nothing) + -- TODO: Banner from some status indicator + (Util.Html.nothing) get_actual_html : Struct.Character.Type -> (Html.Html Struct.Event.Type) get_actual_html char = diff --git a/src/battle/src/View/MessageBoard/Help.elm b/src/battle/src/View/MessageBoard/Help.elm index 038183f..306d6df 100644 --- a/src/battle/src/View/MessageBoard/Help.elm +++ b/src/battle/src/View/MessageBoard/Help.elm @@ -14,7 +14,6 @@ import Struct.HelpRequest import Struct.Model import View.MessageBoard.Help.Guide -import View.MessageBoard.Help.Rank -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- @@ -39,9 +38,6 @@ get_html model help_request = Struct.HelpRequest.None -> (View.MessageBoard.Help.Guide.get_html_contents model) - (Struct.HelpRequest.Rank rank) -> - (View.MessageBoard.Help.Rank.get_html_contents rank) - (Struct.HelpRequest.Attribute att_cat) -> (Battle.View.Help.Attribute.get_html_contents att_cat) diff --git a/src/battle/src/View/MessageBoard/Help/Rank.elm b/src/battle/src/View/MessageBoard/Help/Rank.elm deleted file mode 100644 index a4634a4..0000000 --- a/src/battle/src/View/MessageBoard/Help/Rank.elm +++ /dev/null @@ -1,97 +0,0 @@ -module View.MessageBoard.Help.Rank exposing (get_html_contents) - --- Elm ------------------------------------------------------------------------- -import Html -import Html.Attributes - --- Local Module ---------------------------------------------------------------- -import Struct.Character -import Struct.Event - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_guide_icon_html : (Html.Html Struct.Event.Type) -get_guide_icon_html = - (Html.div - [(Html.Attributes.class "help-guide-icon")] - [] - ) - -get_header_with_icon_html : String -> String -> (Html.Html Struct.Event.Type) -get_header_with_icon_html title rank_name = - (Html.h1 - [] - [ - (get_guide_icon_html), - (Html.text (title ++ " - ")), - (Html.div - [ - (Html.Attributes.class - "message-board-help-figure" - ), - (Html.Attributes.class - ("character-card-" ++ rank_name ++ "-status") - ) - ] - [] - ) - ] - ) - -get_target_help_message : (List (Html.Html Struct.Event.Type)) -get_target_help_message = - [ - (get_header_with_icon_html "Protected Character" "target"), - (Html.text - ( - "Players that lose all of their Protected Characters are" - ++ " eliminated." - ) - ) - ] - -get_commander_help_message : (List (Html.Html Struct.Event.Type)) -get_commander_help_message = - [ - (get_header_with_icon_html "Critical Character" "commander"), - (Html.text - ( - "Players that lose any of their Critical Characters are" - ++ " eliminated." - ) - ) - ] - -get_optional_help_message : (List (Html.Html Struct.Event.Type)) -get_optional_help_message = - [ - (Html.h1 - [] - [ - (get_guide_icon_html), - (Html.text "Reinforcement Character") - ] - ), - (Html.text - ( - "Unless it is their very last character, losing a" - ++ " Reinforcement characters never causes a player to be" - ++ " eliminated." - ) - ) - ] - - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html_contents : ( - Struct.Character.Rank -> - (List (Html.Html Struct.Event.Type)) - ) -get_html_contents rank = - case rank of - Struct.Character.Target -> (get_target_help_message) - Struct.Character.Commander -> (get_commander_help_message) - Struct.Character.Optional -> (get_optional_help_message) diff --git a/src/battle/www/index.html b/src/battle/www/index.html index 9acc21c..0adf108 100644 --- a/src/battle/www/index.html +++ b/src/battle/www/index.html @@ -24,7 +24,7 @@ { user_id: tacticians_online.session.get_user_id(), token: tacticians_online.session.get_token(), - url_params: tacticians_online.urlparams.get_parameters() + url_parameters: tacticians_online.urlparams.get_parameters() }, node: document.getElementById("elm-page") } diff --git a/src/login/www/index.html b/src/login/www/index.html index ac5ab38..65c0402 100644 --- a/src/login/www/index.html +++ b/src/login/www/index.html @@ -22,7 +22,7 @@ { user_id: tacticians_online.session.get_user_id(), token: tacticians_online.session.get_token(), - url_params: tacticians_online.urlparams.get_parameters() + url_parameters: tacticians_online.urlparams.get_parameters() }, node: document.getElementById("elm-page") } diff --git a/src/main-menu/www/index.html b/src/main-menu/www/index.html index 02a0f2e..4cdf47c 100644 --- a/src/main-menu/www/index.html +++ b/src/main-menu/www/index.html @@ -22,7 +22,7 @@ { user_id: tacticians_online.session.get_user_id(), token: tacticians_online.session.get_token(), - url_params: tacticians_online.urlparams.get_parameters() + url_parameters: tacticians_online.urlparams.get_parameters() }, node: document.getElementById("elm-page") } diff --git a/src/map-editor/www/index.html b/src/map-editor/www/index.html index 6c68627..5bb7478 100644 --- a/src/map-editor/www/index.html +++ b/src/map-editor/www/index.html @@ -22,7 +22,7 @@ { user_id: tacticians_online.session.get_user_id(), token: tacticians_online.session.get_token(), - url_params: tacticians_online.urlparams.get_parameters() + url_parameters: tacticians_online.urlparams.get_parameters() }, node: document.getElementById("elm-element") } diff --git a/src/roster-editor/www/index.html b/src/roster-editor/www/index.html index 3ffd5af..8874f36 100644 --- a/src/roster-editor/www/index.html +++ b/src/roster-editor/www/index.html @@ -24,7 +24,7 @@ { user_id: tacticians_online.session.get_user_id(), token: tacticians_online.session.get_token(), - url_params: tacticians_online.urlparams.get_parameters() + url_parameters: tacticians_online.urlparams.get_parameters() }, node: document.getElementById("elm-element") } diff --git a/src/shared/battle-characters/BattleCharacters/Struct/StatusIndicator.elm b/src/shared/battle-characters/BattleCharacters/Struct/StatusIndicator.elm new file mode 100644 index 0000000..c982898 --- /dev/null +++ b/src/shared/battle-characters/BattleCharacters/Struct/StatusIndicator.elm @@ -0,0 +1,44 @@ +module BattleCharacters.Struct.StatusIndicator exposing + ( + Type, + decoder + ) + +-- Elm ------------------------------------------------------------------------- +import Set + +import Json.Decode +import Json.Decode.Pipeline + +-- Battle Character ------------------------------------------------------------ + +-------------------------------------------------------------------------------- +-- TYPES ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +type Visibility = + None + | Limited (Set.Set Int) + | All + +type alias Type = + { + ix : Int, + category : String, + parameter : String + } + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +decoder : (Json.Decode.Decoder Type) +decoder = + (Json.Decode.succeed + Type + |> (Json.Decode.Pipeline.required "i" Json.Decode.int) + |> (Json.Decode.Pipeline.required "c" Json.Decode.string) + |> (Json.Decode.Pipeline.required "p" Json.Decode.string) + ) -- cgit v1.2.3-70-g09d2