private static bool PlayGame() { Deck MainDeck = Extensions.MakeNew(); List <Hand> PlayerHands = new List <Hand>(); int playerHandIndex = 0; Hand DealerHand, currentPlayerHand = null; bool playing = true; int gameState = 0; //0 for running, 1 for player wins, 2 for tie, 3 for loss List <ConsoleKey> validInput = new List <ConsoleKey>() { ConsoleKey.H, ConsoleKey.D, ConsoleKey.S, ConsoleKey.Spacebar, ConsoleKey.Escape }; List <Action> postInput = new List <Action>() { () => Hit(ref currentPlayerHand, ref MainDeck), () => DoubleDown(ref currentPlayerHand, ref MainDeck), () => Split(ref currentPlayerHand), () => Stand(ref currentPlayerHand), () => Abort() }; MainDeck.Shuffle(); PlayerHands.Add(DealHand(MainDeck)); MainDeck.cards.RemoveRange(0, 2); DealerHand = DealHand(MainDeck); MainDeck.cards.RemoveRange(0, 2); if (DealerHand.Score() == 21) //handle dealer blackjack { if (PlayerHands[0].Score() == 21) { gameState = 2; } else { gameState = 3; } } while (playing) { int inputIndex = GetPlayerInput(validInput); currentPlayerHand = PlayerHands[playerHandIndex]; postInput[inputIndex](); PlayerHands[inputIndex] = currentPlayerHand; } return(true); }