Example #1
0
        public GBAPokeParty(IPokePC pokePC, byte[] data)
        {
            this.pokePC = pokePC;
            this.raw    = data;
            this.party  = new List <IPokemon>();
            uint teamSize = LittleEndian.ToUInt32(data, 0);

            for (int i = 0; i < teamSize && i < 6; i++)
            {
                GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(4 + 100 * i, data, 100));
                if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0)
                {
                    if (pkm.IsValid)
                    {
                        party.Add(pkm);
                    }
                    else
                    {
                        party.Add(GBAPokemon.CreateInvalidPokemon(pkm));
                    }
                    party[party.Count - 1].PokeContainer = this;
                }
                else
                {
                    break;
                }
            }
        }
Example #2
0
        public ManagerPokeBox(IPokePC pokePC, uint version, uint boxNumber, string name, bool usingCustom, string wallpaperName, byte[] storage)
        {
            this.pokePC               = pokePC;
            this.boxNumber            = boxNumber;
            this.name                 = name;
            this.usingCustomWallpaper = usingCustom;
            this.wallpaperName        = wallpaperName;
            this.pokemonList          = new GBAPokemon[30];

            if (version <= 1)
            {
                for (int i = 0; i < 30; i++)
                {
                    GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(i * 80, storage, 80));
                    if (!ByteHelper.CompareBytes(0, pkm.Raw))
                    {
                        if (pkm.IsValid)
                        {
                            pokemonList[i] = pkm;
                        }
                        else
                        {
                            pokemonList[i] = GBAPokemon.CreateInvalidPokemon(pkm);
                        }
                        pokemonList[i].PokeContainer = this;
                    }
                    else
                    {
                        pokemonList[i] = null;
                    }
                }
            }
            else if (version == 2)
            {
                for (int i = 0; i < 30; i++)
                {
                    GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(i * 100, storage, 80));
                    if (!ByteHelper.CompareBytes(0, pkm.Raw))
                    {
                        if (pkm.IsValid)
                        {
                            pokemonList[i] = pkm;
                            pkm.DeoxysForm = storage[i * 100 + 80];
                        }
                        else
                        {
                            pokemonList[i] = GBAPokemon.CreateInvalidPokemon(pkm);
                        }
                        pokemonList[i].PokeContainer = this;
                    }
                    else
                    {
                        pokemonList[i] = null;
                    }
                }
            }
        }
        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);
                    }
                }
            }
        }
        public GBADaycare(IPokePC pokePC, byte[] data, GameCodes gameCode)
        {
            this.gameCode = gameCode;
            this.pokePC   = pokePC;
            this.raw      = data;

            if (gameCode == GameCodes.FireRedLeafGreen)
            {
                originalPokemon = new GBAPokemon[3];
                finalPokemon    = new GBAPokemon[3];
                GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(0, raw, 80));
                if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0)
                {
                    if (pkm.IsValid)
                    {
                        originalPokemon[0] = pkm;
                    }
                    else
                    {
                        originalPokemon[0] = GBAPokemon.CreateInvalidPokemon(pkm);
                    }
                    SetFinalPokemon(0);
                }
                pkm = new GBAPokemon(ByteHelper.SubByteArray(140, raw, 80));
                if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0)
                {
                    if (pkm.IsValid)
                    {
                        originalPokemon[1] = pkm;
                    }
                    else
                    {
                        originalPokemon[1] = GBAPokemon.CreateInvalidPokemon(pkm);
                    }
                    SetFinalPokemon(1);
                }

                pkm = new GBAPokemon(ByteHelper.SubByteArray(3352, raw, 80));
                if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0)
                {
                    if (pkm.IsValid)
                    {
                        originalPokemon[2] = pkm;
                    }
                    else
                    {
                        originalPokemon[2] = GBAPokemon.CreateInvalidPokemon(pkm);
                    }
                    SetFinalPokemon(2);
                }
            }
            else if (gameCode == GameCodes.Emerald)
            {
                originalPokemon = new GBAPokemon[2];
                finalPokemon    = new GBAPokemon[2];
                GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(0, raw, 80));
                if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0)
                {
                    if (pkm.IsValid)
                    {
                        originalPokemon[0] = pkm;
                    }
                    else
                    {
                        originalPokemon[0] = GBAPokemon.CreateInvalidPokemon(pkm);
                    }
                    SetFinalPokemon(0);
                }
                pkm = new GBAPokemon(ByteHelper.SubByteArray(140, raw, 80));
                if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0)
                {
                    if (pkm.IsValid)
                    {
                        originalPokemon[1] = pkm;
                    }
                    else
                    {
                        originalPokemon[1] = GBAPokemon.CreateInvalidPokemon(pkm);
                    }
                    SetFinalPokemon(1);
                }
            }
            else if (gameCode == GameCodes.RubySapphire)
            {
                originalPokemon = new GBAPokemon[2];
                finalPokemon    = new GBAPokemon[2];
                GBAPokemon pkm = new GBAPokemon(ByteHelper.SubByteArray(0, raw, 80));
                if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0)
                {
                    if (pkm.IsValid)
                    {
                        originalPokemon[0] = pkm;
                    }
                    else
                    {
                        originalPokemon[0] = GBAPokemon.CreateInvalidPokemon(pkm);
                    }
                    SetFinalPokemon(0);
                }
                pkm = new GBAPokemon(ByteHelper.SubByteArray(80, raw, 80));
                if (pkm.DexID != 0 && pkm.Checksum != 0 && pkm.Experience != 0)
                {
                    if (pkm.IsValid)
                    {
                        originalPokemon[1] = pkm;
                    }
                    else
                    {
                        originalPokemon[1] = GBAPokemon.CreateInvalidPokemon(pkm);
                    }
                    SetFinalPokemon(1);
                }
            }
        }