Esempio n. 1
0
 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;
         }
     }
 }
Esempio n. 2
0
        public XDDaycare(IPokePC pokePC, byte[] data)
        {
            this.pokePC = pokePC;
            this.raw = data;

            if (DaycareStatus > 0) {
                depositedPokemon = new XDPokemon(ByteHelper.SubByteArray(0x8, data, 196));
                depositedPokemon.PokeContainer = this;
            }
        }
Esempio n. 3
0
        public XDDaycare(IPokePC pokePC, byte[] data)
        {
            this.pokePC = pokePC;
            this.raw    = data;

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

            pkm.GameType      = GameType;
            pkm.PokeContainer = this;
            if (pokePC.GameSave != null)
            {
                pokePC.GameSave.OwnPokemon(pkm);
            }
            depositedPokemon    = pkm as XDPokemon;
            depositedPokemon    = pkm as XDPokemon;
            DaycareStatus       = 1;
            InitialLevel        = 0;
            InitialPurification = 0;
        }
 public IPokemon this[int index] {
     get {
         if (index == 0)
         {
             return(shadowPokemon);
         }
         else if (index - 1 >= normalPokemon.Count && index - 1 < 4)
         {
             return(null);
         }
         else
         {
             return(normalPokemon[index - 1]);
         }
     }
     set {
         pokePC.GameSave.IsChanged = true;
         IPokemon pkm = (value != null ? (value is XDPokemon ? value : value.CreateXDPokemon(((GCGameSave)GameSave).CurrentRegion)): null);
         if (pkm != null)
         {
             pkm.PokeContainer = this;
             if (pokePC.GameSave != null)
             {
                 ((GCGameSave)pokePC.GameSave).RegisterPokemon(pkm);
             }
         }
         if (index == 0)
         {
             shadowPokemon = (XDPokemon)pkm;
         }
         else if (index - 1 >= normalPokemon.Count && pkm != null)
         {
             normalPokemon.Add((XDPokemon)pkm);
         }
         else if (pkm != null)
         {
             normalPokemon[index - 1] = (XDPokemon)pkm;
         }
         else if (index - 1 < normalPokemon.Count)
         {
             normalPokemon.RemoveAt(index - 1);
         }
     }
 }
Esempio n. 9
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 XDPokemon ? value : value.CreateXDPokemon(((GCGameSave)GameSave).CurrentRegion)): null);
             if (pkm != null)
             {
                 pkm.PokeContainer = this;
                 if (pokePC.GameSave != null)
                 {
                     pokePC.GameSave.OwnPokemon(pkm);
                 }
             }
             depositedPokemon = pkm as XDPokemon;
             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());
         }
     }
 }
Esempio n. 10
0
 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;
            }
        }
Esempio n. 12
0
 public void Remove(IPokemon pokemon)
 {
     if (pokemon == depositedPokemon) {
         pokePC.GameSave.IsChanged = true;
         depositedPokemon = null;
         DaycareStatus = 0;
         InitialLevel = 0;
         InitialPurification = 0;
     }
 }
Esempio n. 13
0
 public void AddPokemon(IPokemon pokemon)
 {
     pokePC.GameSave.IsChanged = true;
     IPokemon pkm = (pokemon != null ? (pokemon is XDPokemon ? pokemon : pokemon.CreateXDPokemon(((GCGameSave)GameSave).CurrentRegion)): null);
     pkm.GameType = GameType;
     pkm.PokeContainer = this;
     if (pokePC.GameSave != null)
         pokePC.GameSave.OwnPokemon(pkm);
     depositedPokemon = pkm as XDPokemon;
     depositedPokemon = pkm as XDPokemon;
     DaycareStatus = 1;
     InitialLevel = 0;
     InitialPurification = 0;
 }
Esempio n. 14
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 XDPokemon ? value : value.CreateXDPokemon(((GCGameSave)GameSave).CurrentRegion)): null);
                    if (pkm != null) {
                        pkm.PokeContainer = this;
                        if (pokePC.GameSave != null)
                            pokePC.GameSave.OwnPokemon(pkm);
                    }
                    depositedPokemon = pkm as XDPokemon;
                    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());
            }
        }
        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);
                    }
                }
            }
        }
