コード例 #1
0
        private void StopPulling()
        {
            var firstOccupiedHand = Hands.FirstOrDefault(hand => !hand.Enabled);

            if (firstOccupiedHand == null)
            {
                return;
            }

            EnableHand(firstOccupiedHand);
        }
コード例 #2
0
        private void StartPulling()
        {
            var firstFreeHand = Hands.FirstOrDefault(hand => hand.Enabled);

            if (firstFreeHand == null)
            {
                return;
            }

            DisableHand(firstFreeHand);
        }
コード例 #3
0
 public Hand?GetHand(string?name)
 {
     return(Hands.FirstOrDefault(hand => hand.Name == name));
 }
コード例 #4
0
ファイル: Player.cs プロジェクト: Helloworld2345567/BlackJack
        public void ShowPlayerCards(bool hideOneCard = false)
        {
            if (hideOneCard) // This should be set to true only if the player is the dealer AND all players have played.
            {
                log.DealerCard(Name);
                if (Hands.FirstOrDefault().Cards.FirstOrDefault() != null)
                {
                    Hands.First().Cards.First().DisplayCard();
                }
            }
            else
            {
                foreach (Hand hand in Hands)
                {
                    if (Name != "Dealer")
                    {
                        if (hand.Status == HandStatus.Bust)
                        {
                            log.PlayerHasBust(Name, Bet);
                        }
                        else if (hand.Status == HandStatus.BlackJack)
                        {
                            log.PlayerGotBlackJack(Name, Bet * blackJackPayout);
                        }
                        else if (hand.Status == HandStatus.Won)
                        {
                            log.PlayerHasWon(Name, Bet);
                        }
                        else if (hand.Status == HandStatus.Lost)
                        {
                            log.PlayerResult(Name, "lost");
                        }
                        else if (hand.Status == HandStatus.BlackJack)
                        {
                            log.PlayerHasWon(Name, Bet * 1.5);
                        }
                        else if (hand.Status == HandStatus.Push && Name != "Dealer")
                        {
                            log.PlayerHasTied(Name);
                        }
                        else if (hand.Status == HandStatus.InPlay)
                        {
                            log.PlayerCardsInPlay(Name);
                        }
                        else
                        {
                            log.PlayerCards(Name);
                        }
                    }
                    else
                    {
                        if (hand.Status == HandStatus.Bust)
                        {
                            log.PlayerResult(Name, "bust");
                        }
                        else
                        {
                            log.PlayerCards(Name);
                        }
                    }

                    foreach (Card card in hand.Cards)
                    {
                        card.DisplayCard();
                    }

                    log.Total(hand.Total);
                }
            }
            log.SkipLine();
        }