summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/battlemap/src/View/SubMenu')
10 files changed, 1218 insertions, 0 deletions
diff --git a/src/battlemap/src/View/SubMenu/ManualControls.elm b/src/battlemap/src/View/SubMenu/ManualControls.elm new file mode 100644 index 0000000..f2e900c --- /dev/null +++ b/src/battlemap/src/View/SubMenu/ManualControls.elm @@ -0,0 +1,45 @@ +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/TabMenu/Characters.elm b/src/battlemap/src/View/SubMenu/TabMenu/Characters.elm new file mode 100644 index 0000000..2eaca27 --- /dev/null +++ b/src/battlemap/src/View/SubMenu/TabMenu/Characters.elm @@ -0,0 +1,101 @@ +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 new file mode 100644 index 0000000..3f42739 --- /dev/null +++ b/src/battlemap/src/View/SubMenu/TabMenu/Settings.elm @@ -0,0 +1,53 @@ +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 new file mode 100644 index 0000000..1eb3e5e --- /dev/null +++ b/src/battlemap/src/View/SubMenu/TabMenu/Status.elm @@ -0,0 +1,157 @@ +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 new file mode 100644 index 0000000..033426a --- /dev/null +++ b/src/battlemap/src/View/SubMenu/TabMenu/Status/CharacterInfo.elm @@ -0,0 +1,364 @@ +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 new file mode 100644 index 0000000..1073735 --- /dev/null +++ b/src/battlemap/src/View/SubMenu/TabMenu/Timeline.elm @@ -0,0 +1,66 @@ +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 new file mode 100644 index 0000000..0bd59b8 --- /dev/null +++ b/src/battlemap/src/View/SubMenu/TabMenu/Timeline/Attack.elm @@ -0,0 +1,191 @@ +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 new file mode 100644 index 0000000..4e5579a --- /dev/null +++ b/src/battlemap/src/View/SubMenu/TabMenu/Timeline/Movement.elm @@ -0,0 +1,88 @@ +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 new file mode 100644 index 0000000..b64a293 --- /dev/null +++ b/src/battlemap/src/View/SubMenu/TabMenu/Timeline/WeaponSwitch.elm @@ -0,0 +1,84 @@ +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 new file mode 100644 index 0000000..7bb4c36 --- /dev/null +++ b/src/battlemap/src/View/SubMenu/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)] + ) |