summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-01-14 19:30:19 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-01-14 19:30:19 +0100
commitb3bfd26ce3764fae2a846981e4d8c5db90a1aecc (patch)
tree68ae641b5ca4a77c97248aa1671b593d880aeb7b /src/battle/src/View
parentdc8d1139c141b5281145829b5e87602425b4893f (diff)
parentdc7c1857845a5da7cd6cba178c16fa8ea8c68cec (diff)
...
Diffstat (limited to 'src/battle/src/View')
-rw-r--r--src/battle/src/View/Character.elm202
-rw-r--r--src/battle/src/View/Controlled/CharacterCard.elm6
-rw-r--r--src/battle/src/View/Map/Character.elm129
-rw-r--r--src/battle/src/View/MessageBoard.elm28
-rw-r--r--src/battle/src/View/MessageBoard/Attack.elm (renamed from src/battle/src/View/MessageBoard/Animator/Attack.elm)138
-rw-r--r--src/battle/src/View/SubMenu/Timeline/Attack.elm4
-rw-r--r--src/battle/src/View/SubMenu/Timeline/Movement.elm2
-rw-r--r--src/battle/src/View/SubMenu/Timeline/WeaponSwitch.elm2
8 files changed, 105 insertions, 406 deletions
diff --git a/src/battle/src/View/Character.elm b/src/battle/src/View/Character.elm
index dc256c6..dac5989 100644
--- a/src/battle/src/View/Character.elm
+++ b/src/battle/src/View/Character.elm
@@ -1,217 +1,45 @@
-module View.Character exposing
- (
- get_portrait_html,
- get_icon_html
- )
+module View.Character exposing (get_portrait_html)
-- Elm -------------------------------------------------------------------------
import Html
import Html.Attributes
import Html.Events
--- Shared ----------------------------------------------------------------------
-import Util.Html
-
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Character
-import BattleCharacters.Struct.Equipment
-import BattleCharacters.Struct.Portrait
import BattleCharacters.View.Portrait
-- Local Module ----------------------------------------------------------------
-import Constants.UI
-
import Struct.Character
-import Struct.CharacterTurn
import Struct.Event
-import Struct.Model
-import Struct.UI
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_activation_level_class : (
- Struct.Character.Type ->
- (Html.Attribute Struct.Event.Type)
- )
-get_activation_level_class char =
- if (Struct.Character.is_enabled char)
- then
- (Html.Attributes.class "character-icon-enabled")
- else
- (Html.Attributes.class "character-icon-disabled")
-
-get_alliance_class : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Attribute Struct.Event.Type)
- )
-get_alliance_class model char =
- if
- (
- (Struct.Character.get_player_index char) == model.player_i
- ==
- (Struct.Battle.get_own_player_index model.battle)
- )
- then (Html.Attributes.class "character-ally")
- else (Html.Attributes.class "character-enemy")
-
-get_position_style : (
- Struct.Character.Type ->
- (List (Html.Attribute Struct.Event.Type))
- )
-get_position_style char =
- let char_loc = (Struct.Character.get_location char) in
- [
- (Html.Attributes.style
- "top"
- ((String.fromInt (char_loc.y * Constants.UI.tile_size)) ++ "px")
- ),
- (Html.Attributes.style
- "left"
- ((String.fromInt (char_loc.x * Constants.UI.tile_size)) ++ "px")
- )
- ]
-
-get_focus_class : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Attribute Struct.Event.Type)
- )
-get_focus_class model char =
- if
- (
- (Struct.UI.get_previous_action model.ui)
- ==
- (Just (Struct.UI.SelectedCharacter (Struct.Character.get_index char)))
- )
- then
- (Html.Attributes.class "character-selected")
- else
- if
- (
- (Struct.CharacterTurn.try_getting_target model.char_turn)
- ==
- (Just (Struct.Character.get_index char))
- )
- then
- (Html.Attributes.class "character-targeted")
- else
- (Html.Attributes.class "")
-
-get_icon_body_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
-get_icon_body_html char =
- (Html.div
- [
- (Html.Attributes.class "character-icon-body"),
- (Html.Attributes.class
- (
- "asset-character-team-body-"
- ++ (String.fromInt (Struct.Character.get_player_index char))
- )
- )
- ]
- [
- ]
- )
-
-get_icon_head_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
-get_icon_head_html char =
- (Html.div
- [
- (Html.Attributes.class "character-icon-head"),
- (Html.Attributes.class
- (
- "asset-character-icon-"
- ++
- (BattleCharacters.Struct.Portrait.get_icon_id
- (BattleCharacters.Struct.Equipment.get_portrait
- (BattleCharacters.Struct.Character.get_equipment
- (Struct.Character.get_base_character char)
- )
- )
- )
- )
- )
- ]
- [
- ]
- )
-
-get_icon_actual_html : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Html Struct.Event.Type)
- )
-get_icon_actual_html model char =
- (Html.div
- (
- [
- (Html.Attributes.class "tiled"),
- (Html.Attributes.class "character-icon"),
- (get_activation_level_class char),
- (get_alliance_class model char),
- (get_focus_class model char),
- (Html.Attributes.class "clickable"),
- (Html.Events.onClick
- (Struct.Event.CharacterSelected
- (Struct.Character.get_index char)
- )
- )
- ]
- ++ (get_position_style char)
- )
- [
- (get_icon_body_html char),
- (get_icon_head_html char)
- ]
- )
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_portrait_html : (
- Int ->
- Struct.Character.Type ->
- (Html.Html Struct.Event.Type)
- )
-get_portrait_html viewer_ix char =
+get_portrait_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
+get_portrait_html char =
(BattleCharacters.View.Portrait.get_html
- [
- (Html.Attributes.class
- (
- if ((Struct.Character.get_player_index char) == viewer_ix)
- then
- "character-ally"
- else
- "character-enemy"
- )
- ),
- (Html.Attributes.class
- (
- "character-portrait-team-"
- ++
- (String.fromInt (Struct.Character.get_player_index char))
- )
- ),
+ (
(Html.Events.onClick
(Struct.Event.LookingForCharacter (Struct.Character.get_index char))
)
- ]
+ ::
+ (List.map
+ (
+ \effect_name ->
+ (Html.Attributes.class
+ ("character-portrait-effect-" ++ effect_name)
+ )
+ )
+ (Struct.Character.get_extra_display_effects_list char)
+ )
+ )
(BattleCharacters.Struct.Character.get_equipment
(Struct.Character.get_base_character char)
)
)
-
-get_icon_html : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Html Struct.Event.Type)
- )
-get_icon_html model char =
- if (Struct.Character.is_alive char)
- then
- (get_icon_actual_html model char)
- else
- (Util.Html.nothing)
diff --git a/src/battle/src/View/Controlled/CharacterCard.elm b/src/battle/src/View/Controlled/CharacterCard.elm
index 291263c..0d7eda1 100644
--- a/src/battle/src/View/Controlled/CharacterCard.elm
+++ b/src/battle/src/View/Controlled/CharacterCard.elm
@@ -352,7 +352,7 @@ get_minimal_html player_ix char =
(Html.Attributes.class "info-card-picture")
]
[
- (View.Character.get_portrait_html player_ix char)
+ (View.Character.get_portrait_html char)
]
),
(get_health_bar char),
@@ -400,7 +400,7 @@ get_summary_html char_turn player_ix char =
(Html.Attributes.class "info-card-picture")
]
[
- (View.Character.get_portrait_html player_ix char)
+ (View.Character.get_portrait_html char)
]
),
(get_health_bar char),
@@ -456,7 +456,7 @@ get_full_html player_ix char =
(Html.Attributes.class "info-card-picture")
]
[
- (View.Character.get_portrait_html player_ix char)
+ (View.Character.get_portrait_html char)
]
),
(get_health_bar char),
diff --git a/src/battle/src/View/Map/Character.elm b/src/battle/src/View/Map/Character.elm
index b20c29a..b1442b1 100644
--- a/src/battle/src/View/Map/Character.elm
+++ b/src/battle/src/View/Map/Character.elm
@@ -16,80 +16,13 @@ import BattleCharacters.Struct.Equipment
-- Local Module ----------------------------------------------------------------
import Constants.UI
-import Struct.Battle
import Struct.Character
-import Struct.CharacterTurn
import Struct.Event
-import Struct.Model
-import Struct.TurnResult
-import Struct.TurnResultAnimator
import Struct.UI
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_animation_class : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Attribute Struct.Event.Type)
- )
-get_animation_class model char =
- case model.animator of
- Nothing -> (Html.Attributes.class "")
- (Just animator) ->
- case (Struct.TurnResultAnimator.get_current_animation animator) of
- (Struct.TurnResultAnimator.Focus char_index) ->
- if ((Struct.Character.get_index char) /= char_index)
- then
- (Html.Attributes.class "")
- else
- (Html.Attributes.class "character-selected")
-
- (Struct.TurnResultAnimator.TurnResult current_action) ->
- if
- (
- (Struct.TurnResult.get_actor_index current_action)
- /=
- (Struct.Character.get_index char)
- )
- then
- (Html.Attributes.class "")
- else
- case current_action of
- (Struct.TurnResult.Moved _) ->
- (Html.Attributes.class
- "animated-character-icon"
- )
-
- _ -> (Html.Attributes.class "")
- _ -> (Html.Attributes.class "")
-
-get_activation_level_class : (
- Struct.Character.Type ->
- (Html.Attribute Struct.Event.Type)
- )
-get_activation_level_class char =
- if (Struct.Character.is_enabled char)
- then
- (Html.Attributes.class "character-icon-enabled")
- else
- (Html.Attributes.class "character-icon-disabled")
-
-get_alliance_class : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Attribute Struct.Event.Type)
- )
-get_alliance_class model char =
- if
- (
- (Struct.Character.get_player_index char)
- ==
- (Struct.Battle.get_own_player_index model.battle)
- )
- then (Html.Attributes.class "character-ally")
- else (Html.Attributes.class "character-enemy")
-
get_position_style : (
Struct.Character.Type ->
(List (Html.Attribute Struct.Event.Type))
@@ -107,32 +40,6 @@ get_position_style char =
)
]
-get_focus_class : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Attribute Struct.Event.Type)
- )
-get_focus_class model char =
- if
- (
- (Struct.UI.get_previous_action model.ui)
- ==
- (Just (Struct.UI.SelectedCharacter (Struct.Character.get_index char)))
- )
- then
- (Html.Attributes.class "character-selected")
- else
- if
- (
- (Struct.CharacterTurn.try_getting_target model.char_turn)
- ==
- (Just (Struct.Character.get_index char))
- )
- then
- (Html.Attributes.class "character-targeted")
- else
- (Html.Attributes.class "")
-
get_body_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
get_body_html char =
(Html.div
@@ -195,21 +102,13 @@ get_banner_html char =
_ -> (Util.Html.nothing)
-get_actual_html : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Html Struct.Event.Type)
- )
-get_actual_html model char =
+get_actual_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
+get_actual_html char =
(Html.div
(
[
(Html.Attributes.class "tiled"),
(Html.Attributes.class "character-icon"),
- (get_animation_class model char),
- (get_activation_level_class char),
- (get_alliance_class model char),
- (get_focus_class model char),
(Html.Attributes.class "clickable"),
(Html.Events.onClick
(Struct.Event.CharacterSelected
@@ -218,6 +117,16 @@ get_actual_html model char =
)
]
++
+ (List.map
+ (
+ \effect_name ->
+ (Html.Attributes.class
+ ("character-icon-effect-" ++ effect_name)
+ )
+ )
+ (Struct.Character.get_extra_display_effects_list char)
+ )
+ ++
(get_position_style char)
)
[
@@ -230,14 +139,8 @@ get_actual_html model char =
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_html : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Html Struct.Event.Type)
- )
-get_html model char =
+get_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
+get_html char =
if (Struct.Character.is_alive char)
- then
- (get_actual_html model char)
- else
- (Util.Html.nothing)
+ then (get_actual_html char)
+ else (Util.Html.nothing)
diff --git a/src/battle/src/View/MessageBoard.elm b/src/battle/src/View/MessageBoard.elm
index 9b31f65..8a47b40 100644
--- a/src/battle/src/View/MessageBoard.elm
+++ b/src/battle/src/View/MessageBoard.elm
@@ -3,28 +3,38 @@ module View.MessageBoard exposing (get_html)
-- Elm -------------------------------------------------------------------------
import Html
+-- Shared ----------------------------------------------------------------------
+import Util.Html
+
-- Local Module ----------------------------------------------------------------
import Struct.Event
import Struct.Model
+import Struct.MessageBoard
-import View.MessageBoard.Animator
+import View.MessageBoard.Attack
import View.MessageBoard.Error
import View.MessageBoard.Help
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
+display : (
+ Struct.Model.Type ->
+ Struct.MessageBoard.Message ->
+ (Html.Html Struct.Event.Type)
+ )
+display model message =
+ case message of
+ (Error error_msg) -> (View.MessageBoard.Error.get_html model error_msg)
+ (AttackReport attack) -> (View.MessageBoard.Attack.get_html model attack)
+ (Help help_request) ->
+ (View.MessageBoard.Help.get_html model help_request)
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
get_html model =
- case (model.error) of
- (Just error) -> (View.MessageBoard.Error.get_html model error)
- Nothing ->
- case model.animator of
- (Just animator) ->
- (View.MessageBoard.Animator.get_html model.battle animator)
-
- Nothing -> (View.MessageBoard.Help.get_html model)
+ case (Struct.MessageBoard.try_getting_current_message model.message_board) of
+ Nothing -> (Util.Html.nothing)
+ (Just message) -> (display model message)
diff --git a/src/battle/src/View/MessageBoard/Animator/Attack.elm b/src/battle/src/View/MessageBoard/Attack.elm
index 6b79903..041b3e3 100644
--- a/src/battle/src/View/MessageBoard/Animator/Attack.elm
+++ b/src/battle/src/View/MessageBoard/Attack.elm
@@ -1,4 +1,4 @@
-module View.MessageBoard.Animator.Attack exposing (get_html)
+module View.MessageBoard.Attack exposing (get_html)
-- Elm -------------------------------------------------------------------------
import Array
@@ -14,6 +14,7 @@ import Struct.Attack
import Struct.Battle
import Struct.Character
import Struct.Event
+import Struct.Model
import View.Controlled.CharacterCard
@@ -145,45 +146,30 @@ get_defense_animation_class attack char =
else "animated-portrait-dies"
get_attacker_card : (
- (Maybe Struct.Attack.Type) ->
+ Struct.Attack.Type ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_attacker_card maybe_attack char =
+get_attacker_card attack char =
(Html.div
- (case maybe_attack of
- Nothing ->
- if ((Struct.Character.get_current_health char) > 0)
- then
- [
- (Html.Attributes.class "animated-portrait")
- ]
- else
- [
- (Html.Attributes.class "animated-portrait-absent"),
- (Html.Attributes.class "animated-portrait")
- ]
-
- (Just attack) ->
- [
- (Html.Attributes.class
- (case (attack.order, attack.parried) of
- (Struct.Attack.Counter, True) ->
- (get_attack_animation_class attack char)
+ [
+ (Html.Attributes.class
+ (case (attack.order, attack.parried) of
+ (Struct.Attack.Counter, True) ->
+ (get_attack_animation_class attack char)
- (Struct.Attack.Counter, _) ->
- (get_defense_animation_class attack char)
+ (Struct.Attack.Counter, _) ->
+ (get_defense_animation_class attack char)
- (_, True) ->
- (get_defense_animation_class attack char)
+ (_, True) ->
+ (get_defense_animation_class attack char)
- (_, _) ->
- (get_attack_animation_class attack char)
- )
- ),
- (Html.Attributes.class "animated-portrait")
- ]
- )
+ (_, _) ->
+ (get_attack_animation_class attack char)
+ )
+ ),
+ (Html.Attributes.class "animated-portrait")
+ ]
[
(View.Controlled.CharacterCard.get_minimal_html
(Struct.Character.get_player_index char)
@@ -193,61 +179,43 @@ get_attacker_card maybe_attack char =
)
get_defender_card : (
- (Maybe Struct.Attack.Type) ->
+ Struct.Attack.Type ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_defender_card maybe_attack char =
+get_defender_card attack char =
(Html.div
- (case maybe_attack of
- Nothing ->
- if ((Struct.Character.get_current_health char) > 0)
- then
- [
- (Html.Attributes.class "animated-portrait")
- ]
- else
- [
- (Html.Attributes.class "animated-portrait-absent"),
- (Html.Attributes.class "animated-portrait")
- ]
-
- (Just attack) ->
- [
- (Html.Attributes.class
- (case (attack.order, attack.parried) of
- (Struct.Attack.Counter, True) ->
- (get_defense_animation_class attack char)
+ [
+ (Html.Attributes.class
+ (case (attack.order, attack.parried) of
+ (Struct.Attack.Counter, True) ->
+ (get_defense_animation_class attack char)
- (Struct.Attack.Counter, _) ->
- (get_attack_animation_class attack char)
+ (Struct.Attack.Counter, _) ->
+ (get_attack_animation_class attack char)
- (_, True) ->
- (get_attack_animation_class attack char)
+ (_, True) ->
+ (get_attack_animation_class attack char)
- (_, _) ->
- (get_defense_animation_class attack char)
- )
- ),
- (Html.Attributes.class "animated-portrait")
- ]
- )
+ (_, _) ->
+ (get_defense_animation_class attack char)
+ )
+ ),
+ (Html.Attributes.class "animated-portrait")
+ ]
[
(View.Controlled.CharacterCard.get_minimal_html -1 char)
]
)
---------------------------------------------------------------------------------
--- EXPORTED --------------------------------------------------------------------
---------------------------------------------------------------------------------
get_placeholder_html : (
(Array.Array Struct.Character.Type) ->
Int ->
Int ->
- (Maybe Struct.Attack.Type) ->
+ Struct.Attack.Type ->
(Html.Html Struct.Event.Type)
)
-get_placeholder_html characters attacker_ix defender_ix maybe_attack =
+get_placeholder_html characters attacker_ix defender_ix attack =
case
(
(Array.get attacker_ix characters),
@@ -262,16 +230,9 @@ get_placeholder_html characters attacker_ix defender_ix maybe_attack =
]
(
[
- (get_attacker_card maybe_attack atkchar),
- (
- case maybe_attack of
- (Just attack) ->
- (get_attack_html atkchar defchar attack)
-
- Nothing ->
- (get_empty_attack_html)
- ),
- (get_defender_card maybe_attack defchar)
+ (get_attacker_card attack atkchar),
+ (get_attack_html atkchar defchar attack),
+ (get_defender_card attack defchar)
]
)
)
@@ -284,21 +245,18 @@ get_placeholder_html characters attacker_ix defender_ix maybe_attack =
(Html.text "Error: Attack with unknown characters")
]
)
-
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_html : (
- Struct.Battle.Type ->
- Int ->
- Int ->
- (Maybe Struct.Attack.Type) ->
+ Struct.Model.Type ->
+ Struct.Attack.Type ->
(Html.Html Struct.Event.Type)
)
-get_html battle attacker_ix defender_ix maybe_attack =
+get_html model attack =
(get_placeholder_html
- (Struct.Battle.get_characters battle)
- attacker_ix
- defender_ix
- maybe_attack
+ (Struct.Battle.get_characters model.battle)
+ 0 -- TODO: get attacker IX
+ 0 -- TODO: get defender IX
+ attack
)
diff --git a/src/battle/src/View/SubMenu/Timeline/Attack.elm b/src/battle/src/View/SubMenu/Timeline/Attack.elm
index 7301126..fe43b6a 100644
--- a/src/battle/src/View/SubMenu/Timeline/Attack.elm
+++ b/src/battle/src/View/SubMenu/Timeline/Attack.elm
@@ -153,8 +153,8 @@ get_html characters player_ix attack =
]
(
[
- (View.Character.get_portrait_html player_ix atkchar),
- (View.Character.get_portrait_html player_ix defchar),
+ (View.Character.get_portrait_html atkchar),
+ (View.Character.get_portrait_html defchar),
(get_title_html atkchar defchar)
]
++
diff --git a/src/battle/src/View/SubMenu/Timeline/Movement.elm b/src/battle/src/View/SubMenu/Timeline/Movement.elm
index 3ef305e..4d748be 100644
--- a/src/battle/src/View/SubMenu/Timeline/Movement.elm
+++ b/src/battle/src/View/SubMenu/Timeline/Movement.elm
@@ -38,7 +38,7 @@ get_html characters player_ix movement =
(Html.Attributes.class "timeline-movement")
]
[
- (View.Character.get_portrait_html player_ix char),
+ (View.Character.get_portrait_html char),
(Html.text
(
(BattleCharacters.Struct.Character.get_name
diff --git a/src/battle/src/View/SubMenu/Timeline/WeaponSwitch.elm b/src/battle/src/View/SubMenu/Timeline/WeaponSwitch.elm
index 50fd702..f547df8 100644
--- a/src/battle/src/View/SubMenu/Timeline/WeaponSwitch.elm
+++ b/src/battle/src/View/SubMenu/Timeline/WeaponSwitch.elm
@@ -38,7 +38,7 @@ get_html characters player_ix weapon_switch =
(Html.Attributes.class "timeline-weapon-switch")
]
[
- (View.Character.get_portrait_html player_ix char),
+ (View.Character.get_portrait_html char),
(Html.text
(
(BattleCharacters.Struct.Character.get_name