/// <summary>User has a first, middle and last name</summary>
        /// <remarks>Spaces are removed and collapsed so multiple middle names still work</remarks>
        private void AllNames(char[] current, string fname, string mname, string lname)
        {
            // mark the indices
            int mid = this.GetMidpoint(fname.Length, lname.Length);

            current[0]       = fname[0];
            current[mid]     = mname[0];
            current[mid + 1] = lname[0];

            List <char> pre  = new List <char>(this._util.PadMinLength(fname.Substring(1), this.PINLength));
            List <char> post = new List <char>(this._util.PadMinLength(lname.Substring(1), this.PINLength));

            ShuffledDeck <char> deck = new ShuffledDeck <char>(pre, this._util.Generator);
            IEnumerator <char>  shoe = deck.GetEnumerator();

            shoe.MoveNext();

            for (int i = 1; i < mid; ++i)
            {
                current[i] = shoe.Current;
                shoe.MoveNext();
            }

            deck = new ShuffledDeck <char>(post, this._util.Generator);
            shoe = deck.GetEnumerator();
            shoe.MoveNext();

            for (int i = mid + 2; i < current.Length; ++i)
            {
                current[i] = shoe.Current;
                shoe.MoveNext();
            }
        }
示例#2
0
        public List <List <Card> > Deal()
        {
            var player1Cards = new List <Card>();
            var player2Cards = new List <Card>();
            var player3Cards = new List <Card>();
            var player4Cards = new List <Card>();

            for (var cardNo = 0; cardNo < 13; cardNo++)
            {
                var player1Card = _deck.Where(p => !ShuffledDeck.Contains(p)).OrderBy(p => p.RandomSequence).Take(1).First();
                ShuffledDeck.Add(player1Card);
                player1Cards.Add(player1Card);
                var player2Card = _deck.Where(p => !ShuffledDeck.Contains(p)).OrderBy(p => p.RandomSequence).Take(1).First();
                ShuffledDeck.Add(player2Card);
                player2Cards.Add(player2Card);
                var player3Card = _deck.Where(p => !ShuffledDeck.Contains(p)).OrderBy(p => p.RandomSequence).Take(1).First();
                ShuffledDeck.Add(player3Card);
                player3Cards.Add(player3Card);
                var player4Card = _deck.Where(p => !ShuffledDeck.Contains(p)).OrderBy(p => p.RandomSequence).Take(1).First();
                ShuffledDeck.Add(player4Card);
                player4Cards.Add(player4Card);
            }

            return(new List <List <Card> >
            {
                player1Cards.OrderBy(p => GetSuitSequence(player1Cards)[p.Suit]).ThenBy(p => p.BridgeCard).ToList(),
                player2Cards.OrderBy(p => GetSuitSequence(player2Cards)[p.Suit]).ThenBy(p => p.BridgeCard).ToList(),
                player3Cards.OrderBy(p => GetSuitSequence(player3Cards)[p.Suit]).ThenBy(p => p.BridgeCard).ToList(),
                player4Cards.OrderBy(p => GetSuitSequence(player4Cards)[p.Suit]).ThenBy(p => p.BridgeCard).ToList()
            });
        }
示例#3
0
        public void Start()
        {
            Console.Clear();
            var newCard = ShuffledDeck.PopCard();

            Player.DrawCard(newCard);
            var newCardTwo = ShuffledDeck.PopCard();

            Player.DrawCard(newCardTwo);

            _iio.Output("Your first two cards are: ");
            Player.PrintHandCard();

            _iio.Output($"You are currently at {Player.Sum()}");

            if (Player.DetermineBlackjack())
            {
                _iio.Output("Player has won!! Yay!");
                _stateOfGamePlay = false;
            }

            var newCardThree = ShuffledDeck.PopCard();

            Dealer.DrawCard(newCardThree);

            var newCardFour = ShuffledDeck.PopCard();

            Dealer.DrawCard(newCardFour);
            GamePlay();
        }
        /// <summary>Logic if user only has one name</summary>
        private void OneName(char[] current, string name)
        {
            current[0] = name[0];
            List <char>         post = new List <char>(this._util.PadMinLength(name.Substring(1), this.PINLength));
            ShuffledDeck <char> deck = new ShuffledDeck <char>(post, this._util.Generator);

            IEnumerator <char> shoe = deck.GetEnumerator();

            shoe.MoveNext();
            for (int i = 1; i < current.Length; ++i)
            {
                current[i] = shoe.Current;
                shoe.MoveNext();
            }
        }
示例#5
0
        public void GamePlay()
        {
            var choice = _iio.Ask("Hit or stay? (Hit = 1, Stay = 0)");

            while (choice != "0" && _stateOfGamePlay)
            {
                var newHitCard     = ShuffledDeck.PopCard();
                var playerIsBusted = Player.Hit(newHitCard);
                _iio.Output("with a hand of: ");
                Player.PrintHandCard();

                if (Player.DetermineBlackjack())
                {
                    GameState = GameState.PlayerWon;
                    _iio.Output("Player has won Blackjack!!! Yay!");
                    _stateOfGamePlay = false;
                }

                if (playerIsBusted)
                {
                    GameState = GameState.DealerWon;
                    _iio.Output("Player is busted. Dealer wins!!");
                    _stateOfGamePlay = false;
                }

                else
                {
                    choice = _iio.Ask("Hit or stay? (Hit = 1, Stay = 0)");
                }
            }

            if (_stateOfGamePlay)
            {
                var dealerIsBusted = Dealer.Play(ShuffledDeck.Cards);
                if (dealerIsBusted)
                {
                    GameState = GameState.PlayerWon;
                    _iio.Output("The dealer has busted. Player is the winner!!");
                    _stateOfGamePlay = false;
                }
                CheckForWinner();
            }
        }