summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-05-30 22:15:57 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-05-30 22:15:57 +0200
commit17ed7ee567051f7a71da0ff292ac5de637f8a206 (patch)
treee8677823b83d38d3f0183632e8b036a93ea258be /src/battle/src/View
parentb0ef49dd94ed0c20a82d0a6094c3e4399c83bd64 (diff)
Improves code and animations for attacks.
Diffstat (limited to 'src/battle/src/View')
-rw-r--r--src/battle/src/View/MessageBoard/Animator.elm58
-rw-r--r--src/battle/src/View/MessageBoard/Attack.elm184
-rw-r--r--src/battle/src/View/SubMenu/Timeline/Attack.elm25
3 files changed, 102 insertions, 165 deletions
diff --git a/src/battle/src/View/MessageBoard/Animator.elm b/src/battle/src/View/MessageBoard/Animator.elm
deleted file mode 100644
index 99ff190..0000000
--- a/src/battle/src/View/MessageBoard/Animator.elm
+++ /dev/null
@@ -1,58 +0,0 @@
-module View.MessageBoard.Animator exposing (get_html)
-
--- Elm -------------------------------------------------------------------------
-import Html
-
--- Shared ----------------------------------------------------------------------
-import Util.Html
-
--- Local Module ----------------------------------------------------------------
-import Struct.Battle
-import Struct.Event
-import Struct.TurnResult
-import Struct.TurnResultAnimator
-
-import View.MessageBoard.Animator.Attack
-
---------------------------------------------------------------------------------
--- LOCAL -----------------------------------------------------------------------
---------------------------------------------------------------------------------
-get_turn_result_html : (
- Struct.Battle.Type ->
- Struct.TurnResult.Type ->
- (Html.Html Struct.Event.Type)
- )
-get_turn_result_html battle turn_result =
- case turn_result of
- (Struct.TurnResult.Attacked attack) ->
- (View.MessageBoard.Animator.Attack.get_html
- battle
- (Struct.TurnResult.get_actor_index turn_result)
- (Struct.TurnResult.get_attack_defender_index attack)
- (Struct.TurnResult.maybe_get_attack_next_step attack)
- )
-
- _ -> (Util.Html.nothing)
-
---------------------------------------------------------------------------------
--- EXPORTED --------------------------------------------------------------------
---------------------------------------------------------------------------------
-get_html : (
- Struct.Battle.Type ->
- Struct.TurnResultAnimator.Type ->
- (Html.Html Struct.Event.Type)
- )
-get_html battle animator =
- case (Struct.TurnResultAnimator.get_current_animation animator) of
- (Struct.TurnResultAnimator.TurnResult turn_result) ->
- (get_turn_result_html battle turn_result)
-
- (Struct.TurnResultAnimator.AttackSetup (attacker_id, defender_id)) ->
- (View.MessageBoard.Animator.Attack.get_html
- battle
- attacker_id
- defender_id
- Nothing
- )
-
- _ -> (Util.Html.nothing)
diff --git a/src/battle/src/View/MessageBoard/Attack.elm b/src/battle/src/View/MessageBoard/Attack.elm
index 3d2281f..1445c21 100644
--- a/src/battle/src/View/MessageBoard/Attack.elm
+++ b/src/battle/src/View/MessageBoard/Attack.elm
@@ -15,7 +15,6 @@ import Struct.Battle
import Struct.Character
import Struct.Event
import Struct.Model
-import Struct.TurnResult
import View.Controlled.CharacterCard
@@ -24,24 +23,25 @@ import View.Controlled.CharacterCard
--------------------------------------------------------------------------------
get_effect_text : Struct.Attack.Type -> String
get_effect_text attack =
+ let precision = (Struct.Attack.get_precision attack) in
(
(
- case attack.precision of
+ case precision of
Struct.Attack.Hit -> " hit for "
Struct.Attack.Graze -> " grazed for "
Struct.Attack.Miss -> " missed."
)
++
(
- if (attack.precision == Struct.Attack.Miss)
+ if (precision == Struct.Attack.Miss)
then
""
else
(
- ((String.fromInt attack.damage) ++ " damage")
+ ((String.fromInt (Struct.Attack.get_damage attack)) ++ " damage")
++
(
- if (attack.critical)
+ if (Struct.Attack.get_is_a_critical attack)
then " (Critical Hit)."
else "."
)
@@ -82,7 +82,12 @@ get_attack_html attacker defender attack =
[
(Html.text
(
- case (attack.order, attack.parried) of
+ case
+ (
+ (Struct.Attack.get_order attack),
+ (Struct.Attack.get_is_a_parry attack)
+ )
+ of
(Struct.Attack.Counter, True) ->
(
defender_name
@@ -121,7 +126,7 @@ get_attack_animation_class : (
String
)
get_attack_animation_class attack char =
- if (attack.critical)
+ if (Struct.Attack.get_is_a_critical attack)
then "animated-portrait-attack-critical"
else "animated-portrait-attacks"
@@ -131,147 +136,132 @@ get_defense_animation_class : (
String
)
get_defense_animation_class attack char =
- if (attack.damage == 0)
+ if ((Struct.Attack.get_damage attack) == 0)
then
- if (attack.precision == Struct.Attack.Miss)
+ if ((Struct.Attack.get_precision attack) == Struct.Attack.Miss)
then "animated-portrait-dodges"
else "animated-portrait-undamaged"
else if ((Struct.Character.get_current_health char) > 0)
then
- if (attack.precision == Struct.Attack.Graze)
+ if ((Struct.Attack.get_precision attack) == Struct.Attack.Graze)
then "animated-portrait-grazed-damage"
else "animated-portrait-damaged"
else
- if (attack.precision == Struct.Attack.Graze)
+ if ((Struct.Attack.get_precision attack) == Struct.Attack.Graze)
then "animated-portrait-grazed-death"
else "animated-portrait-dies"
get_attacker_card : (
+ Bool ->
Struct.Attack.Type ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_attacker_card attack char =
+get_attacker_card keep_positions attack char =
(Html.div
- (
- (Html.Attributes.class "animated-portrait")
- ::
- (
- if ((attack.order == Struct.Attack.Counter) == attack.parried)
- then
- [
- (Html.Attributes.class
- (get_attack_animation_class attack char)
- ),
- (Html.Attributes.class "initial-attacker")
- ]
- else
- [
- (Html.Attributes.class
- (get_defense_animation_class attack char)
- ),
- (Html.Attributes.class "initial-target")
- ]
+ [
+ (Html.Attributes.class "animated-portrait"),
+ (Html.Attributes.class (get_attack_animation_class attack char)),
+ (Html.Attributes.class
+ (
+ if (keep_positions)
+ then "initial-attacker"
+ else "initial-target"
+ )
)
- )
+ ]
[
(View.Controlled.CharacterCard.get_minimal_html
- (Struct.Character.get_player_index char)
+ -1
char
)
]
)
get_defender_card : (
+ Bool ->
Struct.Attack.Type ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_defender_card attack char =
+get_defender_card keep_positions attack char =
(Html.div
- (
- (Html.Attributes.class "animated-portrait")
- ::
- (
- if ((attack.order == Struct.Attack.Counter) == attack.parried)
- then
- [
- (Html.Attributes.class
- (get_defense_animation_class attack char)
- ),
- (Html.Attributes.class "initial-target")
- ]
- else
- [
- (Html.Attributes.class
- (get_attack_animation_class attack char)
- ),
- (Html.Attributes.class "initial-attacker")
- ]
+ [
+ (Html.Attributes.class "animated-portrait"),
+ (Html.Attributes.class (get_defense_animation_class attack char)),
+ (Html.Attributes.class
+ (
+ if (keep_positions)
+ then "initial-target"
+ else "initial-attacker"
+ )
)
- )
+ ]
[
(View.Controlled.CharacterCard.get_minimal_html -1 char)
]
)
get_placeholder_html : (
- (Array.Array Struct.Character.Type) ->
- Int ->
- Int ->
Struct.Attack.Type ->
+ (Array.Array Struct.Character.Type) ->
(Html.Html Struct.Event.Type)
)
-get_placeholder_html characters attacker_ix defender_ix attack =
- case
- (
- (Array.get attacker_ix characters),
- (Array.get defender_ix characters)
- )
- of
- ((Just atkchar), (Just defchar)) ->
- (Html.div
- [
- (Html.Attributes.class "message-board"),
- (Html.Attributes.class "message-attack")
- ]
- (
- if ((attack.order == Struct.Attack.Counter) == attack.parried)
- then
- [
- (get_attacker_card attack atkchar),
- (get_attack_html atkchar defchar attack),
- (get_defender_card attack defchar)
- ]
- else
- [
- (get_defender_card attack defchar),
- (get_attack_html atkchar defchar attack),
- (get_attacker_card attack atkchar)
- ]
- )
+get_placeholder_html attack characters =
+ let
+ keep_positions =
+ (
+ ((Struct.Attack.get_order attack) == Struct.Attack.Counter)
+ == (Struct.Attack.get_is_a_parry attack)
)
-
- _ ->
- (Html.div
- [
- ]
- [
- (Html.text "Error: Attack with unknown characters")
- ]
+ in
+ case
+ (
+ (Array.get (Struct.Attack.get_actor_index attack) characters),
+ (Array.get (Struct.Attack.get_target_index attack) characters)
)
+ of
+ ((Just atkchar), (Just defchar)) ->
+ (Html.div
+ [
+ (Html.Attributes.class "message-board"),
+ (Html.Attributes.class "message-attack")
+ ]
+ (
+ if (keep_positions)
+ then
+ [
+ (get_attacker_card keep_positions attack atkchar),
+ (get_attack_html atkchar defchar attack),
+ (get_defender_card keep_positions attack defchar)
+ ]
+ else
+ [
+ (get_defender_card keep_positions attack defchar),
+ (get_attack_html atkchar defchar attack),
+ (get_attacker_card keep_positions attack atkchar)
+ ]
+ )
+ )
+
+ _ ->
+ (Html.div
+ [
+ ]
+ [
+ (Html.text "Error: Attack with unknown characters")
+ ]
+ )
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_html : (
Struct.Model.Type ->
- Struct.TurnResult.Attack ->
+ Struct.Attack.Type ->
(Html.Html Struct.Event.Type)
)
get_html model attack =
(get_placeholder_html
+ attack
(Struct.Battle.get_characters model.battle)
- (Struct.TurnResult.get_attack_actor_index attack)
- (Struct.TurnResult.get_attack_target_index attack)
- (Struct.TurnResult.get_attack_data attack)
)
diff --git a/src/battle/src/View/SubMenu/Timeline/Attack.elm b/src/battle/src/View/SubMenu/Timeline/Attack.elm
index 1899ab4..2c92b87 100644
--- a/src/battle/src/View/SubMenu/Timeline/Attack.elm
+++ b/src/battle/src/View/SubMenu/Timeline/Attack.elm
@@ -12,7 +12,6 @@ import BattleCharacters.Struct.Character
-- Local Module ----------------------------------------------------------------
import Struct.Attack
import Struct.Event
-import Struct.TurnResult
import Struct.Character
import View.Character
@@ -49,24 +48,25 @@ get_title_html attacker defender =
get_effect_text : Struct.Attack.Type -> String
get_effect_text attack =
+ let precision = (Struct.Attack.get_precision attack) in
(
(
- case attack.precision of
+ case precision of
Struct.Attack.Hit -> " hit for "
Struct.Attack.Graze -> " grazed for "
Struct.Attack.Miss -> " missed."
)
++
(
- if (attack.precision == Struct.Attack.Miss)
+ if (precision == Struct.Attack.Miss)
then
""
else
(
- ((String.fromInt attack.damage) ++ " damage")
+ ((String.fromInt (Struct.Attack.get_damage attack)) ++ " damage")
++
(
- if (attack.critical)
+ if (Struct.Attack.get_is_a_critical attack)
then " (Critical Hit)."
else "."
)
@@ -96,7 +96,12 @@ get_attack_html attacker defender attack =
[
(Html.text
(
- case (attack.order, attack.parried) of
+ case
+ (
+ (Struct.Attack.get_order attack),
+ (Struct.Attack.get_is_a_parry attack)
+ )
+ of
(Struct.Attack.Counter, True) ->
(
defender_name
@@ -135,14 +140,14 @@ get_attack_html attacker defender attack =
get_html : (
(Array.Array Struct.Character.Type) ->
Int ->
- Struct.TurnResult.Attack ->
+ Struct.Attack.Type ->
(Html.Html Struct.Event.Type)
)
get_html characters player_ix attack =
case
(
- (Array.get attack.attacker_index characters),
- (Array.get attack.defender_index characters)
+ (Array.get (Struct.Attack.get_actor_index attack) characters),
+ (Array.get (Struct.Attack.get_target_index attack) characters)
)
of
((Just atkchar), (Just defchar)) ->
@@ -158,7 +163,7 @@ get_html characters player_ix attack =
(get_attack_html
atkchar
defchar
- (Struct.TurnResult.get_attack_data attack)
+ attack
)
]
)