aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2018-03-13 21:46:39 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2018-03-13 21:46:39 +0100
commit44d1ff6a942a64dd87ea51bb8b4db47515ab983a (patch)
tree388d41232458094e214906189ad8a74ca96a28ca
parentc1dcbd5f5fef731e0c7055be0e52fc0f674715cb (diff)
downloadtacticians-client-44d1ff6a942a64dd87ea51bb8b4db47515ab983a.zip
tacticians-client-44d1ff6a942a64dd87ea51bb8b4db47515ab983a.tar.bz2
Improves attack messages.
-rw-r--r--src/battlemap/src/Struct/Attack.elm4
-rw-r--r--src/battlemap/src/View/SideBar/TabMenu/Timeline/Attack.elm145
-rw-r--r--src/battlemap/www/style.css12
3 files changed, 149 insertions, 12 deletions
diff --git a/src/battlemap/src/Struct/Attack.elm b/src/battlemap/src/Struct/Attack.elm
index 16df73f..4eab68e 100644
--- a/src/battlemap/src/Struct/Attack.elm
+++ b/src/battlemap/src/Struct/Attack.elm
@@ -1,8 +1,8 @@
module Struct.Attack exposing
(
Type,
- Order,
- Precision,
+ Order(..),
+ Precision(..),
apply_to_characters,
decoder
)
diff --git a/src/battlemap/src/View/SideBar/TabMenu/Timeline/Attack.elm b/src/battlemap/src/View/SideBar/TabMenu/Timeline/Attack.elm
index 2fa7e0a..fd95281 100644
--- a/src/battlemap/src/View/SideBar/TabMenu/Timeline/Attack.elm
+++ b/src/battlemap/src/View/SideBar/TabMenu/Timeline/Attack.elm
@@ -8,6 +8,7 @@ import Html.Attributes
--import Html.Events
-- Battlemap -------------------------------------------------------------------
+import Struct.Attack
import Struct.Event
import Struct.TurnResult
import Struct.Character
@@ -16,6 +17,130 @@ 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 : (
+ Struct.Character.Type ->
+ Bool ->
+ (Html.Html Struct.Event.Type)
+ )
+get_portrait_html char float_left =
+ (Html.div
+ [
+ (Html.Attributes.class "battlemap-timeline-portrait"),
+ (
+ if (float_left)
+ then
+ (Html.Attributes.class "battlemap-float-left")
+ else
+ (Html.Attributes.class "battlemap-float-right")
+ ),
+ (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 -> " hits for "
+ Struct.Attack.Graze -> " grazes for "
+ Struct.Attack.Miss -> " misses."
+ )
+ ++
+ (
+ if (attack.precision == Struct.Attack.Miss)
+ then
+ ""
+ else
+ (
+ ((toString attack.damage) ++ " damage")
+ ++
+ (
+ if (attack.critical)
+ then " (Critical)."
+ 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
+ ++ " attempts to strike back, but "
+ ++ attacker_name
+ ++ " parries, and "
+ ++ (get_effect_text attack)
+ )
+
+ (Struct.Attack.Counter, _) ->
+ (
+ defender_name
+ ++ " strikes back, and "
+ ++ (get_effect_text attack)
+ )
+
+ (_, True) ->
+ (
+ attacker_name
+ ++ " attempts a hit, but "
+ ++ defender_name
+ ++ " parries, and "
+ ++ (get_effect_text attack)
+ )
+
+ (_, _) ->
+ (attacker_name ++ " " ++ (get_effect_text attack))
+ )
+ )
+ ]
+ )
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
@@ -38,16 +163,18 @@ get_html model attack =
(Html.Attributes.class "battlemap-timeline-element"),
(Html.Attributes.class "battlemap-timeline-attack")
]
- [
- (Html.text
- (
- (Struct.Character.get_name atkchar)
- ++ " attacked "
- ++ (Struct.Character.get_name defchar)
- ++ "!"
- )
+ (
+ [
+ (get_portrait_html atkchar True),
+ (get_portrait_html defchar False),
+ (get_title_html atkchar defchar)
+ ]
+ ++
+ (List.map
+ (get_attack_html atkchar defchar)
+ attack.sequence
)
- ]
+ )
)
_ ->
diff --git a/src/battlemap/www/style.css b/src/battlemap/www/style.css
index 149eafc..08ec900 100644
--- a/src/battlemap/www/style.css
+++ b/src/battlemap/www/style.css
@@ -96,6 +96,9 @@
width: inherit;
}
+.battlemap-float-left { float: left; }
+.battlemap-float-right { float: right; }
+
.battlemap-manual-controls
{
max-height: 30%;
@@ -117,7 +120,8 @@
flex-wrap: wrap;
}
-.battlemap-character-portrait
+.battlemap-character-portrait,
+.battlemap-timeline-portrait
{
margin: 0.5em;
box-sizing: border-box;
@@ -154,6 +158,12 @@
height: 64px;
float: left;
}
+
+.battlemap-timeline-portrait
+{
+ width: 64px;
+ height: 64px;
+}
/******************************************************************************/
/** Main View Elements ********************************************************/
/******************************************************************************/