Exemplo n.º 1
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hash = 19;
                hash += hash * 31 + IsFlushCardFilter.GetHashCode();
                hash += hash * 31 + IsPairedFilter.GetHashCode();
                hash += hash * 31 + IsOpenEndedStraightDrawsFilter.GetHashCode();
                hash += hash * 31 + IsGutshotsFilter.GetHashCode();
                hash += hash * 31 + IsCardTextureFilter.GetHashCode();
                hash += hash * 31 + IsHighcardFilter.GetHashCode();
                hash += hash * 31 + IsPossibleStraightsFilter.GetHashCode();
                hash += hash * 31 + OpenEndedStraightDraws.GetHashCode();
                hash += hash * 31 + PossibleStraightsCompare.GetHashCode();
                hash += hash * 31 + PossibleStraights.GetHashCode();
                hash += hash * 31 + Gutshots.GetHashCode();

                if (!string.IsNullOrEmpty(HighestCard))
                {
                    hash += hash * 31 + HighestCard.GetHashCode();
                }

                if (!string.IsNullOrEmpty(SelectedCardTexture))
                {
                    hash += hash * 31 + SelectedCardTexture.GetHashCode();
                }

                hash += hash * 31 + IsPairedFilterTrue.GetHashCode();
                hash += hash * 31 + StageType.GetHashCode();

                return(hash);
            }
        }
Exemplo n.º 2
0
        public static string WhoWon(List <WinnerModels> Royal,
                                    List <WinnerModels> ToK, List <WinnerModels> Straight,
                                    List <WinnerModels> Flush, List <WinnerModels> Pair,
                                    HighestCard highestcard, Royalty royalty)
        {
            string result;

            if (Royal.Count > 0)
            {
                Winner(ref Royal, ref royalty, ref highestcard, "Royal Flush", out result);
                return(result);
            }

            if (ToK.Count > 0)
            {
                Winner(ref ToK, ref royalty, ref highestcard, "Three of a Kind", out result);
                return(result);
            }

            if (Straight.Count > 0)
            {
                Winner(ref Straight, ref royalty, ref highestcard, "Straight", out result);
                return(result);
            }

            if (Flush.Count > 0)
            {
                Winner(ref Flush, ref royalty, ref highestcard, "Flush", out result);
                return(result);
            }

            if (Pair.Count > 0)
            {
                Winner(ref Pair, ref royalty, ref highestcard, "Pair", out result);
                return(result);
            }

            return($"Player: {highestcard.playerId} has won with the highest card {highestcard.Total}");
        }
Exemplo n.º 3
0
        public static void Winner(ref List <WinnerModels> list, ref Royalty royalty,
                                  ref HighestCard highestCard, string type, out string result)
        {
            string winners      = "";
            string highestRoyal = royalty.HighestRoyal;

            foreach (WinnerModels player in list)
            {
                winners = $"{winners} {player.playerId}";
            }

            if (list.Count > 1 && highestRoyal == "Commoner")
            {
                result = $"It's a tie! Players: {winners} had a {type}! Player {highestCard.playerId} won with the highest hand {highestCard.Total}";
                return;
            }
            if (list.Count > 1 && highestRoyal != "Commoner")
            {
                result = $"It's a tie! Players: {winners} had a {type}! Player {royalty.playerId} won with the highest Royal {RoyalInterpreter(royalty.HighestRoyal)}";
                return;
            }

            result = $"Player: {winners} won with a {type}!";
        }
Exemplo n.º 4
0
        public void CheckList(List <Player> players)
        {
            List <WinnerModels> RoyalList    = new List <WinnerModels>();
            List <WinnerModels> ToKList      = new List <WinnerModels>();
            List <WinnerModels> StraightList = new List <WinnerModels>();
            List <WinnerModels> FlushList    = new List <WinnerModels>();
            List <WinnerModels> PairList     = new List <WinnerModels>();
            HighestCard         highestcard  = new HighestCard {
                Total = 0, playerId = -1
            };
            Royalty royalty = new Royalty {
                HighestRoyal = "Commoner", playerId = -1
            };

            foreach (Player aPlayer in players)
            {
                bool isToK      = ToK(aPlayer);
                bool isStraight = Straight(aPlayer);
                bool isFlush    = Flush(aPlayer);
                bool isPair     = Pair(aPlayer);

                int    pHighCard = HighCard(aPlayer);
                string pRoyal    = CheckRoyalty(aPlayer);

                //Append player info if it reaches one of the conditionals
                if (isToK)
                {
                    ToKList.Add(new WinnerModels {
                        playerId = aPlayer.Id, Total = pHighCard
                    });
                }
                if (isStraight && isFlush)
                {
                    RoyalList.Add(new WinnerModels {
                        playerId = aPlayer.Id, Total = pHighCard
                    });
                }
                if (isStraight)
                {
                    StraightList.Add(new WinnerModels {
                        playerId = aPlayer.Id, Total = pHighCard
                    });
                }
                if (isFlush)
                {
                    FlushList.Add(new WinnerModels {
                        playerId = aPlayer.Id, Total = pHighCard
                    });
                }
                if (isPair)
                {
                    PairList.Add(new WinnerModels {
                        playerId = aPlayer.Id, Total = pHighCard
                    });
                }
                if (pHighCard > highestcard.Total)
                {
                    highestcard = new HighestCard {
                        playerId = aPlayer.Id, Total = pHighCard
                    };
                }
                if (BloodLine(pRoyal, ref royalty))
                {
                    royalty = new Royalty {
                        HighestRoyal = pRoyal, playerId = aPlayer.Id
                    };
                }

                //Display the players' hands
                Console.WriteLine("{0}: {1}{2}, {3}{4}, {5}{6}",
                                  aPlayer.Id,
                                  aPlayer.Card1.Rank, aPlayer.Card1.Suit,
                                  aPlayer.Card2.Rank, aPlayer.Card2.Suit,
                                  aPlayer.Card3.Rank, aPlayer.Card3.Suit);
            }

            //Display the winner(s)
            Console.WriteLine("\n {0} \n\nPress Enter to continue",
                              WhoWon(RoyalList, ToKList,
                                     StraightList, FlushList,
                                     PairList, highestcard,
                                     royalty));

            Console.ReadLine();
        }