ArmedCards.BusinessLogic.DomainServices.GameRound.Complete.Execute C# (CSharp) Метод

Execute() публичный Метод

Complete the current round
public Execute ( Int32 gameID, List cardIDs, Int32 userId ) : Entities.ActionResponses.RoundComplete
gameID System.Int32 The ID of the game that contains the round
cardIDs List The IDs of the winning cards
userId System.Int32 The user Id trying to complete the round
Результат Entities.ActionResponses.RoundComplete
        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;
        }