コード例 #1
0
        internal static EncounterSlot[] getValidFriendSafari(PK6 pk6)
        {
            if (!pk6.XY)
            {
                return(null);
            }
            if (pk6.Met_Location != 148) // Friend Safari
            {
                return(null);
            }
            if (pk6.Met_Level != 30)
            {
                return(null);
            }

            IEnumerable <DexLevel> vs    = getValidPreEvolutions(pk6);
            List <EncounterSlot>   slots = new List <EncounterSlot>();

            foreach (DexLevel d in vs.Where(d => FriendSafari.Contains(d.Species) && d.Level >= 30))
            {
                var slot = new EncounterSlot
                {
                    Species  = d.Species,
                    LevelMin = 30,
                    LevelMax = 30,
                    Form     = 0,
                    Type     = SlotType.FriendSafari,
                };
                slots.Add(slot);
            }

            return(slots.Any() ? slots.ToArray() : null);
        }
コード例 #2
0
ファイル: SAV_Database.cs プロジェクト: cybercarrot/PKHeX
        private void clickSet(object sender, EventArgs e)
        {
            // Don't care what slot was clicked, just add it to the database
            if (!m_parent.verifiedPKX())
            {
                return;
            }

            PK6 pk = new PK6(m_parent.preparepkx());

            if (!Directory.Exists(DatabasePath))
            {
                Directory.CreateDirectory(DatabasePath);
            }

            string path = Path.Combine(DatabasePath, Util.CleanFileName(pk.FileName));

            if (RawDB.Any(p => p.Identifier == path))
            {
                Util.Alert("File already exists in database!");
                return;
            }

            File.WriteAllBytes(path, pk.Data.Take(PK6.SIZE_STORED).ToArray());
            pk.Identifier = path;

            RawDB.Add(pk);
            RawDB = new List <PK6>(RawDB.Distinct());     // just in case
            Results.Add(pk);
            Results = new List <PK6>(Results.Distinct()); // just in case
            // Refresh database view.
            L_Count.Text = String.Format(Counter, Results.Count);
            FillPKXBoxes(SCR_Box.Value);
            Util.Alert("Added Pokémon from tabs to database.", "Please refresh the search to ensure it shows up; it may be at the bottom of the results.");
        }
コード例 #3
0
        internal static DexLevel[] getValidPreEvolutions(PK6 pk6)
        {
            var             evos = Evolves[pk6.Species].Evos;
            int             dec  = 0;
            List <DexLevel> dl   = new List <DexLevel> {
                new DexLevel {
                    Species = pk6.Species, Level = pk6.CurrentLevel
                }
            };

            foreach (DexLevel evo in evos)
            {
                if (evo.Level == 1) // Level Up (from previous level)
                {
                    dec++;
                }
                int lvl = pk6.CurrentLevel - dec;
                if (lvl >= pk6.Met_Level && lvl > evo.Level)
                {
                    dl.Add(new DexLevel {
                        Species = evo.Species, Level = lvl
                    });
                }
            }
            return(dl.ToArray());
        }
コード例 #4
0
ファイル: SAV6.cs プロジェクト: 0ver-flow/PKHeX
        protected override void setPKM(PKM pkm)
        {
            PK6 pk6 = pkm as PK6;
            // Apply to this Save File
            int      CT   = pk6.CurrentHandler;
            DateTime Date = DateTime.Now;

            pk6.Trade(OT, TID, SID, Country, SubRegion, Gender, false, Date.Day, Date.Month, Date.Year);
            if (CT != pk6.CurrentHandler) // Logic updated Friendship
            {
                // Copy over the Friendship Value only under certain circumstances
                if (pk6.Moves.Contains(216)) // Return
                {
                    pk6.CurrentFriendship = pk6.OppositeFriendship;
                }
                else if (pk6.Moves.Contains(218)) // Frustration
                {
                    pkm.CurrentFriendship = pk6.OppositeFriendship;
                }
                else if (pk6.CurrentHandler == 1) // OT->HT, needs new Friendship/Affection
                {
                    pk6.TradeFriendshipAffection(OT);
                }
            }
            pkm.RefreshChecksum();
        }
コード例 #5
0
ファイル: Core.cs プロジェクト: 0ver-flow/PKHeX
 internal static bool getCanKnowMove(PK6 pk6, int move, int version = -1)
 {
     if (pk6.Species == 235 && !InvalidSketch.Contains(move))
     {
         return(true);
     }
     return(getValidMoves(pk6, Version: version, LVL: true, Relearn: true, Tutor: true, Machine: true).Contains(move));
 }
コード例 #6
0
ファイル: Analysis.cs プロジェクト: kawatzaki/PKHeX
 public LegalityAnalysis(PK6 pk)
 {
     pk6 = pk;
     updateRelearnLegality();
     updateMoveLegality();
     updateChecks();
     getLegalityReport();
 }
コード例 #7
0
        /// <summary>
        /// Creates an instance of <see cref="PKM"/> from the given data.
        /// </summary>
        /// <param name="data">Raw data of the Pokemon file.</param>
        /// <param name="ident">Optional identifier for the Pokemon.  Usually the full path of the source file.</param>
        /// <returns>An instance of <see cref="PKM"/> created from the given <paramref name="data"/>, or null if <paramref name="data"/> is invalid.</returns>
        public static PKM getPKMfromBytes(byte[] data, string ident = null)
        {
            checkEncrypted(ref data);
            switch (getPKMDataFormat(data))
            {
            case 1:
                var PL1 = new PokemonList1(data, PokemonList1.CapacityType.Single, data.Length == PKX.SIZE_1JLIST);
                if (ident != null)
                {
                    PL1[0].Identifier = ident;
                }
                return(PL1[0]);

            case 2:
                var PL2 = new PokemonList2(data, PokemonList2.CapacityType.Single, data.Length == PKX.SIZE_2JLIST);
                if (ident != null)
                {
                    PL2[0].Identifier = ident;
                }
                return(PL2[0]);

            case 3:
                switch (data.Length)
                {
                case PKX.SIZE_3CSTORED: return(new CK3(data, ident));

                case PKX.SIZE_3XSTORED: return(new XK3(data, ident));

                default: return(new PK3(data, ident));
                }

            case 4:
                var pk = new PK4(data, ident);
                if (!pk.Valid || pk.Sanity != 0)
                {
                    var bk = new BK4(data, ident);
                    if (bk.Valid)
                    {
                        return(bk);
                    }
                }
                return(pk);

            case 5:
                return(new PK5(data, ident));

            case 6:
                PKM pkx = new PK6(data, ident);
                if (pkx.SM)
                {
                    pkx = new PK7(data, ident);
                }
                return(pkx);

            default:
                return(null);
            }
        }
コード例 #8
0
        internal static int[] getDexNavRelearn(PK6 pk6, int skipOption)
        {
            int species = getBaseSpecies(pk6, skipOption);

            var moves = new int[1];

            moves = moves.Concat(getEggMoves(species)).ToArray();
            return(moves.Distinct().ToArray());
        }
コード例 #9
0
        private static IEnumerable <EncounterArea> getDexNavAreas(PK6 pk6)
        {
            bool alpha = pk6.Version == 26;

            if (!alpha && pk6.Version != 27)
            {
                return(new EncounterArea[0]);
            }
            return((alpha ? DexNavA : DexNavO).Where(l => l.Location == pk6.Met_Location));
        }
コード例 #10
0
        internal static IEnumerable <int> getLineage(PK6 pk6)
        {
            List <int> res = new List <int>();

            for (int i = -1; i < 2; i++)
            {
                res.Add(getBaseSpecies(pk6, i));
            }
            return(res.Distinct());
        }
コード例 #11
0
ファイル: Core.cs プロジェクト: 0ver-flow/PKHeX
        internal static EncounterSlot[] getValidWildEncounters(PK6 pk6)
        {
            List <EncounterSlot> s = new List <EncounterSlot>();

            foreach (var area in getEncounterAreas(pk6))
            {
                s.AddRange(getValidEncounterSlots(pk6, area, DexNav: pk6.AO));
            }
            return(s.Any() ? s.ToArray() : null);
        }
コード例 #12
0
        internal static int[] getValidRelearn(PK6 pk6, int skipOption)
        {
            int[] moves   = new int[1];
            int   species = getBaseSpecies(pk6, skipOption);

            moves = moves.Concat(getLVLMoves(species, 1)).ToArray();
            moves = moves.Concat(getEggMoves(species)).ToArray();
            moves = moves.Concat(getLVLMoves(species, 100)).ToArray();
            return(moves.Distinct().ToArray());
        }
コード例 #13
0
        internal static bool getEvolutionValid(PK6 pk6)
        {
            var curr = getValidPreEvolutions(pk6);
            var poss = getValidPreEvolutions(pk6, 100);

            if (SplitBreed.Contains(getBaseSpecies(pk6, 1)))
            {
                return(curr.Count() >= poss.Count() - 1);
            }
            return(curr.Count() >= poss.Count());
        }
コード例 #14
0
        internal static bool getDexNavValid(PK6 pk6)
        {
            bool alpha = pk6.Version == 26;

            if (!alpha && pk6.Version != 27)
            {
                return(false);
            }
            EncounterArea[] locs = (alpha ? DexNavA : DexNavO).Where(l => l.Location == pk6.Met_Location).ToArray();
            return(locs.Select(loc => getValidEncounterSlots(pk6, loc)).Any(slots => slots.Length > 0));
        }
コード例 #15
0
        internal static int getBaseSpecies(PK6 pk6, int skipOption)
        {
            DexLevel[] evos = Evolves[pk6.Species].Evos;
            switch (skipOption)
            {
            case -1: return(pk6.Species);

            case 1: return(evos.Length <= 1 ? pk6.Species : evos[evos.Length - 1].Species);

            default: return(evos.Length <= 0 ? pk6.Species : evos.Last().Species);
            }
        }
