summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2019-12-16 14:08:35 +0100
committernsensfel <SpamShield0@noot-noot.org>2019-12-16 14:08:35 +0100
commit2542493b58b23106a398ca048d4c238d442573fd (patch)
tree738cf4a49a8193224e525cf2f64899bf935ffb1b /src/battle/src/View/Map/Character.elm
parent1b44ddcad67726aac12025991dbd7f2c72267cec (diff)
Don't re-compute effects on every display.
Diffstat (limited to 'src/battle/src/View/Map/Character.elm')
-rw-r--r--src/battle/src/View/Map/Character.elm125
1 files changed, 16 insertions, 109 deletions
diff --git a/src/battle/src/View/Map/Character.elm b/src/battle/src/View/Map/Character.elm
index b20c29a..a62d197 100644
--- a/src/battle/src/View/Map/Character.elm
+++ b/src/battle/src/View/Map/Character.elm
@@ -20,7 +20,6 @@ import Struct.Battle
import Struct.Character
import Struct.CharacterTurn
import Struct.Event
-import Struct.Model
import Struct.TurnResult
import Struct.TurnResultAnimator
import Struct.UI
@@ -28,68 +27,6 @@ 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 +44,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 +106,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 +121,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 +143,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)