Esempio n. 16
0
        public XDPokemon CreateXDPokemon(GCRegions currentRegion, bool passFinder = true)
        {
            XDPokemon pkm = new XDPokemon();

            if (passFinder)
                pkm.PokemonFinder = PokemonFinder;
            pkm.GameType = GameTypes.XD;
            pkm.DeoxysForm = DeoxysForm;
            pkm.Language = Language;
            pkm.CurrentRegion = currentRegion;
            pkm.OriginalRegion = OriginalRegion;

            // Pokemon Info
            pkm.Personality = Personality;
            pkm.SpeciesID = SpeciesID;
            pkm.IsSecondAbility2 = IsSecondAbility2;
            pkm.IsEgg = IsEgg;

            // Met Info
            pkm.TrainerName = TrainerName;
            pkm.TrainerGender = TrainerGender;
            pkm.TrainerID = TrainerID;
            pkm.SecretID = SecretID;
            pkm.BallCaughtID = BallCaughtID;
            pkm.LevelMet = LevelMet;
            pkm.MetLocationID = MetLocationID;
            pkm.EncounterType = EncounterType;
            pkm.IsObedient = IsObedient;
            pkm.GameOrigin = GameOrigin;

            // Personalization Info
            pkm.Nickname = Nickname;
            pkm.HeldItemID = HeldItemID;
            pkm.Markings = Markings;

            // Stats Info
            pkm.Experience = Experience;
            pkm.Friendship = Friendship;

            pkm.HPEV = HPEV;
            pkm.AttackEV = AttackEV;
            pkm.DefenseEV = DefenseEV;
            pkm.SpeedEV = SpeedEV;
            pkm.SpAttackEV = SpAttackEV;
            pkm.SpDefenseEV = SpDefenseEV;

            pkm.HPIV = HPIV;
            pkm.AttackIV = AttackIV;
            pkm.DefenseIV = DefenseIV;
            pkm.SpeedIV = SpeedIV;
            pkm.SpAttackIV = SpAttackIV;
            pkm.SpDefenseIV = SpDefenseIV;

            // Status Info
            pkm.StatusCondition = StatusConditionFlags.None;
            pkm.TurnsOfSleepRemaining = 0;
            pkm.TurnsOfBadPoison = 0;
            pkm.PokerusStrain = PokerusStrain;
            pkm.PokerusDaysRemaining = PokerusDaysRemaining;
            pkm.PokerusRemaining = PokerusRemaining;

            // Contest Info
            pkm.Coolness = Coolness;
            pkm.Beauty = Beauty;
            pkm.Cuteness = Cuteness;
            pkm.Smartness = Smartness;
            pkm.Toughness = Toughness;
            pkm.Feel = Feel;

            pkm.CoolRibbonCount = CoolRibbonCount;
            pkm.BeautyRibbonCount = BeautyRibbonCount;
            pkm.CuteRibbonCount = CuteRibbonCount;
            pkm.SmartRibbonCount = SmartRibbonCount;
            pkm.ToughRibbonCount = ToughRibbonCount;
            pkm.HasChampionRibbon = HasChampionRibbon;
            pkm.HasWinningRibbon = HasWinningRibbon;
            pkm.HasVictoryRibbon = HasVictoryRibbon;
            pkm.HasArtistRibbon = HasArtistRibbon;
            pkm.HasEffortRibbon = HasEffortRibbon;
            pkm.HasMarineRibbon = HasMarineRibbon;
            pkm.HasLandRibbon = HasLandRibbon;
            pkm.HasSkyRibbon = HasSkyRibbon;
            pkm.HasCountryRibbon = HasCountryRibbon;
            pkm.HasNationalRibbon = HasNationalRibbon;
            pkm.HasEarthRibbon = HasEarthRibbon;
            pkm.HasWorldRibbon = HasWorldRibbon;

            // Move Info
            pkm.SetMoveAt(0, GetMoveAt(0));
            pkm.SetMoveAt(1, GetMoveAt(1));
            pkm.SetMoveAt(2, GetMoveAt(2));
            pkm.SetMoveAt(3, GetMoveAt(3));

            // Recalculate Stats to make sure they're accurate
            pkm.RecalculateStats();

            return pkm;
        }