コード例 #16
0
        internal static IEnumerable <int> getValidRelearn(PK6 pk6, int skipOption)
        {
            List <int> r = new List <int> {
                0
            };
            int species = getBaseSpecies(pk6, skipOption);

            r.AddRange(getLVLMoves(species, 1, pk6.AltForm));
            r.AddRange(getEggMoves(species, pk6.Species == 678 ? pk6.AltForm : 0));
            r.AddRange(getLVLMoves(species, 100, pk6.AltForm));
            return(r.Distinct());
        }
コード例 #17
0
 private void B_Save_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < seen.Length; i++)
     {
         PKM tempPkm = new PK6();
         tempPkm.Species = i + 1;
         SAV.setSeen(tempPkm, seen[i]);
         SAV.setCaught(tempPkm, caught[i]);
     }
     SAV.Data.CopyTo(Main.SAV.Data, 0);
     Main.SAV.Edited = true;
     Close();
 }
コード例 #18
0
ファイル: SAV_SimplePokedex.cs プロジェクト: goofwear/PKHeX
 private void B_Save_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < seen.Length; i++)
     {
         PKM tempPkm = new PK6();
         tempPkm.Species = i + 1;
         SAV.setSeen(tempPkm, seen[i]);
         SAV.setCaught(tempPkm, caught[i]);
     }
     SAV.Data.CopyTo(Main.SAV.Data, 0);
     Main.SAV.Edited = true;
     Close();
 }
コード例 #19
0
        public void setDex(PK6 pk6)
        {
            if (pk6.Species == 0)
            {
                return;
            }

            int bit  = pk6.Species - 1;
            int lang = pk6.Language - 1; if (lang > 5)
            {
                lang--;                                        // 0-6 language vals
            }
            int origin   = pk6.Version;
            int gender   = pk6.Gender % 2; // genderless -> male
            int shiny    = pk6.IsShiny ? 1 : 0;
            int shiftoff = (shiny * 0x60 * 2) + (gender * 0x60) + 0x60;

            // Set the [Species/Gender/Shiny] Owned Flag
            Data[PokeDex + shiftoff + bit / 8 + 0x8] |= (byte)(1 << (bit % 8));

            // Owned quality flag
            if (origin < 0x18 && bit < 649 && !ORAS) // Species: 1-649 for X/Y, and not for ORAS; Set the Foreign Owned Flag
            {
                Data[PokeDex + 0x64C + bit / 8] |= (byte)(1 << (bit % 8));
            }
            else if (origin >= 0x18 || ORAS) // Set Native Owned Flag (should always happen)
            {
                Data[PokeDex + bit / 8 + 0x8] |= (byte)(1 << (bit % 8));
            }

            // Set the Display flag if none are set
            bool[] chk =
            {
                // Flag Regions (base index 1 to reference Wiki and editor)
                (Data[PokeDex + 0x60 * (5) + bit / 8 + 0x8] & (byte)(1 << (bit % 8))) != 0,
                (Data[PokeDex + 0x60 * (6) + bit / 8 + 0x8] & (byte)(1 << (bit % 8))) != 0,
                (Data[PokeDex + 0x60 * (7) + bit / 8 + 0x8] & (byte)(1 << (bit % 8))) != 0,
                (Data[PokeDex + 0x60 * (8) + bit / 8 + 0x8] & (byte)(1 << (bit % 8))) != 0,
            };
            if (!chk.Contains(true)) // offset is already biased by 0x60, reuse shiftoff but for the display flags.
            {
                Data[PokeDex + shiftoff + 0x60 * (4) + bit / 8 + 0x8] |= (byte)(1 << (bit % 8));
            }

            // Set the Language
            if (lang < 0)
            {
                lang = 1;
            }
            Data[PokeDex + PokeDexLanguageFlags + (bit * 7 + lang) / 8] |= (byte)(1 << (((bit * 7) + lang) % 8));
        }
コード例 #20
0
        internal static EncounterSlot[] getValidEncounterSlots(PK6 pk6, EncounterArea loc)
        {
            // Get Valid levels
            DexLevel[] vs = getValidPreEvolutions(pk6);
            // Get slots where pokemon can exist
            EncounterSlot[] slots = loc.Slots.Where(slot => vs.Any(evo => evo.Species == slot.Species && evo.Level >= slot.LevelMin)).ToArray();

            // Filter for Form Specific
            if (WildForms.Contains(pk6.Species))
            {
                slots = slots.Where(slot => slot.Form == pk6.AltForm).ToArray();
            }
            return(slots);
        }
コード例 #21
0
ファイル: f4-RibbMedal.cs プロジェクト: kawatzaki/PKHeX
        public RibbMedal()
        {
            InitializeComponent();
            pk6 = Main.pk6; // cache copy
            pba = new[] {
                PB_10, PB_11, PB_12, PB_13,
                PB_14, PB_15, PB_16, PB_17,

                PB_20, PB_21, PB_22, PB_23,
                PB_24, PB_25, PB_26, PB_27,

                PB_30, PB_31, PB_32, PB_33,
                PB_34, PB_35, PB_36, PB_37,

                PB_40, PB_41, PB_42, PB_43,
                PB_44, PB_45, PB_46, PB_47,

                PB_50, PB_51, PB_52, PB_53,
                PB_54,

                PB_57,
                PB_O0, PB_O1, PB_O2, PB_O3, PB_O4, PB_O5,
            };
            cba = new [] {
                Kalos1a_0, Kalos1a_1, Kalos1a_2, Kalos1a_3, Kalos1a_4, Kalos1a_5, Kalos1a_6, Kalos1a_7,
                Kalos1b_0, Kalos1b_1, Kalos1b_2, Kalos1b_3, Kalos1b_4, Kalos1b_5, Kalos1b_6, Kalos1b_7,
                Kalos2a_0, Kalos2a_1, Kalos2a_2, Kalos2a_3, Kalos2a_4, Kalos2a_5, Kalos2a_6, Kalos2a_7,
                Kalos2b_0, Kalos2b_1, Kalos2b_2, Kalos2b_3, Kalos2b_4, Kalos2b_5, Kalos2b_6, Kalos2b_7,
                Extra1_0, Extra1_1, Extra1_2, Extra1_3, Extra1_4,

                Extra1_7, ORAS_0, ORAS_1, ORAS_2, ORAS_3, ORAS_4, ORAS_5,
            };
            bma = new Image[pba.Length];
            for (int i = 0; i < bma.Length; i++)
            {
                bma[i]       = pba[i].Image;
                pba[i].Image = Util.ChangeOpacity(bma[i], 0.1);
            }
            Util.TranslateInterface(this, Main.curlanguage);

            // Set up Training Bag Data
            CB_Bag.Items.Clear();
            CB_Bag.Items.Add("---");
            for (int i = 1; i < Main.trainingbags.Length - 1; i++)
            {
                CB_Bag.Items.Add(Main.trainingbags[i]);
            }

            getData();
        }
コード例 #22
0
ファイル: SAV_Database.cs プロジェクト: Tzukkeli/PKHeX
        private void clickSet(object sender, EventArgs e)
        {
            // Don't care what slot was clicked, just add it to the database
            if (!m_parent.verifiedPKX())
            {
                return;
            }

            PK6 pk = m_parent.preparepkx();

            if (!Directory.Exists(DatabasePath))
            {
                Directory.CreateDirectory(DatabasePath);
            }

            string path = Path.Combine(DatabasePath, Util.CleanFileName(pk.FileName));

            if (RawDB.Any(p => p.Identifier == path))
            {
                Util.Alert("File already exists in database!");
                return;
            }

            File.WriteAllBytes(path, pk.Data.Take(PK6.SIZE_STORED).ToArray());
            pk.Identifier = path;

            int pre = RawDB.Count;

            RawDB.Add(pk);
            RawDB = new List <PK6>(RawDB.Distinct()); // just in case
            int post = RawDB.Count;

            if (pre == post)
            {
                Util.Alert("Pokémon already exists in database."); return;
            }
            Results.Add(pk);

            // Refresh database view.
            L_Count.Text = string.Format(Counter, Results.Count);
            slotSelected = Results.Count - 1;
            slotColor    = Properties.Resources.slotSet;
            if ((SCR_Box.Maximum + 1) * 6 < Results.Count)
            {
                SCR_Box.Maximum += 1;
            }
            SCR_Box.Value = Math.Max(0, SCR_Box.Maximum - PKXBOXES.Length / 6 + 1);
            FillPKXBoxes(SCR_Box.Value);
            Util.Alert("Added Pokémon from tabs to database.");
        }
コード例 #23
0
ファイル: frmReport.cs プロジェクト: shiaozzzz/PKHeX
        public void PopulateData(byte[] InputData, int BoxDataOffset)
        {
            SaveData = (byte[])InputData.Clone();
            PokemonList PL = new PokemonList();

            BoxBar.Maximum = 930 + 100;
            BoxBar.Step    = 1;
            for (int BoxNum = 0; BoxNum < 31; BoxNum++)
            {
                int boxoffset = BoxDataOffset + BoxNum * (0xE8 * 30);
                for (int SlotNum = 0; SlotNum < 30; SlotNum++)
                {
                    BoxBar.PerformStep();
                    int    offset   = boxoffset + 0xE8 * SlotNum;
                    byte[] slotdata = new byte[0xE8];
                    Array.Copy(SaveData, offset, slotdata, 0, 0xE8);
                    byte[] dslotdata = PKX.decryptArray(slotdata);
                    if (BitConverter.ToUInt16(dslotdata, 0x8) == 0)
                    {
                        continue;
                    }
                    string Identifier = String.Format("B{0}:{1}", (BoxNum + 1).ToString("00"), (SlotNum + 1).ToString("00"));
                    PK6    pkm        = new PK6(dslotdata, Identifier);
                    if ((pkm.EncryptionConstant == 0) && (pkm.Species == 0))
                    {
                        continue;
                    }
                    if (pkm.Checksum != pkm.CalculateChecksum())
                    {
                        continue;
                    }
                    PL.Add(new Preview(pkm));
                }
            }
            dgData.DataSource          = PL;
            dgData.AutoGenerateColumns = true;
            BoxBar.Maximum             = 930 + dgData.Columns.Count;
            for (int i = 0; i < dgData.Columns.Count; i++)
            {
                BoxBar.PerformStep();
                if (dgData.Columns[i] is DataGridViewImageColumn)
                {
                    continue;                                               // Don't add sorting for Sprites
                }
                dgData.Columns[i].SortMode = DataGridViewColumnSortMode.Automatic;
            }
            BoxBar.Visible = false;
        }
