summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2019-03-22 19:02:58 +0100
committernsensfel <SpamShield0@noot-noot.org>2019-03-22 19:02:58 +0100
commitcaf0e9497229abb56a7428e60b19ee3d05fa7e9c (patch)
tree21272443e733fb9396947f969e01cfe85e6481bd
parent397e54affd6d434ea5d055f34cbac637867cde0a (diff)
[Broken] More factoring in progress...
-rw-r--r--src/battle/src/Struct/HelpRequest.elm10
-rw-r--r--src/battle/src/View/Character.elm58
-rw-r--r--src/battle/src/View/Controlled/CharacterCard.elm135
-rw-r--r--src/battle/src/View/Gauge.elm75
-rw-r--r--src/roster-editor/src/Struct/Character.elm146
-rw-r--r--src/roster-editor/src/Struct/Inventory.elm80
-rw-r--r--src/roster-editor/src/View/Character.elm91
-rw-r--r--src/roster-editor/src/View/CharacterCard.elm4
-rw-r--r--src/shared/battle-characters/BattleCharacters/Struct/Equipment.elm192
-rw-r--r--src/shared/battle-characters/BattleCharacters/Struct/Glyph.elm (renamed from src/roster-editor/src/Struct/Glyph.elm)2
-rw-r--r--src/shared/battle-characters/BattleCharacters/Struct/GlyphBoard.elm (renamed from src/roster-editor/src/Struct/GlyphBoard.elm)12
-rw-r--r--src/shared/battle-characters/BattleCharacters/View/Portrait.elm99
12 files changed, 458 insertions, 446 deletions
diff --git a/src/battle/src/Struct/HelpRequest.elm b/src/battle/src/Struct/HelpRequest.elm
index 42a28d6..905bdf7 100644
--- a/src/battle/src/Struct/HelpRequest.elm
+++ b/src/battle/src/Struct/HelpRequest.elm
@@ -2,6 +2,11 @@ module Struct.HelpRequest exposing (Type(..))
-- Elm -------------------------------------------------------------------------
+-- Battle ----------------------------------------------------------------------
+import Battle.Struct.Attributes
+import Battle.Struct.Statistics
+import Battle.Struct.DamageType
+
-- Local Module ----------------------------------------------------------------
import Struct.Character
@@ -10,4 +15,7 @@ import Struct.Character
--------------------------------------------------------------------------------
type Type =
None
- | HelpOnRank Struct.Character.Rank
+ | Rank Struct.Character.Rank
+ | Attribute Battle.Struct.Attributes.Category
+ | Statistic Battle.Struct.Statistics.Category
+ | DamageType Battle.Struct.DamageType.Type
diff --git a/src/battle/src/View/Character.elm b/src/battle/src/View/Character.elm
index e65f947..d9c2b31 100644
--- a/src/battle/src/View/Character.elm
+++ b/src/battle/src/View/Character.elm
@@ -13,9 +13,10 @@ import Html.Events
import Util.Html
-- Battle Characters -----------------------------------------------------------
-import BattleCharacters.Struct.Armor
import BattleCharacters.Struct.Portrait
+import BattleCharacters.View.Portrait
+
-- Local Module ----------------------------------------------------------------
import Constants.UI
@@ -158,53 +159,6 @@ get_icon_actual_html model char =
]
)
-get_portrait_body_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
-get_portrait_body_html char =
- (Html.div
- [
- (Html.Attributes.class "character-portrait-body"),
- (Html.Attributes.class
- (
- "asset-character-portrait-"
- ++
- (BattleCharacters.Struct.Portrait.get_id
- (Struct.Character.get_portrait char)
- )
- )
- )
- ]
- [
- ]
- )
-
-get_portrait_armor_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
-get_portrait_armor_html char =
- (Html.div
- [
- (Html.Attributes.class "character-portrait-armor"),
- (Html.Attributes.class
- (
- "asset-armor-"
- ++
- (BattleCharacters.Struct.Armor.get_image_id
- (Struct.Character.get_armor char)
- )
- )
- ),
- (Html.Attributes.class
- (
- "asset-armor-variation-"
- ++
- (BattleCharacters.Struct.Portrait.get_body_id
- (Struct.Character.get_portrait char)
- )
- )
- )
- ]
- [
- ]
- )
-
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
@@ -214,7 +168,7 @@ get_portrait_html : (
(Html.Html Struct.Event.Type)
)
get_portrait_html viewer_ix char =
- (Html.div
+ (BattleCharacters.View.Portrait.get_html
[
(Html.Attributes.class
(
@@ -225,7 +179,6 @@ get_portrait_html viewer_ix char =
"character-enemy"
)
),
- (Html.Attributes.class "character-portrait"),
(Html.Attributes.class
(
"character-portrait-team-"
@@ -237,10 +190,7 @@ get_portrait_html viewer_ix char =
(Struct.Event.LookingForCharacter (Struct.Character.get_index char))
)
]
- [
- (get_portrait_body_html char),
- (get_portrait_armor_html char)
- ]
+ char
)
get_icon_html : (
diff --git a/src/battle/src/View/Controlled/CharacterCard.elm b/src/battle/src/View/Controlled/CharacterCard.elm
index 0ece1fa..680e3fc 100644
--- a/src/battle/src/View/Controlled/CharacterCard.elm
+++ b/src/battle/src/View/Controlled/CharacterCard.elm
@@ -19,6 +19,10 @@ import Util.Html
import Battle.Struct.Omnimods
import Battle.Struct.Statistics
+import Battle.View.Gauge
+import Battle.View.Statistic
+import Battle.View.DamageType
+
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Armor
import BattleCharacters.Struct.Weapon
@@ -31,7 +35,6 @@ import Struct.HelpRequest
import Struct.Navigator
import View.Character
-import View.Gauge
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
@@ -64,7 +67,7 @@ get_health_bar char =
(Struct.Character.get_statistics char)
)
in
- (View.Gauge.get_html
+ (Battle.View.Gauge.get_html
("HP: " ++ (String.fromInt current) ++ "/" ++ (String.fromInt max))
(100.0 * ((toFloat current)/(toFloat max)))
[(Html.Attributes.class "character-card-health")]
@@ -132,7 +135,7 @@ get_active_movement_bar maybe_navigator char =
Nothing ->
max
in
- (View.Gauge.get_html
+ (Battle.View.Gauge.get_html
("MP: " ++ (String.fromInt current) ++ "/" ++ (String.fromInt max))
(100.0 * ((toFloat current)/(toFloat max)))
[(Html.Attributes.class "character-card-movement")]
@@ -151,7 +154,7 @@ get_inactive_movement_bar char =
(Struct.Character.get_statistics char)
)
in
- (View.Gauge.get_html
+ (Battle.View.Gauge.get_html
(
"MP: "
++
@@ -252,42 +255,6 @@ get_weapon_field_header damage_multiplier weapon =
]
)
-get_mod_html : (String, Int) -> (Html.Html Struct.Event.Type)
-get_mod_html mod =
- let (category, value) = mod in
- (Html.div
- [
- (Html.Attributes.class "info-card-mod")
- ]
- [
- (Html.text
- (category ++ ": " ++ (String.fromInt value))
- )
- ]
- )
-
-get_multiplied_mod_html : Float -> (String, Int) -> (Html.Html Struct.Event.Type)
-get_multiplied_mod_html multiplier mod =
- let (category, value) = mod in
- (Html.div
- [
- (Html.Attributes.class "character-card-mod")
- ]
- [
- (Html.div
- [
- (Html.Attributes.class "omnimod-icon"),
- (Html.Attributes.class ("omnimod-icon-" ++ category))
- ]
- [
- ]
- ),
- (Html.text
- (String.fromInt (ceiling ((toFloat value) * multiplier)))
- )
- ]
- )
-
get_weapon_details : (
Battle.Struct.Omnimods.Type ->
Float ->
@@ -303,10 +270,15 @@ get_weapon_details omnimods damage_multiplier weapon =
(get_weapon_field_header damage_multiplier weapon),
(Html.div
[
- (Html.Attributes.class "info-card-omnimods-listing")
+ (Html.Attributes.class "omnimod-attack-mods")
]
(List.map
- (get_multiplied_mod_html damage_multiplier)
+ (\(k, v) ->
+ (Battle.View.DamageType.get_html
+ (Battle.Struct.DamageType.decode k)
+ (ceiling ((toFloat v) * damage_multiplier))
+ )
+ )
(Battle.Struct.Omnimods.get_attack_mods omnimods)
)
)
@@ -347,69 +319,18 @@ get_armor_details omnimods armor =
(Html.text (BattleCharacters.Struct.Armor.get_name armor))
]
),
- (Html.div
- [
- (Html.Attributes.class "info-card-omnimods-listing")
- ]
- (List.map
- (get_mod_html)
- (Battle.Struct.Omnimods.get_defense_mods omnimods)
- )
- )
- ]
- )
-
-stat_name : String -> (Html.Html Struct.Event.Type)
-stat_name name =
- (Html.div
- [
- (Html.Attributes.class "character-card-stat-name")
- ]
- [
- (Html.text name)
- ]
- )
-
-stat_val : Int -> Bool -> (Html.Html Struct.Event.Type)
-stat_val val perc =
- (Html.div
- [
- (Html.Attributes.class "character-card-stat-val")
- ]
- [
- (Html.text
- (
- (String.fromInt val)
- ++
- (if perc then "%" else "")
+ (List.map
+ (\(k, v) ->
+ (Battle.View.DamageType.get_html
+ (Battle.Struct.DamageType.decode k)
+ v
+ )
)
+ (Battle.Struct.Omnimods.get_defense_mods omnimods)
)
]
)
-get_relevant_stats : (
- Battle.Struct.Statistics.Type ->
- (Html.Html Struct.Event.Type)
- )
-get_relevant_stats stats =
- (Html.div
- [
- (Html.Attributes.class "character-card-stats")
- ]
- [
- (stat_name "Dodge"),
- (stat_val (Battle.Struct.Statistics.get_dodges stats) True),
- (stat_name "Parry"),
- (stat_val (Battle.Struct.Statistics.get_parries stats) True),
- (stat_name "Accu."),
- (stat_val (Battle.Struct.Statistics.get_accuracy stats) False),
- (stat_name "2xHit"),
- (stat_val (Battle.Struct.Statistics.get_double_hits stats) True),
- (stat_name "Crit."),
- (stat_val (Battle.Struct.Statistics.get_critical_hits stats) True)
- ]
- )
-
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
@@ -503,7 +424,12 @@ get_summary_html char_turn player_ix char =
),
(get_weapon_details omnimods damage_modifier active_weapon),
(get_armor_details omnimods (Struct.Character.get_armor char)),
- (get_relevant_stats char_statistics),
+ (Html.div
+ []
+ (Battle.View.Statistic.get_all_but_gauges_html
+ char_statistics
+ )
+ ),
(get_weapon_summary damage_modifier inactive_weapon)
]
)
@@ -562,7 +488,12 @@ get_full_html player_ix char =
),
(get_weapon_details omnimods damage_modifier active_weapon),
(get_armor_details omnimods armor),
- (get_relevant_stats char_statistics),
+ (Html.div
+ []
+ (Battle.View.Statistic.get_all_but_gauges_html
+ char_statistics
+ )
+ ),
(get_weapon_summary damage_modifier inactive_weapon)
]
)
diff --git a/src/battle/src/View/Gauge.elm b/src/battle/src/View/Gauge.elm
deleted file mode 100644
index 50dbea3..0000000
--- a/src/battle/src/View/Gauge.elm
+++ /dev/null
@@ -1,75 +0,0 @@
-module View.Gauge exposing (get_html)
-
--- Elm -------------------------------------------------------------------------
-import Html
-import Html.Attributes
-
--- Local Module ----------------------------------------------------------------
-import Struct.Event
-
---------------------------------------------------------------------------------
--- LOCAL -----------------------------------------------------------------------
---------------------------------------------------------------------------------
-get_text_div : (
- String ->
- List (Html.Attribute Struct.Event.Type) ->
- (Html.Html Struct.Event.Type)
- )
-get_text_div text extra_txt_attr =
- (Html.div
- (
- [(Html.Attributes.class "gauge-text")]
- ++ extra_txt_attr
- )
- [
- (Html.text text)
- ]
- )
-
-get_bar_div : (
- Float ->
- List (Html.Attribute Struct.Event.Type) ->
- (Html.Html Struct.Event.Type)
- )
-get_bar_div percent extra_bar_attr =
- (Html.div
- (
- [
- (Html.Attributes.style
- "width"
- ((String.fromFloat percent) ++ "%")
- ),
- (Html.Attributes.class
- "gauge-bar"
- )
- ]
- ++
- extra_bar_attr
- )
- [
- ]
- )
-
-
---------------------------------------------------------------------------------
--- EXPORTED --------------------------------------------------------------------
---------------------------------------------------------------------------------
-get_html : (
- String ->
- Float ->
- List (Html.Attribute Struct.Event.Type) ->
- List (Html.Attribute Struct.Event.Type) ->
- List (Html.Attribute Struct.Event.Type) ->
- (Html.Html Struct.Event.Type)
- )
-get_html text percent extra_div_attr extra_bar_attr extra_txt_attr =
- (Html.div
- (
- [(Html.Attributes.class "gauge")]
- ++ extra_div_attr
- )
- [
- (get_text_div text extra_txt_attr),
- (get_bar_div percent extra_bar_attr)
- ]
- )
diff --git a/src/roster-editor/src/Struct/Character.elm b/src/roster-editor/src/Struct/Character.elm
index e6ef776..2b64322 100644
--- a/src/roster-editor/src/Struct/Character.elm
+++ b/src/roster-editor/src/Struct/Character.elm
@@ -7,29 +7,18 @@ module Struct.Character exposing
set_battle_index,
get_name,
set_name,
- get_portrait,
- set_portrait,
- get_armor,
- set_armor,
+ get_equipment,
+ set_equipment,
get_current_omnimods,
get_attributes,
get_statistics,
- get_primary_weapon,
- set_primary_weapon,
- get_secondary_weapon,
- set_secondary_weapon,
get_is_using_secondary,
- get_glyph_board,
- set_glyph_board,
- get_glyphs,
- set_glyph,
set_was_edited,
get_was_edited,
switch_weapons
)
-- Elm -------------------------------------------------------------------------
-import Array
-- Battle ----------------------------------------------------------------------
import Battle.Struct.Omnimods
@@ -38,12 +27,9 @@ import Battle.Struct.Statistics
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Armor
-import BattleCharacters.Struct.Portrait
+import BattleCharacters.Struct.Equipment
import BattleCharacters.Struct.Weapon
-
--- Local Module ----------------------------------------------------------------
-import Struct.Glyph
-import Struct.GlyphBoard
+import BattleCharacters.Struct.GlyphBoard
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
@@ -53,15 +39,10 @@ type alias Type =
ix : Int,
battle_ix : Int,
name : String,
- portrait : BattleCharacters.Struct.Portrait.Type,
+ equipment : BattleCharacters.Struct.Equipment,
attributes : Battle.Struct.Attributes.Type,
statistics : Battle.Struct.Statistics.Type,
- primary_weapon : BattleCharacters.Struct.Weapon.Type,
- secondary_weapon : BattleCharacters.Struct.Weapon.Type,
is_using_secondary : Bool,
- armor : BattleCharacters.Struct.Armor.Type,
- glyph_board : Struct.GlyphBoard.Type,
- glyphs : (Array.Array Struct.Glyph.Type),
current_omnimods : Battle.Struct.Omnimods.Type,
was_edited : Bool
}
@@ -72,21 +53,28 @@ type alias Type =
refresh_omnimods : Type -> Type
refresh_omnimods char =
let
+ equipment = char.equipment
current_omnimods =
(Battle.Struct.Omnimods.merge
(Battle.Struct.Omnimods.merge
(BattleCharacters.Struct.Weapon.get_omnimods
(
if (char.is_using_secondary)
- then char.secondary_weapon
- else char.primary_weapon
+ then
+ (BattleCharacters.Struct.Equipment.get_secondary_weapon
+ equipment
+ )
+ else
+ (BattleCharacters.Struct.Equipment.get_primary_weapon
+ equipment
+ )
)
)
(BattleCharacters.Struct.Armor.get_omnimods char.armor)
)
- (Struct.GlyphBoard.get_omnimods_with_glyphs
- char.glyphs
- char.glyph_board
+ (BattleCharacters.Struct.GlyphBoard.get_omnimods_with_glyphs
+ (BattleCharacters.Struct.Equipment.get_glyphs equipment)
+ (BattleCharacters.Struct.Equipment.get_glyph_board equipment)
)
)
current_attributes =
@@ -113,66 +101,21 @@ refresh_omnimods char =
new : (
Int ->
String ->
- (Maybe BattleCharacters.Struct.Portrait.Type) ->
- (Maybe BattleCharacters.Struct.Weapon.Type) ->
- (Maybe BattleCharacters.Struct.Weapon.Type) ->
- (Maybe BattleCharacters.Struct.Armor.Type) ->
- (Maybe Struct.GlyphBoard.Type) ->
- (List (Maybe Struct.Glyph.Type)) ->
+ BattleCharacters.Struct.Equipment.Type ->
Type
)
-new index name m_portrait m_main_wp m_sec_wp m_armor m_board m_glyphs =
+new index name equipment =
(refresh_omnimods
{
ix = index,
battle_ix = -1,
name = name,
- portrait =
- (
- case m_portrait of
- (Just portrait) -> portrait
- Nothing -> (BattleCharacters.Struct.Portrait.default)
- ),
+ equipment = equipment,
attributes = (Battle.Struct.Attributes.default),
statistics =
(Battle.Struct.Statistics.new_raw
(Battle.Struct.Attributes.default)
),
- primary_weapon =
- (
- case m_main_wp of
- (Just w) -> w
- Nothing -> (BattleCharacters.Struct.Weapon.default)
- ),
- secondary_weapon =
- (
- case m_sec_wp of
- (Just w) -> w
- Nothing -> (BattleCharacters.Struct.Weapon.default)
- ),
- armor =
- (
- case m_armor of
- (Just armor) -> armor
- Nothing -> (BattleCharacters.Struct.Armor.default)
- ),
- glyph_board =
- (
- case m_board of
- (Just board) -> board
- Nothing -> (Struct.GlyphBoard.default)
- ),
- glyphs =
- (Array.fromList
- (List.map
- (\m_g ->
- case m_g of
- (Just g) -> g
- Nothing -> (Struct.Glyph.default)
- )
- m_glyphs
- )
- ),
is_using_secondary = False,
current_omnimods = (Battle.Struct.Omnimods.none),
was_edited = False
@@ -194,11 +137,11 @@ get_name c = c.name
set_name : String -> Type -> Type
set_name name char = {char | name = name}
-get_portrait : Type -> BattleCharacters.Struct.Portrait.Type
-get_portrait c = c.portrait
+get_equipment : Type -> BattleCharacters.Struct.Equipment.Type
+get_equipment c = c.equipment
-set_portrait : BattleCharacters.Struct.Portrait.Type -> Type -> Type
-set_portrait portrait char = {char | portrait = portrait}
+set_equipment : BattleCharacters.Struct.Equipment.Type -> Type -> Type
+set_equipment equipment char = (refresh_omnimods {char | equipment = equipment})
get_current_omnimods : Type -> Battle.Struct.Omnimods.Type
get_current_omnimods c = c.current_omnimods
@@ -209,50 +152,9 @@ get_attributes char = char.attributes
get_statistics : Type -> Battle.Struct.Statistics.Type
get_statistics char = char.statistics
-get_primary_weapon : Type -> BattleCharacters.Struct.Weapon.Type
-get_primary_weapon char = char.primary_weapon
-
-set_primary_weapon : BattleCharacters.Struct.Weapon.Type -> Type -> Type
-set_primary_weapon wp char = (refresh_omnimods {char | primary_weapon = wp})
-
-get_secondary_weapon : Type -> BattleCharacters.Struct.Weapon.Type
-get_secondary_weapon char = char.secondary_weapon
-
-set_secondary_weapon : BattleCharacters.Struct.Weapon.Type -> Type -> Type
-set_secondary_weapon wp char = (refresh_omnimods {char | secondary_weapon = wp})
-
get_is_using_secondary : Type -> Bool
get_is_using_secondary char = char.is_using_secondary
-get_armor : Type -> BattleCharacters.Struct.Armor.Type
-get_armor char = char.armor
-
-set_armor : BattleCharacters.Struct.Armor.Type -> Type -> Type
-set_armor armor char = (refresh_omnimods {char | armor = armor})
-
-get_glyph_board : Type -> Struct.GlyphBoard.Type
-get_glyph_board char = char.glyph_board
-
-set_glyph_board : Struct.GlyphBoard.Type -> Type -> Type
-set_glyph_board glyph_board char =
- (refresh_omnimods
- {char |
- glyph_board = glyph_board,
- glyphs =
- (Array.repeat
- (List.length (Struct.GlyphBoard.get_slots glyph_board))
- (Struct.Glyph.none)
- )
- }
- )
-
-get_glyphs : Type -> (Array.Array Struct.Glyph.Type)
-get_glyphs char = char.glyphs
-
-set_glyph : Int -> Struct.Glyph.Type -> Type -> Type
-set_glyph index glyph char =
- (refresh_omnimods {char | glyphs = (Array.set index glyph char.glyphs)})
-
get_was_edited : Type -> Bool
get_was_edited char = char.was_edited
diff --git a/src/roster-editor/src/Struct/Inventory.elm b/src/roster-editor/src/Struct/Inventory.elm
index aa0cbeb..063c3ce 100644
--- a/src/roster-editor/src/Struct/Inventory.elm
+++ b/src/roster-editor/src/Struct/Inventory.elm
@@ -6,26 +6,37 @@ module Struct.Inventory exposing
has_glyph_board,
has_weapon,
has_armor,
+ allows,
empty,
decoder
)
-- Elm -------------------------------------------------------------------------
+import Array
+
import Json.Decode
import Json.Decode.Pipeline
import Set
+-- Battle Characters -----------------------------------------------------------
+import BattleCharacters.Struct.Armor
+import BattleCharacters.Struct.Equipment
+import BattleCharacters.Struct.Glyph
+import BattleCharacters.Struct.GlyphBoard
+import BattleCharacters.Struct.Portrait
+import BattleCharacters.Struct.Weapon
+
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
--------------------------------------------------------------------------------
type alias Type =
{
- portraits : (Set.Set Int),
- glyphs : (Set.Set Int),
- glyph_boards : (Set.Set Int),
- weapons : (Set.Set Int),
- armors : (Set.Set Int)
+ portraits : (Set.Set BattleCharacters.Struct.Portrait.Ref),
+ glyphs : (Set.Set BattleCharacters.Struct.Glyph.Ref),
+ glyph_boards : (Set.Set BattleCharacters.Struct.GlyphBoard.Ref),
+ weapons : (Set.Set BattleCharacters.Struct.Weapon.Ref),
+ armors : (Set.Set BattleCharacters.Struct.Armor.Ref)
}
--------------------------------------------------------------------------------
@@ -35,20 +46,59 @@ type alias Type =
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
-has_portrait : Int -> Type -> Bool
-has_portrait id inv = (Set.member id inv.portraits)
+has_portrait : Type -> BattleCharacters.Struct.Portrait.Ref -> Bool
+has_portrait inv id = (Set.member id inv.portraits)
-has_glyph : Int -> Type -> Bool
-has_glyph id inv = (Set.member id inv.glyphs)
+has_glyph : Type -> BattleCharacters.Struct.Glyph.Ref -> Bool
+has_glyph inv id = (Set.member id inv.glyphs)
-has_glyph_board : Int -> Type -> Bool
-has_glyph_board id inv = (Set.member id inv.glyph_boards)
+has_glyph_board : Type -> BattleCharacters.Struct.GlyphBoard.Ref -> Bool
+has_glyph_board inv id = (Set.member id inv.glyph_boards)
-has_weapon : Int -> Type -> Bool
-has_weapon id inv = (Set.member id inv.weapons)
+has_weapon : Type -> BattleCharacters.Struct.Weapon.Ref -> Bool
+has_weapon inv id = (Set.member id inv.weapons)
-has_armor : Int -> Type -> Bool
-has_armor id inv = (Set.member id inv.armors)
+has_armor : Type -> BattleCharacters.Struct.Armor.Ref -> Bool
+has_armor inv id = (Set.member id inv.armors)
+
+allows : Type -> BattleCharacters.Struct.Equipment.Type -> Bool
+allows inv equipment =
+ (and
+ (has_weapon
+ inv
+ (BattleCharacters.Struct.Weapon.get_id
+ (BattleCharacters.Struct.Equipment.get_primary_weapon equipment)
+ )
+ )
+ (has_weapon
+ inv
+ (BattleCharacters.Struct.Weapon.get_id
+ (BattleCharacters.Struct.Equipment.get_secondary_weapon equipment)
+ )
+ )
+ (has_armor
+ inv
+ (BattleCharacters.Struct.Armor.get_id
+ (BattleCharacters.Struct.Equipment.get_armor equipment)
+ )
+ )
+ (has_portrait
+ inv
+ (BattleCharacters.Struct.Portrait.get_id
+ (BattleCharacters.Struct.Equipment.get_portrait equipment)
+ )
+ )
+ (has_glyph_board
+ inv
+ (BattleCharacters.Struct.GlyphBoard.get_id
+ (BattleCharacters.Struct.Equipment.get_glyph_board equipment)
+ )
+ )
+ (List.all
+ ((BattleCharacters.Struct.Glyph.get_id) |> (has_glyph inv))
+ (Array.toList (BattleCharacters.Struct.Equipment.get_glyphs equipment))
+ )
+ )
empty : Type
empty =
diff --git a/src/roster-editor/src/View/Character.elm b/src/roster-editor/src/View/Character.elm
index abfa557..a19b448 100644
--- a/src/roster-editor/src/View/Character.elm
+++ b/src/roster-editor/src/View/Character.elm
@@ -16,6 +16,8 @@ import Util.Html
import BattleCharacters.Struct.Armor
import BattleCharacters.Struct.Portrait
+import BattleCharacters.View.Portrait
+
-- Local Module ----------------------------------------------------------------
import Struct.Character
import Struct.Event
@@ -53,53 +55,6 @@ 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 "character-portrait-body"),
- (Html.Attributes.class
- (
- "asset-character-portrait-"
- ++
- (BattleCharacters.Struct.Portrait.get_id
- (Struct.Character.get_portrait char)
- )
- )
- )
- ]
- [
- ]
- )
-
-get_portrait_armor_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
-get_portrait_armor_html char =
- (Html.div
- [
- (Html.Attributes.class "character-portrait-armor"),
- (Html.Attributes.class
- (
- "asset-armor-"
- ++
- (BattleCharacters.Struct.Armor.get_image_id
- (Struct.Character.get_armor char)
- )
- )
- ),
- (Html.Attributes.class
- (
- "asset-armor-variation-"
- ++
- (BattleCharacters.Struct.Portrait.get_body_id
- (Struct.Character.get_portrait char)
- )
- )
- )
- ]
- [
- ]
- )
-
get_battle_index_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)
get_battle_index_html char =
let battle_ix = (Struct.Character.get_battle_index char) in
@@ -121,33 +76,31 @@ get_battle_index_html char =
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_portrait_html : (
- Struct.Character.Type ->
Bool ->
+ Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_portrait_html char click_to_toggle =
+get_portrait_html click_to_toggle char =
(Html.div
- (
- [
- (Html.Attributes.class "character-portrait"),
- (Html.Attributes.class "character-portrait-team-0")
- ]
- ++
- if (click_to_toggle)
- then
- [
- (Html.Events.onClick
- (Struct.Event.ToggleCharacterBattleIndex
- (Struct.Character.get_index char)
- )
- )
- ]
- else
- []
- )
+ []
[
- (get_portrait_body_html char),
- (get_portrait_armor_html char),
+ (BattleCharacters.View.Portrait.get_html
+ (
+ if (click_to_toggle)
+ then
+ [
+ (Html.Events.onClick
+ (Struct.Event.ToggleCharacterBattleIndex
+ (Struct.Character.get_index char)
+ )
+ ),
+ (Html.Attributes.class "character-portrait-team-0")
+ ]
+ else
+ [(Html.Attributes.class "character-portrait-team-0")]
+ )
+ char
+ ),
(get_battle_index_html char)
]
)
diff --git a/src/roster-editor/src/View/CharacterCard.elm b/src/roster-editor/src/View/CharacterCard.elm
index 0ddc2e6..10d35dd 100644
--- a/src/roster-editor/src/View/CharacterCard.elm
+++ b/src/roster-editor/src/View/CharacterCard.elm
@@ -462,7 +462,7 @@ get_minimal_html char =
(Html.Attributes.class "info-card-picture")
]
[
- (View.Character.get_portrait_html char True)
+ (View.Character.get_portrait_html True char)
]
),
(get_health_bar char),
@@ -508,7 +508,7 @@ get_full_html char =
)
]
[
- (View.Character.get_portrait_html char False)
+ (View.Character.get_portrait_html False char)
]
),
(get_health_bar char),
diff --git a/src/shared/battle-characters/BattleCharacters/Struct/Equipment.elm b/src/shared/battle-characters/BattleCharacters/Struct/Equipment.elm
new file mode 100644
index 0000000..8782397
--- /dev/null
+++ b/src/shared/battle-characters/BattleCharacters/Struct/Equipment.elm
@@ -0,0 +1,192 @@
+module BattleCharacters.Struct.Equipment exposing
+ (
+ get_primary_weapon,
+ get_secondary_weapon,
+ get_armor,
+ get_portrait,
+ get_glyph_board,
+ get_glyphs,
+ set_primary_weapon,
+ set_secondary_weapon,
+ set_armor,
+ set_portrait,
+ set_glyph_board,
+ set_glyphs,
+ set_glyph,
+ ref_decoder,
+ ref_encoder,
+ resolve,
+ to_ref
+ )
+
+-- Elm -------------------------------------------------------------------------
+import Array
+
+import List
+
+import Json.Decode
+import Json.Decode.Pipeline
+
+import Json.Encode
+
+-- Battle ----------------------------------------------------------------------
+import BattleCharacters.Struct.Weapon
+import BattleCharacters.Struct.Armor
+import BattleCharacters.Struct.Portrait
+import BattleCharacters.Struct.Glyph
+import BattleCharacters.Struct.GlyphBoard
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type alias Type =
+ {
+ primary : BattleCharacters.Struct.Weapon.Type,
+ secondary : BattleCharacters.Struct.Weapon.Type,
+ armor : BattleCharacters.Struct.Armor.Type,
+ portrait : BattleCharacters.Struct.Portrait.Type,
+ glyph_board : BattleCharacters.Struct.GlyphBoard.Type,
+ glyphs : (Array.Array BattleCharacters.Struct.Glyph.Type)
+ }
+
+type alias Ref =
+ {
+ primary : BattleCharacters.Struct.Weapon.Ref,
+ secondary : BattleCharacters.Struct.Weapon.Ref,
+ armor : BattleCharacters.Struct.Armor.Ref,
+ portrait : BattleCharacters.Struct.Portrait.Ref,
+ glyph_board : BattleCharacters.Struct.GlyphBoard.Ref,
+ glyphs : (Array.Array BattleCharacters.Struct.Glyph.Ref)
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_primary_weapon : Type -> BattleCharacters.Struct.Weapon.Type
+get_primary_weapon equipment = equipment.primary
+
+get_secondary_weapon : Type -> BattleCharacters.Struct.Weapon.Type
+get_secondary_weapon equipment = equipment.secondary
+
+get_armor : Type -> BattleCharacters.Struct.Armor.Type
+get_armor equipment = equipment.armor
+
+get_portrait : Type -> BattleCharacters.Struct.Portrait.Type
+get_portrait equipment = equipment.portrait
+
+get_glyph_board : Type -> BattleCharacters.Struct.GlyphBoard.Type
+get_glyph_board equipment = equipment.glyph_board
+
+get_glyphs : Type -> (Array.Array BattleCharacters.Struct.Glyph.Type)
+get_glyphs equipment = equipment.glyphs
+
+set_primary_weapon : BattleCharacters.Struct.Weapon.Type -> Type -> Type
+set_primary_weapon wp equipment = { equipment | primary = wp }
+
+set_secondary_weapon : BattleCharacters.Struct.Weapon.Type -> Type -> Type
+set_secondary_weapon wp equipment = { equipment | secondary = wp }
+
+set_armor : BattleCharacters.Struct.Armor.Type -> Type -> Type
+set_armor ar equipment = { equipment | armor = ar }
+
+set_portrait : BattleCharacters.Struct.Portrait.Type -> Type -> Type
+set_portrait pt equipment = { equipment | portrait = pt }
+
+set_glyph_board : BattleCharacters.Struct.GlyphBoard.Type -> Type -> Type
+set_glyph_board gb equipment =
+ {equipment |
+ glyph_board = gb,
+ glyphs =
+ (Array.repeat
+ (List.length (BattleCharacters.Struct.GlyphBoard.get_slots gb))
+ (BattleCharacters.Struct.Glyph.none)
+ )
+ }
+
+set_glyphs : (Array.Array BattleCharacters.Struct.Glyph.Type) -> Type -> Type
+set_glyphs gl equipment = { equipment | glyphs = gl }
+
+set_glyph : Int -> BattleCharacters.Struct.Glyph.Type -> Type -> Type
+set_glyph index glyph equipment =
+ { equipment | glyphs = (Array.set index glyph equipment.glyphs) }
+
+ref_decoder : (Json.Decode.Decoder Type)
+ref_decoder =
+ (Json.Decode.succeed
+ Ref
+ |> (Json.Decode.Pipeline.required "pr" Json.Decode.string)
+ |> (Json.Decode.Pipeline.required "sc" Json.Decode.string)
+ |> (Json.Decode.Pipeline.required "ar" Json.Decode.string)
+ |> (Json.Decode.Pipeline.required "pt" Json.Decode.string)
+ |> (Json.Decode.Pipeline.required "gb" Json.Decode.string)
+ |>
+ (Json.Decode.Pipeline.required
+ "gl"
+ (Json.Decode.array (Json.Decode.string))
+ )
+ )
+
+ref_encoder : Ref -> Json.Encode.Value
+ref_encoder ref =
+ (Json.Encode.object
+ [
+ ("pr", (Json.Encode.string ref.primary)),
+ ("sc", (Json.Encode.string ref.secondary)),
+ ("ar", (Json.Encode.string ref.armor)),
+ ("pt", (Json.Encode.string ref.portrait)),
+ ("gb", (Json.Encode.string ref.glyph_board)),
+ ("gl", (Json.Encode.array (Array.map (Json.Encode.string) ref.gl)))
+ ]
+ )
+
+resolve : (
+ (
+ BattleCharacters.Struct.Weapon.Ref ->
+ BattleCharacters.Struct.Weapon.Type
+ ) ->
+ (
+ BattleCharacters.Struct.Armor.Ref ->
+ BattleCharacters.Struct.Armor.Type
+ ) ->
+ (
+ BattleCharacters.Struct.Portrait.Ref ->
+ BattleCharacters.Struct.Portrait.Type
+ ) ->
+ (
+ BattleCharacters.Struct.GlyphBoard.Ref ->
+ BattleCharacters.Struct.GlyphBoard.Type
+ ) ->
+ (
+ BattleCharacters.Struct.Glyph.Ref ->
+ BattleCharacters.Struct.Glyph.Type
+ ) ->
+ Ref ->
+ Type
+ )
+resolve resolve_wp resolve_ar resolve_pt resolve_gb resolve_gl ref =
+ {
+ primary = (resolve_wp ref.primary),
+ secondary = (resolve_wp ref.secondary),
+ armor = (resolve_ar ref.armor),
+ portrait = (resolve_pt ref.portrait),
+ glyph_board = (resolve_gb ref.glyph_board),
+ glyphs = (Array.map (resolve_gl) ref.glyphs)
+ }
+
+to_ref : Type -> Ref
+to_ref equipment =
+ {
+ primary = (BattleCharacters.Struct.Weapon.get_id equipment.primary),
+ secondary = (BattleCharacters.Struct.Weapon.get_id equipment.secondary),
+ armor = (BattleCharacters.Struct.Armor.get_id equipment.armor),
+ portrait = (BattleCharacters.Struct.Portrait.get_id equipment.portrait),
+ glyph_board =
+ (BattleCharacters.Struct.GlyphBoard.get_id equipment.glyph_board),
+ glyphs =
+ (Array.map (BattleCharacters.Struct.Glyph.get_id) equipment.glyphs)
+ }
+
diff --git a/src/roster-editor/src/Struct/Glyph.elm b/src/shared/battle-characters/BattleCharacters/Struct/Glyph.elm
index f871d35..c277b20 100644
--- a/src/roster-editor/src/Struct/Glyph.elm
+++ b/src/shared/battle-characters/BattleCharacters/Struct/Glyph.elm
@@ -1,4 +1,4 @@
-module Struct.Glyph exposing
+module BattleCharacters.Struct.Glyph exposing
(
Type,
Ref,
diff --git a/src/roster-editor/src/Struct/GlyphBoard.elm b/src/shared/battle-characters/BattleCharacters/Struct/GlyphBoard.elm
index fc848e4..7d08ec0 100644
--- a/src/roster-editor/src/Struct/GlyphBoard.elm
+++ b/src/shared/battle-characters/BattleCharacters/Struct/GlyphBoard.elm
@@ -1,4 +1,4 @@
-module Struct.GlyphBoard exposing
+module BattleCharacters.Struct.GlyphBoard exposing
(
Type,
Ref,
@@ -23,8 +23,8 @@ import Json.Decode.Pipeline
-- Battle ----------------------------------------------------------------------
import Battle.Struct.Omnimods
--- Local Module ----------------------------------------------------------------
-import Struct.Glyph
+-- Battle Characters -----------------------------------------------------------
+import BattleCharacters.Struct.Glyph
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
@@ -59,7 +59,7 @@ get_omnimods : Type -> Battle.Struct.Omnimods.Type
get_omnimods g = g.omnimods
get_omnimods_with_glyphs : (
- (Array.Array Struct.Glyph.Type) ->
+ (Array.Array BattleCharacters.Struct.Glyph.Type) ->
Type ->
Battle.Struct.Omnimods.Type
)
@@ -70,7 +70,9 @@ get_omnimods_with_glyphs glyphs board =
(List.map2
(Battle.Struct.Omnimods.scale)
(List.map (\e -> ((toFloat e) / 100.0)) board.slots)
- (List.map (Struct.Glyph.get_omnimods) (Array.toList glyphs))
+ (List.map
+ (BattleCharacters.Struct.Glyph.get_omnimods) (Array.toList glyphs)
+ )
)
)
diff --git a/src/shared/battle-characters/BattleCharacters/View/Portrait.elm b/src/shared/battle-characters/BattleCharacters/View/Portrait.elm
new file mode 100644
index 0000000..50c5c4c
--- /dev/null
+++ b/src/shared/battle-characters/BattleCharacters/View/Portrait.elm
@@ -0,0 +1,99 @@
+module BattleCharacters.View.Portrait exposing
+ (
+ get_html
+ )
+
+-- Elm -------------------------------------------------------------------------
+import Html
+import Html.Attributes
+import Html.Events
+
+-- Shared ----------------------------------------------------------------------
+import Util.Html
+
+-- Battle Characters -----------------------------------------------------------
+import BattleCharacters.Struct.Armor
+import BattleCharacters.Struct.Equipment
+import BattleCharacters.Struct.Portrait
+
+-- Local Module ----------------------------------------------------------------
+import Struct.Event
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_portrait_body_html : (
+ BattleCharacters.Struct.Equipment.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+get_portrait_body_html equipment =
+ (Html.div
+ [
+ (Html.Attributes.class "character-portrait-body"),
+ (Html.Attributes.class
+ (
+ "asset-character-portrait-"
+ ++
+ (BattleCharacters.Struct.Portrait.get_id
+ (BattleCharacters.Struct.Equipment.get_portrait equipment)
+ )
+ )
+ )
+ ]
+ [
+ ]
+ )
+
+get_portrait_armor_html : (
+ BattleCharacters.Struct.Equipment.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+get_portrait_armor_html equipment =
+ (Html.div
+ [
+ (Html.Attributes.class "character-portrait-armor"),
+ (Html.Attributes.class
+ (
+ "asset-armor-"
+ ++
+ (BattleCharacters.Struct.Armor.get_image_id
+ (BattleCharacters.Equipment.get_armor equipment)
+ )
+ )
+ ),
+ (Html.Attributes.class
+ (
+ "asset-armor-variation-"
+ ++
+ (BattleCharacters.Struct.Portrait.get_body_id
+ (BattleCharacters.Struct.Equipment.get_portrait equipment)
+ )
+ )
+ )
+ ]
+ [
+ ]
+ )
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_html : (
+ (List (Html.Attribute Struct.Event.Type)) ->
+ BattleCharacters.Equipment.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+get_html extra_attributes equipment =
+ (Html.div
+ (
+ [
+ (Html.Attributes.class "character-portrait")
+ ]
+ ++
+ extra_attributes
+ )
+ [
+ (get_portrait_body_html equipment),
+ (get_portrait_armor_html equipment)
+ ]
+ )