From c2f3e908511cdf782f4a324002a15b607ffbd125 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Mon, 9 Sep 2019 17:57:36 +0200 Subject: Highlights invalid glyphs. --- .../battle-characters/BattleCharacters/Struct/Glyph.elm | 7 +++++++ src/shared/elm/Util/List.elm | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'src/shared') diff --git a/src/shared/battle-characters/BattleCharacters/Struct/Glyph.elm b/src/shared/battle-characters/BattleCharacters/Struct/Glyph.elm index 9a86fb4..2a5054d 100644 --- a/src/shared/battle-characters/BattleCharacters/Struct/Glyph.elm +++ b/src/shared/battle-characters/BattleCharacters/Struct/Glyph.elm @@ -5,6 +5,7 @@ module BattleCharacters.Struct.Glyph exposing find, get_name, get_id, + get_family_id, get_omnimods, none, default, @@ -27,6 +28,7 @@ type alias Type = { id : String, name : String, + family_id : String, omnimods : Battle.Struct.Omnimods.Type } @@ -48,6 +50,9 @@ find dict ref = get_id : Type -> Ref get_id g = g.id +get_family_id : Type -> Ref +get_family_id g = g.family_id + get_name : Type -> String get_name g = g.name @@ -60,6 +65,7 @@ decoder = Type |> (Json.Decode.Pipeline.required "id" Json.Decode.string) |> (Json.Decode.Pipeline.required "nam" Json.Decode.string) + |> (Json.Decode.Pipeline.required "fam" Json.Decode.string) |> (Json.Decode.Pipeline.required "omni" Battle.Struct.Omnimods.decoder) ) @@ -68,6 +74,7 @@ none = { id = "0", name = "Empty", + family_id = "0", omnimods = (Battle.Struct.Omnimods.none) } diff --git a/src/shared/elm/Util/List.elm b/src/shared/elm/Util/List.elm index 1f914b1..829dd3e 100644 --- a/src/shared/elm/Util/List.elm +++ b/src/shared/elm/Util/List.elm @@ -1,5 +1,7 @@ module Util.List exposing (..) +import Set + import List pop : List a -> (Maybe (a, List a)) @@ -34,3 +36,18 @@ product_map_rec product_fun list_a list_b result = ) ) +duplicates : (List comparable) -> (Set.Set comparable) +duplicates list = + let + (encountered, final_result) = + (List.foldl + (\elem (met, result) -> + if (Set.member elem met) + then (met, (Set.insert elem result)) + else ((Set.insert elem met), result) + ) + ((Set.empty), (Set.empty)) + list + ) + in + final_result -- cgit v1.2.3-70-g09d2