コード例 #24
0
 public LegalityAnalysis(PKM pk)
 {
     if (!(pk is PK6))
     {
         return;
     }
     pk6 = (PK6)pk;
     try
     {
         updateRelearnLegality();
         updateMoveLegality();
         updateChecks();
         getLegalityReport();
     }
     catch { Valid = false; }
 }
コード例 #25
0
        private static int getBaseSpecies(PK6 pk6, int skipOption = 0)
        {
            if (pk6.Species == 292)
            {
                return(290);
            }
            DexLevel[] evos = Evolves[pk6.Species].Evos;
            switch (skipOption)
            {
            case -1: return(pk6.Species);

            case 1: return(evos.Length <= 1 ? pk6.Species : evos[evos.Length - 2].Species);

            default: return(evos.Length <= 0 ? pk6.Species : evos.Last().Species);
            }
        }
コード例 #26
0
        public void setPK6Stored(PK6 pk6, int offset, bool?trade = null, bool?dex = null)
        {
            if (trade ?? SetUpdatePK6)
            {
                setPK6(pk6);
            }
            if (dex ?? SetUpdateDex)
            {
                setDex(pk6);
            }

            byte[] ek6 = encryptArray(pk6.Data);
            Array.Resize(ref ek6, PK6.SIZE_STORED);
            setData(ek6, offset);
            Edited = true;
        }
コード例 #27
0
        public void setPK6Party(PK6 pk6, int offset, bool?trade = null, bool?dex = null)
        {
            if (SetUpdatePK6 || (trade ?? false))
            {
                setPK6(pk6);
            }
            if (SetUpdateDex || (dex ?? false))
            {
                setDex(pk6);
            }

            byte[] ek6 = encryptArray(pk6.Data);
            Array.Resize(ref ek6, PK6.SIZE_PARTY);
            setData(ek6, offset);
            Edited = true;
        }
コード例 #28
0
        public void setEK6Stored(byte[] ek6, int offset, bool?trade = null, bool?dex = null)
        {
            PK6 pk6 = new PK6(decryptArray(ek6));

            if (SetUpdatePK6 || (trade ?? false))
            {
                setPK6(pk6);
            }
            if (SetUpdateDex || (dex ?? false))
            {
                setDex(pk6);
            }

            Array.Resize(ref ek6, PK6.SIZE_STORED);
            setData(ek6, offset);
            Edited = true;
        }
コード例 #29
0
ファイル: Core.cs プロジェクト: 0ver-flow/PKHeX
        private static IEnumerable <int> getValidMoves(PK6 pk6, int Version, bool LVL = false, bool Relearn = false, bool Tutor = false, bool Machine = false)
        {
            List <int> r = new List <int> {
                0
            };
            int  species    = pk6.Species;
            int  lvl        = pk6.CurrentLevel;
            bool ORASTutors = Version == -1 || pk6.AO || !pk6.IsUntraded;

            if (FormChangeMoves.Contains(species)) // Deoxys & Shaymin & Giratina (others don't have extra but whatever)
            {
                int formcount = PersonalTable.AO[species].FormeCount;

                for (int i = 0; i < formcount; i++)
                {
                    r.AddRange(getMoves(species, lvl, i, ORASTutors, Version, LVL, Tutor, Machine));
                }
                if (Relearn)
                {
                    r.AddRange(pk6.RelearnMoves);
                }
                return(r.Distinct().ToArray());
            }

            r.AddRange(getMoves(species, lvl, pk6.AltForm, ORASTutors, Version, LVL, Tutor, Machine));
            IEnumerable <DexLevel> vs = getValidPreEvolutions(pk6);

            foreach (DexLevel evo in vs)
            {
                r.AddRange(getMoves(evo.Species, evo.Level, pk6.AltForm, ORASTutors, Version, LVL, Tutor, Machine));
            }
            if (species == 479) // Rotom
            {
                r.Add(RotomMoves[pk6.AltForm]);
            }
            if (species == 25) // Pikachu
            {
                r.Add(PikachuMoves[pk6.AltForm]);
            }

            if (Relearn)
            {
                r.AddRange(pk6.RelearnMoves);
            }
            return(r.Distinct().ToArray());
        }
コード例 #30
0
        private static IEnumerable <DexLevel> getValidPreEvolutions(PK6 pk6, int lvl = -1)
        {
            if (lvl < 0)
            {
                lvl = pk6.CurrentLevel;
            }
            if (pk6.Species == 292 && pk6.Met_Level + 1 <= lvl && lvl >= 20)
            {
                return new List <DexLevel>
                       {
                           new DexLevel {
                               Species = 292, Level = lvl
                           },
                           new DexLevel {
                               Species = 290, Level = lvl - 1
                           }
                       }
            }
            ;
            var             evos = Evolves[pk6.Species].Evos;
            List <DexLevel> dl   = new List <DexLevel> {
                new DexLevel {
                    Species = pk6.Species, Level = lvl
                }
            };

            foreach (DexLevel evo in evos)
            {
                if (lvl >= pk6.Met_Level && lvl >= evo.Level)
                {
                    dl.Add(new DexLevel {
                        Species = evo.Species, Level = lvl
                    });
                }
                else
                {
                    break;
                }
                if (evo.Level > 1) // Level Up (from previous level)
                {
                    lvl--;
                }
            }
            return(dl);
        }
コード例 #31
0
        public void setPK6Stored(PK6 pk6, int offset, bool?trade = null, bool?dex = null)
        {
            if (pk6 == null)
            {
                return;
            }
            if (trade ?? SetUpdatePK6)
            {
                setPK6(pk6);
            }
            if (dex ?? SetUpdateDex)
            {
                setDex(pk6);
            }

            setData(pk6.EncryptedBoxData, offset);
            Edited = true;
        }
コード例 #32
0
ファイル: SAV_SimplePokedex.cs プロジェクト: goofwear/PKHeX
        public SAV_SimplePokedex()
        {
            InitializeComponent();
            Util.TranslateInterface(this, Main.curlanguage);
            seen = new bool[SAV.MaxSpeciesID];
            caught = new bool[SAV.MaxSpeciesID];

            string[] spec = Util.getSpeciesList(Main.curlanguage);
            for (int i = 0; i < seen.Length; i++)
            {
                PKM tempPkm = new PK6();
                tempPkm.Species = i + 1;
                seen[i] = SAV.getSeen(tempPkm);
                caught[i] = SAV.getCaught(tempPkm);
                CLB_Seen.Items.Add(spec[i + 1]);
                CLB_Caught.Items.Add(spec[i + 1]);
                CLB_Seen.SetItemChecked(i, seen[i]);
                CLB_Caught.SetItemChecked(i, caught[i]);
            }
            initialized = true;
        }
コード例 #33
0
ファイル: f1-Main.cs プロジェクト: CocoaHoo/PKHeX
        // Drag & Drop within Box
        private void pbBoxSlot_MouseDown(object sender, MouseEventArgs e)
        {
            if (ModifierKeys == Keys.Control || ModifierKeys == Keys.Alt || ModifierKeys == Keys.Shift || ModifierKeys == (Keys.Control | Keys.Alt))
            { clickSlot(sender, e); return; }
            PictureBox pb = (PictureBox)(sender);
            if (pb.Image == null)
                return;

            pkm_from_slot = getSlot(sender);
            int offset = getPKXOffset(pkm_from_slot);
            if (e.Button != MouseButtons.Left || e.Clicks != 1) return;
            // Create Temp File to Drag
            Cursor.Current = Cursors.Hand;

            // Prepare Data
            pkm_from = SAV.getData(offset, PK6.SIZE_STORED);
            pkm_from_offset = offset;

            // Make a new file name based off the PID
            byte[] dragdata = PKX.decryptArray(pkm_from);
            Array.Resize(ref dragdata, PK6.SIZE_STORED);
            var pkx = new PK6(dragdata, "Boxes");
            string filename = pkx.FileName;

            // Make File
            string newfile = Path.Combine(Path.GetTempPath(), Util.CleanFileName(filename));
            try
            {
                File.WriteAllBytes(newfile, dragdata);
                DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move);
            }
            catch (ArgumentException x)
            { Util.Error("Drag & Drop Error:", x.ToString()); }
            File.Delete(newfile);
            pkm_from_offset = 0;
        }
コード例 #34
0
ファイル: f1-Main.cs プロジェクト: CocoaHoo/PKHeX
        // Decrypted Export
        private void dragout_MouseDown(object sender, MouseEventArgs e)
        {
            if (!verifiedPKX()) { return; }
            {
                // Create Temp File to Drag
                Cursor.Current = Cursors.Hand;

                // Make a new file name
                byte[] dragdata = preparepkx();
                var pkx = new PK6(dragdata, "Tabs");
                string filename = Path.GetFileNameWithoutExtension(pkx.FileName) + ((e.Button == MouseButtons.Right) ? ".ek6" : ".pk6");
                dragdata = (e.Button == MouseButtons.Right) ? PKX.encryptArray(preparepkx()) : preparepkx();
                // Strip out party stats (if they are there)
                Array.Resize(ref dragdata, PK6.SIZE_STORED);
                // Make file
                string newfile = Path.Combine(Path.GetTempPath(), Util.CleanFileName(filename));
                try
                {
                    File.WriteAllBytes(newfile, dragdata);
                    DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move);
                }
                catch (Exception x)
                { Util.Error("Drag & Drop Error", x.ToString()); }
                File.Delete(newfile);
            }
        }
