summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/roster-editor')
-rw-r--r--src/roster-editor/src/Struct/Character.elm53
-rw-r--r--src/roster-editor/src/Update/SetGlyph.elm29
-rw-r--r--src/roster-editor/src/Update/SetGlyphBoard.elm27
-rw-r--r--src/roster-editor/src/View/CharacterCard.elm17
-rw-r--r--src/roster-editor/src/View/GlyphManagement.elm35
-rw-r--r--src/roster-editor/src/View/GlyphSelection.elm2
6 files changed, 127 insertions, 36 deletions
diff --git a/src/roster-editor/src/Struct/Character.elm b/src/roster-editor/src/Struct/Character.elm
index 003d466..c927c05 100644
--- a/src/roster-editor/src/Struct/Character.elm
+++ b/src/roster-editor/src/Struct/Character.elm
@@ -11,6 +11,8 @@ module Struct.Character exposing
get_was_edited,
set_is_valid,
get_is_valid,
+ set_invalid_glyph_family_indices,
+ get_invalid_glyph_family_indices,
resolve,
to_unresolved,
decoder,
@@ -18,11 +20,18 @@ module Struct.Character exposing
)
-- Elm -------------------------------------------------------------------------
+import Array
+
+import Set
+
import Json.Decode
import Json.Decode.Pipeline
import Json.Encode
+-- Shared ----------------------------------------------------------------------
+import Util.List
+
-- Battle ----------------------------------------------------------------------
import Battle.Struct.Attributes
import Battle.Struct.Omnimods
@@ -30,6 +39,7 @@ import Battle.Struct.Omnimods
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Character
import BattleCharacters.Struct.Equipment
+import BattleCharacters.Struct.Glyph
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
@@ -40,6 +50,7 @@ type alias Type =
battle_ix : Int,
was_edited : Bool,
is_valid : Bool,
+ invalid_glyph_family_ids : (Set.Set BattleCharacters.Struct.Glyph.Ref),
base : BattleCharacters.Struct.Character.Type
}
@@ -49,12 +60,31 @@ type alias Unresolved =
battle_ix : Int,
was_edited : Bool,
is_valid : Bool,
+ invalid_glyph_family_ids : (Set.Set BattleCharacters.Struct.Glyph.Ref),
base : BattleCharacters.Struct.Character.Unresolved
}
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
+compute_invalid_glyph_family_ids : (
+ BattleCharacters.Struct.Equipment.Type ->
+ (Set.Set BattleCharacters.Struct.Glyph.Ref)
+ )
+compute_invalid_glyph_family_ids equipment =
+ (Set.remove
+ (BattleCharacters.Struct.Glyph.get_family_id
+ (BattleCharacters.Struct.Glyph.none)
+ )
+ (Util.List.duplicates
+ (List.map
+ (BattleCharacters.Struct.Glyph.get_family_id)
+ (Array.toList
+ (BattleCharacters.Struct.Equipment.get_glyphs equipment)
+ )
+ )
+ )
+ )
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
@@ -88,6 +118,8 @@ set_is_valid char =
{char |
is_valid =
(
+ (Set.isEmpty char.invalid_glyph_family_ids)
+ &&
(List.all
(\(s, i) -> (i >= 0))
(Battle.Struct.Omnimods.get_all_mods
@@ -104,6 +136,24 @@ set_is_valid char =
)
}
+get_invalid_glyph_family_indices : (
+ Type ->
+ (Set.Set BattleCharacters.Struct.Glyph.Ref)
+ )
+get_invalid_glyph_family_indices char = char.invalid_glyph_family_ids
+
+set_invalid_glyph_family_indices : (
+ BattleCharacters.Struct.Equipment.Type ->
+ Type ->
+ Type
+ )
+set_invalid_glyph_family_indices equipment char =
+ let ids = (compute_invalid_glyph_family_ids equipment) in
+ {char |
+ invalid_glyph_family_ids = ids,
+ is_valid = (char.is_valid && (Set.isEmpty ids))
+ }
+
resolve : (
(
BattleCharacters.Struct.Equipment.Unresolved ->
@@ -119,6 +169,7 @@ resolve equipment_resolver ref =
battle_ix = ref.battle_ix,
was_edited = ref.was_edited,
is_valid = False,
+ invalid_glyph_family_ids = ref.invalid_glyph_family_ids,
base =
(BattleCharacters.Struct.Character.resolve
(equipment_resolver)
@@ -135,6 +186,7 @@ to_unresolved char =
battle_ix = char.battle_ix,
was_edited = char.was_edited,
is_valid = char.is_valid,
+ invalid_glyph_family_ids = char.invalid_glyph_family_ids,
base = (BattleCharacters.Struct.Character.to_unresolved char.base)
}
@@ -146,6 +198,7 @@ decoder =
|> (Json.Decode.Pipeline.hardcoded -1)
|> (Json.Decode.Pipeline.hardcoded False)
|> (Json.Decode.Pipeline.hardcoded True)
+ |> (Json.Decode.Pipeline.hardcoded (Set.empty))
|>
(Json.Decode.Pipeline.required
"bas"
diff --git a/src/roster-editor/src/Update/SetGlyph.elm b/src/roster-editor/src/Update/SetGlyph.elm
index 5d0a7f6..7007d47 100644
--- a/src/roster-editor/src/Update/SetGlyph.elm
+++ b/src/roster-editor/src/Update/SetGlyph.elm
@@ -31,22 +31,29 @@ apply_to model ref =
(
case (model.edited_char, (Dict.get ref model.glyphs)) of
((Just char), (Just glyph)) ->
- let base_char = (Struct.Character.get_base_character char) in
+ let
+ base_char = (Struct.Character.get_base_character char)
+ updated_equipment =
+ (BattleCharacters.Struct.Equipment.set_glyph
+ (Struct.UI.get_glyph_slot model.ui)
+ glyph
+ (BattleCharacters.Struct.Character.get_equipment
+ base_char
+ )
+ )
+ in
{model |
edited_char =
(Just
- (Struct.Character.set_base_character
- (BattleCharacters.Struct.Character.set_equipment
- (BattleCharacters.Struct.Equipment.set_glyph
- (Struct.UI.get_glyph_slot model.ui)
- glyph
- (BattleCharacters.Struct.Character.get_equipment
- base_char
- )
+ (Struct.Character.set_invalid_glyph_family_indices
+ updated_equipment
+ (Struct.Character.set_base_character
+ (BattleCharacters.Struct.Character.set_equipment
+ updated_equipment
+ base_char
)
- base_char
+ char
)
- char
)
),
ui =
diff --git a/src/roster-editor/src/Update/SetGlyphBoard.elm b/src/roster-editor/src/Update/SetGlyphBoard.elm
index ac03e53..70a7fd6 100644
--- a/src/roster-editor/src/Update/SetGlyphBoard.elm
+++ b/src/roster-editor/src/Update/SetGlyphBoard.elm
@@ -30,21 +30,28 @@ apply_to model ref =
(
case (model.edited_char, (Dict.get ref model.glyph_boards)) of
((Just char), (Just glyph_board)) ->
- let base_char = (Struct.Character.get_base_character char) in
+ let
+ base_char = (Struct.Character.get_base_character char)
+ updated_equipment =
+ (BattleCharacters.Struct.Equipment.set_glyph_board
+ glyph_board
+ (BattleCharacters.Struct.Character.get_equipment
+ base_char
+ )
+ )
+ in
{model |
edited_char =
(Just
- (Struct.Character.set_base_character
- (BattleCharacters.Struct.Character.set_equipment
- (BattleCharacters.Struct.Equipment.set_glyph_board
- glyph_board
- (BattleCharacters.Struct.Character.get_equipment
- base_char
- )
+ (Struct.Character.set_invalid_glyph_family_indices
+ updated_equipment
+ (Struct.Character.set_base_character
+ (BattleCharacters.Struct.Character.set_equipment
+ updated_equipment
+ base_char
)
- base_char
+ char
)
- char
)
)
}
diff --git a/src/roster-editor/src/View/CharacterCard.elm b/src/roster-editor/src/View/CharacterCard.elm
index 1f64f38..81e4e9f 100644
--- a/src/roster-editor/src/View/CharacterCard.elm
+++ b/src/roster-editor/src/View/CharacterCard.elm
@@ -5,6 +5,8 @@ module View.CharacterCard exposing
)
-- Elm -------------------------------------------------------------------------
+import Set
+
import List
import Html
@@ -300,13 +302,21 @@ get_armor_details current_tab armor =
)
get_glyph_board_details : (
+ Bool ->
BattleCharacters.Struct.GlyphBoard.Type ->
(Html.Html Struct.Event.Type)
)
-get_glyph_board_details board =
+get_glyph_board_details has_no_invalid_glyphs board =
(Html.div
[
- (Html.Attributes.class "character-card-glyph-board")
+ (Html.Attributes.class "character-card-glyph-board"),
+ (Html.Attributes.class
+ (
+ if (has_no_invalid_glyphs)
+ then "roster-editor-glyph-board-no-problem"
+ else "roster-editor-glyph-board-problem"
+ )
+ )
]
[
(Html.div
@@ -502,6 +512,9 @@ get_full_html current_tab char =
(BattleCharacters.Struct.Equipment.get_armor equipment)
),
(get_glyph_board_details
+ (Set.isEmpty
+ (Struct.Character.get_invalid_glyph_family_indices char)
+ )
(BattleCharacters.Struct.Equipment.get_glyph_board equipment)
),
(get_relevant_atts omnimods char_attributes)
diff --git a/src/roster-editor/src/View/GlyphManagement.elm b/src/roster-editor/src/View/GlyphManagement.elm
index 072dca3..6216b2c 100644
--- a/src/roster-editor/src/View/GlyphManagement.elm
+++ b/src/roster-editor/src/View/GlyphManagement.elm
@@ -3,12 +3,14 @@ module View.GlyphManagement exposing (get_html)
-- Elm -------------------------------------------------------------------------
import Array
+import Set
+
import Html
import Html.Attributes
import Html.Events
-- Battle ----------------------------------------------------------------------
-import Battle.Struct.Omnimods
+import Battle.View.Omnimods
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Glyph
@@ -41,15 +43,27 @@ get_mod_html mod =
)
get_glyph_html : (
+ (Set.Set BattleCharacters.Struct.Glyph.Ref) ->
Int ->
(Int, BattleCharacters.Struct.Glyph.Type)
-> (Html.Html Struct.Event.Type)
)
-get_glyph_html modifier (index, glyph) =
+get_glyph_html invalid_family_ids modifier (index, glyph) =
(Html.div
[
(Html.Attributes.class "character-card-glyph"),
(Html.Attributes.class "clickable"),
+ (Html.Attributes.class
+ (
+ if
+ (Set.member
+ (BattleCharacters.Struct.Glyph.get_family_id glyph)
+ invalid_family_ids
+ )
+ then "roster-editor-invalid-glyph"
+ else "roster-editor-valid-glyph"
+ )
+ ),
(Html.Events.onClick (Struct.Event.ClickedOnGlyph index))
]
[
@@ -61,15 +75,8 @@ get_glyph_html modifier (index, glyph) =
++ "%)"
)
),
- (Html.div
- [
- ]
- (List.map
- (get_mod_html)
- (Battle.Struct.Omnimods.get_all_mods
- (BattleCharacters.Struct.Glyph.get_omnimods glyph)
- )
- )
+ (Battle.View.Omnimods.get_html
+ (BattleCharacters.Struct.Glyph.get_omnimods glyph)
)
]
)
@@ -100,7 +107,11 @@ get_html model =
(Html.Attributes.class "selection-window-listing")
]
(List.map2
- (get_glyph_html)
+ (get_glyph_html
+ (Struct.Character.get_invalid_glyph_family_indices
+ char
+ )
+ )
(BattleCharacters.Struct.GlyphBoard.get_slots
(BattleCharacters.Struct.Equipment.get_glyph_board
equipment
diff --git a/src/roster-editor/src/View/GlyphSelection.elm b/src/roster-editor/src/View/GlyphSelection.elm
index e7b1da8..d1125f6 100644
--- a/src/roster-editor/src/View/GlyphSelection.elm
+++ b/src/roster-editor/src/View/GlyphSelection.elm
@@ -38,7 +38,7 @@ get_glyph_html : (
BattleCharacters.Struct.Glyph.Type ->
(Html.Html Struct.Event.Type)
)
-get_glyph_html glyph =
+get_glyph_html glyph =
(Html.div
[
(Html.Attributes.class "character-card-glyph"),