summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/battlemap')
-rw-r--r--src/battlemap/src/Struct/Armor.elm36
-rw-r--r--src/battlemap/src/Struct/Character.elm20
-rw-r--r--src/battlemap/src/View/Character.elm222
-rw-r--r--src/battlemap/www/index.html1
-rw-r--r--src/battlemap/www/style.css21
5 files changed, 298 insertions, 2 deletions
diff --git a/src/battlemap/src/Struct/Armor.elm b/src/battlemap/src/Struct/Armor.elm
new file mode 100644
index 0000000..c62b0c7
--- /dev/null
+++ b/src/battlemap/src/Struct/Armor.elm
@@ -0,0 +1,36 @@
+module Struct.Armor exposing
+ (
+ Type,
+ Ref,
+ new,
+ get_id
+ )
+
+-- Battlemap -------------------------------------------------------------------
+import Struct.Attributes
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type alias Type =
+ {
+ id : Int
+ }
+
+type alias Ref = Int
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+new : Int -> Type
+new id =
+ {
+ id = id
+ }
+
+get_id : Type -> Ref
+get_id ar = ar.id
diff --git a/src/battlemap/src/Struct/Character.elm b/src/battlemap/src/Struct/Character.elm
index 89b6dea..332c2fd 100644
--- a/src/battlemap/src/Struct/Character.elm
+++ b/src/battlemap/src/Struct/Character.elm
@@ -7,6 +7,8 @@ module Struct.Character exposing
get_name,
get_icon_id,
get_portrait_id,
+ get_armor,
+ get_armor_variation,
get_current_health,
set_current_health,
get_location,
@@ -26,6 +28,7 @@ import Json.Decode
import Json.Decode.Pipeline
-- Battlemap -------------------------------------------------------------------
+import Struct.Armor
import Struct.Attributes
import Struct.Location
import Struct.Statistics
@@ -62,7 +65,8 @@ type alias Type =
enabled : Bool,
attributes : Struct.Attributes.Type,
statistics : Struct.Statistics.Type,
- weapons : Struct.WeaponSet.Type
+ weapons : Struct.WeaponSet.Type,
+ armor : Struct.Armor.Type
}
type alias Ref = String
@@ -92,7 +96,8 @@ finish_decoding get_weapon add_char =
statistics = (Struct.Statistics.new add_char.att weapon_set),
player_id = add_char.pla,
enabled = add_char.ena,
- weapons = weapon_set
+ weapons = weapon_set,
+ armor = (Struct.Armor.new (add_char.ix % 2))
}
--------------------------------------------------------------------------------
@@ -143,6 +148,17 @@ set_enabled enabled char = {char | enabled = enabled}
get_weapons : Type -> Struct.WeaponSet.Type
get_weapons char = char.weapons
+get_armor : Type -> Struct.Armor.Type
+get_armor char = char.armor
+
+get_armor_variation : Type -> String
+get_armor_variation char =
+ case char.portrait of
+ -- Currently hardcoded to match crows from characters.css
+ "11" -> "1"
+ "4" -> "1"
+ _ -> "0"
+
set_weapons : Struct.WeaponSet.Type -> Type -> Type
set_weapons weapons char =
{char |
diff --git a/src/battlemap/src/View/Character.elm b/src/battlemap/src/View/Character.elm
new file mode 100644
index 0000000..e3ff30b
--- /dev/null
+++ b/src/battlemap/src/View/Character.elm
@@ -0,0 +1,222 @@
+module View.Character exposing
+ (
+ get_portrait_html,
+ get_icon_html
+ )
+
+-- Elm -------------------------------------------------------------------------
+import Html
+import Html.Attributes
+import Html.Events
+
+-- Battlemap ------------------------------------------------------------------
+import Constants.UI
+
+import Util.Html
+
+import Struct.Armor
+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 "battlemap-character-icon-enabled")
+ else
+ (Html.Attributes.class "battlemap-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_id char) == model.player_id)
+ then
+ (Html.Attributes.class "battlemap-character-ally")
+ else
+ (Html.Attributes.class "battlemap-character-enemy")
+
+get_position_style : (
+ Struct.Character.Type ->
+ (Html.Attribute Struct.Event.Type)
+ )
+get_position_style char =
+ let char_loc = (Struct.Character.get_location char) in
+ (Html.Attributes.style
+ [
+ ("top", ((toString (char_loc.y * Constants.UI.tile_size)) ++ "px")),
+ ("left", ((toString (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_ref char)))
+ )
+ then
+ (Html.Attributes.class "battlemap-character-selected")
+ else
+ if
+ (
+ (Struct.CharacterTurn.try_getting_target model.char_turn)
+ ==
+ (Just (Struct.Character.get_ref char))
+ )
+ then
+ (Html.Attributes.class "battlemap-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 "battlemap-character-icon-body"),
+ (Html.Attributes.class
+ (
+ "asset-character-team-body-"
+ ++ (Struct.Character.get_player_id char)
+ )
+ )
+ ]
+ [
+ ]
+ )
+
+get_icon_head_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
+get_icon_head_html char =
+ (Html.div
+ [
+ (Html.Attributes.class "battlemap-character-icon-head"),
+ (Html.Attributes.class
+ ("asset-character-icon-" ++ (Struct.Character.get_icon_id 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 "battlemap-tiled"),
+ (Html.Attributes.class "battlemap-character-icon"),
+ (get_activation_level_class char),
+ (get_alliance_class model char),
+ (get_position_style char),
+ (get_focus_class model char),
+ (Html.Attributes.class "clickable"),
+ (Html.Events.onClick
+ (Struct.Event.CharacterSelected (Struct.Character.get_ref char))
+ )
+ ]
+ [
+ (get_icon_body_html char),
+ (get_icon_head_html char)
+ ]
+ )
+
+get_portrait_body_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
+get_portrait_body_html char =
+ (Html.div
+ [
+ (Html.Attributes.class "battlemap-character-portrait-body"),
+ (Html.Attributes.class
+ (
+ "asset-character-portrait-"
+ ++ (Struct.Character.get_portrait_id char)
+ )
+ )
+ ]
+ [
+ ]
+ )
+
+get_portrait_armor_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
+get_portrait_armor_html char =
+ (Html.div
+ [
+ (Html.Attributes.class "battlemap-character-portrait-armor"),
+ (Html.Attributes.class
+ (
+ "asset-armor-"
+ ++
+ (toString
+ (Struct.Armor.get_id (Struct.Character.get_armor char))
+ )
+ )
+ ),
+ (Html.Attributes.class
+ (
+ "asset-armor-variation-"
+ ++ (Struct.Character.get_armor_variation char)
+ )
+ )
+ ]
+ [
+ ]
+ )
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_portrait_html : (
+ String ->
+ Struct.Character.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+get_portrait_html viewer_id char =
+ (Html.div
+ [
+ (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")
+ ]
+ [
+ (get_portrait_body_html char),
+ (get_portrait_armor_html 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/battlemap/www/index.html b/src/battlemap/www/index.html
index d019783..9b216f9 100644
--- a/src/battlemap/www/index.html
+++ b/src/battlemap/www/index.html
@@ -5,6 +5,7 @@
<link rel="stylesheet" type="text/css" href="../battlemap/style.css">
<link rel="stylesheet" type="text/css" href="../asset/tiles.css">
<link rel="stylesheet" type="text/css" href="../asset/characters.css">
+ <link rel="stylesheet" type="text/css" href="../asset/armors.css">
</head>
<body>
<script src="script/main.js"></script>
diff --git a/src/battlemap/www/style.css b/src/battlemap/www/style.css
index ffd32d5..e2b5151 100644
--- a/src/battlemap/www/style.css
+++ b/src/battlemap/www/style.css
@@ -224,6 +224,27 @@
height: 100px;
}
+.battlemap-character-portrait *
+{
+ box-sizing: border-box;
+ background-size: 100% 100%;
+ width: inherit;
+ height: inherit;
+}
+
+.battlemap-character-portrait-body
+{
+ z-index: 1;
+}
+
+.battlemap-character-portrait-armor
+{
+ position: relative;
+ z-index: 1;
+ top: -100%;
+ background-size: 200% 100%;
+}
+
.battlemap-timeline-element,
.battlemap-characters-element
{