private void UpdateRounds(List <RoundPlayer> roundPlayers) { RoundPlayer dealer = roundPlayers .Where(roundPlayer => roundPlayer.Player.Type == PlayerType.Dealer) .First(); roundPlayers.Remove(dealer); foreach (var roundPlayer in roundPlayers) { int score = CalculateCardScore(roundPlayer.Cards.Select(roundPlayerCard => GetCardById(roundPlayerCard.CardId))); if (score > Constants.BlackJackValue) { roundPlayer.State = RoundPlayerState.Lose; } } int dealerScore = CalculateCardScore(dealer.Cards.Select(roundPlayerCard => GetCardById(roundPlayerCard.CardId))); if (dealerScore > Constants.BlackJackValue) { SetWinners(roundPlayers); } if (dealerScore <= Constants.BlackJackValue) { CheckStates(roundPlayers, dealerScore); } _roundPlayerRepository.Update(roundPlayers); }
public void SaveRound(int gameId, List <bool> flags) { var roundPlayers = GetRoundPlayers(gameId).ToList(); for (int i = 0; i < roundPlayers.Count - 1; i++) { roundPlayers[i].IsWin = flags[i]; _roundPlayerRepository.Update(roundPlayers[i]); } int roundId = GetCurrentRoundId(gameId); Round round = _roundRepository.Get(roundId); round.IsCompleted = true; _roundRepository.Update(round); }