public static void CardsByColor()
        {
            string colors;
            bool   containsonly;

            while (true)
            {
                Console.Clear();
                Console.WriteLine("Enter Colors (W - White, U - Blue, B - Black, R - Red, G - Green, C - Colorless):");
                colors = Console.ReadLine();
                if (Regex.IsMatch(colors, @"^[WUBRGCwubrgc]+$"))
                {
                    string decs;
                    while (true)
                    {
                        Console.Clear();
                        Console.WriteLine("Are Only These Colors? (Y/N):");
                        decs = Console.ReadLine();
                        if ("y".Equals(decs.ToLower()))
                        {
                            containsonly = true;
                            break;
                        }
                        else if ("n".Equals(decs.ToLower()))
                        {
                            containsonly = false;
                            break;
                        }
                    }
                    break;
                }
            }

            //'C' for colorless
            bool notinset = false;
            bool nocards  = true;

            if (SeprateFunctions.Colorids.Count == 0)
            {
                SeprateFunctions.SepByColorId(false);
            }
            Console.Clear();
            for (int i = 0; i < SeprateFunctions.Colorids.Count; i++)
            {
                if (containsonly)
                {
                    if (SeprateFunctions.Colorids[i].Length == colors.Length)
                    {
                        foreach (char let in colors)
                        {
                            if (!SeprateFunctions.Colorids[i].Contains(Char.ToUpper(let)))
                            {
                                notinset = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        notinset = true;
                    }
                }
                else
                {
                    notinset = true;
                    foreach (char let in colors)
                    {
                        if (SeprateFunctions.Colorids[i].Contains(Char.ToUpper(let)))
                        {
                            notinset = false;
                            break;
                        }
                    }
                }
                if (!notinset)
                {
                    nocards = false;
                    Console.WriteLine("- " + SeprateFunctions.Colorids[i]);
                    Console.WriteLine("NAME - SET - PRINTING - AMOUNT - ID");
                    foreach (Card card in SeprateFunctions.SepedCardsByColorId[i])
                    {
                        Console.WriteLine(card.Special_name + " " + card.Set + " " + card.Printing + " " + card.Amount + " " + ProgFunctions.Allcards.IndexOf(card));
                    }
                    Console.WriteLine("--------");
                    Console.WriteLine(" ");
                }
                notinset = false;
            }
            if (nocards)
            {
                Console.WriteLine("No Cards In Color(s)");
            }
            Console.WriteLine(" ");
            Console.WriteLine("Enter Any Key To Exit:");
            Console.ReadLine();
        }
Exemple #2
0
        public static void ChooseFeature(int choice)
        {
            string selection;

            if (choice == 1)
            {
                while (true)
                {
                    Console.Clear();
                    Console.WriteLine("Search By Card Name or Card Database ID:");
                    Console.WriteLine("1 - Card Name");
                    Console.WriteLine("2 - Card Database ID");
                    Console.WriteLine("3 - Exit");
                    selection = Console.ReadLine();
                    if (Regex.IsMatch(selection, @"^[1-3]$"))
                    {
                        if (Convert.ToInt32(selection) == 1)
                        {
                            Console.Clear();
                            Console.WriteLine("Enter Card Name:");
                            CardSearchFunctions.CardSearch(Console.ReadLine());
                        }
                        else if (Convert.ToInt32(selection) == 2)
                        {
                            Console.Clear();
                            Console.WriteLine("Enter ID:");
                            CardSearchFunctions.CardSearchByIndex(Convert.ToInt32(Console.ReadLine()));
                        }
                        else if (Convert.ToInt32(selection) == 3)
                        {
                            break;
                        }
                    }
                }
            }
            else if (choice == 2)
            {
                DisplayFunctions.CardsByText();
            }
            else if (choice == 3)
            {
                while (true)
                {
                    Console.Clear();
                    Console.WriteLine("Seprate All Cards By Color Idenity or Search For Cards By Color Idenity:");
                    Console.WriteLine("1 - Sperate Cards");
                    Console.WriteLine("2 - Search By Color");
                    Console.WriteLine("3 - Exit");
                    selection = Console.ReadLine();
                    if (Regex.IsMatch(selection, @"^[1-3]$"))
                    {
                        if (Convert.ToInt32(selection) == 1)
                        {
                            SeprateFunctions.SepByColorId(true);
                        }
                        else if (Convert.ToInt32(selection) == 2)
                        {
                            DisplayFunctions.CardsByColor();
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            else if (choice == 4)
            {
                while (true)
                {
                    Console.Clear();
                    Console.WriteLine("Seprate Cards By Type/Subtype or Search By Type/Subtype:");
                    Console.WriteLine("1 - Seprate By Type");
                    Console.WriteLine("2 - Seprate By Subtype");
                    Console.WriteLine("3 - Search By Type");
                    Console.WriteLine("4 - Searh By Subtype");
                    Console.WriteLine("5 - Exit");
                    selection = Console.ReadLine();
                    if (Regex.IsMatch(selection, @"^[1-5]$"))
                    {
                        if (SeprateFunctions.Types.Count == 0) //SepedCardsByType
                        {
                            SeprateFunctions.SepByTypeLine();
                        }
                        if (Convert.ToInt32(selection) == 1)
                        {
                            FilterFunctions.DisplayByFilter(SeprateFunctions.SepedCardsByType, SeprateFunctions.Types);
                        }
                        else if (Convert.ToInt32(selection) == 2)
                        {
                            FilterFunctions.DisplayByFilter(SeprateFunctions.SepedCardsBySubtype, SeprateFunctions.Subtypes);
                        }
                        else if (Convert.ToInt32(selection) == 3 || Convert.ToInt32(selection) == 4)
                        {
                            bool   exactsearch;
                            bool   usecolors;
                            bool   colorsexact = false;
                            string expr;
                            string colors   = "";
                            string geninput = "";
                            while (true)
                            {
                                Console.Clear();
                                Console.WriteLine("Exact Search? (Y/N):");
                                geninput = Console.ReadLine();
                                if ("y".Equals(geninput.ToLower()))
                                {
                                    exactsearch = true;
                                    break;
                                }
                                else if ("n".Equals(geninput.ToLower()))
                                {
                                    exactsearch = false;
                                    break;
                                }
                            }
                            Console.Clear();
                            if (Convert.ToInt32(selection) == 3)
                            {
                                Console.WriteLine("Enter Type:");
                            }
                            else
                            {
                                Console.WriteLine("Enter Subtype:");
                            }
                            expr = Console.ReadLine();
                            while (true)
                            {
                                Console.Clear();
                                Console.WriteLine("Use Color Idenity To Filter Serach? (Y/N):");
                                geninput = Console.ReadLine();
                                if ("y".Equals(geninput.ToLower()))
                                {
                                    usecolors = true;
                                    break;
                                }
                                else if ("n".Equals(geninput.ToLower()))
                                {
                                    usecolors = false;
                                    break;
                                }
                            }
                            if (usecolors)
                            {
                                while (true)
                                {
                                    Console.Clear();
                                    Console.WriteLine("Enter Colors (W - White, U - Blue, B - Black, R - Red, G - Green, C - Colorless):");
                                    colors = Console.ReadLine();
                                    if (Regex.IsMatch(colors, @"^[WUBRGCwubrgc]+$"))
                                    {
                                        break;
                                    }
                                }
                                while (true)
                                {
                                    Console.Clear();
                                    Console.WriteLine("Are Only These Colors? (Y/N):");
                                    geninput = Console.ReadLine();
                                    if ("y".Equals(geninput.ToLower()))
                                    {
                                        colorsexact = true;
                                        break;
                                    }
                                    else if ("n".Equals(geninput.ToLower()))
                                    {
                                        colorsexact = false;
                                        break;
                                    }
                                }
                            }
                            if (Convert.ToInt32(selection) == 3)
                            {
                                FilterFunctions.CardsByFilter(SeprateFunctions.SepedCardsByType, SeprateFunctions.Types, expr, colors, usecolors, colorsexact, exactsearch);
                            }
                            else
                            {
                                FilterFunctions.CardsByFilter(SeprateFunctions.SepedCardsBySubtype, SeprateFunctions.Subtypes, expr, colors, usecolors, colorsexact, exactsearch);
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            else if (choice == 5)
            {
                while (true)
                {
                    Console.Clear();
                    Console.WriteLine("Seprate Cards By CMC or Search By CMC:");
                    Console.WriteLine("1 - Seprate By CMC");
                    Console.WriteLine("2 - Search By CMC");
                    Console.WriteLine("3 - Exit");
                    selection = Console.ReadLine();
                    if (Regex.IsMatch(selection, @"^[1-3]$"))
                    {
                        if (SeprateFunctions.Cmcs.Count == 0) //SepedCardsByCmcs
                        {
                            SeprateFunctions.SepByCMC();
                        }
                        if (Convert.ToInt32(selection) == 1)
                        {
                            FilterFunctions.DisplayByFilter(SeprateFunctions.SepedCardsByCmcs, SeprateFunctions.Cmcs);
                        }
                        else if (Convert.ToInt32(selection) == 2)
                        {
                            bool   usecolors;
                            bool   colorsexact = false;
                            string expr;
                            string colors   = "";
                            string geninput = "";
                            while (true)
                            {
                                Console.Clear();
                                Console.WriteLine("Enter CMC:");
                                expr = Console.ReadLine();
                                if (Regex.IsMatch(expr, @"^[0-9]+$"))
                                {
                                    break;
                                }
                            }

                            while (true)
                            {
                                Console.Clear();
                                Console.WriteLine("Use Color Idenity To Filter Serach? (Y/N):");
                                geninput = Console.ReadLine();
                                if ("y".Equals(geninput.ToLower()))
                                {
                                    usecolors = true;
                                    break;
                                }
                                else if ("n".Equals(geninput.ToLower()))
                                {
                                    usecolors = false;
                                    break;
                                }
                            }
                            if (usecolors)
                            {
                                while (true)
                                {
                                    Console.Clear();
                                    Console.WriteLine("Enter Colors (W - White, U - Blue, B - Black, R - Red, G - Green, C - Colorless):");
                                    colors = Console.ReadLine();
                                    if (Regex.IsMatch(colors, @"^[WUBRGCwubrgc]+$"))
                                    {
                                        break;
                                    }
                                }
                                while (true)
                                {
                                    Console.Clear();
                                    Console.WriteLine("Are Only These Colors? (Y/N):");
                                    geninput = Console.ReadLine();
                                    if ("y".Equals(geninput.ToLower()))
                                    {
                                        colorsexact = true;
                                        break;
                                    }
                                    else if ("n".Equals(geninput.ToLower()))
                                    {
                                        colorsexact = false;
                                        break;
                                    }
                                }
                            }
                            FilterFunctions.CardsByFilter(SeprateFunctions.SepedCardsByCmcs, SeprateFunctions.Cmcs, expr, colors, usecolors, colorsexact, true);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            else if (choice == 6)
            {
                while (true)
                {
                    Console.Clear();
                    Console.WriteLine("Seprate Cards By Keyword or Search By Keyword:");
                    Console.WriteLine("1 - Seprate By Keyword");
                    Console.WriteLine("2 - Search By Keyword");
                    Console.WriteLine("3 - Exit");
                    selection = Console.ReadLine();
                    if (Regex.IsMatch(selection, @"^[1-3]$"))
                    {
                        if (SeprateFunctions.Keywords.Count == 0) //SepedCardsByKeywords
                        {
                            SeprateFunctions.SepByKeyword();
                        }
                        if (Convert.ToInt32(selection) == 1)
                        {
                            FilterFunctions.DisplayByFilter(SeprateFunctions.SepedCardsByKeywords, SeprateFunctions.Keywords);
                        }
                        else if (Convert.ToInt32(selection) == 2)
                        {
                            bool   exactsearch;
                            bool   usecolors;
                            bool   colorsexact = false;
                            string expr;
                            string colors   = "";
                            string geninput = "";
                            while (true)
                            {
                                Console.Clear();
                                Console.WriteLine("Exact Search? (Y/N):");
                                geninput = Console.ReadLine();
                                if ("y".Equals(geninput.ToLower()))
                                {
                                    exactsearch = true;
                                    break;
                                }
                                else if ("n".Equals(geninput.ToLower()))
                                {
                                    exactsearch = false;
                                    break;
                                }
                            }
                            Console.Clear();
                            Console.WriteLine("Enter Keyword: ");
                            expr = Console.ReadLine();
                            while (true)
                            {
                                Console.Clear();
                                Console.WriteLine("Use Color Idenity To Filter Serach? (Y/N):");
                                geninput = Console.ReadLine();
                                if ("y".Equals(geninput.ToLower()))
                                {
                                    usecolors = true;
                                    break;
                                }
                                else if ("n".Equals(geninput.ToLower()))
                                {
                                    usecolors = false;
                                    break;
                                }
                            }
                            if (usecolors)
                            {
                                while (true)
                                {
                                    Console.Clear();
                                    Console.WriteLine("Enter Colors (W - White, U - Blue, B - Black, R - Red, G - Green, C - Colorless):");
                                    colors = Console.ReadLine();
                                    if (Regex.IsMatch(colors, @"^[WUBRGCwubrgc]+$"))
                                    {
                                        break;
                                    }
                                }
                                while (true)
                                {
                                    Console.Clear();
                                    Console.WriteLine("Are Only These Colors? (Y/N):");
                                    geninput = Console.ReadLine();
                                    if ("y".Equals(geninput.ToLower()))
                                    {
                                        colorsexact = true;
                                        break;
                                    }
                                    else if ("n".Equals(geninput.ToLower()))
                                    {
                                        colorsexact = false;
                                        break;
                                    }
                                }
                            }
                            FilterFunctions.CardsByFilter(SeprateFunctions.SepedCardsByKeywords, SeprateFunctions.Keywords, expr, colors, usecolors, colorsexact, exactsearch);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            else if (choice == 7)
            {
                PriceFunctions.CardsByPrice();
            }
            else if (choice == 8)
            {
                DisplayFunctions.DispalyAllCards();
            }
            else if (choice == 9)
            {
                while (true)
                {
                    Console.Clear();
                    Console.WriteLine("Select List Option:");
                    Console.WriteLine("1 - Create List");
                    Console.WriteLine("2 - Dispaly List");
                    Console.WriteLine("3 - Add To List");
                    Console.WriteLine("4 - Remove From List");
                    Console.WriteLine("5 - Remove List");
                    Console.WriteLine("6 - Print List To File");
                    Console.WriteLine("7 - Load List From File");
                    Console.WriteLine("8 - Exit");
                    selection = Console.ReadLine();
                    if (Regex.IsMatch(selection, @"^[1-8]$"))
                    {
                        if (Convert.ToInt32(selection) == 1)
                        {
                            CardListFunctions.CreateCardList();
                        }
                        else if (Convert.ToInt32(selection) == 2)
                        {
                            CardListFunctions.DisplayCardList();
                        }
                        else if (Convert.ToInt32(selection) == 3)
                        {
                            CardListFunctions.AddToCardList();
                        }
                        else if (Convert.ToInt32(selection) == 4)
                        {
                            CardListFunctions.RemoveFromCardList();
                        }
                        else if (Convert.ToInt32(selection) == 5)
                        {
                            CardListFunctions.RemoveCardList();
                        }
                        else if (Convert.ToInt32(selection) == 6)
                        {
                            CardListFunctions.PrintCardListToFile();
                        }
                        else if (Convert.ToInt32(selection) == 7)
                        {
                            CardListFunctions.LoadListFromFile();
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            else if (choice == 10)
            {
                while (true)
                {
                    Console.Clear();
                    Console.WriteLine("Enter Card Datbase ID or Search For Card To Get ID:");
                    Console.WriteLine("1 - Enter ID");
                    Console.WriteLine("2 - Search");
                    Console.WriteLine("3 - Exit");
                    selection = Console.ReadLine();
                    if (Regex.IsMatch(selection, @"^[1-3]$"))
                    {
                        if (Convert.ToInt32(selection) == 1)
                        {
                            RemoveCard();
                        }
                        else if (Convert.ToInt32(selection) == 2)
                        {
                            Console.Clear();
                            Console.WriteLine("Enter Card Name:");
                            CardSearchFunctions.CardSearch(Console.ReadLine());
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
        }
        public static void CardsByText() //change to allow color selection like other cardsby
        {
            string expr;

            while (true)
            {
                Console.Clear();
                Console.WriteLine("Enter Text(Cards Filterd By Color Idenity):");
                expr = Console.ReadLine();
                if (expr.Length > 0)
                {
                    break;
                }
            }

            bool match   = false;
            bool printed = false;

            if (SeprateFunctions.Colorids.Count == 0)
            {
                SeprateFunctions.SepByColorId(false);
            }
            Console.Clear();
            for (int i = 0; i < SeprateFunctions.SepedCardsByColorId.Count; i++)
            {
                foreach (Card card in SeprateFunctions.SepedCardsByColorId[i])
                {
                    if (card.Card_faces is null)
                    {
                        if (card.Oracle_text != null)
                        {
                            if (Regex.IsMatch(card.Oracle_text.ToLower(), expr.ToLower()))
                            {
                                if (!match)
                                {
                                    Console.WriteLine(" ");
                                    Console.WriteLine(" - " + SeprateFunctions.Colorids[i]);
                                    Console.WriteLine("NAME - SET - PRINTING - AMOUNT - ID");
                                    match   = true;
                                    printed = true;
                                }
                                Console.WriteLine(card.Special_name + " " + card.Set + " " + card.Printing + " " + card.Amount + " " + ProgFunctions.Allcards.IndexOf(card));
                                Console.WriteLine("Oracle Text: " + card.Oracle_text);
                                Console.WriteLine("-----");
                            }
                        }
                    }
                    else
                    {
                        foreach (Cardface cardface in card.Card_faces)
                        {
                            if (cardface.Oracle_text != null)
                            {
                                if (Regex.IsMatch(cardface.Oracle_text.ToLower(), expr.ToLower()))
                                {
                                    if (!match)
                                    {
                                        Console.WriteLine(" ");
                                        Console.WriteLine(" - " + SeprateFunctions.Colorids[i]);
                                        Console.WriteLine("NAME - SET - PRINTING - AMOUNT - ID");
                                        match   = true;
                                        printed = true;
                                    }
                                    Console.WriteLine(cardface.Name + " " + card.Set + " " + card.Printing + " " + card.Amount + " " + ProgFunctions.Allcards.IndexOf(card));
                                    Console.WriteLine("Oracle Text: " + cardface.Oracle_text);
                                    Console.WriteLine("-----");
                                }
                            }
                        }
                    }
                }
                match = false;
            }
            if (!printed)
            {
                Console.WriteLine("No Cards In Search");
            }
            Console.WriteLine(" ");
            Console.WriteLine("Enter Any Key To Exit:");
            Console.ReadLine();
        }