/// <summary> /// Selects a game based on supplied filter /// </summary> /// <param name="filter">Filter used to select game</param> /// <returns>A game that satisfy the supplied filter</returns> public Entities.Game Execute(Entities.Filters.Game.Select filter) { Entities.Game game = _selectGame.Execute(filter); Entities.Filters.GamePlayer.Select playerFilter = new Entities.Filters.GamePlayer.Select(); playerFilter.GameID = filter.GameID; playerFilter.SelectCards = filter.DataToSelect.HasFlag(Entities.Enums.Game.Select.GamePlayerCards); List <Entities.GamePlayer> allPlayers = _selectGamePlayerREPO.Execute(playerFilter); game.Players = allPlayers.Where(x => x.PlayerType == Entities.Enums.GamePlayerType.Player).ToList(); game.Spectators = allPlayers.Where(x => x.PlayerType == Entities.Enums.GamePlayerType.Spectator).ToList(); Entities.Filters.Deck.SelectByGameID deckFilter = new Entities.Filters.Deck.SelectByGameID(); deckFilter.GameIDs.Add(game.GameID); game.GameDecks = _selectDeck.Execute(deckFilter); if (filter.DataToSelect.HasFlag(Entities.Enums.Game.Select.Rounds)) { game.Rounds.Add(_selectGameRound.Execute(game.GameID, true)); } return(game); }
/// <summary> /// Join a game /// </summary> /// <param name="gameID">The id of the game to join</param> /// <param name="user">The current user</param> /// <param name="passphrase">The passphrase for the game</param> /// <param name="playerType">Type of player joining</param> /// <returns>The response to a join request</returns> public Entities.JoinResponse Execute(Int32 gameID, Entities.User user, String passphrase, Entities.Enums.GamePlayerType playerType) { Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select(); filter.GameID = gameID; filter.DataToSelect |= Entities.Enums.Game.Select.Rounds; filter.DataToSelect |= Entities.Enums.Game.Select.GamePlayerCards; Entities.Game game = _selectGame.Execute(filter); Entities.JoinResponse response = _joinGame.Execute(game, user, passphrase,playerType); if (response.Game != null) { if (response.Game.IsWaiting() && response.Result.HasFlag(Entities.Enums.Game.JoinResponseCode.SuccessfulAlreadyPlayer) == false) { _sendMessage.UpdateWaiting(response.Game, true); } else if (response.Result.HasFlag(Entities.Enums.Game.JoinResponseCode.NewRoundStart) == true) { _sendMessage.UpdateGame(response.Game, true); } else { _sendMessage.UpdateLobby(response.Game, true); } } return response; }
/// <summary> /// Insert a vote to kick a user <paramref name="vote"/> /// </summary> /// <param name="vote">The user's vote to kick</param> /// <returns></returns> public Entities.ActionResponses.VoteToKick Execute(Entities.GamePlayerKickVote vote) { Entities.ActionResponses.VoteToKick response = new Entities.ActionResponses.VoteToKick(); Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select(); filter.DataToSelect = Entities.Enums.Game.Select.None; filter.GameID = vote.GameID; Entities.Game game = _selectGame.Execute(filter); if (game.IsCurrentPlayer(vote.VotedUserId)) { response = _insert.Execute(vote); response.ResponseCode = Entities.ActionResponses.Enums.VoteToKick.VoteSuccessful; response.Game = game; if (vote.Vote) { response.VotesToKick++; } else { response.VotesToStay++; } return(response); } else { response.ResponseCode = Entities.ActionResponses.Enums.VoteToKick.IneligiblePlayerToVote; return(response); } }
/// <summary> /// Insert a vote to kick a user <paramref name="vote"/> /// </summary> /// <param name="vote">The user's vote to kick</param> /// <returns></returns> public Entities.ActionResponses.VoteToKick Execute(Entities.GamePlayerKickVote vote) { Entities.ActionResponses.VoteToKick response = new Entities.ActionResponses.VoteToKick(); Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select(); filter.DataToSelect = Entities.Enums.Game.Select.None; filter.GameID = vote.GameID; Entities.Game game = _selectGame.Execute(filter); if (game.IsCurrentPlayer(vote.VotedUserId)) { response = _insert.Execute(vote); response.ResponseCode = Entities.ActionResponses.Enums.VoteToKick.VoteSuccessful; response.Game = game; if (vote.Vote) { response.VotesToKick++; } else { response.VotesToStay++; } return response; } else { response.ResponseCode = Entities.ActionResponses.Enums.VoteToKick.IneligiblePlayerToVote; return response; } }
/// <summary> /// Play a list of cards from a user's hand /// </summary> /// <param name="cardIDs">The card IDs the user has selected </param> /// <param name="gameID">The game ID in which the user wants to play the card</param> /// <param name="userId">The user Id</param> /// <param name="autoPlayed">Were these cards auto played</param> /// <returns>PlayCard action result containing any errors and the round the card was played.</returns> public Entities.ActionResponses.PlayCard Execute(List <Int32> cardIDs, Int32 gameID, Int32 userId, Boolean autoPlayed = false) { Entities.ActionResponses.PlayCard response = _playCard.Execute(cardIDs, gameID, userId, autoPlayed); if (response.ResponseCode == Entities.ActionResponses.Enums.PlayCardResponseCode.Success) { Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select(); filter.DataToSelect = Entities.Enums.Game.Select.GamePlayerCards; filter.GameID = gameID; Entities.Game game = _selectGame.Execute(filter); game.Rounds.Add(response.CurrentRound); if (response.CurrentRound.AllPlayersAnswered() && game.SecondsToPlay > 0) { var cachedJobId = MemoryCache.Default.Get(game.RoundTimerKey); BackgroundJob.Delete(cachedJobId as String); } _sendMessage.CardPlayed(game, true); _updateGame.Execute(game.GameID, DateTime.UtcNow, null); } return(response); }
/// <summary> /// Join a game /// </summary> /// <param name="gameID">The id of the game to join</param> /// <param name="user">The current user</param> /// <param name="passphrase">The passphrase for the game</param> /// <param name="playerType">Type of player joining</param> /// <returns>The response to a join request</returns> public Entities.JoinResponse Execute(Int32 gameID, Entities.User user, String passphrase, Entities.Enums.GamePlayerType playerType) { Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select(); filter.GameID = gameID; filter.DataToSelect |= Entities.Enums.Game.Select.Rounds; filter.DataToSelect |= Entities.Enums.Game.Select.GamePlayerCards; Entities.Game game = _selectGame.Execute(filter); Entities.JoinResponse response = _joinGame.Execute(game, user, passphrase, playerType); if (response.Game != null) { if (response.Game.IsWaiting() && response.Result.HasFlag(Entities.Enums.Game.JoinResponseCode.SuccessfulAlreadyPlayer) == false) { _sendMessage.UpdateWaiting(response.Game, true); } else if (response.Result.HasFlag(Entities.Enums.Game.JoinResponseCode.NewRoundStart) == true) { _sendMessage.UpdateGame(response.Game, true); } else { _sendMessage.UpdateLobby(response.Game, true); } } return(response); }
/// <summary> /// Validate the passhrase policy /// </summary> /// <param name="gameID">The gameID for the game containing the policy</param> /// <param name="passphrase">The user supplied passphrase</param> /// <returns>Returns if the passphrase policy was validated</returns> public bool Execute(Int32 gameID, String passphrase) { Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select(); filter.GameID = gameID; Entities.Game game = _selectGame.Execute(filter); return _validatePassphrase.Execute(game, passphrase); }
public JsonResult Index(int id) { Entities.Models.Game.Listing.Detail model = new Entities.Models.Game.Listing.Detail(); Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select(); filter.GameID = id; return Json(new { Game = new Entities.Models.Game.Listing.Game(_selectGame.Execute(filter), Authentication.Security.CurrentUserId) }, JsonRequestBehavior.AllowGet); }
public JsonResult Index(int id) { Entities.Models.Game.Listing.Detail model = new Entities.Models.Game.Listing.Detail(); Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select(); filter.GameID = id; return(Json(new { Game = new Entities.Models.Game.Listing.Game(_selectGame.Execute(filter), Authentication.Security.CurrentUserId) }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Validate the passhrase policy /// </summary> /// <param name="gameID">The gameID for the game containing the policy</param> /// <param name="passphrase">The user supplied passphrase</param> /// <returns>Returns if the passphrase policy was validated</returns> public bool Execute(Int32 gameID, String passphrase) { Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select(); filter.GameID = gameID; Entities.Game game = _selectGame.Execute(filter); return(_validatePassphrase.Execute(game, passphrase)); }
/// <summary> /// Complete the current round /// </summary> /// <param name="gameID">The ID of the game that contains the round</param> /// <param name="cardIDs">The IDs of the winning cards</param> /// <param name="userId">The user Id trying to complete the round</param> /// <returns></returns> public Entities.ActionResponses.RoundComplete Execute(Int32 gameID, List <Int32> cardIDs, Int32 userId) { Entities.ActionResponses.RoundComplete response = new Entities.ActionResponses.RoundComplete(); Entities.GameRound currentRound = _selectGameRound.Execute(gameID, true); //Validate that the user trying to complete the round is in fact the commander if (currentRound.IsCommander(userId)) { //Validate that select cards were actually played during the round List <Int32> invalidWinners = currentRound.ValidateWinnerSelection(cardIDs); if (invalidWinners.Count == 0) { Entities.User newCommander = currentRound.Winner(); //Update cards as winners Entities.Filters.GameRoundCard.UpdateWinner cardfilter = new Entities.Filters.GameRoundCard.UpdateWinner(); cardfilter.CardIDs = cardIDs; cardfilter.GameID = gameID; Boolean autoPlayed = _updateGameRoundCard.Execute(cardfilter); if (!autoPlayed) { //Update player points Entities.Filters.GamePlayer.UpdatePoints playerFilter = new Entities.Filters.GamePlayer.UpdatePoints(); playerFilter.GameID = gameID; playerFilter.UserId = newCommander.UserId; _updateGamePlayer.Execute(playerFilter); } //Start round Entities.Filters.Game.Select gameFilter = new Entities.Filters.Game.Select(); gameFilter.GameID = gameID; gameFilter.DataToSelect = Entities.Enums.Game.Select.GamePlayerCards; Entities.Game game = _selectGame.Execute(gameFilter); response.NewRoundCreated = _startGameRoud.Execute(game, game.NextCommander(newCommander)); response.CompletedRound = currentRound; response.Game = game; if (!response.NewRoundCreated) { response.Game.Rounds.Add(currentRound); } } } return(response); }
/// <summary> /// Play cards for all players that have yet to play /// </summary> /// <param name="gameID">The game ID</param> public void Execute(int gameID) { Entities.Filters.Game.Select gameFilter = new Entities.Filters.Game.Select(); gameFilter.DataToSelect = Entities.Enums.Game.Select.GamePlayerCards | Entities.Enums.Game.Select.Rounds; gameFilter.GameID = gameID; Entities.Game game = _selectGame.Execute(gameFilter); Entities.GameRound round = game.CurrentRound(); List <Entities.GamePlayer> players = game.Players.Where(x => !round.HasAnswer(x.User.UserId) && game.IsCurrentPlayer(x.User.UserId) && !game.IsCurrentCommander(x.User.UserId)) .Select(x => x).ToList(); Int32 selectCount = 1 + (Int32)round.Question.Instructions; Random rdm = new Random(); List <Int32> cardIDs = null; Entities.ActionResponses.PlayCard response = null; foreach (Entities.GamePlayer player in players) { cardIDs = player.Hand.OrderBy(x => rdm.Next()).Take(selectCount).Select(x => x.CardID).ToList(); response = _playCard.Execute(cardIDs, gameID, player.User.UserId, true); if (response.AutoPlayedSuccess) { if (player.IdlePlayCount + 1 == 3) { //Player is forced to leave game now UnityConfig.Container.Resolve <AppServices.Game.Base.ILeave>().Execute(gameID, player.User, Entities.Enums.GamePlayerType.Player, true); } else { Entities.Filters.GamePlayer.UpdateIdlePlayCount idlePlayCount = new Entities.Filters.GamePlayer.UpdateIdlePlayCount { GameID = gameID, UserId = player.User.UserId }; _updateGamePlayer.Execute(idlePlayCount); } } } }
/// <summary> /// Play cards for all players that have yet to play /// </summary> /// <param name="gameID">The game ID</param> public void Execute(int gameID) { Entities.Filters.Game.Select gameFilter = new Entities.Filters.Game.Select(); gameFilter.DataToSelect = Entities.Enums.Game.Select.GamePlayerCards | Entities.Enums.Game.Select.Rounds; gameFilter.GameID = gameID; Entities.Game game = _selectGame.Execute(gameFilter); Entities.GameRound round = game.CurrentRound(); List<Entities.GamePlayer> players = game.Players.Where(x => !round.HasAnswer(x.User.UserId) && game.IsCurrentPlayer(x.User.UserId) && !game.IsCurrentCommander(x.User.UserId)) .Select(x => x).ToList(); Int32 selectCount = 1 + (Int32)round.Question.Instructions; Random rdm = new Random(); List<Int32> cardIDs = null; Entities.ActionResponses.PlayCard response = null; foreach (Entities.GamePlayer player in players) { cardIDs = player.Hand.OrderBy(x => rdm.Next()).Take(selectCount).Select(x => x.CardID).ToList(); response = _playCard.Execute(cardIDs, gameID, player.User.UserId, true); if (response.AutoPlayedSuccess) { if (player.IdlePlayCount + 1 == 3) { //Player is forced to leave game now UnityConfig.Container.Resolve<AppServices.Game.Base.ILeave>().Execute(gameID, player.User, Entities.Enums.GamePlayerType.Player, true); } else { Entities.Filters.GamePlayer.UpdateIdlePlayCount idlePlayCount = new Entities.Filters.GamePlayer.UpdateIdlePlayCount { GameID = gameID, UserId = player.User.UserId }; _updateGamePlayer.Execute(idlePlayCount); } } } }
/// <summary> /// Selects a game based on supplied filter /// </summary> /// <param name="filter">Filter used to select game</param> /// <returns>A game that satisfy the supplied filter</returns> public Entities.Game Execute(Entities.Filters.Game.Select filter) { Entities.Game game = new Entities.Game(); using (DbCommand cmd = _db.GetStoredProcCommand("Game_Select")) { _db.AddInParameter(cmd, "@GameID", DbType.Int32, filter.GameID); using (IDataReader idr = _db.ExecuteReader(cmd)) { while (idr.Read()) { game = new Entities.Game(idr); } } } return(game); }
/// <summary> /// Starts a game if certain requirements are met /// </summary> /// <param name="gameID">The ID for the game to start</param> /// <param name="commander">The commander for the first round</param> /// <returns>The started game</returns> public Entities.Game Execute(Int32 gameID, Entities.User commander) { Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select(); filter.GameID = gameID; filter.DataToSelect = Entities.Enums.Game.Select.GamePlayerCards; Entities.Game game = _selectGame.Execute(filter); Entities.GamePlayer host = game.Players.First(); if (game.IsCurrentCommander(commander.UserId)) { Boolean successful = _startRound.Execute(game, commander); if (successful) { _sendMessage.UpdateGame(game, true); } } return game; }
/// <summary> /// Starts a game if certain requirements are met /// </summary> /// <param name="gameID">The ID for the game to start</param> /// <param name="commander">The commander for the first round</param> /// <returns>The started game</returns> public Entities.Game Execute(Int32 gameID, Entities.User commander) { Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select(); filter.GameID = gameID; filter.DataToSelect = Entities.Enums.Game.Select.GamePlayerCards; Entities.Game game = _selectGame.Execute(filter); Entities.GamePlayer host = game.Players.First(); if (game.IsCurrentCommander(commander.UserId)) { Boolean successful = _startRound.Execute(game, commander); if (successful) { _sendMessage.UpdateGame(game, true); } } return(game); }
/// <summary> /// Play a list of cards from a user's hand /// </summary> /// <param name="cardIDs">The card IDs the user has selected </param> /// <param name="gameID">The game ID in which the user wants to play the card</param> /// <param name="userId">The user Id</param> /// <param name="autoPlayed">Were these cards auto played</param> /// <returns>PlayCard action result containing any errors and the round the card was played.</returns> public Entities.ActionResponses.PlayCard Execute(List<Int32> cardIDs, Int32 gameID, Int32 userId, Boolean autoPlayed = false) { Entities.ActionResponses.PlayCard response = _playCard.Execute(cardIDs, gameID, userId, autoPlayed); if (response.ResponseCode == Entities.ActionResponses.Enums.PlayCardResponseCode.Success) { Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select(); filter.DataToSelect = Entities.Enums.Game.Select.GamePlayerCards; filter.GameID = gameID; Entities.Game game = _selectGame.Execute(filter); game.Rounds.Add(response.CurrentRound); if(response.CurrentRound.AllPlayersAnswered() && game.SecondsToPlay > 0) { var cachedJobId = MemoryCache.Default.Get(game.RoundTimerKey); BackgroundJob.Delete(cachedJobId as String); } _sendMessage.CardPlayed(game, true); _updateGame.Execute(game.GameID, DateTime.UtcNow, null); } return response; }
/// <summary> /// Complete the current round /// </summary> /// <param name="gameID">The ID of the game that contains the round</param> /// <param name="cardIDs">The IDs of the winning cards</param> /// <param name="userId">The user Id trying to complete the round</param> /// <returns></returns> public Entities.ActionResponses.RoundComplete Execute(Int32 gameID, List<Int32> cardIDs, Int32 userId) { Entities.ActionResponses.RoundComplete response = new Entities.ActionResponses.RoundComplete(); Entities.GameRound currentRound = _selectGameRound.Execute(gameID, true); //Validate that the user trying to complete the round is in fact the commander if (currentRound.IsCommander(userId)) { //Validate that select cards were actually played during the round List<Int32> invalidWinners = currentRound.ValidateWinnerSelection(cardIDs); if (invalidWinners.Count == 0) { Entities.User newCommander = currentRound.Winner(); //Update cards as winners Entities.Filters.GameRoundCard.UpdateWinner cardfilter = new Entities.Filters.GameRoundCard.UpdateWinner(); cardfilter.CardIDs = cardIDs; cardfilter.GameID = gameID; Boolean autoPlayed = _updateGameRoundCard.Execute(cardfilter); if (!autoPlayed) { //Update player points Entities.Filters.GamePlayer.UpdatePoints playerFilter = new Entities.Filters.GamePlayer.UpdatePoints(); playerFilter.GameID = gameID; playerFilter.UserId = newCommander.UserId; _updateGamePlayer.Execute(playerFilter); } //Start round Entities.Filters.Game.Select gameFilter = new Entities.Filters.Game.Select(); gameFilter.GameID = gameID; gameFilter.DataToSelect = Entities.Enums.Game.Select.GamePlayerCards; Entities.Game game = _selectGame.Execute(gameFilter); response.NewRoundCreated = _startGameRoud.Execute(game, game.NextCommander(newCommander)); response.CompletedRound = currentRound; response.Game = game; if(!response.NewRoundCreated) { response.Game.Rounds.Add(currentRound); } } } return response; }
/// <summary> /// Removes a player from the game /// </summary> /// <param name="gameID">The ID of the game to leave</param> /// <param name="user">The user leaving the game</param> /// <param name="playerType">Type of player leaving</param> /// <param name="forcedToLeave">The player was forced to leave</param> public void Execute(Int32 gameID, Entities.User user, Entities.Enums.GamePlayerType playerType, Boolean forcedToLeave = false) { Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select(); filter.GameID = gameID; filter.DataToSelect = Entities.Enums.Game.Select.Rounds | Entities.Enums.Game.Select.GamePlayerCards; Entities.Game game = _selectGame.Execute(filter); Boolean wasWaiting = game.IsWaiting(); Boolean wasCurrentCommander = game.IsCurrentCommander(user.UserId) && playerType == Entities.Enums.GamePlayerType.Player; Entities.GamePlayer player = null; if (playerType == Entities.Enums.GamePlayerType.Player) { player = game.Players.Find(x => x.User.UserId == user.UserId); game.Players.Remove(player); game.PlayerCount--; } else { player = game.Spectators.Find(x => x.User.UserId == user.UserId); game.Spectators.Remove(player); game.SpectatorCount--; } if (wasCurrentCommander) { if (game.HasRounds()) { Entities.GameRound current = game.CurrentRound(); if (!current.HasWinner()) { game.Rounds.Remove(current); game.RoundCount--; Entities.Filters.GameRound.Delete deleteRoundFilter = new Entities.Filters.GameRound.Delete(); deleteRoundFilter.GameRoundID = current.GameRoundID; _deleteRound.Execute(deleteRoundFilter); } } Boolean started = false; if (game.PlayerCount > 0) { started = _startRound.Execute(game, game.NextCommander(null)); } if (game.HasRounds() && started) { _sendMessage.CommanderLeft(game, user.DisplayName); } else { _sendMessage.UpdateGame(game, true); } } else if (game.IsWaiting() && wasWaiting) { _sendMessage.UpdateWaiting(game, true); } else { if (game.HasRounds()) { Entities.GameRound current = game.CurrentRound(); current.CurrentPlayerCount--; if(!game.Players.Any(x => x.Hand.Count > 0 && !current.IsCommander(x.User.UserId))) { if (!current.HasWinner() && current.Answers.Count == 0) { _dealCards.Execute(game, false); } } } _sendMessage.UpdateGame(game, true, (forcedToLeave ? (int?)user.UserId : null)); } _leaveGame.Execute(gameID, user, playerType); }
/// <summary> /// Selects a game based on supplied filter /// </summary> /// <param name="filter">Filter used to select game</param> /// <returns>A game that satisfy the supplied filter</returns> public Entities.Game Execute(Entities.Filters.Game.Select filter) { return(_selectGame.Execute(filter)); }
/// <summary> /// Removes a player from the game /// </summary> /// <param name="gameID">The ID of the game to leave</param> /// <param name="user">The user leaving the game</param> /// <param name="playerType">Type of player leaving</param> /// <param name="forcedToLeave">The player was forced to leave</param> public void Execute(Int32 gameID, Entities.User user, Entities.Enums.GamePlayerType playerType, Boolean forcedToLeave = false) { Entities.Filters.Game.Select filter = new Entities.Filters.Game.Select(); filter.GameID = gameID; filter.DataToSelect = Entities.Enums.Game.Select.Rounds | Entities.Enums.Game.Select.GamePlayerCards; Entities.Game game = _selectGame.Execute(filter); Boolean wasWaiting = game.IsWaiting(); Boolean wasCurrentCommander = game.IsCurrentCommander(user.UserId) && playerType == Entities.Enums.GamePlayerType.Player; Entities.GamePlayer player = null; if (playerType == Entities.Enums.GamePlayerType.Player) { player = game.Players.Find(x => x.User.UserId == user.UserId); game.Players.Remove(player); game.PlayerCount--; } else { player = game.Spectators.Find(x => x.User.UserId == user.UserId); game.Spectators.Remove(player); game.SpectatorCount--; } if (wasCurrentCommander) { if (game.HasRounds()) { Entities.GameRound current = game.CurrentRound(); if (!current.HasWinner()) { game.Rounds.Remove(current); game.RoundCount--; Entities.Filters.GameRound.Delete deleteRoundFilter = new Entities.Filters.GameRound.Delete(); deleteRoundFilter.GameRoundID = current.GameRoundID; _deleteRound.Execute(deleteRoundFilter); } } Boolean started = false; if (game.PlayerCount > 0) { started = _startRound.Execute(game, game.NextCommander(null)); } if (game.HasRounds() && started) { _sendMessage.CommanderLeft(game, user.DisplayName); } else { _sendMessage.UpdateGame(game, true); } } else if (game.IsWaiting() && wasWaiting) { _sendMessage.UpdateWaiting(game, true); } else { if (game.HasRounds()) { Entities.GameRound current = game.CurrentRound(); current.CurrentPlayerCount--; if (!game.Players.Any(x => x.Hand.Count > 0 && !current.IsCommander(x.User.UserId))) { if (!current.HasWinner() && current.Answers.Count == 0) { _dealCards.Execute(game, false); } } } _sendMessage.UpdateGame(game, true, (forcedToLeave ? (int?)user.UserId : null)); } _leaveGame.Execute(gameID, user, playerType); }