public void Play()
        {
            foreach (Player player in players)
            {
                Visualization.ShowProgramMessage("Player " + Convert.ToString(player.Id) + " select Deck and Captains");

                Visualization.ShowDecks(decks);
                int  choiceDeck = Visualization.GetUserInput(decks.Count - 1);
                Deck deckChoice = decks[choiceDeck];
                player.Deck = deckChoice;
                player.FirstHand();
                Visualization.ShowCaptains(captains);
                int choiceCaptain = Visualization.GetUserInput(captains.Count - 1);
                player.ChooseCaptainCard(captains[choiceCaptain]);


                Visualization.ShowListOptions(new List <string>()
                {
                    "Change Card", "Pass"
                }, "Change 3 cards or ready to play:");
                int choice     = Visualization.GetUserInput(1);
                int cont       = 0;
                int choiceCard = -1;
                if (choice == 0)
                {
                    while (true)
                    {
                        if (cont != 3)
                        {
                            Visualization.ShowHand(player.Hand);
                            Visualization.ShowProgramMessage("Input the numbers  of the cards to change (max 3). To stop enter -1");
                            choiceCard = Visualization.GetUserInput(player.Hand.Cards.Count - 1, true);
                        }
                        if (choiceCard == -1 || cont == 3)
                        {
                            break;
                        }
                        else
                        {
                            player.ChangeCard(choiceCard);
                            cont++;
                        }
                    }
                }
                Visualization.ClearConsole();
            }
        }
        public void Play()
        {
            List <string> options = new List <string>()
            {
                "Change Card", "Pass"
            };
            string message = "Change 3 cards or ready to play";

            Visualization.ShowProgramMessage($"Player {ActivePlayer.Id} select Deck and Captain");
            Visualization.ShowDecks(Decks);
            int input = Visualization.GetUserInput(2, false);

            ActivePlayer.Deck = Decks[input];
            Visualization.ShowCaptains(Captains);
            int input2 = Visualization.GetUserInput(2, false);

            ActivePlayer.ChooseCaptainCard(Captains[input2]);
            ActivePlayer.FirstHand();
            Visualization.ShowHand(ActivePlayer.Hand);
            Visualization.ShowListOptions(options, message);
            int input3 = Visualization.GetUserInput(2, false);

            if (input3 == 0)
            {
                Console.WriteLine($"Player {ActivePlayer.Id} change cards:");
                Console.WriteLine("Hand:");
                Visualization.ShowHand(ActivePlayer.Hand);
                Console.WriteLine("Input the number of cards to change (max 3). To stop enter -1");
                int input4 = Visualization.GetUserInput(4, true);
                while (input4 > 0) // si el input es 0 o -1 nunca entra al while asi que lo dejo asi tal cual
                {
                    Console.WriteLine("Enter the Card ID you want to change");
                    int cardid = Visualization.GetUserInput(10, true);
                    ActivePlayer.ChangeCard(cardid);
                    input4 -= 1;
                }
            }
            else
            {
                Console.WriteLine($"Player {ActivePlayer.Id} passed");
            }
            Console.WriteLine($"Player {ActivePlayer.Id} turn has finished");
            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
            Visualization.ClearConsole();
        }
