From 9035652f997759aa76825e1d0be358b1c78c7152 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Tue, 17 Apr 2018 21:16:45 +0200 Subject: Re-activates the (somewhat broken) sub-menus. --- src/battlemap/src/Update/SelectCharacter.elm | 5 +- .../src/View/Controlled/ManualControls.elm | 45 +++ src/battlemap/src/View/Controlled/Targets.elm | 69 ++++ src/battlemap/src/View/SubMenu.elm | 26 +- src/battlemap/src/View/SubMenu/Characters.elm | 101 ++++++ src/battlemap/src/View/SubMenu/ManualControls.elm | 45 --- src/battlemap/src/View/SubMenu/Settings.elm | 53 +++ src/battlemap/src/View/SubMenu/Status.elm | 157 +++++++++ .../src/View/SubMenu/Status/CharacterInfo.elm | 364 +++++++++++++++++++++ .../src/View/SubMenu/TabMenu/Characters.elm | 101 ------ .../src/View/SubMenu/TabMenu/Settings.elm | 53 --- src/battlemap/src/View/SubMenu/TabMenu/Status.elm | 157 --------- .../View/SubMenu/TabMenu/Status/CharacterInfo.elm | 364 --------------------- .../src/View/SubMenu/TabMenu/Timeline.elm | 66 ---- .../src/View/SubMenu/TabMenu/Timeline/Attack.elm | 191 ----------- .../src/View/SubMenu/TabMenu/Timeline/Movement.elm | 88 ----- .../View/SubMenu/TabMenu/Timeline/WeaponSwitch.elm | 84 ----- src/battlemap/src/View/SubMenu/Targets.elm | 69 ---- src/battlemap/src/View/SubMenu/Timeline.elm | 66 ++++ src/battlemap/src/View/SubMenu/Timeline/Attack.elm | 191 +++++++++++ .../src/View/SubMenu/Timeline/Movement.elm | 88 +++++ .../src/View/SubMenu/Timeline/WeaponSwitch.elm | 84 +++++ 22 files changed, 1242 insertions(+), 1225 deletions(-) create mode 100644 src/battlemap/src/View/Controlled/ManualControls.elm create mode 100644 src/battlemap/src/View/Controlled/Targets.elm create mode 100644 src/battlemap/src/View/SubMenu/Characters.elm delete mode 100644 src/battlemap/src/View/SubMenu/ManualControls.elm create mode 100644 src/battlemap/src/View/SubMenu/Settings.elm create mode 100644 src/battlemap/src/View/SubMenu/Status.elm create mode 100644 src/battlemap/src/View/SubMenu/Status/CharacterInfo.elm delete mode 100644 src/battlemap/src/View/SubMenu/TabMenu/Characters.elm delete mode 100644 src/battlemap/src/View/SubMenu/TabMenu/Settings.elm delete mode 100644 src/battlemap/src/View/SubMenu/TabMenu/Status.elm delete mode 100644 src/battlemap/src/View/SubMenu/TabMenu/Status/CharacterInfo.elm delete mode 100644 src/battlemap/src/View/SubMenu/TabMenu/Timeline.elm delete mode 100644 src/battlemap/src/View/SubMenu/TabMenu/Timeline/Attack.elm delete mode 100644 src/battlemap/src/View/SubMenu/TabMenu/Timeline/Movement.elm delete mode 100644 src/battlemap/src/View/SubMenu/TabMenu/Timeline/WeaponSwitch.elm delete mode 100644 src/battlemap/src/View/SubMenu/Targets.elm create mode 100644 src/battlemap/src/View/SubMenu/Timeline.elm create mode 100644 src/battlemap/src/View/SubMenu/Timeline/Attack.elm create mode 100644 src/battlemap/src/View/SubMenu/Timeline/Movement.elm create mode 100644 src/battlemap/src/View/SubMenu/Timeline/WeaponSwitch.elm (limited to 'src') diff --git a/src/battlemap/src/Update/SelectCharacter.elm b/src/battlemap/src/Update/SelectCharacter.elm index 3f0dbd4..152aa9c 100644 --- a/src/battlemap/src/Update/SelectCharacter.elm +++ b/src/battlemap/src/Update/SelectCharacter.elm @@ -73,7 +73,10 @@ ctrl_or_focus_character model target_char_id target_char = model.char_turn ) ), - ui = (Struct.UI.set_previous_action model.ui Nothing) + ui = + (Struct.UI.reset_displayed_tab + (Struct.UI.set_previous_action model.ui Nothing) + ) } else {model | diff --git a/src/battlemap/src/View/Controlled/ManualControls.elm b/src/battlemap/src/View/Controlled/ManualControls.elm new file mode 100644 index 0000000..8d37333 --- /dev/null +++ b/src/battlemap/src/View/Controlled/ManualControls.elm @@ -0,0 +1,45 @@ +module View.ManualControls exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Html +import Html.Attributes +import Html.Events + +-- Battlemap ------------------------------------------------------------------- +import Struct.Direction +import Struct.Event + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +direction_button : ( + Struct.Direction.Type -> + String -> + (Html.Html Struct.Event.Type) + ) +direction_button dir label = + (Html.button + [ + (Html.Events.onClick + (Struct.Event.DirectionRequested dir) + ) + ] + [ (Html.text label) ] + ) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : (Html.Html Struct.Event.Type) +get_html = + (Html.div + [ + (Html.Attributes.class "battlemap-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") + ] + ) diff --git a/src/battlemap/src/View/Controlled/Targets.elm b/src/battlemap/src/View/Controlled/Targets.elm new file mode 100644 index 0000000..7bb4c36 --- /dev/null +++ b/src/battlemap/src/View/Controlled/Targets.elm @@ -0,0 +1,69 @@ +module View.SideBar.Targets exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Dict + +import Html +import Html.Attributes + +-- Battlemap ------------------------------------------------------------------- +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 " + ++ (Struct.Character.get_player_id char) + ++ "): " + ++ + (toString + (Struct.Statistics.get_movement_points + (Struct.Character.get_statistics char) + ) + ) + ++ " movement points; " + ++ "???" + ++ " attack range. Health: " + ++ (toString (Struct.Character.get_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 "battlemap-side-bar-targets") + ] + [(get_target_info_html model target_ref)] + ) diff --git a/src/battlemap/src/View/SubMenu.elm b/src/battlemap/src/View/SubMenu.elm index 694c826..1690024 100644 --- a/src/battlemap/src/View/SubMenu.elm +++ b/src/battlemap/src/View/SubMenu.elm @@ -11,16 +11,32 @@ import Struct.UI import Util.Html +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 -> - (List (Html.Html Struct.Event.Type)) + (Html.Html Struct.Event.Type) ) get_inner_html model tab = - [(Html.text "Not available")] + case tab of + Struct.UI.StatusTab -> + (View.SubMenu.Status.get_html model) + + Struct.UI.CharactersTab -> + (View.SubMenu.Characters.get_html model) + + Struct.UI.SettingsTab -> + (View.SubMenu.Settings.get_html model) + + Struct.UI.TimelineTab -> + (View.SubMenu.Timeline.get_html model) -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- @@ -30,10 +46,8 @@ get_html model = case (Struct.UI.try_getting_displayed_tab model.ui) of (Just tab) -> (Html.div - [ - (Html.Attributes.class "battlemap-sub-menu") - ] - (get_inner_html model tab) + [(Html.Attributes.class "battlemap-sub-menu")] + [(get_inner_html model tab)] ) Nothing -> diff --git a/src/battlemap/src/View/SubMenu/Characters.elm b/src/battlemap/src/View/SubMenu/Characters.elm new file mode 100644 index 0000000..a34cf4a --- /dev/null +++ b/src/battlemap/src/View/SubMenu/Characters.elm @@ -0,0 +1,101 @@ +module View.SubMenu.Characters exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Dict + +import Html +import Html.Attributes +import Html.Events + +-- Battlemap ------------------------------------------------------------------- +import Struct.Character +import Struct.Event +import Struct.Model + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_character_portrait_html : ( + String -> + Struct.Character.Type -> + (Html.Html Struct.Event.Type) + ) +get_character_portrait_html viewer_id char = + (Html.div + [ + (Html.Attributes.class + ( + "asset-character-portrait-" + ++ (Struct.Character.get_portrait_id char) + ) + ), + (Html.Attributes.class + ( + if ((Struct.Character.get_player_id char) == viewer_id) + then + "battlemap-character-ally" + else + "battlemap-character-enemy" + ) + ), + (Html.Attributes.class "battlemap-character-portrait") + ] + [ + ] + ) + +get_character_element_html : ( + String -> + Struct.Character.Type -> + (Html.Html Struct.Event.Type) + ) +get_character_element_html viewer_id char = + (Html.div + [ + (Html.Attributes.class "battlemap-characters-element"), + (Html.Attributes.class "clickable"), + (Html.Events.onClick + (Struct.Event.CharacterInfoRequested + (Struct.Character.get_ref char) + ) + ) + ] + [ + (get_character_portrait_html viewer_id char), + (Html.text + ( + (Struct.Character.get_name char) + ++ ": " + ++ (toString (Struct.Character.get_current_health char)) + ++ " HP, " + ++ + ( + if (Struct.Character.is_enabled char) + then + "active" + else + "inactive" + ) + ++ " (Player " + ++ (Struct.Character.get_player_id char) + ++ ")." + ) + ) + ] + ) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) +get_html model = + (Html.div + [ + (Html.Attributes.class "battlemap-tabmenu-content"), + (Html.Attributes.class "battlemap-tabmenu-characters-tab") + ] + (List.map + (get_character_element_html model.player_id) + (Dict.values model.characters) + ) + ) diff --git a/src/battlemap/src/View/SubMenu/ManualControls.elm b/src/battlemap/src/View/SubMenu/ManualControls.elm deleted file mode 100644 index f2e900c..0000000 --- a/src/battlemap/src/View/SubMenu/ManualControls.elm +++ /dev/null @@ -1,45 +0,0 @@ -module View.SideBar.ManualControls exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Html -import Html.Attributes -import Html.Events - --- Battlemap ------------------------------------------------------------------- -import Struct.Direction -import Struct.Event - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -direction_button : ( - Struct.Direction.Type -> - String -> - (Html.Html Struct.Event.Type) - ) -direction_button dir label = - (Html.button - [ - (Html.Events.onClick - (Struct.Event.DirectionRequested dir) - ) - ] - [ (Html.text label) ] - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : (Html.Html Struct.Event.Type) -get_html = - (Html.div - [ - (Html.Attributes.class "battlemap-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") - ] - ) diff --git a/src/battlemap/src/View/SubMenu/Settings.elm b/src/battlemap/src/View/SubMenu/Settings.elm new file mode 100644 index 0000000..3bd64ff --- /dev/null +++ b/src/battlemap/src/View/SubMenu/Settings.elm @@ -0,0 +1,53 @@ +module View.SubMenu.Settings exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Html +import Html.Attributes +import Html.Events + +-- Battlemap ------------------------------------------------------------------- +import Struct.Event +import Struct.Model + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +scale_button : Float -> String -> (Html.Html Struct.Event.Type) +scale_button mod label = + (Html.button + [ + (Html.Events.onClick + (Struct.Event.ScaleChangeRequested mod) + ) + ] + [ (Html.text label) ] + ) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) +get_html model = + (Html.div + [ + (Html.Attributes.class "battlemap-tabmenu-content"), + (Html.Attributes.class "battlemap-tabmenu-settings-tab") + ] + [ + (scale_button (0.75) "Zoom -"), + (scale_button 0 "Zoom Reset"), + (scale_button (1.15) "Zoom +"), + (Html.button + [ + (Html.Events.onClick Struct.Event.DebugTeamSwitchRequest) + ] + [ (Html.text "[DEBUG] Switch team") ] + ), + (Html.button + [ + (Html.Events.onClick Struct.Event.DebugLoadBattlemapRequest) + ] + [ (Html.text "[DEBUG] Load battlemap") ] + ) + ] + ) diff --git a/src/battlemap/src/View/SubMenu/Status.elm b/src/battlemap/src/View/SubMenu/Status.elm new file mode 100644 index 0000000..2ff5bf4 --- /dev/null +++ b/src/battlemap/src/View/SubMenu/Status.elm @@ -0,0 +1,157 @@ +module View.SubMenu.Status exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Dict + +import Html +import Html.Attributes + +-- Struct.Battlemap ------------------------------------------------------------------- +import Struct.Battlemap +import Struct.Character +import Struct.Error +import Struct.Event +import Struct.Location +import Struct.Model +import Struct.Statistics +import Struct.Tile +import Struct.UI + +import View.SubMenu.Status.CharacterInfo +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_char_info_html : ( + Struct.Model.Type -> + Struct.Character.Ref -> + (Html.Html Struct.Event.Type) + ) +get_char_info_html model char_ref = + case (Dict.get char_ref model.characters) of + Nothing -> (Html.text "Error: Unknown character selected.") + (Just char) -> + (Html.text + ( + "Focusing " + ++ char.name + ++ " (Player " + ++ (Struct.Character.get_player_id char) + ++ "): " + ++ + (toString + (Struct.Statistics.get_movement_points + (Struct.Character.get_statistics char) + ) + ) + ++ " movement points; " + ++ "???" + ++ " attack range. Health: " + ++ (toString (Struct.Character.get_current_health char)) + ++ "/" + ++ + (toString + (Struct.Statistics.get_max_health + (Struct.Character.get_statistics char) + ) + ) + ) + ) + +get_error_html : Struct.Error.Type -> (Html.Html Struct.Event.Type) +get_error_html err = + (Html.div + [ + (Html.Attributes.class "battlemap-tabmenu-error-message") + ] + [ + (Html.text (Struct.Error.to_string err)) + ] + ) + +get_tile_info_html : ( + Struct.Model.Type -> + Struct.Location.Type -> + (Html.Html Struct.Event.Type) + ) +get_tile_info_html model loc = + case (Struct.Battlemap.try_getting_tile_at model.battlemap loc) of + (Just tile) -> + (Html.div + [ + (Html.Attributes.class + "battlemap-tabmenu-tile-info-tab" + ) + ] + [ + (Html.div + [ + (Html.Attributes.class "battlemap-tile-icon"), + (Html.Attributes.class "battlemap-tiled"), + (Html.Attributes.class + ( + "asset-tile-" + ++ + (Struct.Tile.get_icon_id tile) + ) + ) + ] + [ + ] + ), + (Html.div + [ + ] + [ + (Html.text + ( + "Focusing tile (" + ++ (toString loc.x) + ++ ", " + ++ (toString loc.y) + ++ "). {ID = " + ++ (Struct.Tile.get_icon_id tile) + ++ ", cost = " + ++ (toString (Struct.Tile.get_cost tile)) + ++ "}." + ) + ) + ] + ) + ] + ) + + Nothing -> (Html.text "Error: Unknown tile location selected.") + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) +get_html model = + (Html.div + [ + (Html.Attributes.class "battlemap-footer-tabmenu-content"), + (Html.Attributes.class "battlemap-footer-tabmenu-content-status") + ] + [ + (case (Struct.UI.get_previous_action model.ui) of + (Just (Struct.UI.SelectedLocation loc)) -> + (get_tile_info_html + model + (Struct.Location.from_ref loc) + ) + + (Just (Struct.UI.SelectedCharacter target_char)) -> + case (Dict.get target_char model.characters) of + (Just char) -> + (View.SubMenu.Status.CharacterInfo.get_html + model + char + ) + + _ -> (Html.text "Error: Unknown character selected.") + + _ -> + (Html.text "Double-click on a character to control it.") + ) + ] + ) diff --git a/src/battlemap/src/View/SubMenu/Status/CharacterInfo.elm b/src/battlemap/src/View/SubMenu/Status/CharacterInfo.elm new file mode 100644 index 0000000..d5eb8b7 --- /dev/null +++ b/src/battlemap/src/View/SubMenu/Status/CharacterInfo.elm @@ -0,0 +1,364 @@ +module View.SubMenu.Status.CharacterInfo exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Html +import Html.Attributes + +-- Struct.Battlemap ------------------------------------------------------------------- +import Struct.Attributes +import Struct.Character +import Struct.Event +import Struct.Model +import Struct.Statistics +import Struct.Weapon +import Struct.WeaponSet + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_attributes_html: ( + Struct.Attributes.Type -> + (Html.Html Struct.Event.Type) + ) +get_attributes_html att = + (Html.ul + [ + ] + [ + (Html.li + [] + [ + (Html.text + ( + "Constitution: " + ++ (toString (Struct.Attributes.get_constitution att)) + ) + ) + ] + ), + (Html.li + [] + [ + (Html.text + ( + "Dexterity: " + ++ (toString (Struct.Attributes.get_dexterity att)) + ) + ) + ] + ), + (Html.li + [] + [ + (Html.text + ( + "Intelligence: " + ++ (toString (Struct.Attributes.get_intelligence att)) + ) + ) + ] + ), + (Html.li + [] + [ + (Html.text + ( + "Mind: " + ++ (toString (Struct.Attributes.get_mind att)) + ) + ) + ] + ), + (Html.li + [] + [ + (Html.text + ( + "Speed: " + ++ (toString (Struct.Attributes.get_speed att)) + ) + ) + ] + ), + (Html.li + [] + [ + (Html.text + ( + "Strength: " + ++ (toString (Struct.Attributes.get_strength att)) + ) + ) + ] + ) + ] + ) + +get_statistics_html : ( + Struct.Statistics.Type -> + (Html.Html Struct.Event.Type) + ) +get_statistics_html stats = + (Html.ul + [ + ] + [ + (Html.li + [] + [ + (Html.text + ( + "Chance to Dodge (Base): " + ++ (toString (Struct.Statistics.get_dodges stats)) + ++ "%" + ) + ) + ] + ), + (Html.li + [] + [ + (Html.text + ( + "Chance to Parry: " + ++ (toString (Struct.Statistics.get_parries stats)) + ++ "%" + ) + ) + ] + ), + (Html.li + [] + [ + (Html.text + ( + "Actual Damage: [" + ++ (toString (Struct.Statistics.get_damage_min stats)) + ++ ", " + ++ (toString (Struct.Statistics.get_damage_max stats)) + ++ "]" + ) + ) + ] + ), + (Html.li + [] + [ + (Html.text + ( + "Accuracy: " + ++ (toString (Struct.Statistics.get_accuracy stats)) + ) + ) + ] + ), + (Html.li + [] + [ + (Html.text + ( + "Chance to Double Hit: " + ++ (toString (Struct.Statistics.get_double_hits stats)) + ++ "%" + ) + ) + ] + ), + (Html.li + [] + [ + (Html.text + ( + "Chance to Critical Hit: " + ++ (toString (Struct.Statistics.get_critical_hits stats)) + ++ "%" + ) + ) + ] + ) + ] + ) + +get_weapon_name_html : Struct.Weapon.Type -> (Html.Html Struct.Event.Type) +get_weapon_name_html wp = + (Html.text + ( + (Struct.Weapon.get_name wp) + ++ " (" + ++ + (case (Struct.Weapon.get_range_modifier wp) of + Struct.Weapon.Short -> "Short" + Struct.Weapon.Long -> "Long" + ) + ++ " " + ++ + (case (Struct.Weapon.get_damage_modifier wp) of + Struct.Weapon.Heavy -> "Heavy" + Struct.Weapon.Light -> "Light" + ) + ++ " " + ++ + (case (Struct.Weapon.get_range_type wp) of + Struct.Weapon.Ranged -> "Ranged" + Struct.Weapon.Melee -> "Melee" + ) + ++ ")" + ) + ) + +get_weapon_html : Struct.Weapon.Type -> (Html.Html Struct.Event.Type) +get_weapon_html wp = + (Html.ul + [ + ] + [ + (Html.li + [] + [ (get_weapon_name_html wp) ] + ), + (Html.li + [] + [ + (Html.text + ( + "Damage: [" + ++ (toString (Struct.Weapon.get_min_damage wp)) + ++ ", " + ++ (toString (Struct.Weapon.get_max_damage wp)) + ++ "] " + ++ + (case (Struct.Weapon.get_damage_type wp) of + Struct.Weapon.Slash -> "Slashing" + Struct.Weapon.Pierce -> "Piercing" + Struct.Weapon.Blunt -> "Bludgeoning" + ) + ) + ) + ] + ), + (Html.li + [] + [ + (Html.text + ( + "Range: (" + ++ (toString (Struct.Weapon.get_defense_range wp)) + ++ ", " + ++ (toString (Struct.Weapon.get_attack_range wp)) + ++ ")" + ) + ) + ] + ) + ] + ) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html: ( + Struct.Model.Type -> + Struct.Character.Type -> + (Html.Html Struct.Event.Type) + ) +get_html model char = + (Html.div + [ + (Html.Attributes.class "battlemap-tabmenu-character-info") + ] + [ + (Html.text ("Focusing " ++ char.name ++ ":")), + (Html.dl + [ + ] + [ + (Html.dt [] [(Html.text "Location")]), + (Html.dd + [] + ( + let + location = (Struct.Character.get_location char) + in + [ + (Html.text + ( + (toString location.x) + ++ + ", " + ++ + (toString location.y) + ) + ) + ] + ) + ), + (Html.dt [] [(Html.text "Player")]), + (Html.dd + [] + [ + (Html.text + (Struct.Character.get_player_id char) + ) + ] + ), + (Html.dt [] [(Html.text "Health")]), + (Html.dd + [] + [ + (Html.text + ( + (toString + (Struct.Character.get_current_health char) + ) + ++ "/" + ++ + (toString + (Struct.Statistics.get_max_health + (Struct.Character.get_statistics char) + ) + ) + ) + ) + ] + ), + (Html.dt [] [(Html.text "Movement Points")]), + (Html.dd + [] + [ + (Html.text + (toString + (Struct.Statistics.get_movement_points + (Struct.Character.get_statistics char) + ) + ) + ) + ] + ), + (Html.dt [] [(Html.text "Active Weapon:")]), + (Html.dd + [] + [ + (get_weapon_html + (Struct.WeaponSet.get_active_weapon + (Struct.Character.get_weapons char) + ) + ) + ] + ), + (Html.dt [] [(Html.text "Secondary Weapon:")]), + (Html.dd + [] + [ + (get_weapon_html + (Struct.WeaponSet.get_secondary_weapon + (Struct.Character.get_weapons char) + ) + ) + ] + ) + ] + ), + (get_attributes_html (Struct.Character.get_attributes char)), + (get_statistics_html (Struct.Character.get_statistics char)) + ] + ) diff --git a/src/battlemap/src/View/SubMenu/TabMenu/Characters.elm b/src/battlemap/src/View/SubMenu/TabMenu/Characters.elm deleted file mode 100644 index 2eaca27..0000000 --- a/src/battlemap/src/View/SubMenu/TabMenu/Characters.elm +++ /dev/null @@ -1,101 +0,0 @@ -module View.SideBar.TabMenu.Characters exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Dict - -import Html -import Html.Attributes -import Html.Events - --- Battlemap ------------------------------------------------------------------- -import Struct.Character -import Struct.Event -import Struct.Model - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_character_portrait_html : ( - String -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_character_portrait_html viewer_id char = - (Html.div - [ - (Html.Attributes.class - ( - "asset-character-portrait-" - ++ (Struct.Character.get_portrait_id char) - ) - ), - (Html.Attributes.class - ( - if ((Struct.Character.get_player_id char) == viewer_id) - then - "battlemap-character-ally" - else - "battlemap-character-enemy" - ) - ), - (Html.Attributes.class "battlemap-character-portrait") - ] - [ - ] - ) - -get_character_element_html : ( - String -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_character_element_html viewer_id char = - (Html.div - [ - (Html.Attributes.class "battlemap-characters-element"), - (Html.Attributes.class "clickable"), - (Html.Events.onClick - (Struct.Event.CharacterInfoRequested - (Struct.Character.get_ref char) - ) - ) - ] - [ - (get_character_portrait_html viewer_id char), - (Html.text - ( - (Struct.Character.get_name char) - ++ ": " - ++ (toString (Struct.Character.get_current_health char)) - ++ " HP, " - ++ - ( - if (Struct.Character.is_enabled char) - then - "active" - else - "inactive" - ) - ++ " (Player " - ++ (Struct.Character.get_player_id char) - ++ ")." - ) - ) - ] - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) -get_html model = - (Html.div - [ - (Html.Attributes.class "battlemap-tabmenu-content"), - (Html.Attributes.class "battlemap-tabmenu-characters-tab") - ] - (List.map - (get_character_element_html model.player_id) - (Dict.values model.characters) - ) - ) diff --git a/src/battlemap/src/View/SubMenu/TabMenu/Settings.elm b/src/battlemap/src/View/SubMenu/TabMenu/Settings.elm deleted file mode 100644 index 3f42739..0000000 --- a/src/battlemap/src/View/SubMenu/TabMenu/Settings.elm +++ /dev/null @@ -1,53 +0,0 @@ -module View.SideBar.TabMenu.Settings exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Html -import Html.Attributes -import Html.Events - --- Battlemap ------------------------------------------------------------------- -import Struct.Event -import Struct.Model - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -scale_button : Float -> String -> (Html.Html Struct.Event.Type) -scale_button mod label = - (Html.button - [ - (Html.Events.onClick - (Struct.Event.ScaleChangeRequested mod) - ) - ] - [ (Html.text label) ] - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) -get_html model = - (Html.div - [ - (Html.Attributes.class "battlemap-tabmenu-content"), - (Html.Attributes.class "battlemap-tabmenu-settings-tab") - ] - [ - (scale_button (0.75) "Zoom -"), - (scale_button 0 "Zoom Reset"), - (scale_button (1.15) "Zoom +"), - (Html.button - [ - (Html.Events.onClick Struct.Event.DebugTeamSwitchRequest) - ] - [ (Html.text "[DEBUG] Switch team") ] - ), - (Html.button - [ - (Html.Events.onClick Struct.Event.DebugLoadBattlemapRequest) - ] - [ (Html.text "[DEBUG] Load battlemap") ] - ) - ] - ) diff --git a/src/battlemap/src/View/SubMenu/TabMenu/Status.elm b/src/battlemap/src/View/SubMenu/TabMenu/Status.elm deleted file mode 100644 index 1eb3e5e..0000000 --- a/src/battlemap/src/View/SubMenu/TabMenu/Status.elm +++ /dev/null @@ -1,157 +0,0 @@ -module View.SideBar.TabMenu.Status exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Dict - -import Html -import Html.Attributes - --- Struct.Battlemap ------------------------------------------------------------------- -import Struct.Battlemap -import Struct.Character -import Struct.Error -import Struct.Event -import Struct.Location -import Struct.Model -import Struct.Statistics -import Struct.Tile -import Struct.UI - -import View.SideBar.TabMenu.Status.CharacterInfo --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_char_info_html : ( - Struct.Model.Type -> - Struct.Character.Ref -> - (Html.Html Struct.Event.Type) - ) -get_char_info_html model char_ref = - case (Dict.get char_ref model.characters) of - Nothing -> (Html.text "Error: Unknown character selected.") - (Just char) -> - (Html.text - ( - "Focusing " - ++ char.name - ++ " (Player " - ++ (Struct.Character.get_player_id char) - ++ "): " - ++ - (toString - (Struct.Statistics.get_movement_points - (Struct.Character.get_statistics char) - ) - ) - ++ " movement points; " - ++ "???" - ++ " attack range. Health: " - ++ (toString (Struct.Character.get_current_health char)) - ++ "/" - ++ - (toString - (Struct.Statistics.get_max_health - (Struct.Character.get_statistics char) - ) - ) - ) - ) - -get_error_html : Struct.Error.Type -> (Html.Html Struct.Event.Type) -get_error_html err = - (Html.div - [ - (Html.Attributes.class "battlemap-tabmenu-error-message") - ] - [ - (Html.text (Struct.Error.to_string err)) - ] - ) - -get_tile_info_html : ( - Struct.Model.Type -> - Struct.Location.Type -> - (Html.Html Struct.Event.Type) - ) -get_tile_info_html model loc = - case (Struct.Battlemap.try_getting_tile_at model.battlemap loc) of - (Just tile) -> - (Html.div - [ - (Html.Attributes.class - "battlemap-tabmenu-tile-info-tab" - ) - ] - [ - (Html.div - [ - (Html.Attributes.class "battlemap-tile-icon"), - (Html.Attributes.class "battlemap-tiled"), - (Html.Attributes.class - ( - "asset-tile-" - ++ - (Struct.Tile.get_icon_id tile) - ) - ) - ] - [ - ] - ), - (Html.div - [ - ] - [ - (Html.text - ( - "Focusing tile (" - ++ (toString loc.x) - ++ ", " - ++ (toString loc.y) - ++ "). {ID = " - ++ (Struct.Tile.get_icon_id tile) - ++ ", cost = " - ++ (toString (Struct.Tile.get_cost tile)) - ++ "}." - ) - ) - ] - ) - ] - ) - - Nothing -> (Html.text "Error: Unknown tile location selected.") - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) -get_html model = - (Html.div - [ - (Html.Attributes.class "battlemap-footer-tabmenu-content"), - (Html.Attributes.class "battlemap-footer-tabmenu-content-status") - ] - [ - (case (Struct.UI.get_previous_action model.ui) of - (Just (Struct.UI.SelectedLocation loc)) -> - (get_tile_info_html - model - (Struct.Location.from_ref loc) - ) - - (Just (Struct.UI.SelectedCharacter target_char)) -> - case (Dict.get target_char model.characters) of - (Just char) -> - (View.SideBar.TabMenu.Status.CharacterInfo.get_html - model - char - ) - - _ -> (Html.text "Error: Unknown character selected.") - - _ -> - (Html.text "Double-click on a character to control it.") - ) - ] - ) diff --git a/src/battlemap/src/View/SubMenu/TabMenu/Status/CharacterInfo.elm b/src/battlemap/src/View/SubMenu/TabMenu/Status/CharacterInfo.elm deleted file mode 100644 index 033426a..0000000 --- a/src/battlemap/src/View/SubMenu/TabMenu/Status/CharacterInfo.elm +++ /dev/null @@ -1,364 +0,0 @@ -module View.SideBar.TabMenu.Status.CharacterInfo exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Html -import Html.Attributes - --- Struct.Battlemap ------------------------------------------------------------------- -import Struct.Attributes -import Struct.Character -import Struct.Event -import Struct.Model -import Struct.Statistics -import Struct.Weapon -import Struct.WeaponSet - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_attributes_html: ( - Struct.Attributes.Type -> - (Html.Html Struct.Event.Type) - ) -get_attributes_html att = - (Html.ul - [ - ] - [ - (Html.li - [] - [ - (Html.text - ( - "Constitution: " - ++ (toString (Struct.Attributes.get_constitution att)) - ) - ) - ] - ), - (Html.li - [] - [ - (Html.text - ( - "Dexterity: " - ++ (toString (Struct.Attributes.get_dexterity att)) - ) - ) - ] - ), - (Html.li - [] - [ - (Html.text - ( - "Intelligence: " - ++ (toString (Struct.Attributes.get_intelligence att)) - ) - ) - ] - ), - (Html.li - [] - [ - (Html.text - ( - "Mind: " - ++ (toString (Struct.Attributes.get_mind att)) - ) - ) - ] - ), - (Html.li - [] - [ - (Html.text - ( - "Speed: " - ++ (toString (Struct.Attributes.get_speed att)) - ) - ) - ] - ), - (Html.li - [] - [ - (Html.text - ( - "Strength: " - ++ (toString (Struct.Attributes.get_strength att)) - ) - ) - ] - ) - ] - ) - -get_statistics_html : ( - Struct.Statistics.Type -> - (Html.Html Struct.Event.Type) - ) -get_statistics_html stats = - (Html.ul - [ - ] - [ - (Html.li - [] - [ - (Html.text - ( - "Chance to Dodge (Base): " - ++ (toString (Struct.Statistics.get_dodges stats)) - ++ "%" - ) - ) - ] - ), - (Html.li - [] - [ - (Html.text - ( - "Chance to Parry: " - ++ (toString (Struct.Statistics.get_parries stats)) - ++ "%" - ) - ) - ] - ), - (Html.li - [] - [ - (Html.text - ( - "Actual Damage: [" - ++ (toString (Struct.Statistics.get_damage_min stats)) - ++ ", " - ++ (toString (Struct.Statistics.get_damage_max stats)) - ++ "]" - ) - ) - ] - ), - (Html.li - [] - [ - (Html.text - ( - "Accuracy: " - ++ (toString (Struct.Statistics.get_accuracy stats)) - ) - ) - ] - ), - (Html.li - [] - [ - (Html.text - ( - "Chance to Double Hit: " - ++ (toString (Struct.Statistics.get_double_hits stats)) - ++ "%" - ) - ) - ] - ), - (Html.li - [] - [ - (Html.text - ( - "Chance to Critical Hit: " - ++ (toString (Struct.Statistics.get_critical_hits stats)) - ++ "%" - ) - ) - ] - ) - ] - ) - -get_weapon_name_html : Struct.Weapon.Type -> (Html.Html Struct.Event.Type) -get_weapon_name_html wp = - (Html.text - ( - (Struct.Weapon.get_name wp) - ++ " (" - ++ - (case (Struct.Weapon.get_range_modifier wp) of - Struct.Weapon.Short -> "Short" - Struct.Weapon.Long -> "Long" - ) - ++ " " - ++ - (case (Struct.Weapon.get_damage_modifier wp) of - Struct.Weapon.Heavy -> "Heavy" - Struct.Weapon.Light -> "Light" - ) - ++ " " - ++ - (case (Struct.Weapon.get_range_type wp) of - Struct.Weapon.Ranged -> "Ranged" - Struct.Weapon.Melee -> "Melee" - ) - ++ ")" - ) - ) - -get_weapon_html : Struct.Weapon.Type -> (Html.Html Struct.Event.Type) -get_weapon_html wp = - (Html.ul - [ - ] - [ - (Html.li - [] - [ (get_weapon_name_html wp) ] - ), - (Html.li - [] - [ - (Html.text - ( - "Damage: [" - ++ (toString (Struct.Weapon.get_min_damage wp)) - ++ ", " - ++ (toString (Struct.Weapon.get_max_damage wp)) - ++ "] " - ++ - (case (Struct.Weapon.get_damage_type wp) of - Struct.Weapon.Slash -> "Slashing" - Struct.Weapon.Pierce -> "Piercing" - Struct.Weapon.Blunt -> "Bludgeoning" - ) - ) - ) - ] - ), - (Html.li - [] - [ - (Html.text - ( - "Range: (" - ++ (toString (Struct.Weapon.get_defense_range wp)) - ++ ", " - ++ (toString (Struct.Weapon.get_attack_range wp)) - ++ ")" - ) - ) - ] - ) - ] - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html: ( - Struct.Model.Type -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_html model char = - (Html.div - [ - (Html.Attributes.class "battlemap-tabmenu-character-info") - ] - [ - (Html.text ("Focusing " ++ char.name ++ ":")), - (Html.dl - [ - ] - [ - (Html.dt [] [(Html.text "Location")]), - (Html.dd - [] - ( - let - location = (Struct.Character.get_location char) - in - [ - (Html.text - ( - (toString location.x) - ++ - ", " - ++ - (toString location.y) - ) - ) - ] - ) - ), - (Html.dt [] [(Html.text "Player")]), - (Html.dd - [] - [ - (Html.text - (Struct.Character.get_player_id char) - ) - ] - ), - (Html.dt [] [(Html.text "Health")]), - (Html.dd - [] - [ - (Html.text - ( - (toString - (Struct.Character.get_current_health char) - ) - ++ "/" - ++ - (toString - (Struct.Statistics.get_max_health - (Struct.Character.get_statistics char) - ) - ) - ) - ) - ] - ), - (Html.dt [] [(Html.text "Movement Points")]), - (Html.dd - [] - [ - (Html.text - (toString - (Struct.Statistics.get_movement_points - (Struct.Character.get_statistics char) - ) - ) - ) - ] - ), - (Html.dt [] [(Html.text "Active Weapon:")]), - (Html.dd - [] - [ - (get_weapon_html - (Struct.WeaponSet.get_active_weapon - (Struct.Character.get_weapons char) - ) - ) - ] - ), - (Html.dt [] [(Html.text "Secondary Weapon:")]), - (Html.dd - [] - [ - (get_weapon_html - (Struct.WeaponSet.get_secondary_weapon - (Struct.Character.get_weapons char) - ) - ) - ] - ) - ] - ), - (get_attributes_html (Struct.Character.get_attributes char)), - (get_statistics_html (Struct.Character.get_statistics char)) - ] - ) diff --git a/src/battlemap/src/View/SubMenu/TabMenu/Timeline.elm b/src/battlemap/src/View/SubMenu/TabMenu/Timeline.elm deleted file mode 100644 index 1073735..0000000 --- a/src/battlemap/src/View/SubMenu/TabMenu/Timeline.elm +++ /dev/null @@ -1,66 +0,0 @@ -module View.SideBar.TabMenu.Timeline exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Array - -import Html -import Html.Attributes ---import Html.Events -import Html.Lazy - --- Battlemap ------------------------------------------------------------------- -import Struct.Event -import Struct.TurnResult -import Struct.Model - -import View.SideBar.TabMenu.Timeline.Attack -import View.SideBar.TabMenu.Timeline.Movement -import View.SideBar.TabMenu.Timeline.WeaponSwitch - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_turn_result_html : ( - Struct.Model.Type -> - Struct.TurnResult.Type -> - (Html.Html Struct.Event.Type) - ) -get_turn_result_html model turn_result = - case turn_result of - (Struct.TurnResult.Moved movement) -> - (View.SideBar.TabMenu.Timeline.Movement.get_html model movement) - - (Struct.TurnResult.Attacked attack) -> - (View.SideBar.TabMenu.Timeline.Attack.get_html model attack) - - (Struct.TurnResult.SwitchedWeapon weapon_switch) -> - (View.SideBar.TabMenu.Timeline.WeaponSwitch.get_html - model - weapon_switch - ) - -true_get_html : ( - Struct.Model.Type -> - (Array.Array Struct.TurnResult.Type) -> - (Html.Html Struct.Event.Type) - ) -true_get_html model turn_results = - (Html.div - [ - (Html.Attributes.class "battlemap-tabmenu-content"), - (Html.Attributes.class "battlemap-tabmenu-timeline-tab") - ] - (Array.toList - (Array.map - (get_turn_result_html model) - turn_results - ) - ) - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) -get_html model = - (Html.Lazy.lazy (true_get_html model) model.timeline) diff --git a/src/battlemap/src/View/SubMenu/TabMenu/Timeline/Attack.elm b/src/battlemap/src/View/SubMenu/TabMenu/Timeline/Attack.elm deleted file mode 100644 index 0bd59b8..0000000 --- a/src/battlemap/src/View/SubMenu/TabMenu/Timeline/Attack.elm +++ /dev/null @@ -1,191 +0,0 @@ -module View.SideBar.TabMenu.Timeline.Attack exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Dict - -import Html -import Html.Attributes ---import Html.Events - --- Battlemap ------------------------------------------------------------------- -import Struct.Attack -import Struct.Event -import Struct.TurnResult -import Struct.Character -import Struct.Model - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_title_html : ( - Struct.Character.Type -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_title_html attacker defender = - (Html.div - [ - (Html.Attributes.class "battlemap-timeline-attack-title") - ] - [ - (Html.text - ( - (Struct.Character.get_name attacker) - ++ " attacked " - ++ (Struct.Character.get_name defender) - ++ "!" - ) - ) - ] - ) - -get_portrait_html : ( - String -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_portrait_html viewer_id char = - (Html.div - [ - (Html.Attributes.class "battlemap-timeline-portrait"), - (Html.Attributes.class - ( - if ((Struct.Character.get_player_id char) == viewer_id) - then - "battlemap-character-ally" - else - "battlemap-character-enemy" - ) - ), - (Html.Attributes.class - ( - "asset-character-portrait-" - ++ (Struct.Character.get_portrait_id char) - ) - ) - ] - [ - ] - ) - -get_effect_text : Struct.Attack.Type -> String -get_effect_text attack = - ( - ( - case attack.precision of - Struct.Attack.Hit -> " hit for " - Struct.Attack.Graze -> " grazed for " - Struct.Attack.Miss -> " missed." - ) - ++ - ( - if (attack.precision == Struct.Attack.Miss) - then - "" - else - ( - ((toString attack.damage) ++ " damage") - ++ - ( - if (attack.critical) - then " (Critical Hit)." - else "." - ) - ) - ) - ) - -get_attack_html : ( - Struct.Character.Type -> - Struct.Character.Type -> - Struct.Attack.Type -> - (Html.Html Struct.Event.Type) - ) -get_attack_html attacker defender attack = - let - attacker_name = (Struct.Character.get_name attacker) - defender_name = (Struct.Character.get_name defender) - in - (Html.div - [] - [ - (Html.text - ( - case (attack.order, attack.parried) of - (Struct.Attack.Counter, True) -> - ( - defender_name - ++ " attempted to strike back, but " - ++ attacker_name - ++ " parried, and " - ++ (get_effect_text attack) - ) - - (Struct.Attack.Counter, _) -> - ( - defender_name - ++ " striked back, and " - ++ (get_effect_text attack) - ) - - (_, True) -> - ( - attacker_name - ++ " attempted a hit, but " - ++ defender_name - ++ " parried, and " - ++ (get_effect_text attack) - ) - - (_, _) -> - (attacker_name ++ " " ++ (get_effect_text attack)) - ) - ) - ] - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : ( - Struct.Model.Type -> - Struct.TurnResult.Attack -> - (Html.Html Struct.Event.Type) - ) -get_html model attack = - case - ( - (Dict.get (toString attack.attacker_index) model.characters), - (Dict.get (toString attack.defender_index) model.characters) - ) - of - ((Just atkchar), (Just defchar)) -> - (Html.div - [ - (Html.Attributes.class "battlemap-timeline-element"), - (Html.Attributes.class "battlemap-timeline-attack") - ] - ( - [ - (get_portrait_html model.player_id atkchar), - (get_portrait_html model.player_id defchar), - (get_title_html atkchar defchar) - ] - ++ - (List.map - (get_attack_html atkchar defchar) - attack.sequence - ) - ) - ) - - _ -> - (Html.div - [ - (Html.Attributes.class "battlemap-timeline-element"), - (Html.Attributes.class "battlemap-timeline-attack") - ] - [ - (Html.text "Error: Attack with unknown characters") - ] - ) diff --git a/src/battlemap/src/View/SubMenu/TabMenu/Timeline/Movement.elm b/src/battlemap/src/View/SubMenu/TabMenu/Timeline/Movement.elm deleted file mode 100644 index 4e5579a..0000000 --- a/src/battlemap/src/View/SubMenu/TabMenu/Timeline/Movement.elm +++ /dev/null @@ -1,88 +0,0 @@ -module View.SideBar.TabMenu.Timeline.Movement exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Dict - -import Html -import Html.Attributes ---import Html.Events - --- Battlemap ------------------------------------------------------------------- -import Struct.Event -import Struct.TurnResult -import Struct.Character -import Struct.Model - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_portrait_html : ( - String -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_portrait_html viewer_id char = - (Html.div - [ - (Html.Attributes.class "battlemap-timeline-portrait"), - (Html.Attributes.class - ( - if ((Struct.Character.get_player_id char) == viewer_id) - then - "battlemap-character-ally" - else - "battlemap-character-enemy" - ) - ), - (Html.Attributes.class - ( - "asset-character-portrait-" - ++ (Struct.Character.get_portrait_id char) - ) - ) - ] - [ - ] - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : ( - Struct.Model.Type -> - Struct.TurnResult.Movement -> - (Html.Html Struct.Event.Type) - ) -get_html model movement = - case (Dict.get (toString movement.character_index) model.characters) of - (Just char) -> - (Html.div - [ - (Html.Attributes.class "battlemap-timeline-element"), - (Html.Attributes.class "battlemap-timeline-movement") - ] - [ - (get_portrait_html model.player_id char), - (Html.text - ( - (Struct.Character.get_name char) - ++ " moved to (" - ++ (toString movement.destination.x) - ++ ", " - ++ (toString movement.destination.y) - ++ ")." - ) - ) - ] - ) - - _ -> - (Html.div - [ - (Html.Attributes.class "battlemap-timeline-element"), - (Html.Attributes.class "battlemap-timeline-movement") - ] - [ - (Html.text "Error: Moving with unknown character") - ] - ) diff --git a/src/battlemap/src/View/SubMenu/TabMenu/Timeline/WeaponSwitch.elm b/src/battlemap/src/View/SubMenu/TabMenu/Timeline/WeaponSwitch.elm deleted file mode 100644 index b64a293..0000000 --- a/src/battlemap/src/View/SubMenu/TabMenu/Timeline/WeaponSwitch.elm +++ /dev/null @@ -1,84 +0,0 @@ -module View.SideBar.TabMenu.Timeline.WeaponSwitch exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Dict - -import Html -import Html.Attributes ---import Html.Events - --- Battlemap ------------------------------------------------------------------- -import Struct.Event -import Struct.TurnResult -import Struct.Character -import Struct.Model - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_portrait_html : ( - String -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_portrait_html viewer_id char = - (Html.div - [ - (Html.Attributes.class "battlemap-timeline-portrait"), - (Html.Attributes.class - ( - if ((Struct.Character.get_player_id char) == viewer_id) - then - "battlemap-character-ally" - else - "battlemap-character-enemy" - ) - ), - (Html.Attributes.class - ( - "asset-character-portrait-" - ++ (Struct.Character.get_portrait_id char) - ) - ) - ] - [ - ] - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : ( - Struct.Model.Type -> - Struct.TurnResult.WeaponSwitch -> - (Html.Html Struct.Event.Type) - ) -get_html model weapon_switch = - case (Dict.get (toString weapon_switch.character_index) model.characters) of - (Just char) -> - (Html.div - [ - (Html.Attributes.class "battlemap-timeline-element"), - (Html.Attributes.class "battlemap-timeline-weapon-switch") - ] - [ - (get_portrait_html model.player_id char), - (Html.text - ( - (Struct.Character.get_name char) - ++ " switched weapons." - ) - ) - ] - ) - - _ -> - (Html.div - [ - (Html.Attributes.class "battlemap-timeline-element"), - (Html.Attributes.class "battlemap-timeline-weapon-switch") - ] - [ - (Html.text "Error: Unknown character switched weapons") - ] - ) diff --git a/src/battlemap/src/View/SubMenu/Targets.elm b/src/battlemap/src/View/SubMenu/Targets.elm deleted file mode 100644 index 7bb4c36..0000000 --- a/src/battlemap/src/View/SubMenu/Targets.elm +++ /dev/null @@ -1,69 +0,0 @@ -module View.SideBar.Targets exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Dict - -import Html -import Html.Attributes - --- Battlemap ------------------------------------------------------------------- -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 " - ++ (Struct.Character.get_player_id char) - ++ "): " - ++ - (toString - (Struct.Statistics.get_movement_points - (Struct.Character.get_statistics char) - ) - ) - ++ " movement points; " - ++ "???" - ++ " attack range. Health: " - ++ (toString (Struct.Character.get_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 "battlemap-side-bar-targets") - ] - [(get_target_info_html model target_ref)] - ) diff --git a/src/battlemap/src/View/SubMenu/Timeline.elm b/src/battlemap/src/View/SubMenu/Timeline.elm new file mode 100644 index 0000000..eb67085 --- /dev/null +++ b/src/battlemap/src/View/SubMenu/Timeline.elm @@ -0,0 +1,66 @@ +module View.SubMenu.Timeline exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Array + +import Html +import Html.Attributes +--import Html.Events +import Html.Lazy + +-- Battlemap ------------------------------------------------------------------- +import Struct.Event +import Struct.TurnResult +import Struct.Model + +import View.SubMenu.Timeline.Attack +import View.SubMenu.Timeline.Movement +import View.SubMenu.Timeline.WeaponSwitch + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_turn_result_html : ( + Struct.Model.Type -> + Struct.TurnResult.Type -> + (Html.Html Struct.Event.Type) + ) +get_turn_result_html model turn_result = + case turn_result of + (Struct.TurnResult.Moved movement) -> + (View.SubMenu.Timeline.Movement.get_html model movement) + + (Struct.TurnResult.Attacked attack) -> + (View.SubMenu.Timeline.Attack.get_html model attack) + + (Struct.TurnResult.SwitchedWeapon weapon_switch) -> + (View.SubMenu.Timeline.WeaponSwitch.get_html + model + weapon_switch + ) + +true_get_html : ( + Struct.Model.Type -> + (Array.Array Struct.TurnResult.Type) -> + (Html.Html Struct.Event.Type) + ) +true_get_html model turn_results = + (Html.div + [ + (Html.Attributes.class "battlemap-tabmenu-content"), + (Html.Attributes.class "battlemap-tabmenu-timeline-tab") + ] + (Array.toList + (Array.map + (get_turn_result_html model) + turn_results + ) + ) + ) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) +get_html model = + (Html.Lazy.lazy (true_get_html model) model.timeline) diff --git a/src/battlemap/src/View/SubMenu/Timeline/Attack.elm b/src/battlemap/src/View/SubMenu/Timeline/Attack.elm new file mode 100644 index 0000000..6dab423 --- /dev/null +++ b/src/battlemap/src/View/SubMenu/Timeline/Attack.elm @@ -0,0 +1,191 @@ +module View.SubMenu.Timeline.Attack exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Dict + +import Html +import Html.Attributes +--import Html.Events + +-- Battlemap ------------------------------------------------------------------- +import Struct.Attack +import Struct.Event +import Struct.TurnResult +import Struct.Character +import Struct.Model + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_title_html : ( + Struct.Character.Type -> + Struct.Character.Type -> + (Html.Html Struct.Event.Type) + ) +get_title_html attacker defender = + (Html.div + [ + (Html.Attributes.class "battlemap-timeline-attack-title") + ] + [ + (Html.text + ( + (Struct.Character.get_name attacker) + ++ " attacked " + ++ (Struct.Character.get_name defender) + ++ "!" + ) + ) + ] + ) + +get_portrait_html : ( + String -> + Struct.Character.Type -> + (Html.Html Struct.Event.Type) + ) +get_portrait_html viewer_id char = + (Html.div + [ + (Html.Attributes.class "battlemap-timeline-portrait"), + (Html.Attributes.class + ( + if ((Struct.Character.get_player_id char) == viewer_id) + then + "battlemap-character-ally" + else + "battlemap-character-enemy" + ) + ), + (Html.Attributes.class + ( + "asset-character-portrait-" + ++ (Struct.Character.get_portrait_id char) + ) + ) + ] + [ + ] + ) + +get_effect_text : Struct.Attack.Type -> String +get_effect_text attack = + ( + ( + case attack.precision of + Struct.Attack.Hit -> " hit for " + Struct.Attack.Graze -> " grazed for " + Struct.Attack.Miss -> " missed." + ) + ++ + ( + if (attack.precision == Struct.Attack.Miss) + then + "" + else + ( + ((toString attack.damage) ++ " damage") + ++ + ( + if (attack.critical) + then " (Critical Hit)." + else "." + ) + ) + ) + ) + +get_attack_html : ( + Struct.Character.Type -> + Struct.Character.Type -> + Struct.Attack.Type -> + (Html.Html Struct.Event.Type) + ) +get_attack_html attacker defender attack = + let + attacker_name = (Struct.Character.get_name attacker) + defender_name = (Struct.Character.get_name defender) + in + (Html.div + [] + [ + (Html.text + ( + case (attack.order, attack.parried) of + (Struct.Attack.Counter, True) -> + ( + defender_name + ++ " attempted to strike back, but " + ++ attacker_name + ++ " parried, and " + ++ (get_effect_text attack) + ) + + (Struct.Attack.Counter, _) -> + ( + defender_name + ++ " striked back, and " + ++ (get_effect_text attack) + ) + + (_, True) -> + ( + attacker_name + ++ " attempted a hit, but " + ++ defender_name + ++ " parried, and " + ++ (get_effect_text attack) + ) + + (_, _) -> + (attacker_name ++ " " ++ (get_effect_text attack)) + ) + ) + ] + ) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : ( + Struct.Model.Type -> + Struct.TurnResult.Attack -> + (Html.Html Struct.Event.Type) + ) +get_html model attack = + case + ( + (Dict.get (toString attack.attacker_index) model.characters), + (Dict.get (toString attack.defender_index) model.characters) + ) + of + ((Just atkchar), (Just defchar)) -> + (Html.div + [ + (Html.Attributes.class "battlemap-timeline-element"), + (Html.Attributes.class "battlemap-timeline-attack") + ] + ( + [ + (get_portrait_html model.player_id atkchar), + (get_portrait_html model.player_id defchar), + (get_title_html atkchar defchar) + ] + ++ + (List.map + (get_attack_html atkchar defchar) + attack.sequence + ) + ) + ) + + _ -> + (Html.div + [ + (Html.Attributes.class "battlemap-timeline-element"), + (Html.Attributes.class "battlemap-timeline-attack") + ] + [ + (Html.text "Error: Attack with unknown characters") + ] + ) diff --git a/src/battlemap/src/View/SubMenu/Timeline/Movement.elm b/src/battlemap/src/View/SubMenu/Timeline/Movement.elm new file mode 100644 index 0000000..f561d6c --- /dev/null +++ b/src/battlemap/src/View/SubMenu/Timeline/Movement.elm @@ -0,0 +1,88 @@ +module View.SubMenu.Timeline.Movement exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Dict + +import Html +import Html.Attributes +--import Html.Events + +-- Battlemap ------------------------------------------------------------------- +import Struct.Event +import Struct.TurnResult +import Struct.Character +import Struct.Model + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_portrait_html : ( + String -> + Struct.Character.Type -> + (Html.Html Struct.Event.Type) + ) +get_portrait_html viewer_id char = + (Html.div + [ + (Html.Attributes.class "battlemap-timeline-portrait"), + (Html.Attributes.class + ( + if ((Struct.Character.get_player_id char) == viewer_id) + then + "battlemap-character-ally" + else + "battlemap-character-enemy" + ) + ), + (Html.Attributes.class + ( + "asset-character-portrait-" + ++ (Struct.Character.get_portrait_id char) + ) + ) + ] + [ + ] + ) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : ( + Struct.Model.Type -> + Struct.TurnResult.Movement -> + (Html.Html Struct.Event.Type) + ) +get_html model movement = + case (Dict.get (toString movement.character_index) model.characters) of + (Just char) -> + (Html.div + [ + (Html.Attributes.class "battlemap-timeline-element"), + (Html.Attributes.class "battlemap-timeline-movement") + ] + [ + (get_portrait_html model.player_id char), + (Html.text + ( + (Struct.Character.get_name char) + ++ " moved to (" + ++ (toString movement.destination.x) + ++ ", " + ++ (toString movement.destination.y) + ++ ")." + ) + ) + ] + ) + + _ -> + (Html.div + [ + (Html.Attributes.class "battlemap-timeline-element"), + (Html.Attributes.class "battlemap-timeline-movement") + ] + [ + (Html.text "Error: Moving with unknown character") + ] + ) diff --git a/src/battlemap/src/View/SubMenu/Timeline/WeaponSwitch.elm b/src/battlemap/src/View/SubMenu/Timeline/WeaponSwitch.elm new file mode 100644 index 0000000..91191c4 --- /dev/null +++ b/src/battlemap/src/View/SubMenu/Timeline/WeaponSwitch.elm @@ -0,0 +1,84 @@ +module View.SubMenu.Timeline.WeaponSwitch exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Dict + +import Html +import Html.Attributes +--import Html.Events + +-- Battlemap ------------------------------------------------------------------- +import Struct.Event +import Struct.TurnResult +import Struct.Character +import Struct.Model + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_portrait_html : ( + String -> + Struct.Character.Type -> + (Html.Html Struct.Event.Type) + ) +get_portrait_html viewer_id char = + (Html.div + [ + (Html.Attributes.class "battlemap-timeline-portrait"), + (Html.Attributes.class + ( + if ((Struct.Character.get_player_id char) == viewer_id) + then + "battlemap-character-ally" + else + "battlemap-character-enemy" + ) + ), + (Html.Attributes.class + ( + "asset-character-portrait-" + ++ (Struct.Character.get_portrait_id char) + ) + ) + ] + [ + ] + ) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : ( + Struct.Model.Type -> + Struct.TurnResult.WeaponSwitch -> + (Html.Html Struct.Event.Type) + ) +get_html model weapon_switch = + case (Dict.get (toString weapon_switch.character_index) model.characters) of + (Just char) -> + (Html.div + [ + (Html.Attributes.class "battlemap-timeline-element"), + (Html.Attributes.class "battlemap-timeline-weapon-switch") + ] + [ + (get_portrait_html model.player_id char), + (Html.text + ( + (Struct.Character.get_name char) + ++ " switched weapons." + ) + ) + ] + ) + + _ -> + (Html.div + [ + (Html.Attributes.class "battlemap-timeline-element"), + (Html.Attributes.class "battlemap-timeline-weapon-switch") + ] + [ + (Html.text "Error: Unknown character switched weapons") + ] + ) -- cgit v1.2.3-70-g09d2