static void TestDeckClass()
 {
     Deck deck = new Deck();
     for (int i = 0; i < 52; ++i)
     {
         Console.WriteLine(deck.DrawCard().GetFace());
     }
 }
 public Game()
 {
     UserWon = false;
     ComputerWon = false;
     UserScore = 0;
     ComputerScore = 0;
     Deck = new Deck();
 }
Example #3
0
        public Dealer(int deckCount = 1)
        {
            //initialise the dealer by adding the specified number of decks to the available cards
            AvailableCards = new List<Card>();

            for (int DeckNumber = 0; DeckNumber < deckCount; DeckNumber++)
            {
                var Deck = new Deck();
                AvailableCards.AddRange(Deck);
            }
        }
Example #4
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public BlackjackGame()
        {
            dealer.SetScoreCounter( scoreCounter );

            for (int i = 0; i < DECKS_COUNT; i++)
                decks[i] = new Deck();

            TotalLose = 0;

            DealerBlackjack = DealerBust = false;
        }
Example #5
0
 public Shoe(int decks)
 {
     for (var i = 0; i < decks; i++)
     {
         var deck = new Deck();
         foreach (var card in deck)
         {
             _cards.Add(card);
         }
     }
     _capactiy = _cards.Count;
     this.Cut();
 }
Example #6
0
        private Shoe(int decks)
        {
            _deckCount = decks;

            for (var i = 0; i < decks; i++)
            {
                var deck = new Deck();
                deck.Shuffle(100);
                foreach (var card in deck)
                {
                    _cards.Add(card);
                }
            }
            _capactiy = _cards.Count;
        }
        // The blackjack rules class should return a new deck
        public static Deck NewDeck()
        {
            var deck = new Deck();

                //
                foreach (string suit in suits)
                {
                    for (int i = 0; i < values.Length; i++)
                    {
                        // Assign the value of the card and the ids of the cards
                        deck.Add(new Card(ids[i], suit, values[i]));
                    }
                }

                return deck;
        }
Example #8
0
        /// <summary>
        /// 发牌
        /// </summary>
        public void Deal()
        {
            if ((this.AllowedActions & GameAction.Deal) != GameAction.Deal)
            {
                throw new InvalidOperationException();
            }

            this.LastState = GameState.Unknown;

            if (this.deck == null)
            {
                this.deck = new Deck();
            }
            else
            {
                this.deck.Populate();
            }

            this.deck.Shuffle();
            this.Dealer.Hand.Clear();
            this.Player.Hand.Clear();

            this.deck.Deal(this.Dealer.Hand);
            this.deck.Deal(this.Player.Hand);
            //判断初始发了两张牌,庄家和玩家恰好为21点
            if (this.Player.Hand.SoftValue == 21)
            {
                if (this.Dealer.Hand.SoftValue == 21)
                {
                    this.LastState = GameState.Draw;
                }
                else
                {
                    this.Player.Balance += this.Player.Bet / 2*3;
                    this.LastState = GameState.PlayerWon;
                }

                this.Dealer.Hand.Show();
                this.AllowedActions = GameAction.Deal;
            }
            else if (this.Dealer.Hand.TotalValue == 21)
            {
                this.Player.Balance -= this.Player.Bet;
                this.Dealer.Hand.Show();
                this.LastState = GameState.DealerWon;
                this.AllowedActions = GameAction.Deal;
            }
            //如果没有人到21点,则玩家可以选择加牌或者过
            else
            {
                this.AllowedActions = GameAction.Hit | GameAction.Pass;
            }
        }
Example #9
0
 // Create a constructor for the player that has as a new deck
 // for every time the player class is called
 public Player()
 {
     Hand = new Deck();
 }
Example #10
0
        public void Deal()
        {
            if ((this.AllowedActions & GameAction.Deal) != GameAction.Deal)
            {
                // TODO: Add a descriptive error message
                throw new InvalidOperationException();
            }

            this.LastState = GameState.Unknown;
            
            if (this.deck == null)
            {
                this.deck = new Deck();
            }
            else
            {
                this.deck.Populate();
            }

            this.deck.Shuffle();
            this.Dealer.Hand.Clear();
            this.Player.Hand.Clear();

            this.deck.Deal(this.Dealer.Hand);
            this.deck.Deal(this.Player.Hand);

            if (this.Player.Hand.SoftValue == 21)
            {
                if (this.Dealer.Hand.SoftValue == 21)
                {
                    this.LastState = GameState.Draw;
                }
                else
                {
                    this.Player.Balance += this.Player.Bet / 2;
                    this.LastState = GameState.PlayerWon;
                }

                this.Dealer.Hand.Show();
                this.AllowedActions = GameAction.Deal;
            }
            else if (this.Dealer.Hand.TotalValue == 21)
            {
                this.Player.Balance -= this.Player.Bet / 2;
                this.Dealer.Hand.Show();
                this.LastState = GameState.DealerWon;
                this.AllowedActions = GameAction.Deal;
            }
            else
            {
                // TODO: Add support of other actions
                this.AllowedActions = GameAction.Hit | GameAction.Stand;
            }
        }
Example #11
0
 public Core()
 {
     deck = new Deck();
     SetBackCardImage();
 }