コード例 #35
0
        private void getQuickFiller(PictureBox pb, PK6 pk = null)
        {
            if (!fieldsInitialized) return;
            pk = pk ?? preparepkx(false); // don't perform control loss click

            if (pb == dragout) mnuLQR.Enabled = pk.Species != 0; // Species
            pb.Image = pk.Sprite;
            if (pb.BackColor == Color.Red)
                pb.BackColor = Color.Transparent;
        }
コード例 #36
0
ファイル: SAV6.cs プロジェクト: suloku/PKHeX
        public void setPK6Stored(PK6 pk6, int offset, bool? trade = null, bool? dex = null)
        {
            if (pk6 == null) return;
            if (trade ?? SetUpdatePK6)
                setPK6(pk6);
            if (dex ?? SetUpdateDex)
                setDex(pk6);

            setData(pk6.EncryptedBoxData, offset);
            Edited = true;
        }
コード例 #37
0
ファイル: SAV6.cs プロジェクト: suloku/PKHeX
        public void setEK6Stored(byte[] ek6, int offset, bool? trade = null, bool? dex = null)
        {
            if (ek6 == null) return;
            PK6 pk6 = new PK6(decryptArray(ek6));
            if (trade ?? SetUpdatePK6)
                setPK6(pk6);
            if (dex ?? SetUpdateDex)
                setDex(pk6);

            Array.Resize(ref ek6, PK6.SIZE_STORED);
            setData(ek6, offset);
            Edited = true;
        }
コード例 #38
0
ファイル: PKX.cs プロジェクト: CocoaHoo/PKHeX
 internal static string[] getShowdownText(PK6 pk6)
 {
     return getShowdownText(pk6.Nickname, pk6.Species, pk6.HeldItem, pk6.Ability, pk6.EVs, pk6.HPType, pk6.Move1, pk6.Move2, pk6.Move3, pk6.Move4);
 }
コード例 #39
0
ファイル: PKX.cs プロジェクト: suloku/PKHeX
 internal static Image getSprite(PK6 pk6)
 {
     return getSprite(pk6.Species, pk6.AltForm, pk6.Gender, pk6.HeldItem, pk6.IsEgg, pk6.IsShiny);
 }
コード例 #40
0
ファイル: SAV6.cs プロジェクト: from0tohero/PKHeX
        public void setDex(PK6 pk6)
        {
            if (PokeDex < 0) 
                return;
            if (pk6.Species == 0)
                return;

            int bit = pk6.Species - 1;
            int lang = pk6.Language - 1; if (lang > 5) lang--; // 0-6 language vals
            int origin = pk6.Version;
            int gender = pk6.Gender % 2; // genderless -> male
            int shiny = pk6.IsShiny ? 1 : 0;
            int shiftoff = shiny * 0x60 * 2 + gender * 0x60 + 0x60;

            // Set the [Species/Gender/Shiny] Owned Flag
            Data[PokeDex + shiftoff + bit / 8 + 0x8] |= (byte)(1 << (bit % 8));

            // Owned quality flag
            if (origin < 0x18 && bit < 649 && !ORAS) // Species: 1-649 for X/Y, and not for ORAS; Set the Foreign Owned Flag
                Data[PokeDex + 0x64C + bit / 8] |= (byte)(1 << (bit % 8));
            else if (origin >= 0x18 || ORAS) // Set Native Owned Flag (should always happen)
                Data[PokeDex + bit / 8 + 0x8] |= (byte)(1 << (bit % 8));

            // Set the Display flag if none are set
            bool[] chk =
            {
                // Flag Regions (base index 1 to reference Wiki and editor)
                (Data[PokeDex + 0x60*5 + bit/8 + 0x8] & (byte) (1 << (bit%8))) != 0,
                (Data[PokeDex + 0x60*6 + bit/8 + 0x8] & (byte) (1 << (bit%8))) != 0,
                (Data[PokeDex + 0x60*7 + bit/8 + 0x8] & (byte) (1 << (bit%8))) != 0,
                (Data[PokeDex + 0x60*8 + bit/8 + 0x8] & (byte) (1 << (bit%8))) != 0,
            };
            if (!chk.Contains(true)) // offset is already biased by 0x60, reuse shiftoff but for the display flags.
                Data[PokeDex + shiftoff + 0x60 * 4 + bit / 8 + 0x8] |= (byte)(1 << (bit % 8));

            // Set the Language
            if (lang < 0) lang = 1;
            Data[PokeDexLanguageFlags + (bit * 7 + lang) / 8] |= (byte)(1 << ((bit * 7 + lang) % 8));

            // Set DexNav count (only if not encountered previously)
            if (ORAS && getEncounterCount(pk6.Species - 1) == 0)
                setEncounterCount(pk6.Species - 1, 1);
        }
コード例 #41
0
ファイル: PKX.cs プロジェクト: CocoaHoo/PKHeX
 internal static string getFileName(PK6 pk6)
 {
     return
         pk6.Species.ToString("000")
         + (pk6.IsShiny ? " ★" : "")
         + " - "
         + pk6.Nickname // Rather not have language-specific.
         + " - "
         + pk6.Checksum.ToString("X4")
         + pk6.EncryptionConstant.ToString("X8")
         + ".pk6";
 }
コード例 #42
0
ファイル: WC6.cs プロジェクト: gnmmarechal/PKHeX_unleashed
        public PK6 convertToPK6(SAV6 SAV)
        {
            if (!IsPokémon)
                return null;

            int currentLevel = Level > 0 ? Level : (int)(Util.rnd32()%100 + 1);
            PK6 pk = new PK6
            {
                Species = Species,
                HeldItem = HeldItem,
                TID = TID,
                SID = SID,
                Met_Level = currentLevel,
                Nature = Nature != 0xFF ? Nature : (int)(Util.rnd32() % 25),
                Gender = PKX.Personal[Species].Gender == 255 ? 2 : (Gender != 3 ? Gender : PKX.Personal[Species].RandomGender),
                AltForm = Form,
                EncryptionConstant = EncryptionConstant == 0 ? Util.rnd32() : EncryptionConstant,
                Version = OriginGame == 0 ? SAV.Game : OriginGame,
                Language = Language == 0 ? SAV.Language : Language,
                Ball = Pokéball,
                Country = SAV.Country,
                Region = SAV.SubRegion,
                ConsoleRegion = SAV.ConsoleRegion,
                Move1 = Move1, Move2 = Move2, Move3 = Move3, Move4 = Move4,
                Move1_PP = PKX.getBasePP(Move1),
                Move2_PP = PKX.getBasePP(Move2),
                Move3_PP = PKX.getBasePP(Move3),
                Move4_PP = PKX.getBasePP(Move4),
                RelearnMove1 = RelearnMove1, RelearnMove2 = RelearnMove2,
                RelearnMove3 = RelearnMove3, RelearnMove4 = RelearnMove4,
                Met_Location = MetLocation,
                Egg_Location = EggLocation,
                CNT_Cool = CNT_Cool,
                CNT_Beauty = CNT_Beauty,
                CNT_Cute = CNT_Cute,
                CNT_Smart = CNT_Smart,
                CNT_Tough = CNT_Tough,
                CNT_Sheen = CNT_Sheen,

                OT_Name = OT.Length > 0 ? OT : SAV.OT,
                OT_Gender = OTGender != 3 ? OTGender % 2 : SAV.Gender,
                HT_Name = OT.Length > 0 ? SAV.OT : "",
                HT_Gender = OT.Length > 0 ? SAV.Gender : 0,
                CurrentHandler = OT.Length > 0 ? 1 : 0,
                
                EXP = PKX.getEXP(Level, Species),

                // Ribbons
                RIB2_6 = RIB0_3, // Country Ribbon
                RIB2_7 = RIB0_4, // National Ribbon

                RIB3_0 = RIB0_5, // Earth Ribbon
                RIB3_1 = RIB0_6, // World Ribbon
                RIB3_2 = RIB1_5, // Classic Ribbon
                RIB3_3 = RIB1_6, // Premier Ribbon
                RIB3_4 = RIB0_7, // Event Ribbon
                RIB3_5 = RIB1_1, // Birthday Ribbon
                RIB3_6 = RIB1_2, // Special Ribbon
                RIB3_7 = RIB1_3, // Souvenir Ribbon

                RIB4_0 = RIB1_4, // Wishing Ribbon
                RIB4_1 = RIB0_0, // Battle Champ Ribbon
                RIB4_2 = RIB0_1, // Regional Champ Ribbon
                RIB4_3 = RIB0_2, // National Champ Ribbon
                RIB4_4 = RIB1_0, // World Champ Ribbon
                
                OT_Friendship = PKX.getBaseFriendship(Species),
                FatefulEncounter = true,
            };

            if (Day + Month + Year == 0) // No datetime set, typical for wc6full
            {
                DateTime dt = DateTime.Now;
                pk.Met_Day = dt.Day;
                pk.Met_Month = dt.Month;
                pk.Met_Year = dt.Year - 2000;
            }
            else
            {
                pk.Met_Day = (int)Day;
                pk.Met_Month = (int)Month;
                pk.Met_Year = (int)(Year - 2000);
            }

            if (pk.CurrentHandler == 0) // OT
            {
                pk.OT_Memory = 3;
                pk.OT_TextVar = 9;
                pk.OT_Intensity = 1;
                pk.OT_Feeling = Util.rand.Next(0, 9);
            }
            else
            {
                pk.HT_Memory = 3;
                pk.HT_TextVar = 9;
                pk.HT_Intensity = 1;
                pk.HT_Feeling = Util.rand.Next(0, 9);
                pk.HT_Friendship = pk.OT_Friendship;
            }
            pk.IsNicknamed = IsNicknamed;
            pk.Nickname = IsNicknamed ? Nickname : PKX.getSpeciesName(Species, pk.Language);

            // More 'complex' logic to determine final values
            
            // Dumb way to generate random IVs.
            int[] finalIVs = new int[6];
            switch (IVs[0])
            {
                case 0xFE:
                    finalIVs[0] = 31;
                    do { // 31 HP IV, 2 other 31s
                    for (int i = 1; i < 6; i++)
                        finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i];
                    } while (finalIVs.Count(r => r == 31) < 3); // 31 + 2*31
                    break;
                case 0xFD: 
                    do { // 2 other 31s
                    for (int i = 0; i < 6; i++)
                        finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i];
                    } while (finalIVs.Count(r => r == 31) < 2); // 2*31
                    break;
                default: // Random IVs
                    for (int i = 0; i < 6; i++)
                        finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i];
                    break;
            }
            pk.IVs = finalIVs;

            int av = 0;
            switch (AbilityType)
            {
                case 00: // 0 - 0
                case 01: // 1 - 1
                case 02: // 2 - H
                    av = AbilityType;
                    break;
                case 03: // 0/1
                case 04: // 0/1/H
                    av = (int)(Util.rnd32()%(AbilityType - 1));
                    break;
            }
            pk.Ability = PKX.Personal[PKX.Personal[Species].FormeIndex(Species, pk.AltForm)].Abilities[av];
            pk.AbilityNumber = 1 << av;

            switch (PIDType)
            {
                case 00: // Specified
                    pk.PID = PID;
                    break;
                case 01: // Random
                    pk.PID = Util.rnd32();
                    break;
                case 02: // Random Shiny
                    pk.PID = Util.rnd32();
                    pk.PID = (uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF));
                    break;
                case 03: // Random Nonshiny
                    do { pk.PID = Util.rnd32(); } while ((uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF)) < 16);
                    break;
            }

            if (IsEgg)
            {
                pk.IsEgg = true;
                pk.Egg_Day = (int) Day;
                pk.Egg_Month = (int) Month;
                pk.Egg_Year = (int) Year;
            }

            pk.RefreshChecksum();
            return pk;
        }
