//  Used by PlayTimedGame to process the players winnings
        public static void processPlayerWinnings(BSPlayer player, BSDealer dealer)
        {
            //  If this player is playing (do they have cards?)
            //  cant use "hasQuit", because that's set in the previous loop, and the player may still need to be processed
            if (player.getHand(0).Count > 0)
            {
                //  Loop through each hand the player has (Split Hands)
                for (int j = 0; j < player.getHandCount(); j++)
                {
                    BlackjackResult bjr = BlackJack.getGameResult(dealer.getHand(), player.getHand(j));

                    //  Give player the money / take it away
                    if (bjr == BlackjackResult.PlayerWins)
                    {
                        //  If the player wins, has only one hand and has blackjack then pay 3:2 instead of 1:1
                        if ((player.getHandCount() == 1) & (BlackJack.doesHandHaveBlackjack(player.getHand(j))))
                        {
                            player.winBlackJack(j);
                        }
                        else
                        {
                            player.winNormalBet(j);
                        }
                    }
                    else if (bjr == BlackjackResult.Push)
                    {
                        player.pushBet(j);
                    }
                    else // Dealer Wins
                    {
                        player.loseBet(j);
                    }
                }
            }
        }
        //  Initializes the class with the game parameters
        public BasicStrategySimulator(BlackJackGameParams blackJackGameParams)
        {
            this.blackJackGameParams = blackJackGameParams;
            this.cardCounter         = new CardCounting(blackJackGameParams);
            deck    = new Deck(blackJackGameParams.numDecks, Deck.ShuffleType.Durstenfeld, cardCounter);
            players = new List <BSPlayer>();
            dealer  = new BSDealer(blackJackGameParams.H17, deck);

            //  Initialize the players
            for (int i = 0; i < blackJackGameParams.numPlayers; i++)
            {
                BSPlayer newBSPlayer = new BSPlayer(blackJackGameParams);
                players.Add(newBSPlayer);
            }
        }
        public void test_BSPlayer_playHand(BlackJackGameParams blackJackGameParams, string filePath)
        {
            var lines = File.ReadAllLines(filePath).Select(a => a.Split(',', ':'));
            IEnumerator <string[]> iter = lines.GetEnumerator();

            while (1 == 1)
            {
                int         itemCount   = 0;
                List <Card> deckList    = new List <Card>();
                List <Card> playersHand = new List <Card>();
                List <Card> dealersHand = new List <Card>();
                Double      initialBet  = 0;
                Double      winnings    = 0;
                string      name        = "";
                while (iter.MoveNext() & (itemCount < 5))
                {
                    var l = iter.Current;
                    switch (l[0])
                    {
                    case "Name":
                        name = l[1];
                        break;

                    case "Player":
                        for (int i = 1; i < l.Length; i++)
                        {
                            l[i].Replace(" ", "");
                            playersHand.Add(getCardFromText(l[i]));
                        }
                        itemCount += 1;
                        break;

                    case "Dealer":
                        for (int i = 1; i < l.Length; i++)
                        {
                            l[i].Replace(" ", "");
                            dealersHand.Add(getCardFromText(l[i]));
                        }
                        itemCount += 1;
                        break;

                    case "Deck":
                        for (int i = 1; i < l.Length; i++)
                        {
                            l[i].Replace(" ", "");
                            deckList.Add(getCardFromText(l[i]));
                        }
                        itemCount += 1;
                        break;

                    case "Initial":
                        l[1].Replace(" ", "");
                        initialBet = Double.Parse(l[1]);
                        itemCount += 1;
                        break;

                    case "Win":
                        l[1].Replace(" ", "");
                        winnings   = Double.Parse(l[1]);
                        itemCount += 1;
                        break;

                    default:
                        break;
                    }
                }

                //  When the iterator has run out of new items then return
                if (!(itemCount == 5))
                {
                    return;
                }
                BSPlayer  player = new BSPlayer(blackJackGameParams);
                DeckDummy deck   = new DeckDummy();
                BSDealer  dealer = new BSDealer(false, deck);

                deck.setCardList(deckList);

                dealer.setHand(dealersHand);

                player.clearCurrentBets();
                player.clearHand();
                player.setBankRoll(blackJackGameParams.bankroll);
                player.setInitialBet(initialBet);
                player.setFirstHand(playersHand);

                player.playHand(dealer, new CardCounting(blackJackGameParams));
                BasicStrategySimulator.processPlayerWinnings(player, dealer);
                if (player.getTotalHandWinnings() == winnings)
                {
                    System.Diagnostics.Debug.WriteLine(name + ": PASS");
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine(name + ": FAIL");
                }
            }
        }