public ColosseumPokeParty(IPokePC pokePC, byte[] data)
 {
     this.pokePC = pokePC;
     this.raw    = data;
     this.party  = new List <IPokemon>();
     for (int i = 0; i < 6; i++)
     {
         ColosseumPokemon colopkm = new ColosseumPokemon(ByteHelper.SubByteArray(312 * i, data, 312));
         if (colopkm.DexID != 0 && colopkm.Experience != 0)
         {
             if (colopkm.IsValid)
             {
                 party.Add(colopkm);
             }
             else
             {
                 party.Add(ColosseumPokemon.CreateInvalidPokemon(colopkm));
             }
             party[party.Count - 1].PokeContainer = this;
         }
         else
         {
             break;
         }
     }
 }
        public ColosseumDaycare(IPokePC pokePC, byte[] data)
        {
            this.pokePC = pokePC;
            this.raw    = data;

            if (DaycareStatus > 0)
            {
                depositedPokemon = new ColosseumPokemon(ByteHelper.SubByteArray(0x8, data, 312));
                depositedPokemon.PokeContainer = this;
            }
        }
 public void Remove(IPokemon pokemon)
 {
     if (pokemon == depositedPokemon)
     {
         pokePC.GameSave.IsChanged = true;
         depositedPokemon          = null;
         DaycareStatus             = 0;
         InitialLevel        = 0;
         InitialPurification = 0;
     }
 }
 public byte[] GetFinalData()
 {
     for (int i = 0; i < 30; i++)
     {
         ColosseumPokemon pkm = (ColosseumPokemon)pokemonStorage[i];
         if (pkm != null)
         {
             ByteHelper.ReplaceBytes(raw, 20 + i * 312, pkm.GetFinalData());
         }
         else
         {
             ByteHelper.ReplaceBytes(raw, 20 + i * 312, new byte[312]);
         }
     }
     return(raw);
 }
        public void AddPokemon(IPokemon pokemon)
        {
            pokePC.GameSave.IsChanged = true;
            IPokemon pkm = (pokemon != null ? (pokemon is ColosseumPokemon ? pokemon : pokemon.CreateColosseumPokemon(((GCGameSave)GameSave).CurrentRegion)): null);

            pkm.GameType      = GameType;
            pkm.PokeContainer = this;
            if (pokePC.GameSave != null)
            {
                pokePC.GameSave.OwnPokemon(pkm);
            }
            depositedPokemon    = pkm as ColosseumPokemon;
            depositedPokemon    = pkm as ColosseumPokemon;
            DaycareStatus       = 1;
            InitialLevel        = 0;
            InitialPurification = 0;
        }
 public IPokemon this[int index] {
     get {
         if (index == 0)
         {
             return(depositedPokemon);
         }
         else
         {
             throw new ArgumentOutOfRangeException("Index outside of bounds for Daycare", new Exception());
         }
     }
     set {
         if (index == 0)
         {
             pokePC.GameSave.IsChanged = true;
             IPokemon pkm = (value != null ? (value is ColosseumPokemon ? value : value.CreateColosseumPokemon(((GCGameSave)GameSave).CurrentRegion)): null);
             if (pkm != null)
             {
                 pkm.PokeContainer = this;
                 if (pokePC.GameSave != null)
                 {
                     pokePC.GameSave.OwnPokemon(pkm);
                 }
             }
             depositedPokemon = pkm as ColosseumPokemon;
             if (depositedPokemon == null)
             {
                 DaycareStatus       = 0;
                 InitialLevel        = 0;
                 InitialPurification = 0;
             }
             else
             {
                 DaycareStatus       = 1;
                 InitialLevel        = pkm.Level;
                 InitialPurification = pkm.Purification;
             }
         }
         else
         {
             throw new ArgumentOutOfRangeException("Index outside of bounds for Daycare", new Exception());
         }
     }
 }
Пример #7
0
        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);
                    }
                }
            }
        }