コード例 #43
0
 // Language Translation
 private void changeMainLanguage(object sender, EventArgs e)
 {
     PK6 pk = new PK6((fieldsInitialized ? preparepkx() : pk6).Data);
     bool alreadyInit = fieldsInitialized;
     fieldsInitialized = false;
     Menu_Options.DropDown.Close();
     InitializeStrings();
     InitializeLanguage();
     Util.TranslateInterface(this, lang_val[CB_MainLanguage.SelectedIndex]); // Translate the UI to language.
     populateFields(pk); // put data back in form
     fieldsInitialized |= alreadyInit;
 }
コード例 #44
0
        // Misc Options
        private void clickShowdownImportPK6(object sender, EventArgs e)
        {
            if (!formInitialized)
                return;
            if (!Clipboard.ContainsText())
            { Util.Alert("Clipboard does not contain text."); return; }

            // Get Simulator Data
            PKX.ShowdownSet Set = new PKX.ShowdownSet(Clipboard.GetText());

            if (Set.Species < 0)
            { Util.Alert("Set data not found in clipboard."); return; }

            if (DialogResult.Yes != Util.Prompt(MessageBoxButtons.YesNo, "Import this set?", Clipboard.GetText())) 
            { return; }

            // Set Species & Nickname
            CB_Species.SelectedValue = Set.Species;
            CHK_Nicknamed.Checked = Set.Nickname != null;
            if (Set.Nickname != null)
                TB_Nickname.Text = Set.Nickname;
            if (Set.Gender != null && PKX.getGender(Set.Gender) != 2 && PKX.getGender(Set.Gender) != 2)
            {
                int Gender = PKX.getGender(Set.Gender);
                Label_Gender.Text = gendersymbols[Gender];
                Label_Gender.ForeColor = Gender == 2 ? Label_Species.ForeColor : (Gender == 1 ? Color.Red : Color.Blue);
            }

            // Set Form
            string[] formStrings = PKX.getFormList(Set.Species,
                Util.getStringList("types", "en"),
                Util.getStringList("forms", "en"), gendersymbols);
            int form = 0;
            for (int i = 0; i < formStrings.Length; i++)
                if (formStrings[i].Contains(Set.Form ?? ""))
                { form = i; break; }
            CB_Form.SelectedIndex = form;

            // Set Ability
            byte[] abilities = PKX.getAbilities(Set.Species, form);
            int ability = Array.IndexOf(abilities, (byte)Set.Ability);
            if (ability < 0) ability = 0;
            CB_Ability.SelectedIndex = ability;
            ComboBox[] m = { CB_Move1, CB_Move2, CB_Move3, CB_Move4, };
            for (int i = 0; i < 4; i++) m[i].SelectedValue = Set.Moves[i];

            // Set Item and Nature
            CB_HeldItem.SelectedValue = Set.Item < 0 ? 0 : Set.Item;
            CB_Nature.SelectedValue = Set.Nature < 0 ? 0 : Set.Nature;

            // Set IVs
            TB_HPIV.Text = Set.IVs[0].ToString();
            TB_ATKIV.Text = Set.IVs[1].ToString();
            TB_DEFIV.Text = Set.IVs[2].ToString();
            TB_SPAIV.Text = Set.IVs[3].ToString();
            TB_SPDIV.Text = Set.IVs[4].ToString();
            TB_SPEIV.Text = Set.IVs[5].ToString();

            // Set EVs
            TB_HPEV.Text = Set.EVs[0].ToString();
            TB_ATKEV.Text = Set.EVs[1].ToString();
            TB_DEFEV.Text = Set.EVs[2].ToString();
            TB_SPAEV.Text = Set.EVs[3].ToString();
            TB_SPDEV.Text = Set.EVs[4].ToString();
            TB_SPEEV.Text = Set.EVs[5].ToString();

            // Set Level and Friendship
            TB_Level.Text = Set.Level.ToString();
            TB_Friendship.Text = Set.Friendship.ToString();

            // Reset IV/EVs
            BTN_RerollPID.PerformClick();
            BTN_RerollEC.PerformClick();
            if (Set.Shiny) BTN_Shinytize.PerformClick();
            pk6 = preparepkx();
            updateLegality();
        }
コード例 #45
0
ファイル: WC6.cs プロジェクト: goofwear/PKHeX
        public override PKM convertToPKM(SaveFile SAV)
        {
            if (!IsPokémon)
                return null;

            int currentLevel = Level > 0 ? Level : (int)(Util.rnd32()%100 + 1);
            PK6 pk = new PK6
            {
                Species = Species,
                HeldItem = HeldItem,
                TID = TID,
                SID = SID,
                Met_Level = currentLevel,
                Nature = Nature != 0xFF ? Nature : (int)(Util.rnd32() % 25),
                Gender = PersonalTable.AO[Species].Gender == 255 ? 2 : (Gender != 3 ? Gender : PersonalTable.AO[Species].RandomGender),
                AltForm = Form,
                EncryptionConstant = EncryptionConstant == 0 ? Util.rnd32() : EncryptionConstant,
                Version = OriginGame == 0 ? SAV.Game : OriginGame,
                Language = Language == 0 ? SAV.Language : Language,
                Ball = Ball,
                Country = SAV.Country,
                Region = SAV.SubRegion,
                ConsoleRegion = SAV.ConsoleRegion,
                Move1 = Move1, Move2 = Move2, Move3 = Move3, Move4 = Move4,
                RelearnMove1 = RelearnMove1, RelearnMove2 = RelearnMove2,
                RelearnMove3 = RelearnMove3, RelearnMove4 = RelearnMove4,
                Met_Location = MetLocation,
                Egg_Location = EggLocation,
                CNT_Cool = CNT_Cool,
                CNT_Beauty = CNT_Beauty,
                CNT_Cute = CNT_Cute,
                CNT_Smart = CNT_Smart,
                CNT_Tough = CNT_Tough,
                CNT_Sheen = CNT_Sheen,

                OT_Name = OT.Length > 0 ? OT : SAV.OT,
                OT_Gender = OTGender != 3 ? OTGender % 2 : SAV.Gender,
                HT_Name = OT.Length > 0 ? SAV.OT : "",
                HT_Gender = OT.Length > 0 ? SAV.Gender : 0,
                CurrentHandler = OT.Length > 0 ? 1 : 0,

                EXP = PKX.getEXP(Level, Species),

                // Ribbons
                RibbonCountry = RibbonCountry,
                RibbonNational = RibbonNational,

                RibbonEarth = RibbonEarth,
                RibbonWorld = RibbonWorld,
                RibbonClassic = RibbonClassic,
                RibbonPremier = RibbonPremier,
                RibbonEvent = RibbonEvent,
                RibbonBirthday = RibbonBirthday,
                RibbonSpecial = RibbonSpecial,
                RibbonSouvenir = RibbonSouvenir,

                RibbonWishing = RibbonWishing,
                RibbonChampionBattle = RibbonChampionBattle,
                RibbonChampionRegional = RibbonChampionRegional,
                RibbonChampionNational = RibbonChampionNational,
                RibbonChampionWorld = RibbonChampionWorld,

                OT_Friendship = PersonalTable.AO[Species].BaseFriendship,
                OT_Intensity = OT_Intensity,
                OT_Memory = OT_Memory,
                OT_TextVar = OT_TextVar,
                OT_Feeling = OT_Feeling,
                FatefulEncounter = true,
            };
            pk.Move1_PP = pk.getMovePP(Move1, 0);
            pk.Move2_PP = pk.getMovePP(Move2, 0);
            pk.Move3_PP = pk.getMovePP(Move3, 0);
            pk.Move4_PP = pk.getMovePP(Move4, 0);

            if (Date.HasValue)
            {
                pk.MetDate = Date.Value;
            }
            else
            {
                // No datetime set, typical for wc6full
                // Set it to now, instead of zeroing it out.
                pk.MetDate = DateTime.Now;
            }

            if (pk.CurrentHandler == 0) // OT
            {
                pk.OT_Memory = 3;
                pk.OT_TextVar = 9;
                pk.OT_Intensity = 1;
                pk.OT_Feeling = Util.rand.Next(0, 9);
            }
            else
            {
                pk.HT_Memory = 3;
                pk.HT_TextVar = 9;
                pk.HT_Intensity = 1;
                pk.HT_Feeling = Util.rand.Next(0, 9);
                pk.HT_Friendship = pk.OT_Friendship;
            }
            pk.IsNicknamed = IsNicknamed;
            pk.Nickname = IsNicknamed ? Nickname : PKX.getSpeciesName(Species, pk.Language);

            // More 'complex' logic to determine final values

            // Dumb way to generate random IVs.
            int[] finalIVs = new int[6];
            switch (IVs[0])
            {
                case 0xFE:
                    finalIVs[0] = 31;
                    do { // 31 HP IV, 2 other 31s
                    for (int i = 1; i < 6; i++)
                        finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i];
                    } while (finalIVs.Count(r => r == 31) < 3); // 31 + 2*31
                    break;
                case 0xFD:
                    do { // 2 other 31s
                    for (int i = 0; i < 6; i++)
                        finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i];
                    } while (finalIVs.Count(r => r == 31) < 2); // 2*31
                    break;
                default: // Random IVs
                    for (int i = 0; i < 6; i++)
                        finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i];
                    break;
            }
            pk.IVs = finalIVs;

            int av = 0;
            switch (AbilityType)
            {
                case 00: // 0 - 0
                case 01: // 1 - 1
                case 02: // 2 - H
                    av = AbilityType;
                    break;
                case 03: // 0/1
                case 04: // 0/1/H
                    av = (int)(Util.rnd32()%(AbilityType - 1));
                    break;
            }
            pk.Ability = PersonalTable.AO.getAbilities(Species, pk.AltForm)[av];
            pk.AbilityNumber = 1 << av;

            switch (PIDType)
            {
                case 00: // Specified
                    pk.PID = PID;
                    break;
                case 01: // Random
                    pk.PID = Util.rnd32();
                    break;
                case 02: // Random Shiny
                    pk.PID = Util.rnd32();
                    pk.PID = (uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF));
                    break;
                case 03: // Random Nonshiny
                    do { pk.PID = Util.rnd32(); } while ((uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF)) < 16);
                    break;
            }

            if (IsEgg)
            {
                pk.IsEgg = true;
                pk.EggMetDate = Date;
            }

            pk.RefreshChecksum();
            return pk;
        }
