| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'src/battle/src/View/MessageBoard/Attack.elm')
| -rw-r--r-- | src/battle/src/View/MessageBoard/Attack.elm | 184 | 
1 files changed, 87 insertions, 97 deletions
| 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)     ) | 


