public XDPokeParty(IPokePC pokePC, byte[] data) { this.pokePC = pokePC; this.raw = data; this.party = new List <IPokemon>(); for (int i = 0; i < 6; i++) { XDPokemon xdpkm = new XDPokemon(ByteHelper.SubByteArray(i * 196, data, 196)); if (xdpkm.DexID != 0 && xdpkm.Experience != 0) { if (xdpkm.IsValid) { party.Add(xdpkm); } else { party.Add(XDPokemon.CreateInvalidPokemon(xdpkm)); } party[party.Count - 1].PokeContainer = this; } else { break; } } }
public XDPurificationChamber(IPokePC pokePC, byte chamberNumber, byte[] data) { this.pokePC = pokePC; this.raw = data; this.chamberNumber = chamberNumber; this.normalPokemon = new List <XDPokemon>(); for (int i = 0; i < 4; i++) { XDPokemon nPkm = new XDPokemon(ByteHelper.SubByteArray(i * 196, data, 196)); if (nPkm.DexID != 0 && nPkm.Experience != 0) { if (nPkm.IsInvalid) { nPkm = XDPokemon.CreateInvalidPokemon(nPkm); } normalPokemon.Add(nPkm); nPkm.PokeContainer = this; } else { break; } } XDPokemon sPkm = new XDPokemon(ByteHelper.SubByteArray(4 * 196, data, 196)); if (sPkm.DexID != 0 && sPkm.Experience != 0) { if (sPkm.IsInvalid) { sPkm = XDPokemon.CreateInvalidPokemon(sPkm); } shadowPokemon = sPkm; sPkm.PokeContainer = this; } }
public PokemonStorage(byte[] data, PokemonFormatTypes formatType, IPokeContainer container) { int formatSize = 0; this.formatType = formatType; if (formatType == PokemonFormatTypes.Gen3GBA) { formatSize = 80; if (data.Length % formatSize != 0) { throw new Exception("Pokemon Storage data size for GBA games should be divisible by 80"); } this.size = (uint)(data.Length / formatSize); for (int i = 0; i < size; i++) { GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(i * formatSize, data, formatSize)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) { Add(pkm); } else { Add(GBAPokemon.CreateInvalidPokemon(pkm)); } this[Count - 1].PokeContainer = container; } else { Add(null); } } } else if (formatType == PokemonFormatTypes.Gen3PokemonBox) { formatSize = 84; if (data.Length % formatSize != 0) { throw new Exception("Pokemon Storage data size for Pokemon Box games should be divisible by 84"); } this.size = (uint)(data.Length / formatSize); for (int i = 0; i < size; i++) { BoxPokemon pkm = new BoxPokemon(ByteHelper.SubByteArray(i * formatSize, data, formatSize)); if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0) { if (pkm.IsValid) { Add(pkm); } else { Add(BoxPokemon.CreateInvalidPokemon(pkm)); } this[Count - 1].PokeContainer = container; } else { Add(null); } } } else if (formatType == PokemonFormatTypes.Gen3Colosseum) { formatSize = 312; if (data.Length % formatSize != 0) { throw new Exception("Pokemon Storage data size for Colosseum should be divisible by 312"); } this.size = (uint)(data.Length / formatSize); for (int i = 0; i < size; i++) { ColosseumPokemon colopkm = new ColosseumPokemon(ByteHelper.SubByteArray(i * formatSize, data, formatSize)); if (colopkm.DexID != 0 && colopkm.Experience != 0) { if (colopkm.IsValid) { Add(colopkm); } else { Add(ColosseumPokemon.CreateInvalidPokemon(colopkm)); } this[Count - 1].PokeContainer = container; } else { Add(null); } } } else if (formatType == PokemonFormatTypes.Gen3XD) { formatSize = 196; if (data.Length % formatSize != 0) { throw new Exception("Pokemon Storage data size for XD should be divisible by 196"); } this.size = (uint)(data.Length / formatSize); for (int i = 0; i < size; i++) { XDPokemon xdpkm = new XDPokemon(ByteHelper.SubByteArray(i * formatSize, data, formatSize)); if (xdpkm.DexID != 0 && xdpkm.Experience != 0) { if (xdpkm.IsValid) { Add(xdpkm); } else { Add(XDPokemon.CreateInvalidPokemon(xdpkm)); } this[Count - 1].PokeContainer = container; } else { Add(null); } } } }