コード例 #46
0
ファイル: PKX.cs プロジェクト: suloku/PKHeX
 internal static ushort[] getStats(PK6 pk6)
 {
     return getStats(pk6.Species, pk6.Stat_Level, pk6.Nature, pk6.AltForm,
         pk6.EV_HP, pk6.EV_ATK, pk6.EV_DEF, pk6.EV_SPA, pk6.EV_SPD, pk6.EV_SPE,
         pk6.IV_HP, pk6.IV_ATK, pk6.IV_DEF, pk6.IV_SPA, pk6.IV_SPD, pk6.IV_SPE);
 }
コード例 #47
0
ファイル: f1-Main.cs プロジェクト: Bluestar012/PKHeX
        private void getQuickFiller(PictureBox pb, PK6 pk = null)
        {
            if (!fieldsInitialized) return;
            pk = pk ?? preparepkx(false); // don't perform control loss click

            if (pb == dragout) L_QR.Visible = pk.Species != 0; // Species
            pb.Image = pk.Sprite;
        }
コード例 #48
0
ファイル: f1-Main.cs プロジェクト: jaceyen/PKHeX
        // Clicked Label Shortcuts //
        private void clickQR(object sender, EventArgs e)
        {
            if (ModifierKeys == Keys.Alt)
            {
                // Fetch data from QR code...
                byte[] ekx = Util.getQRData();

                if (ekx == null) return;

                if (ekx.Length != PK6.SIZE_STORED) { Util.Alert(String.Format("Decoded data not {0} bytes.", PK6.SIZE_STORED), String.Format("QR Data Size: {0}", ekx.Length)); }
                else try
                    {
                        byte[] pkx = PKX.decryptArray(ekx);
                        if (PKX.verifychk(pkx)) { populateFields(pkx); }
                        else Util.Alert("Invalid checksum in QR data.");
                    }
                    catch { Util.Alert("Error loading decrypted data."); }
            }
            else
            {
                if (!verifiedPKX()) return;
                byte[] pkx = preparepkx();
                byte[] ekx = PKX.encryptArray(pkx);

                Array.Resize(ref ekx, PK6.SIZE_STORED);
                const string server = "http://loadcode.projectpokemon.org/b1s1.html#"; // Rehosted with permission from LC/MS -- massive thanks!
                Image qr = Util.getQRImage(ekx, server);

                if (qr == null) return;

                string[] r = new PK6(pkx, "Tabs").QRText;
                new QR(qr, dragout.Image, r[0], r[1], r[2], "PKHeX @ ProjectPokemon.org").ShowDialog();
            }
        }
コード例 #49
0
ファイル: SAV6.cs プロジェクト: suloku/PKHeX
        public void setDex(PK6 pk6)
        {
            if (PokeDex < 0)
                return;
            if (pk6.Species == 0)
                return;
            if (Version == GameVersion.Unknown)
                return;

            int bit = pk6.Species - 1;
            int lang = pk6.Language - 1; if (lang > 5) lang--; // 0-6 language vals
            int origin = pk6.Version;
            int gender = pk6.Gender % 2; // genderless -> male
            int shiny = pk6.IsShiny ? 1 : 0;
            int shiftoff = shiny * 0x60 * 2 + gender * 0x60 + 0x60;

            // Set the [Species/Gender/Shiny] Owned Flag
            Data[PokeDex + shiftoff + bit / 8 + 0x8] |= (byte)(1 << (bit % 8));

            // Owned quality flag
            if (origin < 0x18 && bit < 649 && !ORAS) // Species: 1-649 for X/Y, and not for ORAS; Set the Foreign Owned Flag
                Data[PokeDex + 0x64C + bit / 8] |= (byte)(1 << (bit % 8));
            else if (origin >= 0x18 || ORAS) // Set Native Owned Flag (should always happen)
                Data[PokeDex + bit / 8 + 0x8] |= (byte)(1 << (bit % 8));

            // Set the Display flag if none are set
            bool Displayed = false;
            Displayed |= (Data[PokeDex + 0x60*5 + bit/8 + 0x8] & (byte) (1 << (bit%8))) != 0;
            Displayed |= (Data[PokeDex + 0x60*6 + bit/8 + 0x8] & (byte) (1 << (bit%8))) != 0;
            Displayed |= (Data[PokeDex + 0x60*7 + bit/8 + 0x8] & (byte) (1 << (bit%8))) != 0;
            Displayed |= (Data[PokeDex + 0x60*8 + bit/8 + 0x8] & (byte) (1 << (bit%8))) != 0;
            if (!Displayed) // offset is already biased by 0x60, reuse shiftoff but for the display flags.
                Data[PokeDex + shiftoff + 0x60 * 4 + bit / 8 + 0x8] |= (byte)(1 << (bit % 8));

            // Set the Language
            if (lang < 0) lang = 1;
            Data[PokeDexLanguageFlags + (bit * 7 + lang) / 8] |= (byte)(1 << ((bit * 7 + lang) % 8));

            // Set Form flags
            int fc = Personal[pk6.Species].FormeCount;
            int f = ORAS ? getDexFormIndexORAS(pk6.Species, fc) : getDexFormIndexXY(pk6.Species, fc);
            if (f >= 0)
            {
                int FormLen = ORAS ? 0x26 : 0x18;
                int FormDex = PokeDex + 0x368;
                bit = f + pk6.AltForm;
                // Set Seen Flag
                Data[FormDex + FormLen*shiny + bit/8] |= (byte)(1 << (bit%8));

                // Set Displayed Flag if necessary, check all flags
                bool FormDisplayed = false;
                for (int i = 0; i < fc; i++)
                {
                    bit = f + i;
                    FormDisplayed |= (Data[FormDex + FormLen*2 + bit/8] & (byte)(1 << (bit%8))) != 0; // Nonshiny
                    FormDisplayed |= (Data[FormDex + FormLen*3 + bit/8] & (byte)(1 << (bit%8))) != 0; // Shiny
                }
                if (!FormDisplayed)
                {
                    bit = f + pk6.AltForm;
                    Data[FormDex + FormLen*(2+shiny) + bit/8] |= (byte)(1 << (bit%8));
                }
            }

            // Set DexNav count (only if not encountered previously)
            if (ORAS && getEncounterCount(pk6.Species - 1) == 0)
                setEncounterCount(pk6.Species - 1, 1);
        }
