public DisplayStage[] HandsDealt(TableDealer tableDealer) { tableDealer.Table.PhaseTitle = "Hands Dealt"; tableDealer.Table.PhaseMessage = ""; tableDealer.DealHands(); return(new DisplayStage[] { DisplayStage.DealtCards }); }
private static void onPlayerStayHandler(PlayerEventArgs e) { if (e.Uuid != TableDealer._id) { // if its a player that called for stay, // increment player turn index PlayerTurnIndex++; // check if index exceeds index of players. // if it does, it is the dealers turn to draw if (PlayerTurnIndex == Players.Count) { if (TableDealer.shouldDrawCard()) { hitForCurrentPlayer(); } else { TableDealer.emitOnPlayerStay(); } } } else { // dealer emit stay event // end the game endGame(); } }
// Player subscriptions // ---------- private static void OnPlayerLoseHandler(PlayerEventArgs e) { if (e.Uuid != TableDealer._id) { // if a player exceeds blackjack value // move to next player PlayerTurnIndex++; // if its dealers turn, check if there are any players left to play against. // if not end the game directly if (PlayerTurnIndex == Players.Count && Players.Any(player => !player.Hand.hasExceeded()) && TableDealer.shouldDrawCard()) { // there more more players to win against, draw cards if needed hitForCurrentPlayer(); } else { endGame(); } } else { // dealer lost by exceeding endGame(); } }
public static void startNextGame() { // take cards from dealer and players and add to discard pile TableDealer.reset(); Players.ForEach(player => player.reset()); // if active deck has less than shuttle trigger value, // reset discard deck and active deck if (ActiveDeck.getCount() < Settings.ActiveDeckReshuffleTarget) { ActiveDeck = new ActiveDeck(); ActiveDeck.createDeck(); updateActiveDeckCount(); DiscardDeck = new DiscardDeck(); updateDiscardDeckCount(); } // reset game status GameStatus = GameStatusEnum.InProgress; PlayerTurnIndex = 0; // retoggle visibility handlers DealerHandVisibility = Visibility.Hidden; NextGameControlsVisibility = Visibility.Hidden; ActiveGameControlsVisibility = Visibility.Visible; // deal initial hand dealInititalHand(); }
// Game play methods // ---------- public static void startNewGame() { // get dealer and players to subscribe to game state events TableDealer.subscribeToGameStateEvents(); Players.ForEach(player => player.subscribeToGameStateEvents()); // create active deck ActiveDeck.createDeck(Settings.NumberOfDecks); updateActiveDeckCount(); // deal initial hand dealInititalHand(); }
private static void onPlayerNextTurnHandler(PlayerEventArgs e) { if (e.Uuid == TableDealer._id) { // check if dealer should still draw a card or end the game if (TableDealer.shouldDrawCard()) { hitForCurrentPlayer(); } else { endGame(); } } return; // do nothing for normal players }
private static void dealInititalHand() { // give out 2 cards to dealer for (int i = 0; i < Settings.initialCardDrawCount; i++) { Card card = ActiveDeck.drawCard(); updateActiveDeckCount(); TableDealer.receiveCard(card); } // give out 2 cards to each player Players.ForEach(player => { for (int i = 0; i < Settings.initialCardDrawCount; i++) { Card card = ActiveDeck.drawCard(); updateActiveDeckCount(); player.receiveCard(card); } }); }
public DisplayStage[] StartNewHand(TableDealer tableDealer) { tableDealer.CleanTableForNewHand(); // See if there are enough players to start a hand // more than one player and at least one non-computer if (tableDealer.Table.OccupiedSeats().Count() > 1 && tableDealer.Table.OccupiedSeats().Any(s => !s.Player.Computer)) { // Reset Pause request for all seats. foreach (var s in tableDealer.Table.AllSeats()) { if (s.Status == SeatStatus.PlayOne) { s.Status = SeatStatus.PleasePause; } } return(new DisplayStage[] { }); } else { tableDealer.Table.PhaseTitle = "Waiting for Player(s)"; tableDealer.Table.PhaseMessage = ""; return(null); } }
public virtual DisplayStage[] ExecutePhase(int game_phase, TableDealer tableDealer) { return PhaseActions[game_phase](tableDealer); }