Ejemplo n.º 1
0
        private ValidationResult <int> ValidateNumberOfPlayers(ValidationParameter <int> validationParameter)
        {
            var responseValidation = new ResponseValidationBuilder <int, int>()
                                     .ValidationParameter(validationParameter)
                                     .MatchBuilder(GetIntegerMatches)
                                     .TestObjectBuilder((matches, vp) => matches[0])
                                     .ErrorChecks(
                Check.ValidNumberOfPlayers)
                                     .Build();

            return(responseValidation.Validate());
        }
Ejemplo n.º 2
0
        private ValidationResult <List <Card> > ValidateCardTrade(ValidationParameter <List <Card> > validationParameter)
        {
            var responseValidation = new ResponseValidationBuilder <List <Card>, int>()
                                     .ValidationParameter(validationParameter)
                                     .MatchBuilder(GetIntegerMatches)
                                     .TestObjectBuilder((matches, vp)
                                                        => vp.Cards.Where(c => matches.Contains((int)c.CountryName)).ToList())
                                     .ErrorChecks(
                Check.ThreeSelectedFromOwnCards,
                Check.ValidSet)
                                     .Build();

            return(responseValidation.Validate());
        }
Ejemplo n.º 3
0
        private ValidationResult <Deployment> ValidateFortificationParameters(ValidationParameter <Deployment> validationParameter)
        {
            var responseValidation = new ResponseValidationBuilder <Deployment, int>()
                                     .ValidationParameter(validationParameter)
                                     .MatchBuilder(GetIntegerMatches)
                                     .TestObjectBuilder(CreateDeployment)
                                     .ErrorChecks(
                Check.ValidCountryIds,
                Check.PlayerHoldsAttackingCountry,
                Check.PlayerHoldsDeploymentCountry,
                Check.DeploymentToNeighbouringCountry,
                Check.SufficientArmies)
                                     .Build();

            return(responseValidation.Validate());
        }
Ejemplo n.º 4
0
        private ValidationResult <Deployment> ValidateArmyTransfer(ValidationParameter <Deployment> validationParameter)
        {
            var responseValidation = new ResponseValidationBuilder <Deployment, int>()
                                     .ValidationParameter(validationParameter)
                                     .MatchBuilder(GetIntegerMatches)
                                     .TestObjectBuilder((matches, vp) => new Deployment
            {
                Armies = matches[0],
                From   = vp.PreviousDeployment.From,
                To     = vp.PreviousDeployment.To
            })
                                     .ErrorChecks(
                Check.SufficientArmies)
                                     .Build();

            return(responseValidation.Validate());
        }
Ejemplo n.º 5
0
        private ValidationResult <Deployment> ValidatePreviousAttackParameters(ValidationParameter <Deployment> validationParameter)
        {
            var previousDeployment = validationParameter.PreviousDeployment;

            var responseValidation = new ResponseValidationBuilder <Deployment, int>()
                                     .ValidationParameter(validationParameter)
                                     .TestObjectBuilder((matches, vp) => vp.PreviousDeployment)
                                     .ErrorChecks(
                Check.PreviousAttackParametersExist,
                Check.SufficientArmies)
                                     .Build();

            _textbox.Write($"Repeating attack with {previousDeployment.Armies} armies from {previousDeployment.From.Name} to {previousDeployment.To.Name}");
            _textbox.Write();

            return(responseValidation.Validate());
        }