コード例 #50
0
ファイル: f1-Main.cs プロジェクト: jaceyen/PKHeX
        // Decrypted Export
        private void dragout_MouseDown(object sender, MouseEventArgs e)
        {
            if (!verifiedPKX()) { return; }
            {
                // Create Temp File to Drag
                string basepath = Application.StartupPath;
                Cursor.Current = Cursors.Hand;

                // Make a new file name
                byte[] dragdata = preparepkx();
                var pkx = new PK6(dragdata, "Tabs");
                string filename = pkx.Nickname;
                if (filename != specieslist[pkx.Species])
                    filename += " (" + pkx.Species + ")";
                filename += " - " + pkx.PID;

                filename += (e.Button == MouseButtons.Right) ? ".ek6" : ".pk6";
                dragdata = (e.Button == MouseButtons.Right) ? PKX.encryptArray(preparepkx()) : preparepkx();
                // Strip out party stats (if they are there)
                Array.Resize(ref dragdata, PK6.SIZE_STORED);
                // Make file
                string newfile = Path.Combine(basepath, Util.CleanFileName(filename));
                try
                {
                    File.WriteAllBytes(newfile, dragdata);

                    string[] filesToDrag = { newfile };
                    dragout.DoDragDrop(new DataObject(DataFormats.FileDrop, filesToDrag), DragDropEffects.Move);
                    File.Delete(newfile);
                }
                catch (Exception x)
                { Util.Error("Drag & Drop Error", x.ToString()); }
                File.Delete(newfile);
            }
        }
コード例 #51
0
ファイル: SAV6.cs プロジェクト: suloku/PKHeX
 // Meta
 public void setPK6(PK6 pk6)
 {
     // Apply to this Save File
     int CT = pk6.CurrentHandler;
     DateTime Date = DateTime.Now;
     pk6.Trade(OT, TID, SID, Country, SubRegion, Gender, false, Date.Day, Date.Month, Date.Year);
     if (CT != pk6.CurrentHandler) // Logic updated Friendship
     {
         // Copy over the Friendship Value only under certain circumstances
         if (pk6.Moves.Contains(216)) // Return
             pk6.CurrentFriendship = pk6.OppositeFriendship;
         else if (pk6.Moves.Contains(218)) // Frustration
             pk6.CurrentFriendship = pk6.OppositeFriendship;
         else if (pk6.CurrentHandler == 1) // OT->HT, needs new Friendship/Affection
             pk6.TradeFriendshipAffection(OT);
     }
     pk6.RefreshChecksum();
 }
コード例 #52
0
ファイル: f1-Main.cs プロジェクト: jaceyen/PKHeX
        public void populateFields(byte[] data, bool focus = true)
        {
            pk6 = new PK6(data);
            if (init & !PKX.verifychk(pk6.Data))
                Util.Alert("PKX File has an invalid checksum.");

            // Reset a little.
            init = false;
            CAL_EggDate.Value = new DateTime(2000, 01, 01);
            if (focus)
                Tab_Main.Focus();

            // Do first
            pk6.Stat_Level = PKX.getLevel(pk6.Species, pk6.EXP);
            if (pk6.Stat_Level == 100)
                pk6.EXP = PKX.getEXP(pk6.Stat_Level, pk6.Species);

            CB_Species.SelectedValue = pk6.Species;
            TB_Level.Text = pk6.Stat_Level.ToString();
            TB_EXP.Text = pk6.EXP.ToString();

            // Load rest
            TB_EC.Text = pk6.EncryptionConstant.ToString("X8");
            CHK_Fateful.Checked = pk6.FatefulEncounter;
            CHK_IsEgg.Checked = pk6.IsEgg;
            CHK_Nicknamed.Checked = pk6.IsNicknamed;
            Label_OTGender.Text = gendersymbols[pk6.OT_Gender];
            Label_OTGender.ForeColor = ((pk6.OT_Gender == 1) ? Color.Red : Color.Blue);
            CHK_Circle.Checked = pk6.Circle;
            CHK_Triangle.Checked = pk6.Triangle;
            CHK_Square.Checked = pk6.Square;
            CHK_Heart.Checked = pk6.Heart;
            CHK_Star.Checked = pk6.Star;
            CHK_Diamond.Checked = pk6.Diamond;
            TB_PID.Text = pk6.PID.ToString("X8");
            CB_HeldItem.SelectedValue = pk6.HeldItem;
            setAbilityList(TB_AbilityNumber, pk6.Species, CB_Ability, CB_Form);
            TB_AbilityNumber.Text = pk6.AbilityNumber.ToString();
            CB_Ability.SelectedIndex = (pk6.AbilityNumber < 6) ? pk6.AbilityNumber >> 1 : 0; // with some simple error handling
            CB_Nature.SelectedValue = pk6.Nature;
            TB_TID.Text = pk6.TID.ToString("00000");
            TB_SID.Text = pk6.SID.ToString("00000");
            TB_Nickname.Text = pk6.Nickname;
            TB_OT.Text = pk6.OT_Name;
            TB_OTt2.Text = pk6.HT_Name;
            TB_Friendship.Text = pk6.CurrentFriendship.ToString();
            if (pk6.CurrentHandler == 1)  // HT
            {
                GB_nOT.BackgroundImage = mixedHighlight;
                GB_OT.BackgroundImage = null;
            }
            else                  // = 0
            {
                GB_OT.BackgroundImage = mixedHighlight;
                GB_nOT.BackgroundImage = null;
            }
            CB_Language.SelectedValue = pk6.Language;
            CB_Country.SelectedValue = pk6.Country;
            CB_SubRegion.SelectedValue = pk6.Region;
            CB_3DSReg.SelectedValue = pk6.ConsoleRegion;
            CB_GameOrigin.SelectedValue = pk6.Version;
            CB_EncounterType.SelectedValue = pk6.EncounterType;
            CB_Ball.SelectedValue = pk6.Ball;

            if (pk6.Met_Month == 0) { pk6.Met_Month = 1; }
            if (pk6.Met_Day == 0) { pk6.Met_Day = 1; }
            try { CAL_MetDate.Value = new DateTime(pk6.Met_Year + 2000, pk6.Met_Month, pk6.Met_Day); }
            catch { CAL_MetDate.Value = new DateTime(2000, 1, 1); }

            if (pk6.Egg_Location != 0)
            {
                // Was obtained initially as an egg.
                CHK_AsEgg.Checked = true;
                GB_EggConditions.Enabled = true;

                CB_EggLocation.SelectedValue = pk6.Egg_Location;
                try { CAL_EggDate.Value = new DateTime(pk6.Egg_Year + 2000, pk6.Egg_Month, pk6.Egg_Day); }
                catch { CAL_MetDate.Value = new DateTime(2000, 1, 1); }
            }
            else { CHK_AsEgg.Checked = GB_EggConditions.Enabled = false; CB_EggLocation.SelectedValue = 0; }

            CB_MetLocation.SelectedValue = pk6.Met_Location;

            // Set CT Gender to None if no CT, else set to gender symbol.
            Label_CTGender.Text = ((TB_OTt2.Text == "") || (pk6.HT_Name == "")) ? "" : gendersymbols[pk6.HT_Gender];
            Label_CTGender.ForeColor = ((pk6.HT_Gender == 1) ? Color.Red : Color.Blue);

            TB_MetLevel.Text = pk6.Met_Level.ToString();

            // Reset Label and ComboBox visibility, as well as non-data checked status.
            Label_PKRS.Visible = CB_PKRSStrain.Visible = CHK_Infected.Checked = pk6.PKRS_Strain != 0;
            Label_PKRSdays.Visible = CB_PKRSDays.Visible = pk6.PKRS_Days != 0;

            // Set SelectedIndexes for PKRS
            CB_PKRSStrain.SelectedIndex = pk6.PKRS_Strain;
            CHK_Cured.Checked = (pk6.PKRS_Strain > 0 && pk6.PKRS_Days == 0);
            CB_PKRSDays.SelectedIndex = Math.Min(CB_PKRSDays.Items.Count - 1, pk6.PKRS_Days); // to strip out bad hacked 'rus

            TB_Cool.Text = pk6.CNT_Cool.ToString();
            TB_Beauty.Text = pk6.CNT_Beauty.ToString();
            TB_Cute.Text = pk6.CNT_Cute.ToString();
            TB_Smart.Text = pk6.CNT_Smart.ToString();
            TB_Tough.Text = pk6.CNT_Tough.ToString();
            TB_Sheen.Text = pk6.CNT_Sheen.ToString();

            TB_HPIV.Text = pk6.IV_HP.ToString();
            TB_ATKIV.Text = pk6.IV_ATK.ToString();
            TB_DEFIV.Text = pk6.IV_DEF.ToString();
            TB_SPEIV.Text = pk6.IV_SPE.ToString();
            TB_SPAIV.Text = pk6.IV_SPA.ToString();
            TB_SPDIV.Text = pk6.IV_SPD.ToString();
            CB_HPType.SelectedValue = pk6.HPType;

            TB_HPEV.Text = pk6.EV_HP.ToString();
            TB_ATKEV.Text = pk6.EV_ATK.ToString();
            TB_DEFEV.Text = pk6.EV_DEF.ToString();
            TB_SPEEV.Text = pk6.EV_SPE.ToString();
            TB_SPAEV.Text = pk6.EV_SPA.ToString();
            TB_SPDEV.Text = pk6.EV_SPD.ToString();

            CB_Move1.SelectedValue = pk6.Move1;
            CB_Move2.SelectedValue = pk6.Move2;
            CB_Move3.SelectedValue = pk6.Move3;
            CB_Move4.SelectedValue = pk6.Move4;
            CB_RelearnMove1.SelectedValue = pk6.RelearnMove1;
            CB_RelearnMove2.SelectedValue = pk6.RelearnMove2;
            CB_RelearnMove3.SelectedValue = pk6.RelearnMove3;
            CB_RelearnMove4.SelectedValue = pk6.RelearnMove4;
            CB_PPu1.SelectedIndex = pk6.Move1_PPUps;
            CB_PPu2.SelectedIndex = pk6.Move2_PPUps;
            CB_PPu3.SelectedIndex = pk6.Move3_PPUps;
            CB_PPu4.SelectedIndex = pk6.Move4_PPUps;
            TB_PP1.Text = pk6.Move1_PP.ToString();
            TB_PP2.Text = pk6.Move2_PP.ToString();
            TB_PP3.Text = pk6.Move3_PP.ToString();
            TB_PP4.Text = pk6.Move4_PP.ToString();

            // Set Form if count is enough, else if count is more than 1 set equal to max else zero.
            CB_Form.SelectedIndex = (CB_Form.Items.Count > pk6.AltForm) ? pk6.AltForm : (CB_Form.Items.Count > 1) ? CB_Form.Items.Count - 1 : 0;

            // Load Extrabyte Value
            TB_ExtraByte.Text = pk6.Data[Convert.ToInt32(CB_ExtraBytes.Text, 16)].ToString();

            updateStats();
            setIsShiny();

            CB_EncounterType.Visible = Label_EncounterType.Visible = !(pk6.Version > 12 || pk6.Version < 7);
            if (pk6.Version > 12 || pk6.Version < 7)
                CB_EncounterType.SelectedValue = 0;

            init = true;
            updateIVs(null, null);
            updatePKRSInfected(null, null);
            updatePKRSCured(null, null);

            TB_EXP.Text = pk6.EXP.ToString();
            Label_Gender.Text = gendersymbols[pk6.Gender];
            Label_Gender.ForeColor = (pk6.Gender == 2) ? Label_Species.ForeColor : ((pk6.Gender == 1) ? Color.Red : Color.Blue);
            if (HaX) // DEV Illegality
            {
                DEV_Ability.SelectedValue = pk6.Ability;
                MT_Level.Text = pk6.Stat_Level.ToString();
                MT_Form.Text = pk6.AltForm.ToString();
            }

            // Set the Preview Box
            dragout.Image = pk6.Sprite;

            // Highlight the Current Handler
            clickGT((pk6.CurrentHandler == 1) ? GB_nOT : GB_OT, null);
        }
