Пример #1
0
        public BodyMassIndex Generate(Country country, Gender playerGender, Percentile percentile, Date dob)
        {
            // retrieve game current date
            DateTime gameDate = _game.CurrentDate;

            // get player age
            PersonAge playerAge = PersonAge.FromDate(dob, gameDate);

            playerAge = playerAge.AsRoundedYears();             // round the value to be able to filter on it.

            AbstractPercentileGrowthSet growthset = _percentileGrowthSetRepository.GetPercentileGrowthSet(playerGender);

            PercentileGrowth percentileGrowth = growthset.GetForPercentile(percentile);

            StatureForAge stature      = percentileGrowth.GetStatureForAge(playerAge);
            WeightForAge  weightForAge = percentileGrowth.GetWeightForAge(playerAge);

            return(new BodyMassIndex(stature.Stature, weightForAge.Mass));
        }
Пример #2
0
        public async Task <Player> GenerateAsync(Gender?playerGender = null, Country[] countries = null, PlayerPosition playerPosition = null)
        {
            if (playerGender == null)
            {
                playerGender = _genderGenerator.Generate();
            }

            if (countries == null)
            {
                countries = _countriesGenerator.Generate().Value;
            }

            PersonName playerName = await _nameGenerator.GenerateAsync(
                playerGender.Value,
                countries.FirstOrDefault());

            Date dob = _dobGenerator.Generate();

            PersonAge playerAge = PersonAge.FromDate(dob, _game.CurrentDate);

            Location birthLocation = await _birthLocationGenerator.GenerateAsync(countries.FirstOrDefault());

            Foot               playerFoot       = _favouriteFootGenerator.Generate();
            Percentile         percentile       = _percentileGenerator.Generate();
            BodyMassIndex      bmi              = _bmiGenerator.Generate(countries.FirstOrDefault(), playerGender.Value, percentile, dob);
            PlayerPosition     position         = _playerPositionGenerator.Generate();
            PhysicalFeatureSet playerFeatureSet = _physicalFeatureSetGenerator.Generate(position, bmi, countries.FirstOrDefault(), playerAge);

            // first name & last name => according to the player's country
            return(new PlayerBuilder()
                   .WithName(playerName)
                   .WithGender(playerGender.Value)
                   .WithBirthInfo(new BirthInfo(dob, birthLocation))
                   .WithFoot(playerFoot)
                   .WithPercentile(percentile)
                   .WithBodyMassIndex(bmi)
                   .WithPlayerPosition(position)
                   .WithFeatureSet(playerFeatureSet)
                   .WithCountries(countries)
                   .Build());
        }