summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/roster-editor')
-rw-r--r-- | src/roster-editor/src/Struct/Character.elm | 56 | ||||
-rw-r--r-- | src/roster-editor/src/Struct/Model.elm | 4 | ||||
-rw-r--r-- | src/roster-editor/src/View/CharacterCard.elm | 24 |
3 files changed, 69 insertions, 15 deletions
diff --git a/src/roster-editor/src/Struct/Character.elm b/src/roster-editor/src/Struct/Character.elm index ee92f8b..003d466 100644 --- a/src/roster-editor/src/Struct/Character.elm +++ b/src/roster-editor/src/Struct/Character.elm @@ -9,6 +9,8 @@ module Struct.Character exposing set_base_character, set_was_edited, get_was_edited, + set_is_valid, + get_is_valid, resolve, to_unresolved, decoder, @@ -22,6 +24,7 @@ import Json.Decode.Pipeline import Json.Encode -- Battle ---------------------------------------------------------------------- +import Battle.Struct.Attributes import Battle.Struct.Omnimods -- Battle Characters ----------------------------------------------------------- @@ -36,6 +39,7 @@ type alias Type = ix : Int, battle_ix : Int, was_edited : Bool, + is_valid : Bool, base : BattleCharacters.Struct.Character.Type } @@ -44,6 +48,7 @@ type alias Unresolved = ix : Int, battle_ix : Int, was_edited : Bool, + is_valid : Bool, base : BattleCharacters.Struct.Character.Unresolved } @@ -75,6 +80,30 @@ get_was_edited char = char.was_edited set_was_edited : Bool -> Type -> Type set_was_edited val char = {char | was_edited = val} +get_is_valid : Type -> Bool +get_is_valid char = char.is_valid + +set_is_valid : Type -> Type +set_is_valid char = + {char | + is_valid = + ( + (List.all + (\(s, i) -> (i >= 0)) + (Battle.Struct.Omnimods.get_all_mods + (BattleCharacters.Struct.Character.get_omnimods char.base) + ) + ) + && + ( + (Battle.Struct.Attributes.get_max_health + (BattleCharacters.Struct.Character.get_attributes char.base) + ) + > 0 + ) + ) + } + resolve : ( ( BattleCharacters.Struct.Equipment.Unresolved -> @@ -84,17 +113,20 @@ resolve : ( Type ) resolve equipment_resolver ref = - { - ix = ref.ix, - battle_ix = ref.battle_ix, - was_edited = ref.was_edited, - base = - (BattleCharacters.Struct.Character.resolve - (equipment_resolver) - (Battle.Struct.Omnimods.none) - ref.base - ) - } + (set_is_valid + { + ix = ref.ix, + battle_ix = ref.battle_ix, + was_edited = ref.was_edited, + is_valid = False, + base = + (BattleCharacters.Struct.Character.resolve + (equipment_resolver) + (Battle.Struct.Omnimods.none) + ref.base + ) + } + ) to_unresolved : Type -> Unresolved to_unresolved char = @@ -102,6 +134,7 @@ to_unresolved char = ix = char.ix, battle_ix = char.battle_ix, was_edited = char.was_edited, + is_valid = char.is_valid, base = (BattleCharacters.Struct.Character.to_unresolved char.base) } @@ -112,6 +145,7 @@ decoder = |> (Json.Decode.Pipeline.required "ix" Json.Decode.int) |> (Json.Decode.Pipeline.hardcoded -1) |> (Json.Decode.Pipeline.hardcoded False) + |> (Json.Decode.Pipeline.hardcoded True) |> (Json.Decode.Pipeline.required "bas" diff --git a/src/roster-editor/src/Struct/Model.elm b/src/roster-editor/src/Struct/Model.elm index 0c304c9..879e185 100644 --- a/src/roster-editor/src/Struct/Model.elm +++ b/src/roster-editor/src/Struct/Model.elm @@ -262,7 +262,9 @@ save_character model = characters = (Array.set (Struct.Character.get_index char) - (Struct.Character.set_was_edited True char) + (Struct.Character.set_is_valid + (Struct.Character.set_was_edited True char) + ) model.characters ) } diff --git a/src/roster-editor/src/View/CharacterCard.elm b/src/roster-editor/src/View/CharacterCard.elm index ca300b7..1f64f38 100644 --- a/src/roster-editor/src/View/CharacterCard.elm +++ b/src/roster-editor/src/View/CharacterCard.elm @@ -208,7 +208,17 @@ get_mod_html mod = in (Html.div [ - (Html.Attributes.class "info-card-mod") + (Html.Attributes.class "info-card-mod"), + (Html.Attributes.class + ( + if (value < 0) + then "omnimod-negative-value" + else + if (value > 0) + then "omnimod-positive-value" + else "omnimod-nil-value" + ) + ) ] [ (Html.div @@ -333,7 +343,8 @@ get_relevant_atts : ( get_relevant_atts omnimods atts = (Html.div [ - (Html.Attributes.class "character-card-atts") + (Html.Attributes.class "character-card-atts"), + (Html.Attributes.class "roster-editor-atts") ] ( [ @@ -370,7 +381,7 @@ get_relevant_atts omnimods atts = ) ) ] - ++ (Battle.View.Attribute.get_all_but_gauges_html atts) + ++ (Battle.View.Attribute.get_true_all_html atts) ) ) @@ -390,6 +401,13 @@ get_minimal_html char = (Html.Attributes.class "info-card-minimal"), (Html.Attributes.class "character-card"), (Html.Attributes.class "character-card-minimal"), + (Html.Attributes.class + ( + if (Struct.Character.get_is_valid char) + then "roster-editor-valid-character" + else "roster-editor-invalid-character" + ) + ), (Html.Events.onClick (Struct.Event.CharacterSelected (Struct.Character.get_index char) |