ArmedCards.BusinessLogic.DomainServices.GamePlayerCard.Play.Execute C# (CSharp) Метод

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

Play a list of cards from a user's hand
public Execute ( List cardIDs, Int32 gameID, Int32 userId, System.Boolean autoPlayed ) : Entities.ActionResponses.PlayCard
cardIDs List The card IDs the user has selected
gameID System.Int32 The game ID in which the user wants to play the card
userId System.Int32 The user Id
autoPlayed System.Boolean Were these cards auto played
Результат Entities.ActionResponses.PlayCard
        public Entities.ActionResponses.PlayCard Execute(List<Int32> cardIDs, Int32 gameID, Int32 userId, Boolean autoPlayed)
        {
            Entities.ActionResponses.PlayCard playResponse = new Entities.ActionResponses.PlayCard();

            List<Entities.GamePlayerCard> cards = _selectGamePlayerCard.Execute(gameID, userId);

            //Check that the user did not play cards they do not have
            List<Int32> missedIds = CheckHand(cards, cardIDs);

            if (missedIds.Count == 0)
            {
                Entities.GameRound round = _selectGameRound.Execute(gameID, true);

                //Validate the user isn't trying to answer multiple times
                if (round.HasAnswer(userId) == false)
                {
                    //Validate the correct number of cards were played
                    if (round.ValidateCardPlayedCount(cardIDs.Count))
                    {
                        //Create GameRoundCards for played cards
                        List<Entities.GameRoundCard> playedCards = CreateRoundCards(cardIDs, userId, round.GameRoundID, gameID, autoPlayed);

                        //Insert playedCards
                        _insertGameRoundCard.Execute(playedCards);

                        if (autoPlayed)
                        {
                            playResponse.AutoPlayedSuccess = true;
                        }

                        //Select round with game cards
                        round = _selectGameRound.Execute(gameID, true);

                        //Remove cards from player's hand
                        _deleteGamePlayerCard.Execute(cardIDs, gameID, userId);

                        playResponse.CurrentRound = round;
                        playResponse.ResponseCode = Entities.ActionResponses.Enums.PlayCardResponseCode.Success;
                    }
                    else
                    {
                        playResponse.ResponseCode = Entities.ActionResponses.Enums.PlayCardResponseCode.InvalidNumberOfCardsPlayed;
                    }
                }
                else
                {
                    playResponse.CurrentRound = round;
                    playResponse.ResponseCode = Entities.ActionResponses.Enums.PlayCardResponseCode.Success;
                }
            }
            else
            {
                playResponse.ResponseCode = Entities.ActionResponses.Enums.PlayCardResponseCode.InvalidCardPlayed;
            }

            return playResponse;
        }