summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/battlemap/src/Struct/Character.elm6
-rw-r--r--src/battlemap/src/Update/SelectCharacter.elm3
-rw-r--r--src/battlemap/src/View/Battlemap.elm2
-rw-r--r--src/battlemap/src/View/Battlemap/Character.elm33
-rw-r--r--src/battlemap/src/View/SideBar/TabMenu/Characters.elm19
-rw-r--r--src/battlemap/src/View/SideBar/TabMenu/Timeline/Attack.elm16
-rw-r--r--src/battlemap/src/View/SideBar/TabMenu/Timeline/Movement.elm14
-rw-r--r--src/battlemap/src/View/SideBar/TabMenu/Timeline/WeaponSwitch.elm14
-rw-r--r--src/battlemap/www/style.css12
9 files changed, 97 insertions, 22 deletions
diff --git a/src/battlemap/src/Struct/Character.elm b/src/battlemap/src/Struct/Character.elm
index d4f65f7..89b6dea 100644
--- a/src/battlemap/src/Struct/Character.elm
+++ b/src/battlemap/src/Struct/Character.elm
@@ -14,6 +14,7 @@ module Struct.Character exposing
get_attributes,
get_statistics,
is_enabled,
+ is_alive,
set_enabled,
get_weapons,
set_weapons,
@@ -116,7 +117,7 @@ get_current_health : Type -> Int
get_current_health c = c.health
set_current_health : Int -> Type -> Type
-set_current_health health c = {c | health = health}
+set_current_health health c = {c | health = (max 0 health)}
get_location : Type -> Struct.Location.Type
get_location t = t.location
@@ -130,6 +131,9 @@ get_attributes char = char.attributes
get_statistics : Type -> Struct.Statistics.Type
get_statistics char = char.statistics
+is_alive : Type -> Bool
+is_alive char = (char.health > 0)
+
is_enabled : Type -> Bool
is_enabled char = char.enabled
diff --git a/src/battlemap/src/Update/SelectCharacter.elm b/src/battlemap/src/Update/SelectCharacter.elm
index 0e08a4d..3f0dbd4 100644
--- a/src/battlemap/src/Update/SelectCharacter.elm
+++ b/src/battlemap/src/Update/SelectCharacter.elm
@@ -92,6 +92,7 @@ can_target_character : (
can_target_character model target =
(
(Struct.CharacterTurn.can_select_target model.char_turn)
+ && (Struct.Character.is_alive target)
&&
(
case
@@ -146,7 +147,7 @@ double_clicked_character model target_char_id =
model
(Struct.Error.new
Struct.Error.IllegalAction
- "Has not yet moved or target is out of range."
+ "Has not yet moved, target is out of range, or dead."
)
),
Cmd.none
diff --git a/src/battlemap/src/View/Battlemap.elm b/src/battlemap/src/View/Battlemap.elm
index b805e6b..14243aa 100644
--- a/src/battlemap/src/View/Battlemap.elm
+++ b/src/battlemap/src/View/Battlemap.elm
@@ -105,7 +105,7 @@ get_html model =
(Html.Lazy.lazy (get_tiles_html) model.battlemap)
::
(List.map
- (View.Battlemap.Character.get_html)
+ (View.Battlemap.Character.get_html model.player_id)
(Dict.values model.characters)
)
++
diff --git a/src/battlemap/src/View/Battlemap/Character.elm b/src/battlemap/src/View/Battlemap/Character.elm
index 80be31f..e70c1e9 100644
--- a/src/battlemap/src/View/Battlemap/Character.elm
+++ b/src/battlemap/src/View/Battlemap/Character.elm
@@ -8,18 +8,20 @@ import Html.Events
-- Battlemap ------------------------------------------------------------------
import Constants.UI
+import Util.Html
+
import Struct.Character
import Struct.Event
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-
---------------------------------------------------------------------------------
--- EXPORTED --------------------------------------------------------------------
---------------------------------------------------------------------------------
-get_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
-get_html char =
+get_actual_html : (
+ String ->
+ Struct.Character.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+get_actual_html viewer_id char =
let
char_loc = (Struct.Character.get_location char)
in
@@ -35,6 +37,15 @@ get_html char =
"battlemap-character-icon-disabled"
)
),
+ (Html.Attributes.class
+ (
+ if ((Struct.Character.get_player_id char) == viewer_id)
+ then
+ "battlemap-character-ally"
+ else
+ "battlemap-character-enemy"
+ )
+ ),
(Html.Attributes.class "battlemap-tiled"),
(Html.Attributes.class
("asset-character-icon-" ++ (Struct.Character.get_icon_id char))
@@ -60,3 +71,13 @@ get_html char =
]
)
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_html : String -> Struct.Character.Type -> (Html.Html Struct.Event.Type)
+get_html viewer_id char =
+ if (Struct.Character.is_alive char)
+ then
+ (get_actual_html viewer_id char)
+ else
+ (Util.Html.nothing)
diff --git a/src/battlemap/src/View/SideBar/TabMenu/Characters.elm b/src/battlemap/src/View/SideBar/TabMenu/Characters.elm
index 79799c3..2eaca27 100644
--- a/src/battlemap/src/View/SideBar/TabMenu/Characters.elm
+++ b/src/battlemap/src/View/SideBar/TabMenu/Characters.elm
@@ -16,10 +16,11 @@ import Struct.Model
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
get_character_portrait_html : (
+ String ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_character_portrait_html char =
+get_character_portrait_html viewer_id char =
(Html.div
[
(Html.Attributes.class
@@ -28,6 +29,15 @@ get_character_portrait_html char =
++ (Struct.Character.get_portrait_id char)
)
),
+ (Html.Attributes.class
+ (
+ if ((Struct.Character.get_player_id char) == viewer_id)
+ then
+ "battlemap-character-ally"
+ else
+ "battlemap-character-enemy"
+ )
+ ),
(Html.Attributes.class "battlemap-character-portrait")
]
[
@@ -35,10 +45,11 @@ get_character_portrait_html char =
)
get_character_element_html : (
+ String ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_character_element_html char =
+get_character_element_html viewer_id char =
(Html.div
[
(Html.Attributes.class "battlemap-characters-element"),
@@ -50,7 +61,7 @@ get_character_element_html char =
)
]
[
- (get_character_portrait_html char),
+ (get_character_portrait_html viewer_id char),
(Html.text
(
(Struct.Character.get_name char)
@@ -84,7 +95,7 @@ get_html model =
(Html.Attributes.class "battlemap-tabmenu-characters-tab")
]
(List.map
- (get_character_element_html)
+ (get_character_element_html model.player_id)
(Dict.values model.characters)
)
)
diff --git a/src/battlemap/src/View/SideBar/TabMenu/Timeline/Attack.elm b/src/battlemap/src/View/SideBar/TabMenu/Timeline/Attack.elm
index 82c9d57..0bd59b8 100644
--- a/src/battlemap/src/View/SideBar/TabMenu/Timeline/Attack.elm
+++ b/src/battlemap/src/View/SideBar/TabMenu/Timeline/Attack.elm
@@ -40,15 +40,25 @@ get_title_html attacker defender =
)
get_portrait_html : (
+ String ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_portrait_html char =
+get_portrait_html viewer_id char =
(Html.div
[
(Html.Attributes.class "battlemap-timeline-portrait"),
(Html.Attributes.class
(
+ if ((Struct.Character.get_player_id char) == viewer_id)
+ then
+ "battlemap-character-ally"
+ else
+ "battlemap-character-enemy"
+ )
+ ),
+ (Html.Attributes.class
+ (
"asset-character-portrait-"
++ (Struct.Character.get_portrait_id char)
)
@@ -157,8 +167,8 @@ get_html model attack =
]
(
[
- (get_portrait_html atkchar),
- (get_portrait_html defchar),
+ (get_portrait_html model.player_id atkchar),
+ (get_portrait_html model.player_id defchar),
(get_title_html atkchar defchar)
]
++
diff --git a/src/battlemap/src/View/SideBar/TabMenu/Timeline/Movement.elm b/src/battlemap/src/View/SideBar/TabMenu/Timeline/Movement.elm
index d8db541..4e5579a 100644
--- a/src/battlemap/src/View/SideBar/TabMenu/Timeline/Movement.elm
+++ b/src/battlemap/src/View/SideBar/TabMenu/Timeline/Movement.elm
@@ -17,15 +17,25 @@ import Struct.Model
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
get_portrait_html : (
+ String ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_portrait_html char =
+get_portrait_html viewer_id char =
(Html.div
[
(Html.Attributes.class "battlemap-timeline-portrait"),
(Html.Attributes.class
(
+ if ((Struct.Character.get_player_id char) == viewer_id)
+ then
+ "battlemap-character-ally"
+ else
+ "battlemap-character-enemy"
+ )
+ ),
+ (Html.Attributes.class
+ (
"asset-character-portrait-"
++ (Struct.Character.get_portrait_id char)
)
@@ -52,7 +62,7 @@ get_html model movement =
(Html.Attributes.class "battlemap-timeline-movement")
]
[
- (get_portrait_html char),
+ (get_portrait_html model.player_id char),
(Html.text
(
(Struct.Character.get_name char)
diff --git a/src/battlemap/src/View/SideBar/TabMenu/Timeline/WeaponSwitch.elm b/src/battlemap/src/View/SideBar/TabMenu/Timeline/WeaponSwitch.elm
index 0216540..b64a293 100644
--- a/src/battlemap/src/View/SideBar/TabMenu/Timeline/WeaponSwitch.elm
+++ b/src/battlemap/src/View/SideBar/TabMenu/Timeline/WeaponSwitch.elm
@@ -17,15 +17,25 @@ import Struct.Model
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
get_portrait_html : (
+ String ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_portrait_html char =
+get_portrait_html viewer_id char =
(Html.div
[
(Html.Attributes.class "battlemap-timeline-portrait"),
(Html.Attributes.class
(
+ if ((Struct.Character.get_player_id char) == viewer_id)
+ then
+ "battlemap-character-ally"
+ else
+ "battlemap-character-enemy"
+ )
+ ),
+ (Html.Attributes.class
+ (
"asset-character-portrait-"
++ (Struct.Character.get_portrait_id char)
)
@@ -52,7 +62,7 @@ get_html model weapon_switch =
(Html.Attributes.class "battlemap-timeline-weapon-switch")
]
[
- (get_portrait_html char),
+ (get_portrait_html model.player_id char),
(Html.text
(
(Struct.Character.get_name char)
diff --git a/src/battlemap/www/style.css b/src/battlemap/www/style.css
index 0454862..2f4624a 100644
--- a/src/battlemap/www/style.css
+++ b/src/battlemap/www/style.css
@@ -139,7 +139,6 @@
margin: 0.5em;
box-sizing: border-box;
border: 2px solid rgba(0,0,0,0.5);
- border-radius: 25px 25px 0 25px;
width: 100px;
height: 100px;
}
@@ -220,7 +219,16 @@
{
box-sizing: border-box;
border: 2px solid rgba(0,0,0,0.5);
- border-radius: 25px;
+}
+
+.battlemap-character-ally
+{
+ border-radius: 25px 25px 0 25px;
+}
+
+.battlemap-character-enemy
+{
+ border-radius: 25px 25px 25px 0;
}
.battlemap-marker-icon