コード例 #1
0
        public Card getHighestCardInHand(IEnumerable<Card> hand, Dealer a_dealer)
        {
            int[] cardScores = a_dealer.getCardScoreArray();

            int Highest = 0;
            highestCard = null;

            foreach (Card c in hand)
            {
                if (cardScores[(int)c.GetValue()] >= Highest)
                {
                    Highest = cardScores[(int)c.GetValue()];
                    if (highestCard == null)
                    {
                        highestCard = c;
                    }
                    else if (cardScores[(int)c.GetValue()] > cardScores[(int)highestCard.GetValue()])
                    {
                        highestCard = c;
                    }
                    else if (isHigherCardColorValue(c.GetColor(), highestCard.GetColor()))
                    {
                        highestCard = c;
                    }

                }
            }
            return highestCard;
        }
コード例 #2
0
        public bool CalcWinner(Player a_player, Dealer a_dealer)
        {
            int[] cardScores = a_dealer.getCardScoreArray();
            IEnumerable<Card> pHand = a_player.GetHand();
            IEnumerable<Card> dHand = a_dealer.GetHand();

            Card PlayerHighest = getHighestCardInHand(pHand, a_dealer);
            Card DealerHighest = getHighestCardInHand(dHand, a_dealer);

            if (cardScores[(int)PlayerHighest.GetValue()] == cardScores[(int)DealerHighest.GetValue()])
            {
                //if the second parameter is higher value then false is returned, aka player win.
                return isHigherCardColorValue(DealerHighest.GetColor(), PlayerHighest.GetColor());
            }

            if (cardScores[(int)PlayerHighest.GetValue()] > cardScores[(int)DealerHighest.GetValue()])
            {
                //player won
                return false;
            }
            else
            {
                //dealer won.
                return true;
            }
        }