public Player Generate(Line line, AgeRange ageRange) { return GeneratePlayer(line, null, ageRange, 0); }
private int GetPersonAge(AgeRange ageRange) { return _numberRandomizer.GetNumber(ageRange.MinimumAge, ageRange.MaximumAge); }
public Player Generate(AgeRange ageRange) { return GeneratePlayer(null, null, ageRange, 0); }
private Player GeneratePlayer(Line line, Position position, AgeRange ageRange, int startNumber) { var player = new Player(); player.Name = GetPlayerName(); // A position is needed to randomly pick a player profile for a specific position. // The position can be passed into this method as an argument. // Also a line can be provided, then a position within that line will be randomly determined. // If no line and position is provided a position will be picked randomly. if (position == null) { // If no Line is provided, pick one randomly. if (line == null) { line = _listRandomizer.GetItem(_lines); } // Get random position for this line. var positions = _positions.Where(x => x.Line.Equals(line)); position = _listRandomizer.GetItem(positions); } // A Position for getting a random player profile is determined now, so get the player profile. var playerProfile = GetPlayerProfile(position); // The profile name and percentage is stored for testing purposes only. player.PlayerProfile = playerProfile.Name; // Age. if (ageRange == null) { ageRange = new AgeRange(16, 36); } var age = GetPersonAge(ageRange); player.Age = age; // Randomly calculate skill scores. player.SkillScores = startNumber > 0 ? _profileScoreCalculator.Calculate(startNumber, playerProfile, age) : _profileScoreCalculator.Calculate(playerProfile, age); foreach (var playerSkillScore in player.SkillScores) { playerSkillScore.Player = player; } // Now the skill scores for the player are determined, determine the real position for the player. // This position can be different from the position that either was passed into this method or picked randomly. var determinedPosition = _positionDeterminator.Determine(player.SkillScores); player.PreferredPosition = determinedPosition; player.Rating = PlayerRater.GetRating(player); return player; }
public Player Generate(Position position, AgeRange ageRange) { return GeneratePlayer(null, position, ageRange, 0); }