コード例 #53
0
ファイル: PKX.cs プロジェクト: suloku/PKHeX
 internal static string getFileName(PK6 pk6)
 {
     return
         $"{pk6.Species.ToString("000")}{(pk6.IsShiny ? " ★" : "")} - {pk6.Nickname} - {pk6.Checksum.ToString("X4")}{pk6.EncryptionConstant.ToString("X8")}.pk6";
 }
コード例 #54
0
 private void showLegality(PK6 pk, bool tabs, bool verbose)
 {
     LegalityAnalysis la = new LegalityAnalysis(pk);
     if (tabs)
         updateLegality(la);
     Util.Alert(verbose ? la.VerboseReport : la.Report);
 }
コード例 #55
0
ファイル: f1-Main.cs プロジェクト: jaceyen/PKHeX
        private void clickSet(object sender, EventArgs e)
        {
            if (!verifiedPKX()) { return; }
            int slot = getSlot(sender);
            if (slot == 30 && (CB_Species.SelectedIndex == 0 || CHK_IsEgg.Checked)) { Util.Alert("Can't have empty/egg first slot."); return; }
            int offset = getPKXOffset(slot);

            byte[] pkxdata = preparepkx();
            if (!SAV.ORAS)
            {
                PK6 pk = new PK6(pkxdata);
                // User Protection
                string err = "";
                if (pk.Moves.Any(m => m > 617))
                    err = "Move does not exist in X/Y.";
                else if (pk.Ability > 188)
                    err = "Ability does not exist in X/Y.";
                else if (pk.HeldItem > 717)
                    err = "Item does not exist in X/Y.";

                if ((err != "") && Util.Prompt(MessageBoxButtons.YesNo, err, "Continue?") != DialogResult.Yes)
                    return;
            }
            if (slot >= 30 && slot < 36) // Party
                SAV.setPK6Party(new PK6(pkxdata), offset);
            else if (slot < 30 || (slot >= 36 && slot < 42 && DEV_Ability.Enabled))
                SAV.setPK6Stored(new PK6(pkxdata), offset);
            else return;

            if (slot >= 30 && slot < 36)
                setParty();
            else
                getQuickFiller(SlotPictureBoxes[slot], pkxdata);

            getSlotColor(slot, Properties.Resources.slotSet);
        }
コード例 #56
0
ファイル: PKX.cs プロジェクト: suloku/PKHeX
        internal static string[] getQRText(PK6 pk6)
        {
            string[] response = new string[3];
            // Summarize
            string filename = pk6.Nickname;
            if (pk6.Nickname != Main.specieslist[pk6.Species] && Main.specieslist[pk6.Species] != null)
                filename += " (" + Main.specieslist[pk6.Species] + ")";
            response[0] = $"{filename} [{Main.abilitylist[pk6.Ability]}] lv{pk6.Stat_Level} @ {Main.itemlist[pk6.HeldItem]} -- {Main.natures[pk6.Nature]}";
            response[1] = $"{Main.movelist[pk6.Move1]} / {Main.movelist[pk6.Move2]} / {Main.movelist[pk6.Move3]} / {Main.movelist[pk6.Move4]}";
            response[2] = string.Format(
                "IVs:{0}{1}{2}{3}{4}{5}"
                + Environment.NewLine + Environment.NewLine +
                "EVs:{6}{7}{8}{9}{10}{11}",
                Environment.NewLine + pk6.IV_HP.ToString("00"),
                Environment.NewLine + pk6.IV_ATK.ToString("00"),
                Environment.NewLine + pk6.IV_DEF.ToString("00"),
                Environment.NewLine + pk6.IV_SPA.ToString("00"),
                Environment.NewLine + pk6.IV_SPD.ToString("00"),
                Environment.NewLine + pk6.IV_SPE.ToString("00"),
                Environment.NewLine + pk6.EV_HP,
                Environment.NewLine + pk6.EV_ATK,
                Environment.NewLine + pk6.EV_DEF,
                Environment.NewLine + pk6.EV_SPA,
                Environment.NewLine + pk6.EV_SPD,
                Environment.NewLine + pk6.EV_SPE);

            return response;
        }
コード例 #57
0
ファイル: f1-Main.cs プロジェクト: jaceyen/PKHeX
        // Drag & Drop within Box
        private void pbBoxSlot_MouseDown(object sender, MouseEventArgs e)
        {
            if (ModifierKeys == Keys.Control || ModifierKeys == Keys.Alt || ModifierKeys == Keys.Shift || ModifierKeys == (Keys.Control | Keys.Alt))
            { clickSlot(sender, e); return; }
            PictureBox pb = (PictureBox)(sender);
            if (pb.Image == null)
                return;

            pkm_from_slot = getSlot(sender);
            int offset = getPKXOffset(pkm_from_slot);
            if (e.Button != MouseButtons.Left || e.Clicks != 1) return;
            // Create Temp File to Drag
            string basepath = Application.StartupPath;
            Cursor.Current = Cursors.Hand;

            // Prepare Data
            pkm_from = SAV.getData(offset, PK6.SIZE_STORED);
            pkm_from_offset = offset;

            // Make a new file name based off the PID
            byte[] dragdata = PKX.decryptArray(pkm_from);
            Array.Resize(ref dragdata, PK6.SIZE_STORED);
            var pkx = new PK6(dragdata, "Boxes");
            string filename = pkx.Nickname;
            if (filename != specieslist[pkx.Species])
                filename += " (" + pkx.Species + ")";
            filename += " - " + pkx.PID + ".pk6";

            // Make File
            string newfile = Path.Combine(basepath, Util.CleanFileName(filename));
            try
            {
                File.WriteAllBytes(newfile, dragdata);

                string[] filesToDrag = { newfile };
                DoDragDrop(new DataObject(DataFormats.FileDrop, filesToDrag), DragDropEffects.Move);
                File.Delete(newfile); // after drop, delete the temporary file
            }
            catch (ArgumentException x)
            { Util.Error("Drag & Drop Error:", x.ToString()); }
            File.Delete(newfile);
            pkm_from_offset = 0;
        }
コード例 #58
0
ファイル: PKX.cs プロジェクト: suloku/PKHeX
 internal static string getShowdownText(PK6 pk6)
 {
     if (pk6.Species == 0) return "";
     ShowdownSet Set = new ShowdownSet
     {
         Nickname = pk6.Nickname,
         Species = pk6.Species,
         Item = pk6.HeldItem,
         Ability = pk6.Ability,
         EVs = pk6.EVs,
         IVs = pk6.IVs,
         Moves = pk6.Moves,
         Nature = pk6.Nature,
         Gender = new[] { " (M)", " (F)", "" }[pk6.Gender],
         Friendship = pk6.CurrentFriendship,
         Level = getLevel(pk6.Species, pk6.EXP),
         Shiny = pk6.IsShiny,
         Form = pk6.AltForm > 0 ? getFormList(pk6.Species,
         Util.getStringList("Types", "en"),
         Util.getStringList("Forms", "en"), new [] {"", "F", ""})[pk6.AltForm] : "",
     };
     if (Set.Form == "F") Set.Gender = "";
     return Set.getText();
 }
コード例 #59
0
        private void clickClone(object sender, EventArgs e)
        {
            if (getSlot(sender) > 30) return; // only perform action if cloning to boxes
            if (!verifiedPKX()) return; // don't copy garbage to the box

            PK6 pk;
            int box = CB_BoxSelect.SelectedIndex + 1; // get box we're cloning to

            if (Util.Prompt(MessageBoxButtons.YesNo, $"Clone Pokemon from Editing Tabs to all slots in Box {box}?") == DialogResult.Yes)
                pk = preparepkx();
            else if (Util.Prompt(MessageBoxButtons.YesNo, $"Delete Pokemon from all slots in Box {box}?") == DialogResult.Yes)
                pk = new PK6();
            else
                return; // abort clone/delete

            for (int i = 0; i < 30; i++) // write encrypted array to all box slots
            {
                SAV.setPK6Stored(pk, getPKXOffset(i));
                getQuickFiller(SlotPictureBoxes[i], pk);
            }
        }
コード例 #60
0
ファイル: PK6Wrapped.cs プロジェクト: PokeD/PokeD.Core
 public PK6Wrapped(PK6 data) { Data = data; }