示例#3
0
 public void Play()
 {
     for (int i = 1; i <= 2; i++)
     {
         Visualization.ShowProgramMessage($"Player {i} select Deck and Captain: ");
         Visualization.ShowDecks(decks);
         Visualization.GetUserInput(decks.Count);
         Visualization.ShowCaptains(captains);
         Visualization.GetUserInput(captains.Count);
         players[i].FirstHand();
         Visualization.ShowHand(players[i].Hand);
         Visualization.ShowListOptions(new List <string>()
         {
             "Change Card", "Pass"
         }, "Change 3 cards or ready to play");
         int usrdec = Visualization.GetUserInput(1);
         if (usrdec == 0)
         {
             int j = 0;
             while (i < 3)
             {
                 Visualization.ShowProgramMessage($"Player {i} change cards:");
                 Visualization.ShowHand(players[i].Hand);
                 Visualization.ShowProgramMessage("Input the number of the cards to change (max 3). To stop enter -1");
                 int usrdec2 = Visualization.GetUserInput(players[i].Hand.Cards.Count);
                 if (usrdec2 == -1)
                 {
                     break;
                 }
                 Random random    = new Random();
                 int    newrandom = random.Next(players[i].Hand.Cards.Count);
                 players[i].Hand.Cards[newrandom] = this.decks[i].Cards[newrandom];
                 j++;
             }
         }
         Visualization.ClearConsole();
     }
 }
        static void Main(string[] args)
        {
            List <String> opcionesj = new List <string>();

            opcionesj.Add("Change Card");
            opcionesj.Add("Pass");

            Game game = new Game();

            game.AddDecks();
            game.AddCaptains();

            //Lista players
            string[] players = new string[2];
            players[0] = "Player 1";
            players[1] = "Player 2";

            Player        player  = new Player();
            Player        player1 = new Player();
            List <Player> playerS = new List <Player>();

            playerS.Add(player);
            playerS.Add(player1);

            Random rand   = new Random();
            int    index  = rand.Next(players.Length);
            int    index2 = 0;

            if (index == 0)
            {
                index2 = 1;
            }
            else
            {
                Console.WriteLine($"Randomly selected player is {players[index]}");
            }
            Visualization.ShowProgramMessage($"{players[index]} select Deck and Captain");

            List <Deck> decks = new List <Deck>();

            decks.Add(game.Decks[0]);
            decks.Add(game.Decks[1]);
            Visualization.ShowDecks(decks);
            int deckDecition = Visualization.GetUserInput();

            if (deckDecition == 0 && index == 0)
            {
                playerS[0].Deck = decks[0];
                playerS[1].Deck = decks[1];
                Visualization.ShowProgramMessage($"Deck Selected by {players[0]} was: deck 1");
                Visualization.ShowProgramMessage($"Deck given to {players[1]} was: deck 2");
            }
            else if (deckDecition == 0 && index == 1)
            {
                playerS[1].Deck = decks[0];
                playerS[0].Deck = decks[1];
                Visualization.ShowProgramMessage($"Deck Selected by {players[1]} was: deck 1");
                Visualization.ShowProgramMessage($"Deck given to {players[0]} was: deck 2");
            }
            else if (deckDecition == 1 && index == 0)
            {
                playerS[0].Deck = decks[1];
                playerS[1].Deck = decks[0];
                Visualization.ShowProgramMessage($"Deck Selected by {players[0]} was: deck 2");
                Visualization.ShowProgramMessage($"Deck given to {players[1]} was: deck 1");
            }
            else
            {
                playerS[1].Deck = decks[1];
                playerS[0].Deck = decks[0];
                Visualization.ShowProgramMessage($"Deck Selected by {players[1]} was: deck 2");
                Visualization.ShowProgramMessage($"Deck given to {players[0]} was: deck 1");
            }


            Visualization.ShowCapatains(game.Captains);
            int captainDecition = Visualization.GetUserInput();

            if (captainDecition == 0 && index == 0)
            {
                playerS[0].ChooseCaptainCard(game.Captains[0]);
                playerS[1].ChooseCaptainCard(game.Captains[1]);
                Visualization.ShowProgramMessage($"Captain Selected by {players[0]} was: {playerS[0].Captain.Name}\n");
                Visualization.ShowProgramMessage($"Captain given to {players[1]} was: {playerS[1].Captain.Name}\n");
            }

            else if (captainDecition == 0 && index == 1)
            {
                playerS[1].ChooseCaptainCard(game.Captains[0]);
                playerS[0].ChooseCaptainCard(game.Captains[1]);
                Visualization.ShowProgramMessage($"Captain Selected by {players[1]} was: {playerS[1].Captain.Name}\n");
                Visualization.ShowProgramMessage($"Captain given to {players[0]} was: {playerS[0].Captain.Name}\n");
            }
            else if (captainDecition == 1 && index == 0)
            {
                playerS[0].ChooseCaptainCard(game.Captains[1]);
                playerS[1].ChooseCaptainCard(game.Captains[0]);
                Visualization.ShowProgramMessage($"Captain Selected by {players[0]} was: {playerS[0].Captain.Name}\n");
                Visualization.ShowProgramMessage($"Captain given to {players[1]} was: {playerS[1].Captain.Name}\n");
            }
            else
            {
                playerS[1].ChooseCaptainCard(game.Captains[1]);
                playerS[0].ChooseCaptainCard(game.Captains[0]);
                Visualization.ShowProgramMessage($"Captain Selected by {players[1]} was: {playerS[1].Captain.Name}\n");
                Visualization.ShowProgramMessage($"Captain given to {players[0]} was: {playerS[0].Captain.Name}\n");
            }


            Board board = new Board();

            player.Board  = board;
            player1.Board = board;

            player.Deck.Shuffle();
            player1.Deck.Shuffle();

            player.FirstHand();
            player1.FirstHand();

            bool chekeo = game.CheckIfEndGame(player, player1);

            Console.WriteLine($"Turn of {players[index]}\n");
            Visualization.ShowHand(playerS[index].Hand);
            Visualization.ShowListOptions("Change 3 Cards or ready to play", opcionesj);

            int cardDesition = Visualization.GetUserInput();

            Console.WriteLine($"Turn of {players[index2]}\n");
            Visualization.ShowHand(playerS[index2].Hand);
            Visualization.ShowListOptions("Change 3 Cards or ready to play", opcionesj);


            //Cmabio de Cartas

            /*
             * int counter = 0;
             *
             * if (cardDesition == 0)
             * {
             *  while (cardDesition == -1 || counter >= 3)
             *  {
             *      counter += 1;
             *  }
             * }
             * else
             * {
             *  Visualization.ShowHand(playerS[index2].Hand);
             *  Visualization.ShowListOptions("Change 3 Cards or ready to play", opcionesj);
             * }
             */



            /*
             * int counter = 1;
             * Console.WriteLine("Player Hand:");
             * foreach (Card card in player.Hand.Cards)
             * {
             *  Console.WriteLine($"{counter++}: {card.Name}");
             * }
             * counter = 1;
             * Console.WriteLine("\nPlayer Deck:");
             * foreach (Card card in player.Deck.Cards)
             * {
             *  Console.WriteLine($"{counter++}: {card.Name}");
             * }
             */
            //Test Change Card

            //player.ChangeCard(3);
            //counter = 1;
            //Console.WriteLine("\n New Player Hand:");
            //foreach (Card card in player.Hand.Cards)
            //{
            //    Console.WriteLine($"{counter++}: {card.Name}");
            //}
            //counter = 1;
            //Console.WriteLine("\n New Player Deck:");
            //foreach (Card card in player.Deck.Cards)
            //{
            //    Console.WriteLine($"{counter++}: {card.Name}");
            //}


            //Test draw card

            //player.DrawCard();
            //counter = 1;
            //Console.WriteLine("\n New Player Hand:");
            //foreach (Card card in player.Hand.Cards)
            //{
            //    Console.WriteLine($"{counter++}: {card.Name}");
            //}
            //counter = 1;
            //Console.WriteLine("\n New Player Deck:");
            //foreach (Card card in player.Deck.Cards)
            //{
            //    Console.WriteLine($"{counter++}: {card.Name}");
            //}


            //Test play card

            //player.PlayCard(6);
            //counter = 1;
            //Console.WriteLine("\n New Player Hand:");
            //foreach (Card card in player.Hand.Cards)
            //{
            //    Console.WriteLine($"{counter++}: {card.Name}");
            //}
            //Console.WriteLine(String.Join(", ", board.GetMeleeAttackPoints()));
            //Console.WriteLine(String.Join(", ", board.GetRangeAttackPoints()));
            //Console.WriteLine(String.Join(", ", board.GetLongRangeAttackPoints()));
        }
        public void Play()
        {
            for (int readyPlayers = 0; readyPlayers < 2; readyPlayers++)
            {
                visualization.ShowProgramMessage("Player " + (activePlayer.Id + 1) + " Please choose your Deck and Captain");
                visualization.printSeparator();
                visualization.ShowDecks(decks);
                int deckNumberAnswer = visualization.GetUserInput(decks.Count, false);
                visualization.printSeparator();
                activePlayer.Deck = decks[deckNumberAnswer];
                activePlayer.FirstHand();
                visualization.ShowCaptains(captains);
                visualization.printSeparator();
                int captainNumberAnswer = visualization.GetUserInput(Captains.Count, false);
                visualization.printSeparator();
                activePlayer.ChooseCaptainCard(Captains[captainNumberAnswer]);
                visualization.ShowHand(activePlayer.Hand);
                visualization.printSeparator();
                visualization.ShowListOptions(changeCardOptionList, readyOrNot);
                visualization.printSeparator();
                int answerReadyOrNot = visualization.GetUserInput(changeCardOptionList.Count, false);

                if (answerReadyOrNot == 0)
                {
                    visualization.printSeparator();
                    visualization.ShowProgramMessage("Player " + (activePlayer.Id + 1) + " change your cards");
                    visualization.printSeparator();

                    for (int i = 0; i < 3; i++)
                    {
                        visualization.ShowHand(activePlayer.Hand);
                        visualization.printSeparator();
                        visualization.ShowProgramMessage("Input the number of the cards you want to change (Max 3). Input -1 to stop " + i);
                        int loopAnswer = visualization.GetUserInput(activePlayer.Hand.Cards.Count, true);
                        visualization.printSeparator();
                        if (loopAnswer == -1)
                        {
                            i = 4;
                        }
                        else
                        {
                            activePlayer.ChangeCard(loopAnswer);
                        }
                    }

                    visualization.printSeparator();
                    visualization.ShowProgramMessage("Done those all your changes. Now youre ready to fight!!!");
                }
                visualization.printSeparator();
                visualization.ShowProgramMessage("OK Thats all you need Player " + (activePlayer.Id + 1) + " now ... PREPARE TO FIGHT TILL YOUR LAST BREATH");
                visualization.printSeparator();
                visualization.ShowProgramMessage("Press any key to clear console and change player");
                Console.ReadKey();
                visualization.ClearConsole();
                if (activePlayer.Id == players[0].Id)
                {
                    activePlayer = players[1];
                }
                else
                {
                    activePlayer = players[0];
                }
            }
        }
