Ejemplo n.º 1
0
        public void EndGame()
        {
            var Winners = getWinners();

            foreach (IPlayer winner in Winners)
            {
                winner.Win(GameTable.Bank / Winners.Count);
                Console.WriteLine("Winner is " + winner.Name.ToString() + " with " + CombinationIndicator.getCombination(winner.Hand.hand).ToString());
            }
        }
Ejemplo n.º 2
0
        public List <IPlayer> getWinners()
        {
            var winner = GameTable.Players[0];

            for (int i = 1; i < GameTable.Players.Count; i++)
            {
                if (CombinationIndicator.getCombination(GameTable.Players[i].Hand.hand) > CombinationIndicator.getCombination(winner.Hand.hand))
                {
                    winner = GameTable.Players[i];
                }
            }
            List <IPlayer> winners = new List <IPlayer>();

            foreach (IPlayer player in GameTable.Players)
            {
                if (CombinationIndicator.getCombination(player.Hand.hand) == CombinationIndicator.getCombination(winner.Hand.hand))
                {
                    winners.Add(player);
                }
            }
            if (winners.Count > 1)
            {
                var winnerByHighCard = winners[0];
                for (int i = 1; i < winners.Count; i++)
                {
                    if (winners[i].Hand.highCard > winnerByHighCard.Hand.highCard)
                    {
                        winnerByHighCard = winners[i];
                    }
                }
                List <IPlayer> TotalWiners = new List <IPlayer>();
                foreach (IPlayer player in winners)
                {
                    if (player.Hand.highCard == winnerByHighCard.Hand.highCard)
                    {
                        TotalWiners.Add(player);
                    }
                }
                return(TotalWiners);
            }
            else
            {
                return(winners);
            }
        }
Ejemplo n.º 3
0
        public void GameLoop()
        {
            Dealer.Setup();
            ShowInfo();

            Console.Clear();

            Dealer.CollectBlindes();
            ShowInfo();

            Console.Clear();

            Dealer.DealPreFlup();
            Console.WriteLine("Your cards is: " + Player.Hand.showPreFlup());
            ShowInfo();

            Console.Clear();

            Dealer.CollectBets();
            ShowInfo();

            Console.Clear();

            Dealer.DealFlup();
            Console.WriteLine("Cards on the table: " + Dealer.showCardsOnTable());
            Console.WriteLine("Your cards is: " + Player.Hand.showPreFlup());
            ShowInfo();

            Console.Clear();

            Dealer.CollectBets();
            ShowInfo();

            Console.Clear();

            Dealer.DealTurn();
            Console.WriteLine("Cards on the table: " + Dealer.showCardsOnTable());
            Console.WriteLine("Your cards is: " + Player.Hand.showPreFlup());
            ShowInfo();

            Console.Clear();

            Dealer.CollectBets();
            ShowInfo();

            Console.Clear();

            Dealer.DealRiver();
            Console.WriteLine("Cards on the table: " + Dealer.showCardsOnTable());
            Console.WriteLine("Your cards is: " + Player.Hand.showPreFlup());
            ShowInfo();

            Console.Clear();

            Dealer.CollectBets();
            ShowInfo();

            Console.Clear();

            Console.WriteLine("Cards on the table: " + Dealer.showCardsOnTable() + "\n");
            Console.WriteLine("\n" + "----------TABLE----------");
            foreach (IPlayer pokerist in Players)
            {
                Console.WriteLine(pokerist.Name + " " + pokerist.PokerChips + " " + pokerist.Hand.showPreFlup() + " - " + CombinationIndicator.getCombination(pokerist.Hand.hand) + "\n");
            }
            Console.WriteLine("-------------------------");
            Dealer.EndGame();
            Console.WriteLine("\n" + "Press any key to continue");
            Console.ReadKey();
            Console.Clear();

            Console.WriteLine("Restart?(Y/N)");
            var output = Console.ReadLine();

            Console.Clear();
            if (output == "Y")
            {
                GameLoop();
            }
            if (output == "N")
            {
            }
        }