summaryrefslogtreecommitdiff |
diff options
-rw-r--r-- | src/battle/src/Struct/Attack.elm | 72 | ||||
-rw-r--r-- | src/battle/src/Update/Puppeteer/Hit.elm | 104 |
2 files changed, 104 insertions, 72 deletions
diff --git a/src/battle/src/Struct/Attack.elm b/src/battle/src/Struct/Attack.elm index a4937db..7ef8280 100644 --- a/src/battle/src/Struct/Attack.elm +++ b/src/battle/src/Struct/Attack.elm @@ -3,8 +3,6 @@ module Struct.Attack exposing Type, Order(..), Precision(..), - apply_to_characters, - apply_inverse_to_characters, decoder ) @@ -73,76 +71,6 @@ decoder = (Json.Decode.field "dmg" (Json.Decode.int)) ) -apply_damage_to_character : ( - Int -> - Struct.Character.Type -> - Struct.Character.Type - ) -apply_damage_to_character damage char = - (Struct.Character.set_current_health - ((Struct.Character.get_current_health char) - damage) - char - ) - -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- -apply_to_characters : ( - Int -> - Int -> - Type -> - (Array.Array Struct.Character.Type) -> - (Array.Array Struct.Character.Type) - ) -apply_to_characters attacker_ix defender_ix attack characters = - if ((attack.order == 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 - ) - - Nothing -> characters - -apply_inverse_to_characters : ( - Int -> - Int -> - Type -> - (Array.Array Struct.Character.Type) -> - (Array.Array Struct.Character.Type) - ) -apply_inverse_to_characters attacker_ix defender_ix attack characters = - if ((attack.order == 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 - ) - - 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 diff --git a/src/battle/src/Update/Puppeteer/Hit.elm b/src/battle/src/Update/Puppeteer/Hit.elm new file mode 100644 index 0000000..3c0e409 --- /dev/null +++ b/src/battle/src/Update/Puppeteer/Hit.elm @@ -0,0 +1,104 @@ +module Update.Puppeteer.Hit exposing (forward, backward) + +-- Local Module ---------------------------------------------------------------- +import Action.Scroll + +import Struct.Battle +import Struct.Character +import Struct.Event +import Struct.Model +import Struct.UI + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +apply_damage_to_character : ( + Int -> + Struct.Character.Type -> + Struct.Character.Type + ) +apply_damage_to_character damage char = + (Struct.Character.set_current_health + ((Struct.Character.get_current_health char) - damage) + char + ) + +apply_to_characters : ( + Int -> + Int -> + Type -> + (Array.Array Struct.Character.Type) -> + (Array.Array Struct.Character.Type) + ) +apply_to_characters attacker_ix defender_ix attack characters = + if ((attack.order == 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 + ) + + Nothing -> characters + +apply_inverse_to_characters : ( + Int -> + Int -> + Type -> + (Array.Array Struct.Character.Type) -> + (Array.Array Struct.Character.Type) + ) +apply_inverse_to_characters attacker_ix defender_ix attack characters = + if ((attack.order == 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 + ) + + 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 + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +forward : ( + Int -> + Struct.Attack.Type -> + Struct.Model.Type -> + (Struct.Model.Type, (List (Cmd Struct.Event.Type))) + ) +forward actor_ix hit model = (model, []) + + +backward : ( + Int -> + Struct.Attack.Type -> + Struct.Model.Type -> + (Struct.Model.Type, (List (Cmd Struct.Event.Type))) + ) +backward actor_ix hit model = (model, []) |