From 393a98b5ba0465d9e4dcb9c29c9fd3503f7d79b5 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Tue, 11 Sep 2018 18:54:02 +0200 Subject: Still working on the roster editor... --- src/roster-editor/src/ElmModule/View.elm | 13 +- src/roster-editor/src/Struct/Model.elm | 2 + src/roster-editor/src/Update/SelectCharacter.elm | 297 +----------- src/roster-editor/src/View/CharacterCard.elm | 485 ++++++++++++++++++ src/roster-editor/src/View/Controlled.elm | 144 +----- .../src/View/Controlled/CharacterCard.elm | 540 --------------------- .../src/View/Controlled/ManualControls.elm | 60 --- src/roster-editor/src/View/Controlled/Targets.elm | 69 --- src/roster-editor/src/View/SubMenu.elm | 85 ---- 9 files changed, 524 insertions(+), 1171 deletions(-) create mode 100644 src/roster-editor/src/View/CharacterCard.elm delete mode 100644 src/roster-editor/src/View/Controlled/CharacterCard.elm delete mode 100644 src/roster-editor/src/View/Controlled/ManualControls.elm delete mode 100644 src/roster-editor/src/View/Controlled/Targets.elm delete mode 100644 src/roster-editor/src/View/SubMenu.elm diff --git a/src/roster-editor/src/ElmModule/View.elm b/src/roster-editor/src/ElmModule/View.elm index 3f643f5..f559cb5 100644 --- a/src/roster-editor/src/ElmModule/View.elm +++ b/src/roster-editor/src/ElmModule/View.elm @@ -2,21 +2,16 @@ module ElmModule.View exposing (view) -- Elm ------------------------------------------------------------------------- import Html -import Html.Lazy import Html.Attributes --- Map ------------------------------------------------------------------- -import Constants.UI - +-- Roster Editor --------------------------------------------------------------- import Struct.Event import Struct.Model -import View.MessageBoard +import View.Controlled +import View.CurrentTab import View.MainMenu -import View.CharacterSelection -import View.PortraitSelection -import View.WeaponSelection -import View. +import View.MessageBoard -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- diff --git a/src/roster-editor/src/Struct/Model.elm b/src/roster-editor/src/Struct/Model.elm index 3e7fc01..43a1fe3 100644 --- a/src/roster-editor/src/Struct/Model.elm +++ b/src/roster-editor/src/Struct/Model.elm @@ -44,6 +44,7 @@ type alias Type = error: (Maybe Struct.Error.Type), player_id: String, roster_id: String, + edited_char: (Maybe Struct.Character.Type), session_token: String, ui: Struct.UI.Type } @@ -75,6 +76,7 @@ new flags = else flags.user_id ), session_token = flags.token, + edited_char = Nothing, ui = (Struct.UI.default) } in diff --git a/src/roster-editor/src/Update/SelectCharacter.elm b/src/roster-editor/src/Update/SelectCharacter.elm index 169046c..ab54e2d 100644 --- a/src/roster-editor/src/Update/SelectCharacter.elm +++ b/src/roster-editor/src/Update/SelectCharacter.elm @@ -3,296 +3,43 @@ module Update.SelectCharacter exposing (apply_to) -- Elm ------------------------------------------------------------------------- import Array -import Task - --- Map ------------------------------------------------------------------- -import Action.Scroll - -import Struct.Map +-- Roster Editor --------------------------------------------------------------- import Struct.Character -import Struct.CharacterTurn import Struct.Error import Struct.Event -import Struct.Location import Struct.Model -import Struct.Navigator -import Struct.Statistics -import Struct.UI -import Struct.Weapon -import Struct.WeaponSet -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- -get_character_navigator : ( - Struct.Model.Type -> - Struct.Character.Type -> - Struct.Navigator.Type - ) -get_character_navigator model char = - let - weapon = - (Struct.WeaponSet.get_active_weapon - (Struct.Character.get_weapons char) - ) - in - (Struct.Navigator.new - (Struct.Character.get_location char) - (Struct.Statistics.get_movement_points - (Struct.Character.get_statistics char) - ) - (Struct.Weapon.get_defense_range weapon) - (Struct.Weapon.get_attack_range weapon) - (Struct.Map.get_movement_cost_function - model.map - (Struct.Character.get_location char) - (Array.toList model.characters) - ) - ) - -attack_character : ( - Struct.Model.Type -> - Int -> - Struct.Character.Type -> - Struct.Model.Type - ) -attack_character model target_char_id target_char = - {model | - char_turn = - (Struct.CharacterTurn.set_target - (Just target_char_id) - model.char_turn - ), - ui = - (Struct.UI.reset_displayed_nav - (Struct.UI.reset_displayed_tab - (Struct.UI.set_previous_action Nothing model.ui) - ) - ) - } - -ctrl_or_focus_character : ( - Struct.Model.Type -> - Int -> - Struct.Character.Type -> - Struct.Model.Type - ) -ctrl_or_focus_character model target_char_id target_char = - if (Struct.Character.is_enabled target_char) - then - let - nav = - (case (Struct.UI.try_getting_displayed_nav model.ui) of - (Just dnav) -> dnav - Nothing -> - (get_character_navigator model target_char) - ) - in - {model | - char_turn = - (Struct.CharacterTurn.set_navigator - nav - (Struct.CharacterTurn.set_active_character - target_char - model.char_turn - ) - ), - ui = - (Struct.UI.reset_displayed_nav - (Struct.UI.reset_displayed_tab - (Struct.UI.set_previous_action Nothing model.ui) - ) - ) - } - else - {model | - ui = - (Struct.UI.set_previous_action - (Just (Struct.UI.SelectedCharacter target_char_id)) - (Struct.UI.set_displayed_nav - (get_character_navigator model target_char) - model.ui - ) - ) - } -can_target_character : ( - Struct.Model.Type -> - Struct.Character.Type -> - Bool - ) -can_target_character model target = +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +apply_to : Struct.Model.Type -> (Struct.Model.Type, (Cmd Struct.Event.Type)) +apply_to model target_char_ix = + -- TODO: store currently edited char, if it exists. + -- Basically, there will be a marker on characters to tell if they've been + -- edited. There will also be a "Save" button, like in the map editor, that + -- will send all modified characters to the server (and mark them as + -- up-to-date). ( - (Struct.CharacterTurn.can_select_target model.char_turn) - && (Struct.Character.is_alive target) - && ( - case - (Struct.CharacterTurn.try_getting_navigator - model.char_turn - ) - of - (Just nav) -> - case - (Struct.Navigator.try_getting_path_to - (Struct.Location.get_ref - (Struct.Character.get_location target) - ) - nav - ) - of - (Just _) -> True - _ -> False - - _ -> - False - ) - ) - -second_click_on : ( - Struct.Model.Type -> - Int -> - (Struct.Model.Type, (Cmd Struct.Event.Type)) - ) -second_click_on model target_char_id = - case (Array.get target_char_id model.characters) of - (Just target_char) -> - case - ( - (Struct.CharacterTurn.try_getting_active_character - model.char_turn - ), - (Struct.CharacterTurn.try_getting_target model.char_turn) - ) - of - ((Just _), (Just char_turn_target_id)) -> - if (char_turn_target_id == target_char_id) - then - ( - model, - Cmd.none - ) - else - ( - (ctrl_or_focus_character model target_char_id target_char), - (Task.attempt - (Struct.Event.attempted) - (Action.Scroll.to - (Struct.Character.get_location target_char) - model.ui - ) - ) - ) - - ((Just _), Nothing) -> - if (can_target_character model target_char) - then - ( - (attack_character - model - target_char_id - target_char - ), - Cmd.none - ) - else - ( - (ctrl_or_focus_character model target_char_id target_char), - (Task.attempt - (Struct.Event.attempted) - (Action.Scroll.to - (Struct.Character.get_location target_char) - model.ui - ) - ) - ) - - (_, _) -> - ( - (ctrl_or_focus_character model target_char_id target_char), - (Task.attempt - (Struct.Event.attempted) - (Action.Scroll.to - (Struct.Character.get_location target_char) - model.ui - ) - ) - ) - - Nothing -> - ( - (Struct.Model.invalidate - (Struct.Error.new - Struct.Error.Programming - "SelectCharacter: Unknown char selected." - ) - model - ), - Cmd.none - ) - -first_click_on : ( - Struct.Model.Type -> - Int -> - (Struct.Model.Type, (Cmd Struct.Event.Type)) - ) -first_click_on model target_char_id = - if - ( - (Struct.CharacterTurn.try_getting_target model.char_turn) - == - (Just target_char_id) - ) - then - (model, Cmd.none) - else - case (Array.get target_char_id model.characters) of - (Just target_char) -> - ( - {model | - ui = - (Struct.UI.set_previous_action - (Just (Struct.UI.SelectedCharacter target_char_id)) - (Struct.UI.set_displayed_tab - Struct.UI.StatusTab - (Struct.UI.set_displayed_nav - (get_character_navigator model target_char) - model.ui - ) - ) - ) - }, - Cmd.none - ) - - Nothing -> - ( + case (Array.get target_char_ix model.characters) of + Nothing -> (Struct.Model.invalidate (Struct.Error.new Struct.Error.Programming - "SelectCharacter: Unknown char selected." + ( + "Unknown character index selected \"" + ++ (toString target_char_ix) + ++ "\"." + ) ) model - ), - Cmd.none - ) + ) --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -apply_to : ( - Struct.Model.Type -> - Int -> - (Struct.Model.Type, (Cmd Struct.Event.Type)) - ) -apply_to model target_char_id = - if - ( - (Struct.UI.get_previous_action model.ui) - == - (Just (Struct.UI.SelectedCharacter target_char_id)) + (Just char) -> {model | edited_char = (Just char)} + ), + Cmd.none ) - then - (second_click_on model target_char_id) - else - (first_click_on model target_char_id) diff --git a/src/roster-editor/src/View/CharacterCard.elm b/src/roster-editor/src/View/CharacterCard.elm new file mode 100644 index 0000000..f3e8fb9 --- /dev/null +++ b/src/roster-editor/src/View/CharacterCard.elm @@ -0,0 +1,485 @@ +module View.Controlled.CharacterCard exposing + ( + get_minimal_html, + get_summary_html, + get_full_html + ) + +-- Elm ------------------------------------------------------------------------- +import List + +import Html +import Html.Attributes +import Html.Events + +-- Battle ---------------------------------------------------------------------- +import Struct.Armor +import Struct.Character +import Struct.CharacterTurn +import Struct.Event +import Struct.HelpRequest +import Struct.Navigator +import Struct.Omnimods +import Struct.Statistics +import Struct.Weapon +import Struct.WeaponSet + +import Util.Html + +import View.Character +import View.Gauge + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_name : ( + Struct.Character.Type -> + (Html.Html Struct.Event.Type) + ) +get_name char = + (Html.div + [ + (Html.Attributes.class "roster-info-card-name"), + (Html.Attributes.class "roster-info-card-text-field"), + (Html.Attributes.class "roster-character-card-name") + ] + [ + (Html.text (Struct.Character.get_name char)) + ] + ) + +get_health_bar : ( + Struct.Character.Type -> + (Html.Html Struct.Event.Type) + ) +get_health_bar char = + let + current = (Struct.Character.get_sane_current_health char) + max = + (Struct.Statistics.get_max_health + (Struct.Character.get_statistics char) + ) + in + (View.Gauge.get_html + ("HP: " ++ (toString current) ++ "/" ++ (toString max)) + (100.0 * ((toFloat current)/(toFloat max))) + [(Html.Attributes.class "roster-character-card-health")] + [] + [] + ) + +get_rank_status : ( + Struct.Character.Rank -> + (Html.Html Struct.Event.Type) + ) +get_rank_status rank = + (Html.div + [ + (Html.Attributes.class "roster-character-card-status"), + (Html.Attributes.class "clickable"), + (Html.Events.onClick + (Struct.Event.RequestedHelp (Struct.HelpRequest.HelpOnRank rank)) + ), + (Html.Attributes.class + ( + case rank of + Struct.Character.Commander -> + "roster-character-card-commander-status" + + Struct.Character.Target -> + "roster-character-card-target-status" + + Struct.Character.Optional -> "" + ) + ) + ] + [ + ] + ) + +get_statuses : ( + Struct.Character.Type -> + (Html.Html Struct.Event.Type) + ) +get_statuses char = + (Html.div + [ + (Html.Attributes.class "roster-character-card-statuses") + ] + [ + ( + case (Struct.Character.get_rank char) of + Struct.Character.Optional -> (Util.Html.nothing) + other -> (get_rank_status other) + ) + ] + ) + +get_active_movement_bar : ( + (Maybe Struct.Navigator.Type) -> + Struct.Character.Type -> + (Html.Html Struct.Event.Type) + ) +get_active_movement_bar maybe_navigator char = + let + max = + (Struct.Statistics.get_movement_points + (Struct.Character.get_statistics char) + ) + current = + case maybe_navigator of + (Just navigator) -> + (Struct.Navigator.get_remaining_points navigator) + + Nothing -> + max + in + (View.Gauge.get_html + ("MP: " ++ (toString current) ++ "/" ++ (toString max)) + (100.0 * ((toFloat current)/(toFloat max))) + [(Html.Attributes.class "roster-character-card-movement")] + [] + [] + ) + +get_inactive_movement_bar : ( + Struct.Character.Type -> + (Html.Html Struct.Event.Type) + ) +get_inactive_movement_bar char = + let + max = + (Struct.Statistics.get_movement_points + (Struct.Character.get_statistics char) + ) + in + (View.Gauge.get_html + ( + "MP: " + ++ + (toString + (Struct.Statistics.get_movement_points + (Struct.Character.get_statistics char) + ) + ) + ) + 100.0 + [(Html.Attributes.class "roster-character-card-movement")] + [] + [] + ) + +get_movement_bar : ( + Struct.CharacterTurn.Type -> + Struct.Character.Type -> + (Html.Html Struct.Event.Type) + ) +get_movement_bar char_turn char = + case (Struct.CharacterTurn.try_getting_active_character char_turn) of + (Just active_char) -> + if + ( + (Struct.Character.get_index active_char) + == + (Struct.Character.get_index char) + ) + then + (get_active_movement_bar + (Struct.CharacterTurn.try_getting_navigator char_turn) + active_char + ) + else + (get_inactive_movement_bar char) + + Nothing -> + (get_inactive_movement_bar char) + +get_weapon_field_header : ( + Float -> + Struct.Weapon.Type -> + (Html.Html Struct.Event.Type) + ) +get_weapon_field_header damage_multiplier weapon = + (Html.div + [ + (Html.Attributes.class "roster-character-card-header") + ] + [ + (Html.div + [ + ] + [ + (Html.text (Struct.Weapon.get_name weapon)) + ] + ), + (Html.div + [ + ] + [ + (Html.text + ( + "~" + ++ + (toString + (ceiling + ( + (toFloat (Struct.Weapon.get_damage_sum weapon)) + * damage_multiplier + ) + ) + ) + ++ " dmg @ [" + ++ (toString (Struct.Weapon.get_defense_range weapon)) + ++ ", " + ++ (toString (Struct.Weapon.get_attack_range weapon)) + ++ "]" + ) + ) + ] + ) + ] + ) + +get_mod_html : (String, Int) -> (Html.Html Struct.Event.Type) +get_mod_html mod = + let + (category, value) = mod + in + (Html.div + [ + (Html.Attributes.class "roster-info-card-mod") + ] + [ + (Html.text + (category ++ ": " ++ (toString 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 "roster-character-card-mod") + ] + [ + (Html.text + ( + category + ++ ": " + ++ (toString (ceiling ((toFloat value) * multiplier))) + ) + ) + ] + ) + +get_weapon_details : ( + Struct.Omnimods.Type -> + Float -> + Struct.Weapon.Type -> + (Html.Html Struct.Event.Type) + ) +get_weapon_details omnimods damage_multiplier weapon = + (Html.div + [ + (Html.Attributes.class "roster-character-card-weapon") + ] + [ + (get_weapon_field_header damage_multiplier weapon), + (Html.div + [ + (Html.Attributes.class "roster-info-card-omnimods-listing") + ] + (List.map + (get_multiplied_mod_html damage_multiplier) + (Struct.Omnimods.get_attack_mods omnimods) + ) + ) + ] + ) + +get_weapon_summary : ( + Float -> + Struct.Weapon.Type -> + (Html.Html Struct.Event.Type) + ) +get_weapon_summary damage_multiplier weapon = + (Html.div + [ + (Html.Attributes.class "roster-character-card-weapon-summary") + ] + [ + (get_weapon_field_header damage_multiplier weapon) + ] + ) + +get_armor_details : ( + Struct.Omnimods.Type -> + Struct.Armor.Type -> + (Html.Html Struct.Event.Type) + ) +get_armor_details omnimods armor = + (Html.div + [ + (Html.Attributes.class "roster-character-card-armor") + ] + [ + (Html.div + [ + (Html.Attributes.class "roster-character-card-armor-name") + ] + [ + (Html.text (Struct.Armor.get_name armor)) + ] + ), + (Html.div + [ + (Html.Attributes.class "roster-info-card-omnimods-listing") + ] + (List.map + (get_mod_html) + (Struct.Omnimods.get_defense_mods omnimods) + ) + ) + ] + ) + +stat_name : String -> (Html.Html Struct.Event.Type) +stat_name name = + (Html.div + [ + (Html.Attributes.class "roster-character-card-stat-name") + ] + [ + (Html.text name) + ] + ) + +stat_val : Int -> Bool -> (Html.Html Struct.Event.Type) +stat_val val perc = + (Html.div + [ + (Html.Attributes.class "roster-character-card-stat-val") + ] + [ + (Html.text + ( + (toString val) + ++ + ( + if perc + then + "%" + else + "" + ) + ) + ) + ] + ) + +get_relevant_stats : ( + Struct.Statistics.Type -> + (Html.Html Struct.Event.Type) + ) +get_relevant_stats stats = + (Html.div + [ + (Html.Attributes.class "roster-character-card-stats") + ] + [ + (stat_name "Dodge"), + (stat_val (Struct.Statistics.get_dodges stats) True), + (stat_name "Parry"), + (stat_val (Struct.Statistics.get_parries stats) True), + (stat_name "Accu."), + (stat_val (Struct.Statistics.get_accuracy stats) False), + (stat_name "2xHit"), + (stat_val (Struct.Statistics.get_double_hits stats) True), + (stat_name "Crit."), + (stat_val (Struct.Statistics.get_critical_hits stats) True) + ] + ) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_minimal_html : Struct.Character.Type -> (Html.Html Struct.Event.Type) +get_minimal_html char = + (Html.div + [ + (Html.Attributes.class "roster-info-card"), + (Html.Attributes.class "roster-info-card-minimal"), + (Html.Attributes.class "roster-character-card"), + (Html.Attributes.class "roster-character-card-minimal") + ] + [ + (get_name char), + (Html.div + [ + (Html.Attributes.class "roster-info-card-top"), + (Html.Attributes.class "roster-character-card-top") + ] + [ + (Html.div + [ + (Html.Attributes.class "roster-info-card-picture") + ] + [ + (View.Character.get_portrait_html char) + ] + ), + (get_health_bar char), + (get_inactive_movement_bar char), + (get_statuses char) + ] + ) + ] + ) + +get_full_html : Struct.Character.Type -> (Html.Html Struct.Event.Type) +get_full_html char = + let + weapon_set = (Struct.Character.get_weapons char) + main_weapon = (Struct.WeaponSet.get_active_weapon weapon_set) + char_statistics = (Struct.Character.get_statistics char) + damage_modifier = (Struct.Statistics.get_damage_modifier char_statistics) + secondary_weapon = (Struct.WeaponSet.get_secondary_weapon weapon_set) + armor = (Struct.Character.get_armor char) + omnimods = (Struct.Character.get_current_omnimods char) + in + (Html.div + [ + (Html.Attributes.class "roster-info-card"), + (Html.Attributes.class "roster-character-card") + ] + [ + (get_name char), + (Html.div + [ + (Html.Attributes.class "roster-info-card-top"), + (Html.Attributes.class "roster-character-card-top") + ] + [ + (Html.div + [ + (Html.Attributes.class "roster-info-card-picture") + ] + [ + (View.Character.get_portrait_html char) + ] + ), + (get_health_bar char), + (get_inactive_movement_bar char), + (get_statuses char) + ] + ), + (get_weapon_details omnimods damage_modifier main_weapon), + (get_armor_details omnimods armor), + (get_relevant_stats char_statistics), + (get_weapon_summary damage_modifier secondary_weapon) + ] + ) diff --git a/src/roster-editor/src/View/Controlled.elm b/src/roster-editor/src/View/Controlled.elm index d0c33a5..45c8a70 100644 --- a/src/roster-editor/src/View/Controlled.elm +++ b/src/roster-editor/src/View/Controlled.elm @@ -3,156 +3,34 @@ module View.Controlled exposing (get_html) -- Elm ------------------------------------------------------------------------- import Html import Html.Attributes -import Html.Events +import Html.Lazy --- Struct.Map ------------------------------------------------------------------- -import Struct.CharacterTurn +-- Roster Editor --------------------------------------------------------------- import Struct.Event -import Struct.Navigator +import Struct.Model import Util.Html -import View.Controlled.CharacterCard -import View.Controlled.ManualControls +import View.CharacterCard -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- -has_a_path : Struct.CharacterTurn.Type -> Bool -has_a_path char_turn = - case (Struct.CharacterTurn.try_getting_navigator char_turn) of - (Just nav) -> ((Struct.Navigator.get_path nav) /= []) - Nothing -> False - - -attack_button : Struct.CharacterTurn.Type -> (Html.Html Struct.Event.Type) -attack_button char_turn = - (Html.button - [ (Html.Events.onClick Struct.Event.AttackWithoutMovingRequest) ] - [ - (Html.text - ( - if (has_a_path char_turn) - then ("Go & Select Target") - else ("Select Target") - ) - ) - ] - ) - -abort_button : (Html.Html Struct.Event.Type) -abort_button = - (Html.button - [ (Html.Events.onClick Struct.Event.AbortTurnRequest) ] - [ (Html.text "Abort") ] - ) - -undo_button : (Html.Html Struct.Event.Type) -undo_button = - (Html.button - [ (Html.Events.onClick Struct.Event.UndoActionRequest) ] - [ (Html.text "Undo") ] - ) - -end_turn_button : String -> (Html.Html Struct.Event.Type) -end_turn_button suffix = - (Html.button - [ - (Html.Events.onClick Struct.Event.TurnEnded), - (Html.Attributes.class "battle-end-turn-button") - ] - [ (Html.text ("End Turn" ++ suffix)) ] - ) - -inventory_button : Bool -> (Html.Html Struct.Event.Type) -inventory_button go_prefix = - (Html.button - [ (Html.Events.onClick Struct.Event.WeaponSwitchRequest) ] - [ - (Html.text - ( - if (go_prefix) - then ("Go & Switch Weapon") - else ("Switch Weapon") - ) - ) - ] - ) - -get_available_actions : ( - Struct.CharacterTurn.Type -> - (List (Html.Html Struct.Event.Type)) - ) -get_available_actions char_turn = - case (Struct.CharacterTurn.get_state char_turn) of - Struct.CharacterTurn.SelectedCharacter -> - [ - (attack_button char_turn), - (inventory_button (has_a_path char_turn)), - (end_turn_button " Doing Nothing"), - (abort_button) - ] - - Struct.CharacterTurn.MovedCharacter -> - [ - (inventory_button False), - (end_turn_button " by Moving"), - (undo_button), - (abort_button) - ] - - Struct.CharacterTurn.ChoseTarget -> - [ - (end_turn_button " by Attacking"), - (undo_button), - (abort_button) - ] - - Struct.CharacterTurn.SwitchedWeapons -> - [ - (end_turn_button " by Switching Weapons"), - (undo_button), - (abort_button) - ] - - _ -> - [ - ] -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- -get_html : Struct.CharacterTurn.Type -> Int -> (Html.Html Struct.Event.Type) -get_html char_turn player_ix = - case - (Struct.CharacterTurn.try_getting_active_character char_turn) - of +get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) +get_html model = + case model.edited_char of + Nothing -> (Util.Html.nothing) (Just char) -> (Html.div - [(Html.Attributes.class "battle-controlled")] + [(Html.Attributes.class "roster-editor-controlled")] [ - (View.Controlled.CharacterCard.get_summary_html - char_turn - player_ix + (Html.Lazy.lazy + (View.CharacterCard.get_summary_html) char - ), - ( - if - ( - (Struct.CharacterTurn.get_state char_turn) - == - Struct.CharacterTurn.SelectedCharacter - ) - then - (View.Controlled.ManualControls.get_html) - else - (Util.Html.nothing) - ), - (Html.div - [(Html.Attributes.class "battle-controlled-actions")] - (get_available_actions char_turn) ) ] ) - - Nothing -> (Util.Html.nothing) diff --git a/src/roster-editor/src/View/Controlled/CharacterCard.elm b/src/roster-editor/src/View/Controlled/CharacterCard.elm deleted file mode 100644 index ac56cbb..0000000 --- a/src/roster-editor/src/View/Controlled/CharacterCard.elm +++ /dev/null @@ -1,540 +0,0 @@ -module View.Controlled.CharacterCard exposing - ( - get_minimal_html, - get_summary_html, - get_full_html - ) - --- Elm ------------------------------------------------------------------------- -import List - -import Html -import Html.Attributes -import Html.Events - --- Battle ---------------------------------------------------------------------- -import Struct.Armor -import Struct.Character -import Struct.CharacterTurn -import Struct.Event -import Struct.HelpRequest -import Struct.Navigator -import Struct.Omnimods -import Struct.Statistics -import Struct.Weapon -import Struct.WeaponSet - -import Util.Html - -import View.Character -import View.Gauge - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_name : ( - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_name char = - (Html.div - [ - (Html.Attributes.class "battle-info-card-name"), - (Html.Attributes.class "battle-info-card-text-field"), - (Html.Attributes.class "battle-character-card-name") - ] - [ - (Html.text (Struct.Character.get_name char)) - ] - ) - -get_health_bar : ( - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_health_bar char = - let - current = (Struct.Character.get_sane_current_health char) - max = - (Struct.Statistics.get_max_health - (Struct.Character.get_statistics char) - ) - in - (View.Gauge.get_html - ("HP: " ++ (toString current) ++ "/" ++ (toString max)) - (100.0 * ((toFloat current)/(toFloat max))) - [(Html.Attributes.class "battle-character-card-health")] - [] - [] - ) - -get_rank_status : ( - Struct.Character.Rank -> - (Html.Html Struct.Event.Type) - ) -get_rank_status rank = - (Html.div - [ - (Html.Attributes.class "battle-character-card-status"), - (Html.Attributes.class "clickable"), - (Html.Events.onClick - (Struct.Event.RequestedHelp (Struct.HelpRequest.HelpOnRank rank)) - ), - (Html.Attributes.class - ( - case rank of - Struct.Character.Commander -> - "battle-character-card-commander-status" - - Struct.Character.Target -> - "battle-character-card-target-status" - - Struct.Character.Optional -> "" - ) - ) - ] - [ - ] - ) - -get_statuses : ( - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_statuses char = - (Html.div - [ - (Html.Attributes.class "battle-character-card-statuses") - ] - [ - ( - case (Struct.Character.get_rank char) of - Struct.Character.Optional -> (Util.Html.nothing) - other -> (get_rank_status other) - ) - ] - ) - -get_active_movement_bar : ( - (Maybe Struct.Navigator.Type) -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_active_movement_bar maybe_navigator char = - let - max = - (Struct.Statistics.get_movement_points - (Struct.Character.get_statistics char) - ) - current = - case maybe_navigator of - (Just navigator) -> - (Struct.Navigator.get_remaining_points navigator) - - Nothing -> - max - in - (View.Gauge.get_html - ("MP: " ++ (toString current) ++ "/" ++ (toString max)) - (100.0 * ((toFloat current)/(toFloat max))) - [(Html.Attributes.class "battle-character-card-movement")] - [] - [] - ) - -get_inactive_movement_bar : ( - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_inactive_movement_bar char = - let - max = - (Struct.Statistics.get_movement_points - (Struct.Character.get_statistics char) - ) - in - (View.Gauge.get_html - ( - "MP: " - ++ - (toString - (Struct.Statistics.get_movement_points - (Struct.Character.get_statistics char) - ) - ) - ) - 100.0 - [(Html.Attributes.class "battle-character-card-movement")] - [] - [] - ) - -get_movement_bar : ( - Struct.CharacterTurn.Type -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_movement_bar char_turn char = - case (Struct.CharacterTurn.try_getting_active_character char_turn) of - (Just active_char) -> - if - ( - (Struct.Character.get_index active_char) - == - (Struct.Character.get_index char) - ) - then - (get_active_movement_bar - (Struct.CharacterTurn.try_getting_navigator char_turn) - active_char - ) - else - (get_inactive_movement_bar char) - - Nothing -> - (get_inactive_movement_bar char) - -get_weapon_field_header : ( - Float -> - Struct.Weapon.Type -> - (Html.Html Struct.Event.Type) - ) -get_weapon_field_header damage_multiplier weapon = - (Html.div - [ - (Html.Attributes.class "battle-character-card-header") - ] - [ - (Html.div - [ - ] - [ - (Html.text (Struct.Weapon.get_name weapon)) - ] - ), - (Html.div - [ - ] - [ - (Html.text - ( - "~" - ++ - (toString - (ceiling - ( - (toFloat (Struct.Weapon.get_damage_sum weapon)) - * damage_multiplier - ) - ) - ) - ++ " dmg @ [" - ++ (toString (Struct.Weapon.get_defense_range weapon)) - ++ ", " - ++ (toString (Struct.Weapon.get_attack_range weapon)) - ++ "]" - ) - ) - ] - ) - ] - ) - -get_mod_html : (String, Int) -> (Html.Html Struct.Event.Type) -get_mod_html mod = - let - (category, value) = mod - in - (Html.div - [ - (Html.Attributes.class "battle-info-card-mod") - ] - [ - (Html.text - (category ++ ": " ++ (toString 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 "battle-character-card-mod") - ] - [ - (Html.text - ( - category - ++ ": " - ++ (toString (ceiling ((toFloat value) * multiplier))) - ) - ) - ] - ) - -get_weapon_details : ( - Struct.Omnimods.Type -> - Float -> - Struct.Weapon.Type -> - (Html.Html Struct.Event.Type) - ) -get_weapon_details omnimods damage_multiplier weapon = - (Html.div - [ - (Html.Attributes.class "battle-character-card-weapon") - ] - [ - (get_weapon_field_header damage_multiplier weapon), - (Html.div - [ - (Html.Attributes.class "battle-info-card-omnimods-listing") - ] - (List.map - (get_multiplied_mod_html damage_multiplier) - (Struct.Omnimods.get_attack_mods omnimods) - ) - ) - ] - ) - -get_weapon_summary : ( - Float -> - Struct.Weapon.Type -> - (Html.Html Struct.Event.Type) - ) -get_weapon_summary damage_multiplier weapon = - (Html.div - [ - (Html.Attributes.class "battle-character-card-weapon-summary") - ] - [ - (get_weapon_field_header damage_multiplier weapon) - ] - ) - -get_armor_details : ( - Struct.Omnimods.Type -> - Struct.Armor.Type -> - (Html.Html Struct.Event.Type) - ) -get_armor_details omnimods armor = - (Html.div - [ - (Html.Attributes.class "battle-character-card-armor") - ] - [ - (Html.div - [ - (Html.Attributes.class "battle-character-card-armor-name") - ] - [ - (Html.text (Struct.Armor.get_name armor)) - ] - ), - (Html.div - [ - (Html.Attributes.class "battle-info-card-omnimods-listing") - ] - (List.map - (get_mod_html) - (Struct.Omnimods.get_defense_mods omnimods) - ) - ) - ] - ) - -stat_name : String -> (Html.Html Struct.Event.Type) -stat_name name = - (Html.div - [ - (Html.Attributes.class "battle-character-card-stat-name") - ] - [ - (Html.text name) - ] - ) - -stat_val : Int -> Bool -> (Html.Html Struct.Event.Type) -stat_val val perc = - (Html.div - [ - (Html.Attributes.class "battle-character-card-stat-val") - ] - [ - (Html.text - ( - (toString val) - ++ - ( - if perc - then - "%" - else - "" - ) - ) - ) - ] - ) - -get_relevant_stats : ( - Struct.Statistics.Type -> - (Html.Html Struct.Event.Type) - ) -get_relevant_stats stats = - (Html.div - [ - (Html.Attributes.class "battle-character-card-stats") - ] - [ - (stat_name "Dodge"), - (stat_val (Struct.Statistics.get_dodges stats) True), - (stat_name "Parry"), - (stat_val (Struct.Statistics.get_parries stats) True), - (stat_name "Accu."), - (stat_val (Struct.Statistics.get_accuracy stats) False), - (stat_name "2xHit"), - (stat_val (Struct.Statistics.get_double_hits stats) True), - (stat_name "Crit."), - (stat_val (Struct.Statistics.get_critical_hits stats) True) - ] - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_minimal_html : ( - Int -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_minimal_html player_ix char = - (Html.div - [ - (Html.Attributes.class "battle-info-card"), - (Html.Attributes.class "battle-info-card-minimal"), - (Html.Attributes.class "battle-character-card"), - (Html.Attributes.class "battle-character-card-minimal") - ] - [ - (get_name char), - (Html.div - [ - (Html.Attributes.class "battle-info-card-top"), - (Html.Attributes.class "battle-character-card-top") - ] - [ - (Html.div - [ - (Html.Attributes.class "battle-info-card-picture") - ] - [ - (View.Character.get_portrait_html player_ix char) - ] - ), - (get_health_bar char), - (get_inactive_movement_bar char), - (get_statuses char) - ] - ) - ] - ) - -get_summary_html : ( - Struct.CharacterTurn.Type -> - Int -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_summary_html char_turn player_ix char = - let - weapon_set = (Struct.Character.get_weapons char) - main_weapon = (Struct.WeaponSet.get_active_weapon weapon_set) - char_statistics = (Struct.Character.get_statistics char) - damage_modifier = (Struct.Statistics.get_damage_modifier char_statistics) - secondary_weapon = (Struct.WeaponSet.get_secondary_weapon weapon_set) - omnimods = (Struct.Character.get_current_omnimods char) - in - (Html.div - [ - (Html.Attributes.class "battle-character-card") - ] - [ - (get_name char), - (Html.div - [ - (Html.Attributes.class "battle-info-card-top"), - (Html.Attributes.class "battle-character-card-top") - ] - [ - (Html.div - [ - (Html.Attributes.class "battle-info-card-picture") - ] - [ - (View.Character.get_portrait_html player_ix char) - ] - ), - (get_health_bar char), - (get_movement_bar char_turn char), - (get_statuses char) - ] - ), - (get_weapon_details omnimods damage_modifier main_weapon), - (get_armor_details omnimods (Struct.Character.get_armor char)), - (get_relevant_stats char_statistics), - (get_weapon_summary damage_modifier secondary_weapon) - ] - ) - -get_full_html : ( - Int -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_full_html player_ix char = - let - weapon_set = (Struct.Character.get_weapons char) - main_weapon = (Struct.WeaponSet.get_active_weapon weapon_set) - char_statistics = (Struct.Character.get_statistics char) - damage_modifier = (Struct.Statistics.get_damage_modifier char_statistics) - secondary_weapon = (Struct.WeaponSet.get_secondary_weapon weapon_set) - armor = (Struct.Character.get_armor char) - omnimods = (Struct.Character.get_current_omnimods char) - in - (Html.div - [ - (Html.Attributes.class "battle-info-card"), - (Html.Attributes.class "battle-character-card") - ] - [ - (get_name char), - (Html.div - [ - (Html.Attributes.class "battle-info-card-top"), - (Html.Attributes.class "battle-character-card-top") - ] - [ - (Html.div - [ - (Html.Attributes.class "battle-info-card-picture") - ] - [ - (View.Character.get_portrait_html player_ix char) - ] - ), - (get_health_bar char), - (get_inactive_movement_bar char), - (get_statuses char) - ] - ), - (get_weapon_details omnimods damage_modifier main_weapon), - (get_armor_details omnimods armor), - (get_relevant_stats char_statistics), - (get_weapon_summary damage_modifier secondary_weapon) - ] - ) diff --git a/src/roster-editor/src/View/Controlled/ManualControls.elm b/src/roster-editor/src/View/Controlled/ManualControls.elm deleted file mode 100644 index 1dceafb..0000000 --- a/src/roster-editor/src/View/Controlled/ManualControls.elm +++ /dev/null @@ -1,60 +0,0 @@ -module View.Controlled.ManualControls exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Html -import Html.Attributes -import Html.Events - --- Map ------------------------------------------------------------------- -import Struct.Direction -import Struct.Event - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -direction_button : ( - Struct.Direction.Type -> - String -> - (Html.Html Struct.Event.Type) - ) -direction_button dir label = - (Html.div - [ - (Html.Attributes.class ("battle-manual-controls-" ++ label)), - (Html.Attributes.class "clickable"), - (Html.Events.onClick - (Struct.Event.DirectionRequested dir) - ) - ] - [] - ) - -go_button : (Html.Html Struct.Event.Type) -go_button = - (Html.button - [ - (Html.Attributes.class "battle-manual-controls-go"), - (Html.Events.onClick Struct.Event.AttackWithoutMovingRequest) - ] - [ - (Html.text "Go") - ] - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : (Html.Html Struct.Event.Type) -get_html = - (Html.div - [ - (Html.Attributes.class "battle-manual-controls") - ] - [ - (direction_button Struct.Direction.Left "left"), - (direction_button Struct.Direction.Down "down"), - (direction_button Struct.Direction.Up "up"), - (direction_button Struct.Direction.Right "right"), - (go_button) - ] - ) diff --git a/src/roster-editor/src/View/Controlled/Targets.elm b/src/roster-editor/src/View/Controlled/Targets.elm deleted file mode 100644 index eee5a54..0000000 --- a/src/roster-editor/src/View/Controlled/Targets.elm +++ /dev/null @@ -1,69 +0,0 @@ -module View.SideBar.Targets exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Dict - -import Html -import Html.Attributes - --- Map ------------------------------------------------------------------- -import Struct.Character -import Struct.Event -import Struct.Model -import Struct.Statistics - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - -get_target_info_html : ( - Struct.Model.Type -> - Struct.Character.Ref -> - (Html.Html Struct.Event.Type) - ) -get_target_info_html model char_ref = - case (Dict.get char_ref model.characters) of - Nothing -> (Html.text "Error: Unknown character selected.") - (Just char) -> - (Html.text - ( - "Attacking " - ++ char.name - ++ " (player " - ++ (toString (Struct.Character.get_player_ix char)) - ++ "): " - ++ - (toString - (Struct.Statistics.get_movement_points - (Struct.Character.get_statistics char) - ) - ) - ++ " movement points; " - ++ "???" - ++ " attack range. Health: " - ++ (toString (Struct.Character.get_sane_current_health char)) - ++ "/" - ++ - (toString - (Struct.Statistics.get_max_health - (Struct.Character.get_statistics char) - ) - ) - ) - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : ( - Struct.Model.Type -> - Struct.Character.Ref -> - (Html.Html Struct.Event.Type) - ) -get_html model target_ref = - (Html.div - [ - (Html.Attributes.class "battle-side-bar-targets") - ] - [(get_target_info_html model target_ref)] - ) diff --git a/src/roster-editor/src/View/SubMenu.elm b/src/roster-editor/src/View/SubMenu.elm deleted file mode 100644 index e661b9c..0000000 --- a/src/roster-editor/src/View/SubMenu.elm +++ /dev/null @@ -1,85 +0,0 @@ -module View.SubMenu exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Array - -import Html -import Html.Attributes -import Html.Lazy - --- Map ------------------------------------------------------------------- -import Struct.CharacterTurn -import Struct.Event -import Struct.Model -import Struct.UI - -import Util.Html - -import View.Controlled.CharacterCard - -import View.SubMenu.Characters -import View.SubMenu.Settings -import View.SubMenu.Status -import View.SubMenu.Timeline - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_inner_html : ( - Struct.Model.Type -> - Struct.UI.Tab -> - (Html.Html Struct.Event.Type) - ) -get_inner_html model tab = - case tab of - Struct.UI.StatusTab -> - (View.SubMenu.Status.get_html model) - - Struct.UI.CharactersTab -> - (Html.Lazy.lazy2 - (View.SubMenu.Characters.get_html) - model.characters - model.player_ix - ) - - Struct.UI.SettingsTab -> - (View.SubMenu.Settings.get_html model) - - Struct.UI.TimelineTab -> - (View.SubMenu.Timeline.get_html model) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) -get_html model = - case (Struct.UI.try_getting_displayed_tab model.ui) of - (Just tab) -> - (Html.div - [(Html.Attributes.class "battle-sub-menu")] - [(get_inner_html model tab)] - ) - - Nothing -> - case (Struct.CharacterTurn.try_getting_target model.char_turn) of - (Just char_ref) -> - case (Array.get char_ref model.characters) of - (Just char) -> - (Html.div - [(Html.Attributes.class "battle-sub-menu")] - [ - (Html.text "Targeting:"), - (Html.Lazy.lazy3 - (View.Controlled.CharacterCard.get_summary_html) - model.char_turn - model.player_ix - char - ) - ] - ) - - Nothing -> - (Util.Html.nothing) - - Nothing -> - (Util.Html.nothing) -- cgit v1.2.3-70-g09d2