summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-05-29 20:26:01 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-05-29 20:26:01 +0200
commitb0ef49dd94ed0c20a82d0a6094c3e4399c83bd64 (patch)
tree2ef27df721029f75d13341b8237b4a7293264029
parentd35c5a2213bdc13cfdcd5dc15dbe5000b655ea25 (diff)
Updates attack elements in timeline and message board.
-rw-r--r--src/battle/src/Struct/PuppeteerAction.elm11
-rw-r--r--src/battle/src/Update/Puppeteer.elm7
-rw-r--r--src/battle/src/Update/Puppeteer/Hit.elm102
-rw-r--r--src/battle/src/View/MessageBoard/Attack.elm96
-rw-r--r--src/battle/src/View/SubMenu/Timeline/Attack.elm6
5 files changed, 117 insertions, 105 deletions
diff --git a/src/battle/src/Struct/PuppeteerAction.elm b/src/battle/src/Struct/PuppeteerAction.elm
index 9c0ba00..8543dca 100644
--- a/src/battle/src/Struct/PuppeteerAction.elm
+++ b/src/battle/src/Struct/PuppeteerAction.elm
@@ -30,6 +30,7 @@ type Effect =
| Focus Int
| DisplayMessage Struct.MessageBoard.Message
| ClearMessage Struct.MessageBoard.Message
+ | Hit Struct.TurnResult.Attack
| Move (Int, BattleMap.Struct.Direction.Type)
| RefreshCharacter (Bool, Int)
| RefreshCharactersOf (Bool, Int)
@@ -71,7 +72,15 @@ from_attacked attack =
),
(PerformFor
(
- 5.0,
+ 1.5,
+ [
+ ]
+ )
+ ),
+ (Perform [ (Hit attack) ]),
+ (PerformFor
+ (
+ 1.5,
[
]
)
diff --git a/src/battle/src/Update/Puppeteer.elm b/src/battle/src/Update/Puppeteer.elm
index 28ae6aa..de397ac 100644
--- a/src/battle/src/Update/Puppeteer.elm
+++ b/src/battle/src/Update/Puppeteer.elm
@@ -14,6 +14,7 @@ import Update.Puppeteer.AnnounceVictory
import Update.Puppeteer.DisplayCharacterNavigator
import Update.Puppeteer.DisplayMessage
import Update.Puppeteer.Focus
+import Update.Puppeteer.Hit
import Update.Puppeteer.Move
import Update.Puppeteer.RefreshCharacter
import Update.Puppeteer.RefreshCharactersOf
@@ -48,6 +49,9 @@ forward effect model =
model
)
+ (Struct.PuppeteerAction.Hit attack) ->
+ (Update.Puppeteer.Hit.forward attack model)
+
(Struct.PuppeteerAction.DisplayMessage message) ->
(Update.Puppeteer.DisplayMessage.forward message model)
@@ -121,6 +125,9 @@ backward effect model =
model
)
+ (Struct.PuppeteerAction.Hit attack) ->
+ (Update.Puppeteer.Hit.backward attack model)
+
(Struct.PuppeteerAction.DisplayCharacterNavigator character_ix) ->
(Update.Puppeteer.DisplayCharacterNavigator.backward
character_ix
diff --git a/src/battle/src/Update/Puppeteer/Hit.elm b/src/battle/src/Update/Puppeteer/Hit.elm
index 2584030..3b95e3e 100644
--- a/src/battle/src/Update/Puppeteer/Hit.elm
+++ b/src/battle/src/Update/Puppeteer/Hit.elm
@@ -4,14 +4,12 @@ module Update.Puppeteer.Hit exposing (forward, backward)
import Array
-- Local Module ----------------------------------------------------------------
-import Action.Scroll
-
import Struct.Attack
import Struct.Battle
+import Struct.TurnResult
import Struct.Character
import Struct.Event
import Struct.Model
-import Struct.UI
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
@@ -29,78 +27,80 @@ apply_damage_to_character damage char =
apply_to_characters : (
Int ->
- Int ->
Struct.Attack.Type ->
(Array.Array Struct.Character.Type) ->
(Array.Array Struct.Character.Type)
)
-apply_to_characters attacker_ix defender_ix attack characters =
- if ((attack.order == Struct.Attack.Counter) == attack.parried)
- then
- case (Array.get defender_ix characters) of
- (Just char) ->
- (Array.set
- defender_ix
- (apply_damage_to_character attack.damage char)
- characters
- )
-
- Nothing -> characters
- else
- case (Array.get attacker_ix characters) of
- (Just char) ->
- (Array.set
- attacker_ix
- (apply_damage_to_character attack.damage char)
- characters
- )
+apply_to_characters defender_ix attack characters =
+ case (Array.get defender_ix characters) of
+ (Just char) ->
+ (Array.set
+ defender_ix
+ (apply_damage_to_character attack.damage char)
+ characters
+ )
- Nothing -> characters
+ Nothing -> characters
apply_inverse_to_characters : (
Int ->
- Int ->
Struct.Attack.Type ->
(Array.Array Struct.Character.Type) ->
(Array.Array Struct.Character.Type)
)
-apply_inverse_to_characters attacker_ix defender_ix attack characters =
- if ((attack.order == Struct.Attack.Counter) == attack.parried)
- then
- case (Array.get defender_ix characters) of
- (Just char) ->
- (Array.set
- defender_ix
- (apply_damage_to_character (-1 * attack.damage) char)
- characters
- )
+apply_inverse_to_characters defender_ix attack characters =
+ case (Array.get defender_ix characters) of
+ (Just char) ->
+ (Array.set
+ defender_ix
+ (apply_damage_to_character (-1 * attack.damage) char)
+ characters
+ )
- Nothing -> characters
- else
- case (Array.get attacker_ix characters) of
- (Just char) ->
- (Array.set
- attacker_ix
- (apply_damage_to_character (-1 * attack.damage) char)
- characters
- )
-
- Nothing -> characters
+ Nothing -> characters
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
forward : (
- Struct.Attack.Type ->
+ Struct.TurnResult.Attack ->
Struct.Model.Type ->
(Struct.Model.Type, (List (Cmd Struct.Event.Type)))
)
-forward hit model = (model, [])
+forward attack model =
+ (
+ {model |
+ battle =
+ (Struct.Battle.set_characters
+ (apply_to_characters
+ (Struct.TurnResult.get_attack_target_index attack)
+ (Struct.TurnResult.get_attack_data attack)
+ (Struct.Battle.get_characters model.battle)
+ )
+ model.battle
+ )
+ },
+ []
+ )
backward : (
- Struct.Attack.Type ->
+ Struct.TurnResult.Attack ->
Struct.Model.Type ->
(Struct.Model.Type, (List (Cmd Struct.Event.Type)))
)
-backward hit model = (model, [])
+backward attack model =
+ (
+ {model |
+ battle =
+ (Struct.Battle.set_characters
+ (apply_inverse_to_characters
+ (Struct.TurnResult.get_attack_target_index attack)
+ (Struct.TurnResult.get_attack_data attack)
+ (Struct.Battle.get_characters model.battle)
+ )
+ model.battle
+ )
+ },
+ []
+ )
diff --git a/src/battle/src/View/MessageBoard/Attack.elm b/src/battle/src/View/MessageBoard/Attack.elm
index e589bab..3d2281f 100644
--- a/src/battle/src/View/MessageBoard/Attack.elm
+++ b/src/battle/src/View/MessageBoard/Attack.elm
@@ -94,16 +94,16 @@ get_attack_html attacker defender attack =
(Struct.Attack.Counter, _) ->
(
- defender_name
+ attacker_name
++ " striked back, and "
++ (get_effect_text attack)
)
(_, True) ->
(
- attacker_name
+ defender_name
++ " attempted a hit, but "
- ++ defender_name
+ ++ attacker_name
++ " parried, and "
++ (get_effect_text attack)
)
@@ -153,29 +153,27 @@ get_attacker_card : (
)
get_attacker_card attack char =
(Html.div
- [
- (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)
-
- (_, True) ->
- (get_defense_animation_class attack char)
-
- (_, _) ->
- (get_attack_animation_class attack char)
- )
- ),
- (Html.Attributes.class "animated-portrait"),
+ (
+ (Html.Attributes.class "animated-portrait")
+ ::
(
- if (attack.order == Struct.Attack.Counter)
- then (Html.Attributes.class "initial-target")
- else (Html.Attributes.class "initial-attacker")
+ 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")
+ ]
)
- ]
+ )
[
(View.Controlled.CharacterCard.get_minimal_html
(Struct.Character.get_player_index char)
@@ -191,29 +189,27 @@ get_defender_card : (
)
get_defender_card attack char =
(Html.div
- [
- (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)
-
- (_, True) ->
- (get_attack_animation_class attack char)
-
- (_, _) ->
- (get_defense_animation_class attack char)
- )
- ),
- (Html.Attributes.class "animated-portrait"),
+ (
+ (Html.Attributes.class "animated-portrait")
+ ::
(
- if (attack.order == Struct.Attack.Counter)
- then (Html.Attributes.class "initial-attacker")
- else (Html.Attributes.class "initial-target")
+ 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")
+ ]
)
- ]
+ )
[
(View.Controlled.CharacterCard.get_minimal_html -1 char)
]
@@ -240,18 +236,18 @@ get_placeholder_html characters attacker_ix defender_ix attack =
(Html.Attributes.class "message-attack")
]
(
- if (attack.order == Struct.Attack.Counter)
+ if ((attack.order == Struct.Attack.Counter) == attack.parried)
then
[
- (get_defender_card attack defchar),
+ (get_attacker_card attack atkchar),
(get_attack_html atkchar defchar attack),
- (get_attacker_card attack atkchar)
+ (get_defender_card attack defchar)
]
else
[
- (get_attacker_card attack atkchar),
+ (get_defender_card attack defchar),
(get_attack_html atkchar defchar attack),
- (get_defender_card attack defchar)
+ (get_attacker_card attack atkchar)
]
)
)
diff --git a/src/battle/src/View/SubMenu/Timeline/Attack.elm b/src/battle/src/View/SubMenu/Timeline/Attack.elm
index 9295951..1899ab4 100644
--- a/src/battle/src/View/SubMenu/Timeline/Attack.elm
+++ b/src/battle/src/View/SubMenu/Timeline/Attack.elm
@@ -108,16 +108,16 @@ get_attack_html attacker defender attack =
(Struct.Attack.Counter, _) ->
(
- defender_name
+ attacker_name
++ " striked back, and "
++ (get_effect_text attack)
)
(_, True) ->
(
- attacker_name
+ defender_name
++ " attempted a hit, but "
- ++ defender_name
+ ++ attacker_name
++ " parried, and "
++ (get_effect_text attack)
)