示例#6
0
        public void Play()
        {
            Visualization.ShowProgramMessage("Player 1 select Deck and captain:");
            players[0].Deck = Visualization.ShowDecks(decks);
            players[0].ChooseCaptainCard(Visualization.ShowCaptains(captains));

            players[0].FirstHand();
            Visualization.ShowHand(players[0].Hand);

            bool playerOneSelecting     = true;
            int  numberOfTimesPlayerOne = 0;

            while (playerOneSelecting)
            {
                Visualization.ShowListOptions(new List <string> {
                    "ShowListOptions", "Pass"
                }, "Change 3 cards or ready to play:");
                int userOption = Int32.Parse(System.Console.ReadLine());

                if (userOption == 1)
                {
                    playerOneSelecting = false;
                }
                else
                {
                    if (numberOfTimesPlayerOne < 3)
                    {
                        System.Console.WriteLine("Input the number of the card you wan't to change. To stop write -1");
                        int userCard = Int32.Parse(System.Console.ReadLine());

                        if (userCard == -1)
                        {
                            playerOneSelecting = false;
                        }
                        else
                        {
                            players[0].Hand.Cards.RemoveAt(userCard);


                            Random rnd          = new Random();
                            int    randomNumber = rnd.Next(0, players[0].Deck.Cards.Count);

                            players[0].DrawCard(randomNumber);
                        }
                    }
                    else
                    {
                        Visualization.ConsoleError("Ya no puedes cambiar mas cartas");
                        playerOneSelecting = false;
                    }
                }
            }

            Visualization.ClearConsole();

            Visualization.ShowProgramMessage("Player 2 select Deck and captain:");
            players[1].Deck = Visualization.ShowDecks(decks);
            players[1].ChooseCaptainCard(Visualization.ShowCaptains(captains));

            players[1].FirstHand();
            Visualization.ShowHand(players[1].Hand);

            bool playerTwoSelecting     = true;
            int  numberOfTimesPlayerTwo = 0;

            while (playerTwoSelecting)
            {
                Visualization.ShowListOptions(new List <string> {
                    "ShowListOptions", "Pass"
                }, "Change 3 cards or ready to play:");
                int userOption = Int32.Parse(System.Console.ReadLine());

                if (userOption == 1)
                {
                    playerTwoSelecting = false;
                }
                else
                {
                    if (numberOfTimesPlayerTwo < 3)
                    {
                        System.Console.WriteLine("Input the number of the card you wan't to change. To stop write -1");
                        int userCard = Int32.Parse(System.Console.ReadLine());

                        if (userCard == -1)
                        {
                            playerTwoSelecting = false;
                        }
                        else
                        {
                            players[1].Hand.Cards.RemoveAt(userCard);


                            Random rnd          = new Random();
                            int    randomNumber = rnd.Next(0, players[1].Deck.Cards.Count);

                            players[1].DrawCard(randomNumber);
                        }
                    }
                    else
                    {
                        Visualization.ConsoleError("Ya no puedes cambiar mas cartas");
                        playerTwoSelecting = false;
                    }
                }
            }
            Visualization.ClearConsole();
        }