Exemple #1
0
        // ====================================================================
        // File Read(): The method below pulls the CSV file, reads it and will return a list
        //              of all the content's in the file.
        // ====================================================================

        public List <CarData> FileRead()
        {
            List <CarData> cardData      = new List <CarData>();
            string         DataDirectory = AppDomain.CurrentDomain.BaseDirectory;

            using (var reader = new StreamReader(DataDirectory + "Worlds_ Card Library Data Table.csv"))
            {
                string DataRet;

                while ((DataRet = reader.ReadLine()) != null)
                {
                    var listItem = new CarData();
                    var Line     = DataRet.Split(',');
                    // Variables to set each value of the items in the list
                    listItem.cardName  = Line[0];
                    listItem.cardType  = Line[1];
                    listItem.cardCost  = Line[2];
                    listItem.cardPower = Line[3];
                    listItem.cardHP    = Line[4];
                    listItem.cardText  = Line[5];
                    listItem.cardColor = Line[6];
                    listItem.cardSet   = Line[7];

                    cardData.Add(listItem); //Item in the current line gets stored.
                }
            }

            return(cardData); //Returns EVERYTHING IN THE FILE!!!
        }
Exemple #2
0
        /// <summary>
        /// Card by Card
        /// ==================================
        /// Views each of the cards stored in the collection and edit's the cards.
        /// </summary>
        /// <param name="cardList"></param>

        public static void CardByCard(List <CarData> cardList)
        {
            bool breakLoop = true;
            int  dataIdx   = 0;

            while (breakLoop)
            {
                Console.Clear();
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("<<<== Worlds Set View == Card Data Index No. " + (dataIdx + 1) + "==================================>>>");

                // Changes the Card text like the mass list above.
                switch (cardList[dataIdx].cardColor)
                {
                case "Burrom":
                    Console.ForegroundColor = ConsoleColor.Red;
                    break;

                case "Gelofon":
                    Console.ForegroundColor = ConsoleColor.DarkCyan;
                    break;

                case "Earth":
                    Console.ForegroundColor = ConsoleColor.Magenta;
                    break;

                case "Ariani":
                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                    break;

                case "Mooran":
                    Console.ForegroundColor = ConsoleColor.Green;
                    break;

                case "Grey Relic":
                    Console.ForegroundColor = ConsoleColor.Black;
                    break;

                default:
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                    break;
                }

                // Writes for Single View.
                Console.WriteLine("\n " + cardList[dataIdx].cardName + " \n Set: " + cardList[dataIdx].cardSet +
                                  " \n Type: " + cardList[dataIdx].cardType + " \n Tribe/Color: " + cardList[dataIdx].cardColor +
                                  " \n Cost: " + cardList[dataIdx].cardCost + " \n Power: " + cardList[dataIdx].cardPower +
                                  "\n Life/Hit Points: " + cardList[dataIdx].cardHP + "\n \n Card Text:\n " + cardList[dataIdx].cardText + "\n");
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("<<<===================================================================================>>>\n");

                //Complex Menu Selection - Changes based on how the view works
                Console.WriteLine("\tPrevious - Press[<-] || <A>dd a card || <R>emove Card Displayed || " +
                                  "<E>dit || Advance - Press [->] || <B>ack");
                Console.WriteLine("\tPrevious x 10 - Press[\\/] || Advance x 10 - Press [/\\]");
                var usrInput = Console.ReadKey();
                Console.Clear();
                switch (usrInput.Key)
                {
                // Set's up the [↑] Arrow Key to go through the data
                case ConsoleKey.UpArrow:
                    dataIdx += 10;
                    if (dataIdx >= cardList.Count)
                    {
                        dataIdx = cardList.Count - 1;
                    }
                    break;

                // Set's up the [↓] Arrow Key to go through the data
                case ConsoleKey.DownArrow:
                    dataIdx -= 10;
                    if (dataIdx < 0)
                    {
                        dataIdx = 0;
                    }
                    break;

                // Set's up the [→] Arrow Key to go through the data
                case ConsoleKey.RightArrow:
                    dataIdx += 1;
                    if (dataIdx >= cardList.Count)
                    {
                        dataIdx = cardList.Count - 1;
                    }
                    break;

                // Set's up the [←] Arrow Key to go through the data
                case ConsoleKey.LeftArrow:
                    dataIdx -= 1;
                    if (dataIdx < 0)
                    {
                        dataIdx = 0;
                    }
                    break;

                // Breaks out of the loop.
                case ConsoleKey.B:
                    breakLoop = false;
                    break;

                // Function, not a method, devoted to Adding to the Database.
                case ConsoleKey.A:
                    while (true)
                    {
                        // Variable Prime to add new entries.
                        var newCard = new CarData();
                        Console.WriteLine(">>>>>>>>>>!!!Adding A New Card!!!<<<<<<<<<<");

                        // Sets New Card Name
                        Console.WriteLine("Name of the card: ");
                        string CardName = Console.ReadLine();

                        // Sets new Card Type, Relic, Unit or Skill
                        Console.WriteLine("\nIs this card a Skill, Unit or Relic?: ");
                        string CardType = Console.ReadLine();

                        // Sets the cost of the New Card
                        Console.WriteLine("\nHow much does it cost to play it?: ");
                        string CardCost = Console.ReadLine();

                        // Sets the Cards Strength
                        Console.WriteLine("\nHow much damage can it inflict?: ");
                        string CardPower = Console.ReadLine();

                        // Sets the New Cards Toughness
                        Console.WriteLine("\nHow much Punishment can it take?: ");
                        string CardHP = Console.ReadLine();

                        // Sets the Card Effects
                        Console.WriteLine("\nWhat can it do when it's in play?");
                        Console.WriteLine("Please Note: Commas(',') replaced");
                        string CardText = Console.ReadLine().Replace(",", ";");

                        // Sets The Cards Color
                        Console.WriteLine("\nWhat tribe is this unit apart of? <Card Color!>");
                        Console.WriteLine("->><E>arth, <B>urrom, <A>riani, <M>ooran, <G>elofon, <R>elic<<-");

                        // Prepares new card color
                        var    colorInput  = Console.ReadKey();
                        bool   colorOption = true;
                        string CardColor   = "";

                        while (colorOption)
                        {
                            switch (colorInput.Key)
                            {
                            case ConsoleKey.E:
                                CardColor   = "Earth";
                                colorOption = false;
                                break;

                            case ConsoleKey.B:
                                CardColor   = "Burrom";
                                colorOption = false;
                                break;

                            case ConsoleKey.A:
                                CardColor   = "Ariani";
                                colorOption = false;
                                break;

                            case ConsoleKey.M:
                                CardColor   = "Mooran";
                                colorOption = false;
                                break;

                            case ConsoleKey.G:
                                CardColor   = "Gelofon";
                                colorOption = false;
                                break;

                            case ConsoleKey.R:
                                CardColor   = "Grey Relic";
                                colorOption = false;
                                break;

                            default:
                                break;
                            }
                            ;
                        }

                        // Sets the set the card is from
                        Console.WriteLine("\nWhat set?: ");
                        string CardSet = Console.ReadLine();

                        // Final Confirmtion
                        Console.WriteLine("Reading Above, Are you sure you want to add this card?" +
                                          "<Y>es, <B>ack; Any other key will restart this process");
                        var turnPoint = Console.ReadKey();

                        newCard.cardName  = CardName;
                        newCard.cardType  = CardType;
                        newCard.cardCost  = CardCost;
                        newCard.cardPower = CardPower;
                        newCard.cardHP    = CardHP;
                        newCard.cardText  = CardText;
                        newCard.cardColor = CardColor;
                        newCard.cardSet   = CardSet;

                        if (turnPoint.Key == ConsoleKey.Y)
                        {
                            Console.Clear();
                            cardList.Add(newCard);
                            CarDataService.FileWrite(cardList);
                            break;
                        }
                        Console.Clear();
                        if (turnPoint.Key == ConsoleKey.B)
                        {
                            break;
                        }
                    }
                    break;

                // This section removes the currently viewed card.
                case ConsoleKey.R:
                    Console.WriteLine("Are you sure? Once this is removed, it cannot be recovered" +
                                      "<Y>es, any other key will quit the action.");
                    var deleteInput = Console.ReadKey();
                    if (deleteInput.Key == ConsoleKey.Y)
                    {
                        cardList.RemoveAt(dataIdx);
                        CarDataService.FileWrite(cardList);
                        if (dataIdx <= cardList.Count)
                        {
                            dataIdx--;
                        }
                    }
                    break;

                // This will edit the information on the currently viewed card.
                case ConsoleKey.E:
                    Console.WriteLine("What do you want to Edit?");
                    Console.WriteLine("<N>ame, <T>ype, C<O>st, <P>ower, <H>it Points, T<E>xt, <C>olor, <S>et: ");
                    var editInput = Console.ReadKey();
                    Console.Clear();

                    switch (editInput.Key)
                    {
                    case ConsoleKey.N:
                        Console.WriteLine("Input a New Name: ");
                        cardList[dataIdx].cardName = Console.ReadLine();
                        break;

                    case ConsoleKey.T:
                        Console.WriteLine("Input a New Card Type: ");
                        cardList[dataIdx].cardType = Console.ReadLine();
                        break;

                    case ConsoleKey.O:
                        Console.WriteLine("Input a New Cost: ");
                        cardList[dataIdx].cardCost = Console.ReadLine();
                        break;

                    case ConsoleKey.P:
                        Console.WriteLine("Input the New Attack: ");
                        cardList[dataIdx].cardPower = Console.ReadLine();
                        break;

                    case ConsoleKey.H:
                        Console.WriteLine("Input the New Hit Points: ");
                        cardList[dataIdx].cardHP = Console.ReadLine();
                        break;

                    case ConsoleKey.E:
                        Console.WriteLine("Input a New Card Effect: ");
                        cardList[dataIdx].cardText = Console.ReadLine().Replace(",", ";");
                        break;

                    case ConsoleKey.S:
                        Console.WriteLine("Re-Write the Card Set: ");
                        cardList[dataIdx].cardSet = Console.ReadLine();
                        break;

                    case ConsoleKey.C:
                        var    colorInput  = Console.ReadKey();
                        bool   colorOption = true;
                        string CardColor   = "";
                        while (colorOption)
                        {
                            Console.WriteLine("What is the new Color?");
                            Console.WriteLine("->><E>arth, <B>urrom, <A>riani, <M>ooran, <G>elofon, <R>elic<<-");
                            switch (colorInput.Key)
                            {
                            case ConsoleKey.E:
                                CardColor   = "Earth";
                                colorOption = false;
                                break;

                            case ConsoleKey.B:
                                CardColor   = "Burrom";
                                colorOption = false;
                                break;

                            case ConsoleKey.A:
                                CardColor   = "Ariani";
                                colorOption = false;
                                break;

                            case ConsoleKey.M:
                                CardColor   = "Mooran";
                                colorOption = false;
                                break;

                            case ConsoleKey.G:
                                CardColor   = "Gelofon";
                                colorOption = false;
                                break;

                            case ConsoleKey.R:
                                CardColor   = "Grey Relic";
                                colorOption = false;
                                break;

                            default:
                                break;
                            }
                            ;
                        }
                        cardList[dataIdx].cardColor = CardColor;
                        break;

                    default:
                        break;
                    }
                    CarDataService.FileWrite(cardList);
                    break;

                default:
                    break;
                }
            }
        }