private int getPkmnEggMovesCount() { entry = WinFormsUtil.getIndex(CB_Species); byte[] input = files[entry]; pkm = new EggMoves7(input); if (pkm.Count < 1) { files[entry] = new byte[0]; return(0); } return(pkm.Count); }
public async Task <EggMoves[]> GetEggMoves(bool edited = false) { var garcEggMoves = await this.GetGarc(GarcNames.EggMoves, edited : edited); var files = await garcEggMoves.GetFiles(); var array = new EggMoves[files.Length]; for (var i = 0; i < files.Length; i++) { var file = files[i]; array[i] = EggMoves.New(this.Version); array[i].Read(file); } return(array); }
public static EggMoves[] GetArray(byte[] data, int count) { int[] ptrs = new int[count + 1]; int baseOffset = (data[1] << 8 | data[0]) - (count * 2); for (int i = 1; i < ptrs.Length; i++) { var ofs = (i - 1) * 2; ptrs[i] = (data[ofs + 1] << 8 | data[ofs]) - baseOffset; } EggMoves[] entries = new EggMoves[count + 1]; entries[0] = new EggMoves2(Array.Empty <byte>()); for (int i = 1; i < entries.Length; i++) { entries[i] = new EggMoves2(data.Skip(ptrs[i]).TakeWhile(b => b != 0xFF).ToArray()); } return(entries); }
public void LoadMoves(DatabaseConnection dbConnection, int ID, int formNum) { MySql database = dbConnection.Database; string query = "SELECT pokedex_pokemonlevelmove.LevelNum, pokedex_pokemonlevelmove.Move " + "FROM pokedex_pokemonlevelmove " + "WHERE pokedex_pokemonlevelmove.DexNum = \'" + ID + "\' " + "AND pokedex_pokemonlevelmove.FormNum = \'" + formNum + "\' " + "ORDER BY pokedex_pokemonlevelmove.MoveIndex"; foreach (DataColumnCollection column in database.RetrieveRowsEnumerable(query)) { int levelNum = column["LevelNum"].ValueString.ToInt(); int moveNum = column["Move"].ValueString.ToInt(); LevelUpMove move = new LevelUpMove(moveNum, levelNum); LevelUpMoves.Add(move); } query = "SELECT pokedex_pokemontmmove.Move " + "FROM pokedex_pokemontmmove " + "WHERE pokedex_pokemontmmove.DexNum = \'" + ID + "\' " + "AND pokedex_pokemontmmove.FormNum = \'" + formNum + "\' " + "ORDER BY pokedex_pokemontmmove.MoveIndex"; foreach (DataColumnCollection column in database.RetrieveRowsEnumerable(query)) { TMMoves.Add(column["Move"].ValueString.ToInt()); } query = "SELECT pokedex_pokemoneggmove.Move " + "FROM pokedex_pokemoneggmove " + "WHERE pokedex_pokemoneggmove.DexNum = \'" + ID + "\' " + "AND pokedex_pokemoneggmove.FormNum = \'" + formNum + "\' " + "ORDER BY pokedex_pokemoneggmove.MoveIndex"; foreach (DataColumnCollection column in database.RetrieveRowsEnumerable(query)) { EggMoves.Add(column["Move"].ValueString.ToInt()); } query = "SELECT pokedex_pokemontutormove.Move " + "FROM pokedex_pokemontutormove " + "WHERE pokedex_pokemontutormove.DexNum = \'" + ID + "\' " + "AND pokedex_pokemontutormove.FormNum = \'" + formNum + "\' " + "ORDER BY pokedex_pokemontutormove.MoveIndex"; foreach (DataColumnCollection column in database.RetrieveRowsEnumerable(query)) { TutorMoves.Add(column["Move"].ValueString.ToInt()); } query = "SELECT pokedex_pokemondwmove.Move " + "FROM pokedex_pokemondwmove " + "WHERE pokedex_pokemondwmove.DexNum = \'" + ID + "\' " + "AND pokedex_pokemondwmove.FormNum = \'" + formNum + "\' " + "ORDER BY pokedex_pokemondwmove.MoveIndex"; foreach (DataColumnCollection column in database.RetrieveRowsEnumerable(query)) { DWMoves.Add(column["Move"].ValueString.ToInt()); } query = "SELECT pokedex_pokemoneventmove.Move " + "FROM pokedex_pokemoneventmove " + "WHERE pokedex_pokemoneventmove.DexNum = \'" + ID + "\' " + "AND pokedex_pokemoneventmove.FormNum = \'" + formNum + "\' " + "ORDER BY pokedex_pokemoneventmove.MoveIndex"; foreach (DataColumnCollection column in database.RetrieveRowsEnumerable(query)) { EventMoves.Add(column["Move"].ValueString.ToInt()); } }
//public Enums.Sex GenerateLegalSex() { // if (MaleRatio + FemaleRatio <= 0) { // return Enums.Sex.Genderless; // } else if (Server.Math.Rand(0, MaleRatio + FemaleRatio) < MaleRatio) { // return Enums.Sex.Male; // } else { // return Enums.Sex.Female; // } //} public void Load(int ID, int formNum) { FormIndex = formNum; using (XmlReader reader = XmlReader.Create(Paths.DataPath + "Dex\\" + ID.ToString() + "-" + FormIndex + ".xml")) { while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { #region Basic Data case "FormName": { FormName = reader.ReadString(); } break; case "Height": { Height = reader.ReadString().ToDbl(); } break; case "Weight": { Weight = reader.ReadString().ToDbl(); } break; case "Male": { MaleRatio = reader.ReadString().ToInt(); } break; case "Female": { FemaleRatio = reader.ReadString().ToInt(); } break; case "RecruitRate": { RecruitRate = reader.ReadString().ToInt(); } break; case "BodyStyle": { string style = reader.ReadString(); if (style.IsEnum <Enums.BodyShape>()) { BodyStyle = style.ToEnum <Enums.BodyShape>(); } } break; #endregion #region Stats case "HP": { BaseHP = reader.ReadString().ToInt(); } break; case "Atk": { BaseAtk = reader.ReadString().ToInt(); } break; case "Def": { BaseDef = reader.ReadString().ToInt(); } break; case "SpAtk": { BaseSpAtk = reader.ReadString().ToInt(); } break; case "SpDef": { BaseSpDef = reader.ReadString().ToInt(); } break; case "Speed": { BaseSpeed = reader.ReadString().ToInt(); } break; #endregion #region Pokemon Info case "Type1": { Type1 = reader.ReadString().ToEnum <Enums.Element>(); } break; case "Type2": { Type2 = reader.ReadString().ToEnum <Enums.Element>(); } break; case "Ability1": { Ability1 = reader.ReadString(); } break; case "Ability2": { Ability2 = reader.ReadString(); } break; case "Ability3": { Ability3 = reader.ReadString(); } break; case "Exp": { ExpYield = reader.ReadString().ToInt(); } break; #endregion #region Moves case "LevelUpMove": { if (reader.Read()) { int level = reader.ReadElementString("Level").ToInt(-1); int move = GameData.GetMove(reader.ReadElementString("Name")); if (level > -1 && move > -1) { LevelUpMoves.Add(new LevelUpMove(move, level)); } } } break; case "TMMove": { if (reader.Read()) { int move = GameData.GetMove(reader.ReadElementString("Name")); if (move > -1) { TMMoves.Add(move); } } } break; case "EggMove": { if (reader.Read()) { int move = GameData.GetMove(reader.ReadElementString("Name")); if (move > -1) { EggMoves.Add(move); } } } break; case "DWMove": { if (reader.Read()) { int move = GameData.GetMove(reader.ReadElementString("Name")); if (move > -1) { DWMoves.Add(move); } } } break; case "TutorMove": { if (reader.Read()) { int move = GameData.GetMove(reader.ReadElementString("Name")); if (move > -1) { TutorMoves.Add(move); } } } break; case "EventMove": { if (reader.Read()) { int move = GameData.GetMove(reader.ReadElementString("Name")); if (move > -1) { EventMoves.Add(move); } } } break; #endregion } } } } }