public async Task Bulbasaur() { PokemonInfoTable pokeInfo = await ORASConfig.GameConfig.GetPokemonInfo(); TmsHms tmsHms = await ORASConfig.GameConfig.GetTmsHms(); PokemonInfo nullInfo = pokeInfo[0]; PokemonInfo bulbasaurInfo = pokeInfo[Species.Bulbasaur]; Assert.AreNotEqual(nullInfo, bulbasaurInfo, "Species info for Bulbasaur is the same as Null/Egg"); Assert.AreEqual(6.9, bulbasaurInfo.WeightKg, "Species weight for Bulbasaur doesn't match the Pokedex!"); Assert.AreEqual(0.7, bulbasaurInfo.HeightM, "Species height for Bulbasaur doesn't match the Pokedex!"); Assert.AreEqual(PokemonTypes.Grass, PokemonTypes.GetValueFrom(bulbasaurInfo.Types[0]), "Bulbasaur's primary type should be Grass!"); Assert.AreEqual(PokemonTypes.Poison, PokemonTypes.GetValueFrom(bulbasaurInfo.Types[1]), "Bulbasaur's secondary type should be Poison!"); TestContext.Out.WriteLine("Bulbasaur can learn the following TMs:"); foreach (var(_, tm) in bulbasaurInfo.TmHm .Select((b, i) => (b, i)) .Where(t => t.Item1)) { string type = tm >= tmsHms.TmIds.Length ? "HM" : "TM"; int num = (type == "HM") ? (tm - 100 + 1) : (tm + 1); TestContext.Out.WriteLine($"\t{type} {num}: {tmsHms.GetMove( tm ).Name}"); } }
public async Task PokemonTypeSearcher_ReturnsTypes() { #region Arrange string name = PokemonNameMother.Name(); PokemonName pokemonName = new PokemonName() { Name = name }; var pokemonTypeRepository = new Mock <PokemonTypeRepository>(); pokemonTypeRepository .Setup(r => r.Search(It.Is <PokemonName>(n => String.Equals(n.Name, name, StringComparison.InvariantCultureIgnoreCase)))) .ReturnsAsync(PokemonTypesMother.PokemonTypes()); var pokemonTypeSearcher = new PokemonTypeSearcher(pokemonTypeRepository.Object); #endregion #region Act PokemonTypes pokemonTypes = await pokemonTypeSearcher.Execute(pokemonName); #endregion #region Assert var typesArray = pokemonTypes.Types.Select(s => s.PokemonTypeName.Name).ToArray(); Assert.Equal(typesArray, PokemonTypesMother.PokemonTypes().Types.Select(s => s.PokemonTypeName.Name).ToArray(), StringComparer.InvariantCultureIgnoreCase); #endregion }
public static async Task Main(string[] args) { string pokemonName; if (args.Any()) { pokemonName = args.First(); } else { Console.WriteLine("Enter pokemon name:"); pokemonName = Console.ReadLine(); } try { PokeApiPokemonTypeRepository pokeApiPokemonTypeRepository = new PokeApiPokemonTypeRepository(); PokemonTypeSearcher pokemonTypeSearcher = new PokemonTypeSearcher(pokeApiPokemonTypeRepository); GetPokemonTypes getPokemonType = new GetPokemonTypes(pokemonTypeSearcher); PokemonTypes pokemonTypes = await getPokemonType.Execute(pokemonName); Console.WriteLine(PokemonTypeToStringConverter.Execute(pokemonTypes)); } catch (PokemonNotFoundException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public Pokemon(PokemonId pokemonId, PokemonName pokemonName, PokemonTypes pokemonTypes, PokemonFavouriteCount pokemonFavouriteCount) { PokemonId = pokemonId; PokemonName = pokemonName; PokemonTypes = pokemonTypes; PokemonFavouriteCount = pokemonFavouriteCount; }
private static void RandomizeTypes(Random random, Pokemon poke) { var types = Enum.GetValues <PokemonTypes>(); PokemonTypes originalType = poke.Type1; PokemonTypes type; PokemonTypes type2 = PokemonTypes.None; bool validTyping; do { type = types[random.Next(0, types.Length)]; validTyping = type != PokemonTypes.None; var forceSecondType = random.Next(0, 10) > 6; if ((validTyping && poke.Type2 != PokemonTypes.None) || forceSecondType) { if (poke.Type2 != originalType || forceSecondType) { type2 = types[random.Next(0, types.Length)]; validTyping = type != PokemonTypes.None || type == type2; } else { type2 = type; } } } while (!validTyping); Logger.Log($"Type 1: {type}\n"); Logger.Log($"Type 2: {type2}\n"); poke.Type1 = type; poke.Type2 = type2; }
private void Update() { if (InputManager.clicked && !pokemonChosen) { chosen = input.Choose(PokemonTypes.Pikachu, PokemonTypes.Charmender, PokemonTypes.Bulbasaur, PokemonTypes.Squirtle); Debug.Log("you choose" + chosen); pokemonChosen = true; InputManager.clicked = false; Debug.Log("choose attack"); } else if (InputManager.clicked) { switch (chosen) { case PokemonTypes.Bulbasaur: bulba.Bulba(); break; case PokemonTypes.Charmender: charmi.Charmie(); break; case PokemonTypes.Pikachu: pika.Pika(); break; case PokemonTypes.Squirtle: squirt.Squirt(); break; default: throw new ArgumentException("Incorrect Attack"); } Debug.Log("choose attack"); InputManager.clicked = false; } }
public PokemonData(DataRow row) { this.id = (ushort)(long)row["ID"]; this.dexID = (ushort)(long)row["DexID"]; this.name = row["Name"] as string; this.pokedexEntry = row["PokedexEntry"] as string ?? ""; this.type1 = GetPokemonTypeFromString(row["Type1"] as string); this.type2 = (row["Type2"] as string == null ? this.type1 : GetPokemonTypeFromString(row["Type2"] as string)); this.ability1ID = PokemonDatabase.GetAbilityIDFromString(row["Ability1"] as string); this.ability2ID = (row["Ability2"] as string == null ? (byte)0 : PokemonDatabase.GetAbilityIDFromString(row["Ability2"] as string)); //this.ability2ID = (row["Ability2"] as string == null ? this.ability1ID : PokemonDatabase.GetAbilityIDFromString(row["Ability2"] as string)); this.eggGroup1 = GetEggGroupFromString(row["EggGroup1"] as string); this.eggGroup2 = GetEggGroupFromString(row["EggGroup2"] as string); this.experienceGroup = GetExperienceGroupFromString(row["ExperienceGroup"] as string); this.hp = (byte)(long)row["HP"]; this.attack = (byte)(long)row["Attack"]; this.defense = (byte)(long)row["Defense"]; this.spAttack = (byte)(long)row["SpAttack"]; this.spDefense = (byte)(long)row["SpDefense"]; this.speed = (byte)(long)row["Speed"]; this.genderRatio = (byte)(long)row["GenderRatio"]; this.forms = null; this.evolutions = null; this.learnableMoves = new List <LearnableMove>(); this.familyDexID = this.dexID; }
public static string Execute(PokemonTypes pokemonTypes) { return(JsonConvert.SerializeObject( new { Types = pokemonTypes.Types.Select(s => s.PokemonTypeName.Name) })); }
public async Task <PokemonTypes> Execute(PokemonName pokemonName) { PokemonTypes pokemonTypes = await _pokemonTypeRepository.Search(pokemonName); if (pokemonTypes == null) { throw new PokemonNotFoundException(pokemonName); } return(pokemonTypes); }
SkillCatolog ProtoType(string name, PokemonTypes type, int manaCost, int dps, int acc, int pp, int turns, string effect, SkillsEffect[] skillsEffect) => new SkillCatolog { Name = name, SkillType = type, ManaCost = manaCost, Dps = dps, Acc = acc, Pp = pp, Turns = turns, Effect = effect, };
private static PokemonTypes StringToEnumType(string stringType) { PokemonTypes type = PokemonTypes.Normal; foreach (PokemonTypes enumType in Enum.GetValues(typeof(PokemonTypes))) { if (stringType == enumType.ToString()) { type = enumType; } } return(type); }
public static Skill GetEmptySkill(PokemonTypes skillType) { return(new Skill { Acc = 0, Dps = 0, ManaCost = 0, Name = "Empty", Effect = "The Admin needs to meke some more skills Contect him if it takes to long", Pp = 0, SkillType = skillType, Turns = 0 }); }
public IActionResult OutputDeck(string catogorie, string value, float supValue) { switch (catogorie) { case "Index": break; case "Alle": SetPreViewDeck(GetPokemonListFromDB(PokemonTypes.Alle, _dataBase), _curentHttpContent); break; case "Type": PokemonTypes typeOf = Enum.Parse <PokemonTypes>(value); SetPreViewDeck(GetPokemonListFromDB(typeOf, _dataBase), _curentHttpContent); break; case "Generate": int.TryParse(value, out int countOfPokemon); SetPreViewDeck(GetRandomPokemonsFromDB(countOfPokemon, _dataBase), _curentHttpContent); break; case "Property": PokemonPropery propType = Enum.Parse <PokemonPropery>(value); SetPreViewDeck(GetPokemonListFromDB(propType, supValue, _dataBase), _curentHttpContent); break; case "SkillTypes": PokemonTypes typeOfSkill = Enum.Parse <PokemonTypes>(value); return(View("SkillTypes", _dataBase.Skills.ToList().FindAll(skill => skill.SkillType == typeOfSkill))); case "SingelCard": Pokemon mon = _dataBase.Pokemons.ToList().Where(p => p.Name == value).FirstOrDefault(); mon.ThisPokemonsSkills = _dataBase.Skills.ToList().Where(s => s.SkillType == mon.Type).ToList(); SetPreViewDeck(new List <Pokemon> { mon }, _curentHttpContent); return(View("SingelCardPlusSkills", mon)); default: SetPreViewDeck(null, _curentHttpContent); break; } return(View(new PlayerViewModel { ShowThisDeck = GetPreViewDeck(_curentHttpContent) })); }
public static List <Pokemon> GetPokemonListFromDB(PokemonTypes prop, SiteContext db) { List <Pokemon> newDeck = new List <Pokemon>(); Random rand = new Random(); switch (prop) { case PokemonTypes.Alle: newDeck = db.Pokemons.ToList(); GiveSkillsFromDb(newDeck, db); break; case PokemonTypes.Normal: newDeck = db.Pokemons.ToList().FindAll(pokemon => pokemon.Type == PokemonTypes.Normal); GiveSkillsFromDb(newDeck, db); break; case PokemonTypes.Fire: newDeck = db.Pokemons.ToList().FindAll(pokemon => pokemon.Type == PokemonTypes.Fire); GiveSkillsFromDb(newDeck, db); break; case PokemonTypes.Water: newDeck = db.Pokemons.ToList().FindAll(pokemon => pokemon.Type == PokemonTypes.Water); GiveSkillsFromDb(newDeck, db); break; case PokemonTypes.Electric: newDeck = db.Pokemons.ToList().FindAll(pokemon => pokemon.Type == PokemonTypes.Electric); GiveSkillsFromDb(newDeck, db); break; case PokemonTypes.Grass: newDeck = db.Pokemons.ToList().FindAll(pokemon => pokemon.Type == PokemonTypes.Grass); GiveSkillsFromDb(newDeck, db); break; case PokemonTypes.Psychic: newDeck = db.Pokemons.ToList().FindAll(pokemon => pokemon.Type == PokemonTypes.Psychic); GiveSkillsFromDb(newDeck, db); break; default: break; } return(newDeck); }
public MoveData(DataRow row) { this.id = (ushort)(long)row["ID"]; this.name = row["Name"] as string; this.description = row["Description"] as string; this.type = GetPokemonTypeFromString(row["Type"] as string); this.power = (byte)(long)row["Power"]; this.accuracy = (byte)(long)row["Accuracy"]; this.pp = (byte)(long)row["PP"]; this.category = GetMoveCategoryFromString(row["Category"] as string); this.conditionType = GetConditionTypeFromString(row["ConditionType"] as string); this.contestDescription = row["ContestDescription"] as string; this.appeal = (byte)(long)row["Appeal"]; this.jam = (byte)(long)row["Jam"]; }
public void ResetMoveData(string moveName, string description, bool recoil, bool highCritRate, bool flinch, bool contact, bool disabled, PokemonTypes type, MoveCategories category, float recoilDamage, int power) { this.moveName = moveName; this.description = description; this.recoil = recoil; this.highCritRate = highCritRate; this.flinch = flinch; this.contact = contact; this.disabled = disabled; this.type = type; this.category = category; this.recoilDamage = recoilDamage; this.basePower = power; this.curPower = this.basePower; }
private async Task <PokemonTypes> ObtainPokeDataAsync(string pokemon) { var pokemonTypeData = new PokemonTypes(); var basePokemonUrl = Configuration["PokeApiUrl"] + "pokemon/" + pokemon; using (var httpClient = new HttpClient()) { using (var response = await httpClient.GetAsync(basePokemonUrl)) { if (!response.IsSuccessStatusCode) { throw new Exception("Something went wrong when obtaining pokemon type"); } string apiResponse = await response.Content.ReadAsStringAsync(); pokemonTypeData = JsonConvert.DeserializeObject <PokemonTypes>(apiResponse); } } return(pokemonTypeData); }
public async Task List(int page, int size) { try { IsBusy = true; currentPaged = await _pokedexService.ListAsync(page, size); if (currentPaged != null) { var types = currentPaged.Results.SelectMany(x => x.Types.Select(t => t.Type.Name)).Distinct().ToList(); IEnumerable <SelectableItem <string> > selectable; if (PokemonTypes != null && PokemonTypes.Any(d => d.Selected)) { selectable = types.Select(x => new SelectableItem <string>(x, PokemonTypes.Any(s => s.Item == x && s.Selected))); } else { selectable = types.Select(x => new SelectableItem <string>(x)); } TotalItems = currentPaged.Count; FilterItems(currentPaged.Results); PokemonTypes = new ObservableRangeCollection <SelectableItem <string> >(selectable); CurrentPage = page; } } catch (Exception ex) { throw; } finally { IsBusy = false; } }
public Pokemon(string name, int ndexid, bool?missable, bool?legendary, PokemonTypes pokemontypes, string evolutionDetails, List <string> locations, List <string> notes) { Name = name; Id = new Guid(); NDexId = ndexid; IsLegendary = legendary.HasValue && legendary.Value; IsMissable = missable.HasValue && missable.Value; //PokemonTypesEnum = pokemontypes; Evolutions = new List <string> { evolutionDetails }; Locations = locations; Notes = notes; }
public async Task Search_NotFound_ReturnsNull() { #region Arrange PokeApiPokemonTypeRepository pokemonTypeRepository = new PokeApiPokemonTypeRepository(); PokemonName pokemonName = new PokemonName() { Name = PokemonNameMother.Random() }; #endregion #region Act PokemonTypes pokemonTypes = await pokemonTypeRepository.Search(pokemonName); #endregion #region Assert Assert.Null(pokemonTypes); #endregion }
public async Task Search_Found_ReturnsTypes() { #region Arrange PokeApiPokemonTypeRepository pokemonTypeRepository = new PokeApiPokemonTypeRepository(); PokemonName pokemonName = new PokemonName() { Name = PokemonNameMother.Name() }; #endregion #region Act PokemonTypes pokemonTypes = await pokemonTypeRepository.Search(pokemonName); #endregion #region Assert var typesArray = pokemonTypes.Types.Select(s => s.PokemonTypeName.Name).ToArray(); Assert.Equal(typesArray, PokemonTypesMother.PokemonTypes().Types.Select(s => s.PokemonTypeName.Name).ToArray(), StringComparer.InvariantCultureIgnoreCase); #endregion }
public Pokemon(PokemonId pokemonId, PokemonName pokemonName, PokemonTypes pokemonTypes) { PokemonId = pokemonId; PokemonName = pokemonName; PokemonTypes = pokemonTypes; }
// prototype om PokemonTempsopte geven PokemonCatolog ProtoType(string name, int hp, float height, float weight, float bmi, PokemonTypes pType) => new PokemonCatolog { Name = name, // <-- naam van PokemonTemp Type = pType, // <-- het type van de PokemonTemp PokemonPictureUrl = $"/images/Pokemon/{name}.svg", // <--- url naar de image file HealthPoints = hp, //< -- aantal hp Mana = 160, // <-- mana standaart 160 Height = height, // <-- groot van de mokemon Weight = weight, // <-- Gewicht van de mokemon BMI = bmi, // <-- BMI van de mokemon Level = new Random().Next(10, 30) };
public float AttackEffect(PokemonTypes attackerType, PokemonTypes defenderType) { return(typeChart[(int)attackerType, (int)defenderType]); }
public void SetHiddenPowerType(PokemonTypes type) { if (type < PokemonTypes.Fighting || type > PokemonTypes.Dark) return; // Invalid Hidden Power type // The minus two is because the types enum is offset by two due to including the Unknown and Normal types byte typeBits = (byte)(((int)type - 2 - 30) * 63 / 50); // The minimum value for this move type // Now we could say that we're done since we have the info to change the IVs. // But let's make sure the IVs are as close to the originals as possible. BitArray originalTypeBits = GetHiddenPowerTypeBits(); int minDeviation = ByteHelper.GetBitDeviation(ByteHelper.GetBits(typeBits), originalTypeBits); byte minDeviationTypeBits = typeBits; while (typeBits + 1 <= 0x3F && GetHiddenPowerType((byte)(typeBits + 1)) == type) { typeBits++; int newDeviation = ByteHelper.GetBitDeviation(ByteHelper.GetBits(typeBits), originalTypeBits); if (newDeviation < minDeviation) { minDeviation = newDeviation; minDeviationTypeBits = typeBits; } } SetHiddenPowerTypeBits(new BitArray(minDeviationTypeBits)); }
public override async Task RandomizeEggMoves(Random taskRandom, ProgressNotifier progressNotifier, CancellationToken token) { var config = this.ValidateAndGetConfig().EggMoves; if (!config.RandomizeEggMoves) { return; } await this.LogAsync($"======== Beginning Egg Move randomization ========{Environment.NewLine}"); progressNotifier?.NotifyUpdate(ProgressUpdate.StatusOnly("Randomizing egg moves...")); var eggMovesList = await this.Game.GetEggMoves(); var speciesInfo = await this.Game.GetPokemonInfo(edited : true); var moves = (await this.Game.GetMoves()).ToList(); var pokeNames = (await this.Game.GetTextFile(TextNames.SpeciesNames)).Lines; var moveNames = (await this.Game.GetTextFile(TextNames.MoveNames)).Lines; for (var i = 0; i < eggMovesList.Length; i++) { var name = pokeNames[speciesInfo.GetSpeciesForEntry(i)]; var species = speciesInfo[i]; var eggMoves = eggMovesList[i]; var chooseFrom = moves.ToList(); // Clone list var chooseFromSameType = chooseFrom.Where(mv => species.HasType(PokemonTypes.GetValueFrom(mv.Type))).ToList(); var preferSameType = config.FavorSameType && taskRandom.NextDouble() < (double)config.SameTypePercentage; ushort PickRandomMove() { var move = (preferSameType ? chooseFromSameType : chooseFrom).GetRandom(taskRandom); var moveId = (ushort)moves.IndexOf(move); // We have to make sure the "-----" move is not picked because it breaks the game. Ideally // we would just exclude it from the list of considered moves, but to ensure seed-compatiblity // with the previous version of the randomizer, we need to keep the list of moves exactly // the same when we pull a random one. We then replace any "-----" choices with the first real // move. if (moveId == 0) { moveId++; } return(moveId); } if (eggMoves.Empty || eggMoves.Count == 0) { continue; } await this.LogAsync($"{name}:"); progressNotifier?.NotifyUpdate(ProgressUpdate.Update($"Randomizing egg moves...\n{name}", i / (double)eggMovesList.Length)); for (var m = 0; m < eggMoves.Count; m++) { eggMoves.Moves[m] = PickRandomMove(); await this.LogAsync($" - {moveNames[ eggMoves.Moves[ m ] ]}"); } await this.LogAsync(); eggMovesList[i] = eggMoves; } await this.Game.SaveEggMoves(eggMovesList); await this.LogAsync($"======== Finished Egg Move randomization ========{Environment.NewLine}"); }
public override async Task RandomizeLearnsets(ProgressNotifier progressNotifier, CancellationToken token) { progressNotifier?.NotifyUpdate(ProgressUpdate.StatusOnly("Randomizing learnsets...")); var config = this.ValidateAndGetConfig().Learnsets; var learnsets = (await this.Game.GetLearnsets()).ToList(); var speciesInfo = await this.Game.GetPokemonInfo(edited : true); var moves = (await this.Game.GetMoves()).ToList(); var pokeNames = (await this.Game.GetTextFile(TextNames.SpeciesNames)).Lines; for (int i = 0; i < learnsets.Count; i++) { string name = pokeNames[speciesInfo.GetSpeciesForEntry(i)]; progressNotifier?.NotifyUpdate(ProgressUpdate.Update($"Randomizing learnsets...\n{name}", i / (double)learnsets.Count)); bool preferSameType; var learnset = learnsets[i]; var species = speciesInfo[i]; var chooseFrom = moves; var chooseFromSameType = chooseFrom.Where(mv => species.HasType(PokemonTypes.GetValueFrom(mv.Type))).ToList(); Move move; for (int m = 0; m < learnset.Moves.Length; m++) { preferSameType = config.FavorSameType && this.rand.Next(2) == 0; move = (preferSameType ? chooseFromSameType : chooseFrom).GetRandom(this.rand); learnset.Moves[m] = (ushort)moves.IndexOf(move); } if (config.RandomizeLevels) { learnset.Levels = learnset.Levels .Select(_ => (ushort)this.rand.Next(1, MathUtil.Clamp(config.LearnAllMovesBy, 10, 100))) .OrderBy(l => l) .ToArray(); } if (learnset.Levels.Length > 0) { // Make sure there's always at least one move on the Pokemon learnset.Levels[0] = 1; // Pick a random STAB/Normal attack move var firstMoveChoose = moves.Where(m => m.Type == PokemonTypes.Normal.Id || species.HasType(PokemonTypes.GetValueFrom(m.Type))) .Where(m => m.Category == Move.CategoryPhysical || m.Category == Move.CategorySpecial) .ToList(); move = firstMoveChoose.GetRandom(this.rand); learnset.Moves[0] = (ushort)moves.IndexOf(move); if (config.AtLeast4Moves) { if (learnset.Levels.Length < 4) { learnset.Levels = new ushort[4]; } if (learnset.Moves.Length < 4) { learnset.Moves = new ushort[4]; } // Make sure every Pokemon has at least 4 moves at level 1 for (int m = 1; m < 4; m++) { preferSameType = config.FavorSameType && this.rand.Next(2) == 0; move = (preferSameType ? chooseFromSameType : chooseFrom).GetRandom(this.rand); learnset.Levels[m] = 1; learnset.Moves[m] = (ushort)moves.IndexOf(move); } } // Go down the list and make sure there are no duplicates for (int m = learnset.Moves.Length - 1; m >= 0; m--) { while (Array.IndexOf(learnset.Moves, learnset.Moves[m], 0, m) >= 0) { preferSameType = config.FavorSameType && this.rand.Next(2) == 0; move = (preferSameType ? chooseFromSameType : chooseFrom).GetRandom(this.rand); learnset.Moves[m] = (ushort)moves.IndexOf(move); } } } learnsets[i] = learnset; } await this.Game.SaveLearnsets(learnsets); }
public override async Task RandomizeLearnsets(Random taskRandom, ProgressNotifier progressNotifier, CancellationToken token) { var config = this.ValidateAndGetConfig().Learnsets; if (!config.RandomizeLearnsets) { return; } await this.LogAsync($"======== Beginning Learnset randomization ========{Environment.NewLine}"); progressNotifier?.NotifyUpdate(ProgressUpdate.StatusOnly("Randomizing learnsets...")); var learnsets = (await this.Game.GetLearnsets()).ToList(); var speciesInfo = await this.Game.GetPokemonInfo(edited : true); var moves = (await this.Game.GetMoves()).ToList(); var pokeNames = (await this.Game.GetTextFile(TextNames.SpeciesNames)).Lines; var moveNames = (await this.Game.GetTextFile(TextNames.MoveNames)).Lines; var maxMoveNameLength = moveNames.Max(n => n.Length); for (var i = 0; i < learnsets.Count; i++) { var name = pokeNames[speciesInfo.GetSpeciesForEntry(i)]; await this.LogAsync($"{name}:"); progressNotifier?.NotifyUpdate(ProgressUpdate.Update($"Randomizing learnsets...\n{name}", i / (double)learnsets.Count)); var learnset = learnsets[i]; var species = speciesInfo[i]; var chooseFrom = moves.ToList(); // Clone list var chooseFromSameType = chooseFrom.Where(mv => species.HasType(PokemonTypes.GetValueFrom(mv.Type))).ToList(); ushort PickRandomMove() { var preferSameType = config.FavorSameType && taskRandom.NextDouble() < (double)config.SameTypePercentage; var move = (preferSameType ? chooseFromSameType : chooseFrom).GetRandom(taskRandom); var moveId = (ushort)moves.IndexOf(move); // We have to make sure the "-----" move is not picked because it breaks the game. Ideally // we would just exclude it from the list of considered moves, but to ensure seed-compatiblity // with the previous version of the randomizer, we need to keep the list of moves exactly // the same when we pull a random one. We then replace any "-----" choices with the first real // move. if (moveId == 0) { moveId++; } // Same logic as above but for One-Hit KO moves if (config.NoOneHitMoves && Legality.Moves.OneHitMoves.Contains(moveId)) { moveId++; } return(moveId); } for (var m = 0; m < learnset.Moves.Length; m++) { learnset.Moves[m] = PickRandomMove(); } if (config.RandomizeLevels) { learnset.Levels = learnset.Levels .Select(_ => (ushort)taskRandom.Next(1, MathUtil.Clamp(config.LearnAllMovesBy, 10, 100))) .OrderBy(l => l) .ToArray(); } if (learnset.Levels.Length > 0) { // Make sure there's always at least one move on the Pokemon learnset.Levels[0] = 1; // Pick a random STAB/Normal attack move var firstMoveChoose = moves.Where(m => m.Type == PokemonTypes.Normal.Id || species.HasType(PokemonTypes.GetValueFrom(m.Type))) .Where(m => m.Category == Move.CategoryPhysical || m.Category == Move.CategorySpecial) .ToList(); var move = firstMoveChoose.GetRandom(taskRandom); learnset.Moves[0] = (ushort)moves.IndexOf(move); if (config.AtLeast4Moves) { if (learnset.Levels.Length < 4) { learnset.Levels = new ushort[4]; } if (learnset.Moves.Length < 4) { learnset.Moves = new ushort[4]; } // Make sure every Pokemon has at least 4 moves at level 1 for (var m = 1; m < 4; m++) { learnset.Levels[m] = 1; learnset.Moves[m] = PickRandomMove(); } } // Go down the list and make sure there are no duplicates for (var m = learnset.Moves.Length - 1; m >= 0; m--) { while (Array.IndexOf(learnset.Moves, learnset.Moves[m], 0, m) >= 0) { learnset.Moves[m] = PickRandomMove(); } } } for (var m = 0; m < learnset.Moves.Length; m++) { await this.LogAsync($" - {moveNames[ learnset.Moves[ m ] ].PadLeft( maxMoveNameLength )} @ Lv. {learnset.Levels[ m ]}"); } await this.LogAsync(); learnsets[i] = learnset; } await this.Game.SaveLearnsets(learnsets); await this.LogAsync($"======== Finished Learnset randomization ========{Environment.NewLine}"); }
public static void CreatePokedex() { var xData = new XmlDocument(); xData.Load("Assets/pokedata_clear.xml"); XmlNodeList xPokemonList = xData.SelectNodes("pokedex/pokemon"); if (xPokemonList != null) { int progressCounter = 1; foreach (XmlNode xPokemon in xPokemonList) { if (xPokemon.Attributes != null && int.Parse(xPokemon.Attributes["id"].Value) <= 151) { var pokemonObj = ScriptableObject.CreateInstance <Pokemon>(); AssetDatabase.CreateAsset(pokemonObj, "Assets/Resources/Pokedex/" + xPokemon.Attributes["id"].Value + "_" + xPokemon.SelectSingleNode("name").InnerText + ".asset"); pokemonObj.id = int.Parse(xPokemon.Attributes["id"].Value); Sprite[] pokemonSprites = AssetDatabase.LoadAllAssetsAtPath("Assets/Sprites/Pokemons/pokemon_" + pokemonObj.id + ".png").OfType <Sprite>().ToArray(); pokemonObj.front = pokemonSprites[0]; pokemonObj.back = pokemonSprites[1]; pokemonObj.icon = pokemonSprites[2]; foreach (XmlNode xChild in xPokemon.ChildNodes) { switch (xChild.Name) { case "name": pokemonObj.name = xChild.InnerText; break; case "type": string typeString = xChild.InnerText; PokemonTypes typeEnum = StringToEnumType(typeString); pokemonObj.types.Add(typeEnum); break; case "stats": foreach (XmlNode xGrandChild in xChild.ChildNodes) { switch (xGrandChild.Name) { case "HP": pokemonObj.hp = int.Parse(xGrandChild.InnerText); break; case "SPD": pokemonObj.spd = int.Parse(xGrandChild.InnerText); break; } } break; case "evolutions": foreach (XmlNode xEvolution in xChild.ChildNodes) { if (xEvolution.Attributes != null) { var evolution = new Evolution { id = int.Parse(xEvolution.Attributes["id"].Value) }; foreach (XmlNode xEvolutionChild in xEvolution.ChildNodes) { switch (xEvolutionChild.Name) { case "name": evolution.name = xEvolutionChild.InnerText; break; case "lvl": evolution.lvl = int.Parse(xEvolutionChild.InnerText); break; } } pokemonObj.evolutions.Add(evolution); } } break; case "description": pokemonObj.description = xChild.InnerText; break; } } EditorUtility.SetDirty(pokemonObj); float prog = progressCounter / 151 - 1; EditorUtility.DisplayProgressBar("Pokedex", "Creating Pokedex " + progressCounter + " / " + 151, prog); progressCounter++; } } EditorUtility.ClearProgressBar(); } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); Debug.Log("Pokedex Created"); }
public static string Execute(PokemonTypes pokemonTypes) { return(string.Join(", ", pokemonTypes.Types.Select(s => s.PokemonTypeName.Name).ToArray())); }
private void PopulateComboBoxes() { bool oldLoaded = loaded; loaded = false; AddComparisonComboBoxItems(comboBoxHatchCounterComparison); AddComparisonComboBoxItems(comboBoxStatComparison); AddComparisonComboBoxItems(comboBoxConditionComparison); AddComparisonComboBoxItems(comboBoxIVComparison); AddComparisonComboBoxItems(comboBoxEVComparison); AddComparisonComboBoxItems(comboBoxLevelComparison); AddComparisonComboBoxItems(comboBoxFriendshipComparison); AddComparisonComboBoxItems(comboBoxHiddenPowerDamageComparison); comboBoxSpecies.Items.Clear(); for (ushort i = 1; i <= 386; i++) { AddComboBoxItem(comboBoxSpecies, PokemonDatabase.GetPokemonFromDexID(i).Name, (int)i); } comboBoxType.Items.Clear(); for (PokemonTypes i = PokemonTypes.Normal; i <= PokemonTypes.Dark; i++) { AddComboBoxItem(comboBoxType, i.ToString(), (int)i); } comboBoxNature.Items.Clear(); for (byte i = 0; i <= 24; i++) { AddComboBoxItem(comboBoxNature, PokemonDatabase.GetNatureFromID(i).Name, (int)i); } comboBoxAbility.Items.Clear(); for (byte i = 1; i <= 76; i++) { AddComboBoxItem(comboBoxAbility, PokemonDatabase.GetAbilityFromID(i).Name, (int)i); } comboBoxHeldItem.Items.Clear(); AddComboBoxItem(comboBoxHeldItem, "Any", 0); for (int i = 1; ItemDatabase.GetItemAt(i) != null; i++) { ItemData item = ItemDatabase.GetItemAt(i); if (!item.IsImportant && item.ID < 500) { AddComboBoxItem(comboBoxHeldItem, item.Name, (int)item.ID); } } comboBoxPokeBall.Items.Clear(); AddComboBoxItem(comboBoxPokeBall, "Poké Ball", 4); AddComboBoxItem(comboBoxPokeBall, "Great Ball", 3); AddComboBoxItem(comboBoxPokeBall, "Ultra Ball", 2); AddComboBoxItem(comboBoxPokeBall, "Master Ball", 1); AddComboBoxItem(comboBoxPokeBall, "Safari Ball", 5); AddComboBoxItem(comboBoxPokeBall, "Timer Ball", 10); AddComboBoxItem(comboBoxPokeBall, "Repeat Ball", 9); AddComboBoxItem(comboBoxPokeBall, "Net Ball", 6); AddComboBoxItem(comboBoxPokeBall, "Dive Ball", 7); AddComboBoxItem(comboBoxPokeBall, "Nest Ball", 8); AddComboBoxItem(comboBoxPokeBall, "Premier Ball", 12); AddComboBoxItem(comboBoxPokeBall, "Luxury Ball", 11); comboBoxRibbon.Items.Clear(); for (PokemonRibbons i = PokemonRibbons.Any; i <= PokemonRibbons.World; i++) { // Add spaces to the names string name = i.ToString(); StringBuilder newName = new StringBuilder(); foreach (char c in name) { if (char.IsUpper(c) && newName.Length > 0) { newName.Append(' '); } newName.Append(c); } AddComboBoxItem(comboBoxRibbon, newName.ToString(), (int)i); } comboBoxPokerus.Items.Clear(); AddComboBoxItem(comboBoxPokerus, "None", (int)PokerusStatuses.None); AddComboBoxItem(comboBoxPokerus, "Infected", (int)PokerusStatuses.Infected); AddComboBoxItem(comboBoxPokerus, "Cured", (int)PokerusStatuses.Cured); ComboBox[] statComboBoxes = new ComboBox[] { comboBoxStatType, comboBoxIVType, comboBoxEVType }; for (int i = 0; i < 3; i++) { statComboBoxes[i].Items.Clear(); AddComboBoxItem(statComboBoxes[i], "HP", (int)StatTypes.HP); AddComboBoxItem(statComboBoxes[i], "Attack", (int)StatTypes.Attack); AddComboBoxItem(statComboBoxes[i], "Defense", (int)StatTypes.Defense); AddComboBoxItem(statComboBoxes[i], "Sp Attack", (int)StatTypes.SpAttack); AddComboBoxItem(statComboBoxes[i], "Sp Defense", (int)StatTypes.SpDefense); AddComboBoxItem(statComboBoxes[i], "Speed", (int)StatTypes.Speed); AddComboBoxItem(statComboBoxes[i], "Any", (int)StatTypes.Any); AddComboBoxItem(statComboBoxes[i], "All", (int)StatTypes.All); AddComboBoxItem(statComboBoxes[i], "Total", (int)StatTypes.Total); } comboBoxConditionType.Items.Clear(); AddComboBoxItem(comboBoxConditionType, "Cool", (int)ConditionTypes.Cool); AddComboBoxItem(comboBoxConditionType, "Beauty", (int)ConditionTypes.Beauty); AddComboBoxItem(comboBoxConditionType, "Cute", (int)ConditionTypes.Cute); AddComboBoxItem(comboBoxConditionType, "Smart", (int)ConditionTypes.Smart); AddComboBoxItem(comboBoxConditionType, "Tough", (int)ConditionTypes.Tough); AddComboBoxItem(comboBoxConditionType, "Feel", (int)ConditionTypes.Feel); AddComboBoxItem(comboBoxConditionType, "Any", (int)ConditionTypes.Any); AddComboBoxItem(comboBoxConditionType, "All", (int)ConditionTypes.All); AddComboBoxItem(comboBoxConditionType, "Total", (int)ConditionTypes.Total); comboBoxGender.Items.Clear(); AddComboBoxItem(comboBoxGender, "Male", (int)Genders.Male); AddComboBoxItem(comboBoxGender, "Female", (int)Genders.Female); AddComboBoxItem(comboBoxGender, "Genderless", (int)Genders.Genderless); comboBoxFamily.Items.Clear(); for (ushort i = 1; i <= 386; i++) { PokemonData pokemonData = PokemonDatabase.GetPokemonFromDexID(i); if (pokemonData.FamilyDexID == i) { AddComboBoxItem(comboBoxFamily, pokemonData.Name, (int)i); } } ComboBox[] moveComboBoxes = new ComboBox[] { comboBoxMove1, comboBoxMove2, comboBoxMove3, comboBoxMove4 }; for (int i = 0; i < 4; i++) { moveComboBoxes[i].Items.Clear(); AddComboBoxItem(moveComboBoxes[i], "None", 0); for (ushort j = 1; j <= 354; j++) { AddComboBoxItem(moveComboBoxes[i], PokemonDatabase.GetMoveFromID(j).Name, (int)j); } } comboBoxHiddenPowerType.Items.Clear(); for (PokemonTypes i = PokemonTypes.Fighting; i <= PokemonTypes.Dark; i++) { AddComboBoxItem(comboBoxHiddenPowerType, i.ToString(), (int)i); } comboBoxEggGroup.Items.Clear(); for (EggGroups i = EggGroups.Field; i <= EggGroups.Ditto; i++) { AddComboBoxItem(comboBoxEggGroup, PokemonDatabase.GetEggGroupName(i), (int)i); } comboBoxEggMode.Items.Clear(); AddComboBoxItem(comboBoxEggMode, "Include Eggs", (int)EggModes.IncludeEggs); AddComboBoxItem(comboBoxEggMode, "Exclude Eggs", (int)EggModes.ExcludeEggs); AddComboBoxItem(comboBoxEggMode, "Only Eggs", (int)EggModes.OnlyEggs); comboBoxShinyMode.Items.Clear(); AddComboBoxItem(comboBoxShinyMode, "Include Shinies", (int)ShinyModes.IncludeShinies); AddComboBoxItem(comboBoxShinyMode, "Exclude Shinies", (int)ShinyModes.ExcludeShinies); AddComboBoxItem(comboBoxShinyMode, "Only Shinies", (int)ShinyModes.OnlyShinies); comboBoxShadowMode.Items.Clear(); AddComboBoxItem(comboBoxShadowMode, "Include Shadow", (int)ShadowModes.IncludeShadow); AddComboBoxItem(comboBoxShadowMode, "Exclude Shadow", (int)ShadowModes.ExcludeShadow); AddComboBoxItem(comboBoxShadowMode, "Only Shadow", (int)ShadowModes.OnlyShadow); comboBoxSortMethod.Items.Clear(); AddComboBoxItem(comboBoxSortMethod, "None", (int)SortMethods.None); AddComboBoxItem(comboBoxSortMethod, "Dex Number", (int)SortMethods.DexNumber); AddComboBoxItem(comboBoxSortMethod, "Alphabetical", (int)SortMethods.Alphabetical); AddComboBoxItem(comboBoxSortMethod, "Level", (int)SortMethods.Level); AddComboBoxItem(comboBoxSortMethod, "Friendship", (int)SortMethods.Friendship); AddComboBoxItem(comboBoxSortMethod, "Hatch Counter", (int)SortMethods.HatchCounter); AddComboBoxItem(comboBoxSortMethod, "Type", (int)SortMethods.Type); AddComboBoxItem(comboBoxSortMethod, "Hidden Power Type", (int)SortMethods.HiddenPowerType); AddComboBoxItem(comboBoxSortMethod, "Hidden Power Damage", (int)SortMethods.HiddenPowerDamage); AddComboBoxItem(comboBoxSortMethod, "Total Stats", (int)SortMethods.TotalStats); AddComboBoxItem(comboBoxSortMethod, "Total IVs", (int)SortMethods.TotalIVs); AddComboBoxItem(comboBoxSortMethod, "Total EVs", (int)SortMethods.TotalEVs); AddComboBoxItem(comboBoxSortMethod, "Total Conditions", (int)SortMethods.TotalCondition); AddComboBoxItem(comboBoxSortMethod, "Ribbon Count", (int)SortMethods.RibbonCount); AddComboBoxItem(comboBoxSortMethod, "HP", (int)SortMethods.HP); AddComboBoxItem(comboBoxSortMethod, "Attack", (int)SortMethods.Attack); AddComboBoxItem(comboBoxSortMethod, "Defense", (int)SortMethods.Defense); AddComboBoxItem(comboBoxSortMethod, "Sp Attack", (int)SortMethods.SpAttack); AddComboBoxItem(comboBoxSortMethod, "Sp Defense", (int)SortMethods.SpDefense); AddComboBoxItem(comboBoxSortMethod, "Speed", (int)SortMethods.Speed); AddComboBoxItem(comboBoxSortMethod, "HP IV", (int)SortMethods.HPIV); AddComboBoxItem(comboBoxSortMethod, "Attack IV", (int)SortMethods.AttackIV); AddComboBoxItem(comboBoxSortMethod, "Defense IV", (int)SortMethods.DefenseIV); AddComboBoxItem(comboBoxSortMethod, "Sp Attack IV", (int)SortMethods.SpAttackIV); AddComboBoxItem(comboBoxSortMethod, "Sp Defense IV", (int)SortMethods.SpDefenseIV); AddComboBoxItem(comboBoxSortMethod, "Speed IV", (int)SortMethods.SpeedIV); AddComboBoxItem(comboBoxSortMethod, "HP EV", (int)SortMethods.HPEV); AddComboBoxItem(comboBoxSortMethod, "Attack EV", (int)SortMethods.AttackEV); AddComboBoxItem(comboBoxSortMethod, "Defense EV", (int)SortMethods.DefenseEV); AddComboBoxItem(comboBoxSortMethod, "Sp Attack EV", (int)SortMethods.SpAttackEV); AddComboBoxItem(comboBoxSortMethod, "Sp Defense EV", (int)SortMethods.SpDefenseEV); AddComboBoxItem(comboBoxSortMethod, "Speed EV", (int)SortMethods.SpeedEV); AddComboBoxItem(comboBoxSortMethod, "Coolness", (int)SortMethods.Coolness); AddComboBoxItem(comboBoxSortMethod, "Beauty", (int)SortMethods.Beauty); AddComboBoxItem(comboBoxSortMethod, "Cuteness", (int)SortMethods.Cuteness); AddComboBoxItem(comboBoxSortMethod, "Smartness", (int)SortMethods.Smartness); AddComboBoxItem(comboBoxSortMethod, "Toughness", (int)SortMethods.Toughness); AddComboBoxItem(comboBoxSortMethod, "Feel", (int)SortMethods.Feel); comboBoxSortOrder.Items.Clear(); AddComboBoxItem(comboBoxSortOrder, "Highest to Lowest", (int)SortOrders.HighestToLowest); AddComboBoxItem(comboBoxSortOrder, "Lowest to Highest", (int)SortOrders.LowestToHighest); comboBoxSearchMode.Items.Clear(); AddComboBoxItem(comboBoxSearchMode, "New Search", (int)SearchModes.NewSearch); AddComboBoxItem(comboBoxSearchMode, "Add Results", (int)SearchModes.AddResults); AddComboBoxItem(comboBoxSearchMode, "Refine Results", (int)SearchModes.RefineResults); loaded = oldLoaded; }
void SetHiddenPowerType(PokemonTypes type);