private bool _checkLevels(Gotchi gotchi, GotchiRequirements requirements) { int level = GotchiExperienceCalculator.GetLevel(ExperienceGroup.Default, gotchi.Experience); return(level >= requirements.MinimumLevelValue && level <= requirements.MaximumLevelValue); }
public static async Task <BattleGotchi> GenerateGotchiAsync(GotchiGenerationParameters parameters) { BattleGotchi result = new BattleGotchi(); if (!(parameters.Base is null)) { // If a base gotchi was provided, copy over some of its characteristics. result.Gotchi.BornTimestamp = parameters.Base.BornTimestamp; result.Gotchi.DiedTimestamp = parameters.Base.DiedTimestamp; result.Gotchi.EvolvedTimestamp = parameters.Base.EvolvedTimestamp; result.Gotchi.FedTimestamp = parameters.Base.FedTimestamp; } // Select a random base species to start with. Species species = parameters.Species; if (species is null) { Species[] base_species_list = await SpeciesUtils.GetBaseSpeciesAsync(); if (base_species_list.Count() > 0) { species = base_species_list.ElementAt(BotUtils.RandomInteger(0, base_species_list.Count())); } } if (!(species is null)) { result.Gotchi.SpeciesId = species.Id; } // Evolve it the given number of times. for (int i = 0; i < parameters.MaxEvolutions; ++i) { if (!await EvolveAndUpdateGotchiAsync(result.Gotchi)) { break; } } // Generate stats (if applicable). if (parameters.GenerateStats) { result.Gotchi.Experience = GotchiExperienceCalculator.ExperienceToLevel(result.Stats.ExperienceGroup, BotUtils.RandomInteger(parameters.MinLevel, parameters.MaxLevel + 1)); result.Stats = await new GotchiStatsCalculator(Global.GotchiContext).GetStatsAsync(result.Gotchi); } // Generate moveset (if applicable). if (parameters.GenerateMoveset) { result.Moves = await Global.GotchiContext.MoveRegistry.GetMoveSetAsync(result.Gotchi); } // Generate types. result.Types = await Global.GotchiContext.TypeRegistry.GetTypesAsync(result.Gotchi); // Generate a name for the gotchi. result.Gotchi.Name = (species is null ? "Wild Gotchi" : species.ShortName) + string.Format(" (Lv. {0})", result.Stats is null ? 1 : result.Stats.Level); return(result); }