summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-01-14 19:30:19 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-01-14 19:30:19 +0100
commitb3bfd26ce3764fae2a846981e4d8c5db90a1aecc (patch)
tree68ae641b5ca4a77c97248aa1671b593d880aeb7b
parentdc8d1139c141b5281145829b5e87602425b4893f (diff)
parentdc7c1857845a5da7cd6cba178c16fa8ea8c68cec (diff)
...
-rw-r--r--conf/nginx.conf15
-rw-r--r--src/battle/src/Struct/Battle.elm55
-rw-r--r--src/battle/src/Struct/Character.elm59
-rw-r--r--src/battle/src/Struct/MessageBoard.elm72
-rw-r--r--src/battle/src/Struct/Model.elm22
-rw-r--r--src/battle/src/Struct/PuppeteerAction.elm16
-rw-r--r--src/battle/src/Struct/TurnResult.elm371
-rw-r--r--src/battle/src/Update/HandleServerReply.elm2
-rw-r--r--src/battle/src/View/Character.elm202
-rw-r--r--src/battle/src/View/Controlled/CharacterCard.elm6
-rw-r--r--src/battle/src/View/Map/Character.elm129
-rw-r--r--src/battle/src/View/MessageBoard.elm28
-rw-r--r--src/battle/src/View/MessageBoard/Attack.elm (renamed from src/battle/src/View/MessageBoard/Animator/Attack.elm)138
-rw-r--r--src/battle/src/View/SubMenu/Timeline/Attack.elm4
-rw-r--r--src/battle/src/View/SubMenu/Timeline/Movement.elm2
-rw-r--r--src/battle/src/View/SubMenu/Timeline/WeaponSwitch.elm2
16 files changed, 303 insertions, 820 deletions
diff --git a/conf/nginx.conf b/conf/nginx.conf
index afafbd5..82ec6b7 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -69,6 +69,21 @@ http {
}
}
+ server {
+# listen 127.0.0.1;
+ listen *:2900;
+ server_name localhost;
+ access_log /var/log/nginx/localhost.access_log main;
+ error_log /var/log/nginx/localhost.error_log info;
+
+ root /my/src/nickel-bet-client/www/;
+
+ location / {
+ autoindex on;
+ autoindex_exact_size off;
+ }
+ }
+
# ## Public tests
# server {
# listen 443;
diff --git a/src/battle/src/Struct/Battle.elm b/src/battle/src/Struct/Battle.elm
index c7f5c0a..84d08ba 100644
--- a/src/battle/src/Struct/Battle.elm
+++ b/src/battle/src/Struct/Battle.elm
@@ -85,14 +85,14 @@ regenerate_attack_of_opportunity_tags_for_char char_ix char battle =
let
tag_name = ("matk_c" ++ (String.fromInt char_ix))
map_without_this_tag =
- (BattleMap.Struct.Map.remove_tag tag_name battle.map)
+ (BattleMap.Struct.Map.remove_marker tag_name battle.map)
in
case (Struct.Character.get_melee_attack_range char) of
0 -> {battle | map = map_without_this_tag}
attack_range ->
{battle |
map =
- (BattleMap.Struct.Map.add_tag
+ (BattleMap.Struct.Map.add_marker
tag_name
(BattleMap.Struct.Marker.new_melee_attack
char_ix
@@ -131,12 +131,19 @@ new =
---- Characters ----
--------------------
add_character : Struct.Character.Type -> Type -> Type
-add_character char battle =
- let characters = battle.characters in
- (regenerate_attack_of_opportunity_markers_of_char
+add_character s0char battle =
+ let
+ s1char =
+ (Struct.Character.reset_extra_display_effects
+ battle.own_player_ix
+ s0char
+ )
+ characters = battle.characters
+ in
+ (regenerate_attack_of_opportunity_tags_for_char
(Array.length characters)
- char
- {battle | characters = (Array.push char characters)}
+ s1char
+ {battle | characters = (Array.push s1char characters)}
)
get_character : Int -> Type -> (Maybe Struct.Character.Type)
@@ -163,21 +170,27 @@ set_characters chars battle = {battle | characters = chars}
refresh_character : BattleMap.Struct.DataSet.Type -> Int -> Type -> Type
refresh_character map_dataset ix battle =
- let
- character = (get_character ix battle)
- refreshed_character =
- (Struct.Character.refresh_omnimods
- (\loc ->
- (BattleMap.Struct.Map.get_omnimods_at loc map_dataset battle.map)
+ case (get_character ix battle) of
+ Nothing -> battle
+ (Just character) ->
+ let
+ refreshed_character =
+ (Struct.Character.refresh_omnimods
+ (\loc ->
+ (BattleMap.Struct.Map.get_omnimods_at
+ loc
+ map_dataset
+ battle.map
+ )
+ )
+ character
+ )
+ in
+ (regenerate_attack_of_opportunity_tags_for_char
+ ix
+ refreshed_character
+ (set_character ix refreshed_character battle)
)
- character
- )
- in
- (regenerate_attack_of_opportunity_tags_for_char
- ix
- refreshed_character
- (set_character ix refreshed_character battle)
- )
-----------------
---- Players ----
diff --git a/src/battle/src/Struct/Character.elm b/src/battle/src/Struct/Character.elm
index 54a3a8c..6cdbaab 100644
--- a/src/battle/src/Struct/Character.elm
+++ b/src/battle/src/Struct/Character.elm
@@ -21,6 +21,11 @@ module Struct.Character exposing
set_base_character,
get_melee_attack_range,
refresh_omnimods,
+ add_extra_display_effect,
+ remove_extra_display_effect,
+ get_extra_display_effects,
+ get_extra_display_effects_list,
+ reset_extra_display_effects,
decoder,
resolve
)
@@ -60,7 +65,8 @@ type alias Type =
player_ix : Int,
enabled : Bool,
defeated : Bool,
- base : BattleCharacters.Struct.Character.Type
+ base : BattleCharacters.Struct.Character.Type,
+ extra_display_effects : (Set.Set String)
}
type alias Unresolved =
@@ -187,7 +193,7 @@ refresh_omnimods : (
Type ->
Type
)
-refresh_omnimods omnimods_fun character =
+refresh_omnimods omnimods_fun char =
let
previous_max_health =
(Battle.Struct.Attributes.get_max_health
@@ -236,6 +242,52 @@ set_enabled enabled char = {char | enabled = enabled}
set_defeated : Bool -> Type -> Type
set_defeated defeated char = {char | defeated = defeated}
+add_extra_display_effect : String -> Type -> Type
+add_extra_display_effect effect_name char =
+ {char |
+ extra_display_effects =
+ (Set.insert effect_name char.extra_display_effects)
+ }
+
+remove_extra_display_effect : String -> Type -> Type
+remove_extra_display_effect effect_name char =
+ {char |
+ extra_display_effects =
+ (Set.remove effect_name char.extra_display_effects)
+ }
+
+get_extra_display_effects : Type -> (Set.Set String)
+get_extra_display_effects char = char.extra_display_effects
+
+get_extra_display_effects_list : Type -> (List String)
+get_extra_display_effects_list char = (Set.toList char.extra_display_effects)
+
+reset_extra_display_effects : Int -> Type -> Type
+reset_extra_display_effects viewer_ix char =
+ {char |
+ extra_display_effects =
+ (Set.fromList
+ [
+ (
+ if (viewer_ix == char.player_ix)
+ then "ally"
+ else "enemy"
+ ),
+ ("team-" ++ (String.fromInt char.player_ix)),
+ (
+ if (char.enabled)
+ then "enabled"
+ else "disabled"
+ ),
+ (
+ if (is_alive char)
+ then "alive"
+ else "dead"
+ )
+ ]
+ )
+ }
+
decoder : (Json.Decode.Decoder Unresolved)
decoder =
(Json.Decode.succeed
@@ -284,5 +336,6 @@ resolve location_omnimod_resolver equipment_resolver ref =
(equipment_resolver)
(location_omnimod_resolver ref.location)
ref.base
- )
+ ),
+ extra_display_effects = (Set.empty)
}
diff --git a/src/battle/src/Struct/MessageBoard.elm b/src/battle/src/Struct/MessageBoard.elm
new file mode 100644
index 0000000..4c3ad1c
--- /dev/null
+++ b/src/battle/src/Struct/MessageBoard.elm
@@ -0,0 +1,72 @@
+module Struct.MessageBoard exposing
+ (
+ Type,
+ Message(..),
+ display,
+ try_getting_current_message,
+ clear_current_message,
+ new,
+ clear
+ )
+
+-- Elm -------------------------------------------------------------------------
+
+-- Local Module ----------------------------------------------------------------
+import Struct.Attack
+import Struct.Error
+import Struct.HelpRequest
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type Message =
+ Help Struct.HelpRequest.Type
+ | Error Struct.Error.Type
+ | AttackReport Struct.Attack.Type
+
+type alias Type =
+ {
+ secondary_messages : (List Message),
+ main_message : (Maybe Message)
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+display : Message -> Type -> Type
+display message board =
+ case message of
+ (AttackReport _) -> {board | main_message = (Just message)}
+ _ ->
+ {board |
+ secondary_messages = (message :: board.secondary_messages)
+ }
+
+try_getting_current_message : Type -> (Maybe Message)
+try_getting_current_message board =
+ case board.secondary_messages of
+ [] -> board.main_message
+ (secondary_message :: _) -> (Just secondary_message)
+
+clear_current_message : Type -> Type
+clear_current_message board =
+ case board.secondary_messages of
+ [] -> {board | main_message = Nothing}
+ (_ :: remaining_secondary_messages) ->
+ {board |
+ secondary_messages = remaining_secondary_messages
+ }
+
+new : Type
+new =
+ {
+ secondary_messages = [],
+ main_message = Nothing
+ }
+
+clear : Type -> Type
+clear board = (new)
diff --git a/src/battle/src/Struct/Model.elm b/src/battle/src/Struct/Model.elm
index a53b4df..989f66d 100644
--- a/src/battle/src/Struct/Model.elm
+++ b/src/battle/src/Struct/Model.elm
@@ -19,9 +19,9 @@ import BattleMap.Struct.DataSet
-- Local Module ----------------------------------------------------------------
import Struct.CharacterTurn
import Struct.Error
-import Struct.HelpRequest
-import Struct.TurnResult
+import Struct.MessageBoard
import Struct.Puppeteer
+import Struct.TurnResult
import Struct.UI
--------------------------------------------------------------------------------
@@ -30,11 +30,10 @@ import Struct.UI
type alias Type =
{
flags : Struct.Flags.Type,
- help_request : Struct.HelpRequest.Type,
puppeteer : Struct.Puppeteer.Type,
ui : Struct.UI.Type,
char_turn : Struct.CharacterTurn.Type,
- error : (Maybe Struct.Error.Type),
+ message_board : Struct.MessageBoard.Type,
battle : Struct.Battle.Type,
@@ -56,11 +55,10 @@ new flags =
model =
{
flags = flags,
- help_request = Struct.HelpRequest.None,
puppeteer = (Struct.Puppeteer.new),
ui = (Struct.UI.default),
char_turn = (Struct.CharacterTurn.new),
- error = Nothing,
+ message_board = (Struct.MessageBoard.new),
characters_data_set = (BattleCharacters.Struct.DataSet.new),
map_data_set = (BattleMap.Struct.DataSet.new),
@@ -86,8 +84,7 @@ new flags =
clear : Type -> Type
clear model =
{model |
- help_request = Struct.HelpRequest.None,
- error = Nothing,
+ message_board = (Struct.MessageBoard.clear),
ui =
(Struct.UI.reset_displayed_nav
(Struct.UI.set_previous_action Nothing model.ui)
@@ -98,8 +95,9 @@ clear model =
invalidate : Struct.Error.Type -> Type -> Type
invalidate err model =
{model |
- error = (Just err)
+ message_board =
+ (Struct.MessageBoard.display
+ (Struct.MessageBoard.Error err)
+ model.message_board
+ )
}
-
-clear_error : Type -> Type
-clear_error model = {model | error = Nothing}
diff --git a/src/battle/src/Struct/PuppeteerAction.elm b/src/battle/src/Struct/PuppeteerAction.elm
index 47a0bcc..c8207b0 100644
--- a/src/battle/src/Struct/PuppeteerAction.elm
+++ b/src/battle/src/Struct/PuppeteerAction.elm
@@ -11,8 +11,10 @@ import Set
-- Battle Map ------------------------------------------------------------------
import BattleMap.Struct.DataSet
+import BattleMap.Struct.Direction
-- Local Module ----------------------------------------------------------------
+import Struct.Attack
import Struct.Battle
import Struct.TurnResult
@@ -24,9 +26,9 @@ type Effect =
| AnnounceVictory Int
| Focus Int
| Hit Struct.Attack.Type
- | Move (Int, Battle.Struct.Direction)
- | RefreshCharacter (Boolean, Int)
- | RefreshCharactersOf (Boolean, Int)
+ | Move (Int, BattleMap.Struct.Direction.Type)
+ | RefreshCharacter (Bool, Int)
+ | RefreshCharactersOf (Bool, Int)
| StartTurn Int
| SwapWeapons Int
| Target (Int, Int)
@@ -54,7 +56,7 @@ from_attacked attack =
(PerformFor (2.0, [(Focus attacker_ix)])),
(PerformFor (2.0, [(Focus defender_ix)])),
(List.map
- (PerformFor (..., (Hit attack)))
+ (PerformFor (5.0, (Hit attack)))
),
(Perform
[
@@ -70,8 +72,10 @@ from_moved movement =
(
[
(PerformFor (1.0, [(Focus actor_ix)])),
- (Perform [(RefreshCharacter (False, actor_ix))]),
- |
+ (Perform [(RefreshCharacter (False, actor_ix))])
+ ]
+ ++
+ [
(List.map
(\dir ->
(PerformFor
diff --git a/src/battle/src/Struct/TurnResult.elm b/src/battle/src/Struct/TurnResult.elm
index aaf3dfa..b0d7d09 100644
--- a/src/battle/src/Struct/TurnResult.elm
+++ b/src/battle/src/Struct/TurnResult.elm
@@ -7,13 +7,6 @@ module Struct.TurnResult exposing
PlayerVictory,
PlayerDefeat,
PlayerTurnStart,
- get_next_movement_dir,
- get_actor_index,
- get_attack_defender_index,
- maybe_get_attack_next_step,
- apply_inverse_step,
- apply_step,
- maybe_remove_step,
decoder
)
@@ -90,218 +83,6 @@ type Type =
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-apply_movement_step : (
- (BattleMap.Struct.Location.Type -> Battle.Struct.Omnimods.Type) ->
- Movement ->
- (Array.Array Struct.Character.Type) ->
- (Array.Array Struct.Player.Type) ->
- (
- (Array.Array Struct.Character.Type),
- (Array.Array Struct.Player.Type)
- )
- )
-apply_movement_step tile_omnimods movement characters players =
- (
- (Util.Array.update_unsafe
- movement.character_index
- (\char ->
- case (List.head movement.path) of
- (Just dir) ->
- (Struct.Character.dirty_set_location
- (BattleMap.Struct.Location.neighbor
- dir
- (Struct.Character.get_location char)
- )
- char
- )
-
- Nothing ->
- let current_location = (Struct.Character.get_location char) in
- (Struct.Character.set_location
- current_location
- (tile_omnimods current_location)
- char
- )
- )
- characters
- ),
- players
- )
-
-apply_inverse_movement_step : (
- (BattleMap.Struct.Location.Type -> Battle.Struct.Omnimods.Type) ->
- Movement ->
- (Array.Array Struct.Character.Type) ->
- (Array.Array Struct.Player.Type) ->
- (
- (Array.Array Struct.Character.Type),
- (Array.Array Struct.Player.Type)
- )
- )
-apply_inverse_movement_step tile_omnimods movement characters players =
- (
- (Util.Array.update_unsafe
- movement.character_index
- (\char ->
- (
- let
- location =
- (List.foldr
- (BattleMap.Struct.Location.neighbor)
- (Struct.Character.get_location char)
- --(movement.destination)
- (List.map
- (BattleMap.Struct.Direction.opposite_of)
- movement.path
- )
- )
- in
- (Struct.Character.set_location
- location
- (tile_omnimods location)
- char
- )
- )
- )
- characters
- ),
- players
- )
-
-apply_switched_weapon : (
- WeaponSwitch ->
- (Array.Array Struct.Character.Type) ->
- (Array.Array Struct.Player.Type) ->
- (
- (Array.Array Struct.Character.Type),
- (Array.Array Struct.Player.Type)
- )
- )
-apply_switched_weapon weapon_switch characters players =
- (
- (Util.Array.update_unsafe
- weapon_switch.character_index
- (\char ->
- (Struct.Character.set_base_character
- (BattleCharacters.Struct.Character.switch_weapons
- (Struct.Character.get_base_character char)
- )
- char
- )
- )
- characters
- ),
- players
- )
-
-apply_player_defeat : (
- PlayerDefeat ->
- (Array.Array Struct.Character.Type) ->
- (Array.Array Struct.Player.Type) ->
- (
- (Array.Array Struct.Character.Type),
- (Array.Array Struct.Player.Type)
- )
- )
-apply_player_defeat pdefeat characters players =
- (
- (Array.map
- (\c ->
- if ((Struct.Character.get_player_index c) == pdefeat.player_index)
- then (Struct.Character.set_defeated True c)
- else c
- )
- characters
- ),
- players
- )
-
-apply_inverse_player_defeat : (
- PlayerDefeat ->
- (Array.Array Struct.Character.Type) ->
- (Array.Array Struct.Player.Type) ->
- (
- (Array.Array Struct.Character.Type),
- (Array.Array Struct.Player.Type)
- )
- )
-apply_inverse_player_defeat pdefeat characters players =
- (
- (Array.map
- (\c ->
- (
- if
- (
- (Struct.Character.get_player_index c)
- == pdefeat.player_index
- )
- then (Struct.Character.set_defeated False c)
- else c
- )
- )
- characters
- ),
- players
- )
-
-apply_attack_step : (
- Attack ->
- (Array.Array Struct.Character.Type) ->
- (Array.Array Struct.Player.Type) ->
- (
- (Array.Array Struct.Character.Type),
- (Array.Array Struct.Player.Type)
- )
- )
-apply_attack_step attack characters players =
- case (List.head attack.sequence) of
- (Just attack_step) ->
- (
- (Struct.Attack.apply_to_characters
- attack.attacker_index
- attack.defender_index
- attack_step
- characters
- ),
- players
- )
-
- Nothing ->
- (
- characters,
- (Util.Array.update_unsafe
- attack.attacker_index
- (Struct.Player.set_luck attack.attacker_luck)
- (Util.Array.update_unsafe
- attack.defender_index
- (Struct.Player.set_luck attack.defender_luck)
- players
- )
- )
- )
-
-apply_inverse_attack : (
- Attack ->
- (Array.Array Struct.Character.Type) ->
- (Array.Array Struct.Player.Type) ->
- (
- (Array.Array Struct.Character.Type),
- (Array.Array Struct.Player.Type)
- )
- )
-apply_inverse_attack attack characters players =
- (
- (List.foldr
- (Struct.Attack.apply_inverse_to_characters
- attack.attacker_index
- attack.defender_index
- )
- characters
- attack.sequence
- ),
- players
- )
-
movement_decoder : (Json.Decode.Decoder Movement)
movement_decoder =
(Json.Decode.map3
@@ -397,162 +178,10 @@ internal_decoder kind =
++ "\"."
)
)
-
-maybe_remove_movement_step : Movement -> (Maybe Type)
-maybe_remove_movement_step movement =
- case (List.tail movement.path) of
- Nothing -> Nothing
- (Just path_tail) ->
- (Just
- (Moved
- {movement |
- path = path_tail
- }
- )
- )
-
-maybe_remove_attack_step : Attack -> (Maybe Type)
-maybe_remove_attack_step attack =
- case (List.tail attack.sequence) of
- Nothing -> Nothing
- (Just sequence_tail) ->
- (Just
- (Attacked
- {attack |
- sequence = sequence_tail
- }
- )
- )
-
-apply_player_victory : (
- PlayerVictory ->
- (Array.Array Struct.Character.Type) ->
- (Array.Array Struct.Player.Type) ->
- (
- (Array.Array Struct.Character.Type),
- (Array.Array Struct.Player.Type)
- )
- )
-apply_player_victory player_victory characters players =
- (
- characters,
- players
- )
-
-apply_player_turn_started : (
- PlayerTurnStart ->
- (Array.Array Struct.Character.Type) ->
- (Array.Array Struct.Player.Type) ->
- (
- (Array.Array Struct.Character.Type),
- (Array.Array Struct.Player.Type)
- )
- )
-apply_player_turn_started player_defeat characters players =
- (
- characters,
- players
- )
-
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
-apply_step : (
- (BattleMap.Struct.Location.Type -> Battle.Struct.Omnimods.Type) ->
- Type ->
- (Array.Array Struct.Character.Type) ->
- (Array.Array Struct.Player.Type) ->
- (
- (Array.Array Struct.Character.Type),
- (Array.Array Struct.Player.Type)
- )
- )
-apply_step tile_omnimods turn_result characters players =
- case turn_result of
- (Moved movement) ->
- (apply_movement_step (tile_omnimods) movement characters players)
-
- (SwitchedWeapon weapon_switch) ->
- (apply_switched_weapon weapon_switch characters players)
-
- (Attacked attack) ->
- (apply_attack_step attack characters players)
-
- (PlayerWon pvict) ->
- (apply_player_victory pvict characters players)
-
- (PlayerLost pdefeat) ->
- (apply_player_defeat pdefeat characters players)
-
- (PlayerTurnStarted pturns) ->
- (apply_player_turn_started pturns characters players)
-
-apply_inverse_step : (
- (BattleMap.Struct.Location.Type -> Battle.Struct.Omnimods.Type) ->
- Type ->
- (Array.Array Struct.Character.Type) ->
- (Array.Array Struct.Player.Type) ->
- (
- (Array.Array Struct.Character.Type),
- (Array.Array Struct.Player.Type)
- )
- )
-apply_inverse_step tile_omnimods turn_result characters players =
- case turn_result of
- (Moved movement) ->
- (apply_inverse_movement_step
- (tile_omnimods)
- movement
- characters
- players
- )
-
- (SwitchedWeapon weapon_switch) ->
- (apply_switched_weapon weapon_switch characters players)
-
- (Attacked attack) ->
- (apply_inverse_attack attack characters players)
-
- (PlayerWon pvict) -> (characters, players)
-
- (PlayerLost pdefeat) ->
- (apply_inverse_player_defeat pdefeat characters players)
-
- (PlayerTurnStarted pturns) -> (characters, players)
-
decoder : (Json.Decode.Decoder Type)
decoder =
(Json.Decode.field "t" Json.Decode.string)
|> (Json.Decode.andThen internal_decoder)
-
-maybe_remove_step : Type -> (Maybe Type)
-maybe_remove_step turn_result =
- case turn_result of
- (Moved movement) -> (maybe_remove_movement_step movement)
- (SwitchedWeapon _) -> Nothing
- (Attacked attack) -> (maybe_remove_attack_step attack)
- (PlayerWon pvict) -> Nothing
- (PlayerLost pdefeat) -> Nothing
- (PlayerTurnStarted pturns) -> Nothing
-
-get_next_movement_dir : Movement -> BattleMap.Struct.Direction.Type
-get_next_movement_dir movement =
- case (List.head movement.path) of
- (Just dir) -> dir
- Nothing -> BattleMap.Struct.Direction.None
-
-get_attack_defender_index : Attack -> Int
-get_attack_defender_index attack = attack.defender_index
-
-maybe_get_attack_next_step : Attack -> (Maybe Struct.Attack.Type)
-maybe_get_attack_next_step attack = (List.head attack.sequence)
-
-get_actor_index : Type -> Int
-get_actor_index turn_result =
- case turn_result of
- (Moved movement) -> movement.character_index
- (SwitchedWeapon weapon_switch) -> weapon_switch.character_index
- (Attacked attack) -> attack.attacker_index
- (PlayerWon pvict) -> pvict.player_index
- (PlayerLost pdefeat) -> pdefeat.player_index
- (PlayerTurnStarted pturns) -> pturns.player_index
diff --git a/src/battle/src/Update/HandleServerReply.elm b/src/battle/src/Update/HandleServerReply.elm
index 8dee69b..31b3318 100644
--- a/src/battle/src/Update/HandleServerReply.elm
+++ b/src/battle/src/Update/HandleServerReply.elm
@@ -39,7 +39,7 @@ import Struct.Model
import Struct.Player
import Struct.Puppeteer
import Struct.ServerReply
-import Struct.UI
+import Struct.TurnResult
import Update.Puppeteer
diff --git a/src/battle/src/View/Character.elm b/src/battle/src/View/Character.elm
index dc256c6..dac5989 100644
--- a/src/battle/src/View/Character.elm
+++ b/src/battle/src/View/Character.elm
@@ -1,217 +1,45 @@
-module View.Character exposing
- (
- get_portrait_html,
- get_icon_html
- )
+module View.Character exposing (get_portrait_html)
-- Elm -------------------------------------------------------------------------
import Html
import Html.Attributes
import Html.Events
--- Shared ----------------------------------------------------------------------
-import Util.Html
-
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Character
-import BattleCharacters.Struct.Equipment
-import BattleCharacters.Struct.Portrait
import BattleCharacters.View.Portrait
-- Local Module ----------------------------------------------------------------
-import Constants.UI
-
import Struct.Character
-import Struct.CharacterTurn
import Struct.Event
-import Struct.Model
-import Struct.UI
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_activation_level_class : (
- Struct.Character.Type ->
- (Html.Attribute Struct.Event.Type)
- )
-get_activation_level_class char =
- if (Struct.Character.is_enabled char)
- then
- (Html.Attributes.class "character-icon-enabled")
- else
- (Html.Attributes.class "character-icon-disabled")
-
-get_alliance_class : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Attribute Struct.Event.Type)
- )
-get_alliance_class model char =
- if
- (
- (Struct.Character.get_player_index char) == model.player_i
- ==
- (Struct.Battle.get_own_player_index model.battle)
- )
- then (Html.Attributes.class "character-ally")
- else (Html.Attributes.class "character-enemy")
-
-get_position_style : (
- Struct.Character.Type ->
- (List (Html.Attribute Struct.Event.Type))
- )
-get_position_style char =
- let char_loc = (Struct.Character.get_location char) in
- [
- (Html.Attributes.style
- "top"
- ((String.fromInt (char_loc.y * Constants.UI.tile_size)) ++ "px")
- ),
- (Html.Attributes.style
- "left"
- ((String.fromInt (char_loc.x * Constants.UI.tile_size)) ++ "px")
- )
- ]
-
-get_focus_class : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Attribute Struct.Event.Type)
- )
-get_focus_class model char =
- if
- (
- (Struct.UI.get_previous_action model.ui)
- ==
- (Just (Struct.UI.SelectedCharacter (Struct.Character.get_index char)))
- )
- then
- (Html.Attributes.class "character-selected")
- else
- if
- (
- (Struct.CharacterTurn.try_getting_target model.char_turn)
- ==
- (Just (Struct.Character.get_index char))
- )
- then
- (Html.Attributes.class "character-targeted")
- else
- (Html.Attributes.class "")
-
-get_icon_body_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
-get_icon_body_html char =
- (Html.div
- [
- (Html.Attributes.class "character-icon-body"),
- (Html.Attributes.class
- (
- "asset-character-team-body-"
- ++ (String.fromInt (Struct.Character.get_player_index char))
- )
- )
- ]
- [
- ]
- )
-
-get_icon_head_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
-get_icon_head_html char =
- (Html.div
- [
- (Html.Attributes.class "character-icon-head"),
- (Html.Attributes.class
- (
- "asset-character-icon-"
- ++
- (BattleCharacters.Struct.Portrait.get_icon_id
- (BattleCharacters.Struct.Equipment.get_portrait
- (BattleCharacters.Struct.Character.get_equipment
- (Struct.Character.get_base_character char)
- )
- )
- )
- )
- )
- ]
- [
- ]
- )
-
-get_icon_actual_html : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Html Struct.Event.Type)
- )
-get_icon_actual_html model char =
- (Html.div
- (
- [
- (Html.Attributes.class "tiled"),
- (Html.Attributes.class "character-icon"),
- (get_activation_level_class char),
- (get_alliance_class model char),
- (get_focus_class model char),
- (Html.Attributes.class "clickable"),
- (Html.Events.onClick
- (Struct.Event.CharacterSelected
- (Struct.Character.get_index char)
- )
- )
- ]
- ++ (get_position_style char)
- )
- [
- (get_icon_body_html char),
- (get_icon_head_html char)
- ]
- )
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_portrait_html : (
- Int ->
- Struct.Character.Type ->
- (Html.Html Struct.Event.Type)
- )
-get_portrait_html viewer_ix char =
+get_portrait_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
+get_portrait_html char =
(BattleCharacters.View.Portrait.get_html
- [
- (Html.Attributes.class
- (
- if ((Struct.Character.get_player_index char) == viewer_ix)
- then
- "character-ally"
- else
- "character-enemy"
- )
- ),
- (Html.Attributes.class
- (
- "character-portrait-team-"
- ++
- (String.fromInt (Struct.Character.get_player_index char))
- )
- ),
+ (
(Html.Events.onClick
(Struct.Event.LookingForCharacter (Struct.Character.get_index char))
)
- ]
+ ::
+ (List.map
+ (
+ \effect_name ->
+ (Html.Attributes.class
+ ("character-portrait-effect-" ++ effect_name)
+ )
+ )
+ (Struct.Character.get_extra_display_effects_list char)
+ )
+ )
(BattleCharacters.Struct.Character.get_equipment
(Struct.Character.get_base_character char)
)
)
-
-get_icon_html : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Html Struct.Event.Type)
- )
-get_icon_html model char =
- if (Struct.Character.is_alive char)
- then
- (get_icon_actual_html model char)
- else
- (Util.Html.nothing)
diff --git a/src/battle/src/View/Controlled/CharacterCard.elm b/src/battle/src/View/Controlled/CharacterCard.elm
index 291263c..0d7eda1 100644
--- a/src/battle/src/View/Controlled/CharacterCard.elm
+++ b/src/battle/src/View/Controlled/CharacterCard.elm
@@ -352,7 +352,7 @@ get_minimal_html player_ix char =
(Html.Attributes.class "info-card-picture")
]
[
- (View.Character.get_portrait_html player_ix char)
+ (View.Character.get_portrait_html char)
]
),
(get_health_bar char),
@@ -400,7 +400,7 @@ get_summary_html char_turn player_ix char =
(Html.Attributes.class "info-card-picture")
]
[
- (View.Character.get_portrait_html player_ix char)
+ (View.Character.get_portrait_html char)
]
),
(get_health_bar char),
@@ -456,7 +456,7 @@ get_full_html player_ix char =
(Html.Attributes.class "info-card-picture")
]
[
- (View.Character.get_portrait_html player_ix char)
+ (View.Character.get_portrait_html char)
]
),
(get_health_bar char),
diff --git a/src/battle/src/View/Map/Character.elm b/src/battle/src/View/Map/Character.elm
index b20c29a..b1442b1 100644
--- a/src/battle/src/View/Map/Character.elm
+++ b/src/battle/src/View/Map/Character.elm
@@ -16,80 +16,13 @@ import BattleCharacters.Struct.Equipment
-- Local Module ----------------------------------------------------------------
import Constants.UI
-import Struct.Battle
import Struct.Character
-import Struct.CharacterTurn
import Struct.Event
-import Struct.Model
-import Struct.TurnResult
-import Struct.TurnResultAnimator
import Struct.UI
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_animation_class : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Attribute Struct.Event.Type)
- )
-get_animation_class model char =
- case model.animator of
- Nothing -> (Html.Attributes.class "")
- (Just animator) ->
- case (Struct.TurnResultAnimator.get_current_animation animator) of
- (Struct.TurnResultAnimator.Focus char_index) ->
- if ((Struct.Character.get_index char) /= char_index)
- then
- (Html.Attributes.class "")
- else
- (Html.Attributes.class "character-selected")
-
- (Struct.TurnResultAnimator.TurnResult current_action) ->
- if
- (
- (Struct.TurnResult.get_actor_index current_action)
- /=
- (Struct.Character.get_index char)
- )
- then
- (Html.Attributes.class "")
- else
- case current_action of
- (Struct.TurnResult.Moved _) ->
- (Html.Attributes.class
- "animated-character-icon"
- )
-
- _ -> (Html.Attributes.class "")
- _ -> (Html.Attributes.class "")
-
-get_activation_level_class : (
- Struct.Character.Type ->
- (Html.Attribute Struct.Event.Type)
- )
-get_activation_level_class char =
- if (Struct.Character.is_enabled char)
- then
- (Html.Attributes.class "character-icon-enabled")
- else
- (Html.Attributes.class "character-icon-disabled")
-
-get_alliance_class : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Attribute Struct.Event.Type)
- )
-get_alliance_class model char =
- if
- (
- (Struct.Character.get_player_index char)
- ==
- (Struct.Battle.get_own_player_index model.battle)
- )
- then (Html.Attributes.class "character-ally")
- else (Html.Attributes.class "character-enemy")
-
get_position_style : (
Struct.Character.Type ->
(List (Html.Attribute Struct.Event.Type))
@@ -107,32 +40,6 @@ get_position_style char =
)
]
-get_focus_class : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Attribute Struct.Event.Type)
- )
-get_focus_class model char =
- if
- (
- (Struct.UI.get_previous_action model.ui)
- ==
- (Just (Struct.UI.SelectedCharacter (Struct.Character.get_index char)))
- )
- then
- (Html.Attributes.class "character-selected")
- else
- if
- (
- (Struct.CharacterTurn.try_getting_target model.char_turn)
- ==
- (Just (Struct.Character.get_index char))
- )
- then
- (Html.Attributes.class "character-targeted")
- else
- (Html.Attributes.class "")
-
get_body_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
get_body_html char =
(Html.div
@@ -195,21 +102,13 @@ get_banner_html char =
_ -> (Util.Html.nothing)
-get_actual_html : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Html Struct.Event.Type)
- )
-get_actual_html model char =
+get_actual_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
+get_actual_html char =
(Html.div
(
[
(Html.Attributes.class "tiled"),
(Html.Attributes.class "character-icon"),
- (get_animation_class model char),
- (get_activation_level_class char),
- (get_alliance_class model char),
- (get_focus_class model char),
(Html.Attributes.class "clickable"),
(Html.Events.onClick
(Struct.Event.CharacterSelected
@@ -218,6 +117,16 @@ get_actual_html model char =
)
]
++
+ (List.map
+ (
+ \effect_name ->
+ (Html.Attributes.class
+ ("character-icon-effect-" ++ effect_name)
+ )
+ )
+ (Struct.Character.get_extra_display_effects_list char)
+ )
+ ++
(get_position_style char)
)
[
@@ -230,14 +139,8 @@ get_actual_html model char =
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_html : (
- Struct.Model.Type ->
- Struct.Character.Type ->
- (Html.Html Struct.Event.Type)
- )
-get_html model char =
+get_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
+get_html char =
if (Struct.Character.is_alive char)
- then
- (get_actual_html model char)
- else
- (Util.Html.nothing)
+ then (get_actual_html char)
+ else (Util.Html.nothing)
diff --git a/src/battle/src/View/MessageBoard.elm b/src/battle/src/View/MessageBoard.elm
index 9b31f65..8a47b40 100644
--- a/src/battle/src/View/MessageBoard.elm
+++ b/src/battle/src/View/MessageBoard.elm
@@ -3,28 +3,38 @@ module View.MessageBoard exposing (get_html)
-- Elm -------------------------------------------------------------------------
import Html
+-- Shared ----------------------------------------------------------------------
+import Util.Html
+
-- Local Module ----------------------------------------------------------------
import Struct.Event
import Struct.Model
+import Struct.MessageBoard
-import View.MessageBoard.Animator
+import View.MessageBoard.Attack
import View.MessageBoard.Error
import View.MessageBoard.Help
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
+display : (
+ Struct.Model.Type ->
+ Struct.MessageBoard.Message ->
+ (Html.Html Struct.Event.Type)
+ )
+display model message =
+ case message of
+ (Error error_msg) -> (View.MessageBoard.Error.get_html model error_msg)
+ (AttackReport attack) -> (View.MessageBoard.Attack.get_html model attack)
+ (Help help_request) ->
+ (View.MessageBoard.Help.get_html model help_request)
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
get_html model =
- case (model.error) of
- (Just error) -> (View.MessageBoard.Error.get_html model error)
- Nothing ->
- case model.animator of
- (Just animator) ->
- (View.MessageBoard.Animator.get_html model.battle animator)
-
- Nothing -> (View.MessageBoard.Help.get_html model)
+ case (Struct.MessageBoard.try_getting_current_message model.message_board) of
+ Nothing -> (Util.Html.nothing)
+ (Just message) -> (display model message)
diff --git a/src/battle/src/View/MessageBoard/Animator/Attack.elm b/src/battle/src/View/MessageBoard/Attack.elm
index 6b79903..041b3e3 100644
--- a/src/battle/src/View/MessageBoard/Animator/Attack.elm
+++ b/src/battle/src/View/MessageBoard/Attack.elm
@@ -1,4 +1,4 @@
-module View.MessageBoard.Animator.Attack exposing (get_html)
+module View.MessageBoard.Attack exposing (get_html)
-- Elm -------------------------------------------------------------------------
import Array
@@ -14,6 +14,7 @@ import Struct.Attack
import Struct.Battle
import Struct.Character
import Struct.Event
+import Struct.Model
import View.Controlled.CharacterCard
@@ -145,45 +146,30 @@ get_defense_animation_class attack char =
else "animated-portrait-dies"
get_attacker_card : (
- (Maybe Struct.Attack.Type) ->
+ Struct.Attack.Type ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_attacker_card maybe_attack char =
+get_attacker_card attack char =
(Html.div
- (case maybe_attack of
- Nothing ->
- if ((Struct.Character.get_current_health char) > 0)
- then
- [
- (Html.Attributes.class "animated-portrait")
- ]
- else
- [
- (Html.Attributes.class "animated-portrait-absent"),
- (Html.Attributes.class "animated-portrait")
- ]
-
- (Just attack) ->
- [
- (Html.Attributes.class
- (case (attack.order, attack.parried) of
- (Struct.Attack.Counter, True) ->
- (get_attack_animation_class attack char)
+ [
+ (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)
+ (Struct.Attack.Counter, _) ->
+ (get_defense_animation_class attack char)
- (_, True) ->
- (get_defense_animation_class attack char)
+ (_, True) ->
+ (get_defense_animation_class attack char)
- (_, _) ->
- (get_attack_animation_class attack char)
- )
- ),
- (Html.Attributes.class "animated-portrait")
- ]
- )
+ (_, _) ->
+ (get_attack_animation_class attack char)
+ )
+ ),
+ (Html.Attributes.class "animated-portrait")
+ ]
[
(View.Controlled.CharacterCard.get_minimal_html
(Struct.Character.get_player_index char)
@@ -193,61 +179,43 @@ get_attacker_card maybe_attack char =
)
get_defender_card : (
- (Maybe Struct.Attack.Type) ->
+ Struct.Attack.Type ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_defender_card maybe_attack char =
+get_defender_card attack char =
(Html.div
- (case maybe_attack of
- Nothing ->
- if ((Struct.Character.get_current_health char) > 0)
- then
- [
- (Html.Attributes.class "animated-portrait")
- ]
- else
- [
- (Html.Attributes.class "animated-portrait-absent"),
- (Html.Attributes.class "animated-portrait")
- ]
-
- (Just attack) ->
- [
- (Html.Attributes.class
- (case (attack.order, attack.parried) of
- (Struct.Attack.Counter, True) ->
- (get_defense_animation_class attack char)
+ [
+ (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)
+ (Struct.Attack.Counter, _) ->
+ (get_attack_animation_class attack char)
- (_, True) ->
- (get_attack_animation_class attack char)
+ (_, True) ->
+ (get_attack_animation_class attack char)
- (_, _) ->
- (get_defense_animation_class attack char)
- )
- ),
- (Html.Attributes.class "animated-portrait")
- ]
- )
+ (_, _) ->
+ (get_defense_animation_class attack char)
+ )
+ ),
+ (Html.Attributes.class "animated-portrait")
+ ]
[
(View.Controlled.CharacterCard.get_minimal_html -1 char)
]
)
---------------------------------------------------------------------------------
--- EXPORTED --------------------------------------------------------------------
---------------------------------------------------------------------------------
get_placeholder_html : (
(Array.Array Struct.Character.Type) ->
Int ->
Int ->
- (Maybe Struct.Attack.Type) ->
+ Struct.Attack.Type ->
(Html.Html Struct.Event.Type)
)
-get_placeholder_html characters attacker_ix defender_ix maybe_attack =
+get_placeholder_html characters attacker_ix defender_ix attack =
case
(
(Array.get attacker_ix characters),
@@ -262,16 +230,9 @@ get_placeholder_html characters attacker_ix defender_ix maybe_attack =
]
(
[
- (get_attacker_card maybe_attack atkchar),
- (
- case maybe_attack of
- (Just attack) ->
- (get_attack_html atkchar defchar attack)
-
- Nothing ->
- (get_empty_attack_html)
- ),
- (get_defender_card maybe_attack defchar)
+ (get_attacker_card attack atkchar),
+ (get_attack_html atkchar defchar attack),
+ (get_defender_card attack defchar)
]
)
)
@@ -284,21 +245,18 @@ get_placeholder_html characters attacker_ix defender_ix maybe_attack =
(Html.text "Error: Attack with unknown characters")
]
)
-
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_html : (
- Struct.Battle.Type ->
- Int ->
- Int ->
- (Maybe Struct.Attack.Type) ->
+ Struct.Model.Type ->
+ Struct.Attack.Type ->
(Html.Html Struct.Event.Type)
)
-get_html battle attacker_ix defender_ix maybe_attack =
+get_html model attack =
(get_placeholder_html
- (Struct.Battle.get_characters battle)
- attacker_ix
- defender_ix
- maybe_attack
+ (Struct.Battle.get_characters model.battle)
+ 0 -- TODO: get attacker IX
+ 0 -- TODO: get defender IX
+ attack
)
diff --git a/src/battle/src/View/SubMenu/Timeline/Attack.elm b/src/battle/src/View/SubMenu/Timeline/Attack.elm
index 7301126..fe43b6a 100644
--- a/src/battle/src/View/SubMenu/Timeline/Attack.elm
+++ b/src/battle/src/View/SubMenu/Timeline/Attack.elm
@@ -153,8 +153,8 @@ get_html characters player_ix attack =
]
(
[
- (View.Character.get_portrait_html player_ix atkchar),
- (View.Character.get_portrait_html player_ix defchar),
+ (View.Character.get_portrait_html atkchar),
+ (View.Character.get_portrait_html defchar),
(get_title_html atkchar defchar)
]
++
diff --git a/src/battle/src/View/SubMenu/Timeline/Movement.elm b/src/battle/src/View/SubMenu/Timeline/Movement.elm
index 3ef305e..4d748be 100644
--- a/src/battle/src/View/SubMenu/Timeline/Movement.elm
+++ b/src/battle/src/View/SubMenu/Timeline/Movement.elm
@@ -38,7 +38,7 @@ get_html characters player_ix movement =
(Html.Attributes.class "timeline-movement")
]
[
- (View.Character.get_portrait_html player_ix char),
+ (View.Character.get_portrait_html char),
(Html.text
(
(BattleCharacters.Struct.Character.get_name
diff --git a/src/battle/src/View/SubMenu/Timeline/WeaponSwitch.elm b/src/battle/src/View/SubMenu/Timeline/WeaponSwitch.elm
index 50fd702..f547df8 100644
--- a/src/battle/src/View/SubMenu/Timeline/WeaponSwitch.elm
+++ b/src/battle/src/View/SubMenu/Timeline/WeaponSwitch.elm
@@ -38,7 +38,7 @@ get_html characters player_ix weapon_switch =
(Html.Attributes.class "timeline-weapon-switch")
]
[
- (View.Character.get_portrait_html player_ix char),
+ (View.Character.get_portrait_html char),
(Html.text
(
(BattleCharacters.Struct.Character.get_name