diff --git a/Legality/Analysis.cs b/Legality/Analysis.cs
index c23251823..940284439 100644
--- a/Legality/Analysis.cs
+++ b/Legality/Analysis.cs
@@ -21,9 +21,11 @@ namespace PKHeX
public string Report => getLegalityReport();
public string VerboseReport => getVerboseLegalityReport();
- public LegalityAnalysis(PK6 pk)
+ public LegalityAnalysis(PKM pk)
{
- pk6 = pk;
+ if (!(pk is PK6))
+ return;
+ pk6 = pk as PK6;
updateRelearnLegality();
updateMoveLegality();
updateChecks();
@@ -66,7 +68,7 @@ namespace PKHeX
}
private string getLegalityReport()
{
- if (!pk6.Gen6)
+ if (pk6 == null || !pk6.Gen6)
return "Analysis only available for Pokémon that originate from X/Y & OR/AS.";
var chks = Checks;
@@ -91,6 +93,8 @@ namespace PKHeX
private string getVerboseLegalityReport()
{
string r = getLegalityReport() + Environment.NewLine;
+ if (pk6 == null)
+ return r;
r += "===" + Environment.NewLine + Environment.NewLine;
int rl = r.Length;
diff --git a/Legality/Checks.cs b/Legality/Checks.cs
index 3b924e242..08500ec93 100644
--- a/Legality/Checks.cs
+++ b/Legality/Checks.cs
@@ -37,6 +37,13 @@ namespace PKHeX
if (pk6.PID == 0)
return new LegalityCheck(Severity.Fishy, "PID is not set.");
+ if (EncounterType == typeof (EncounterStatic))
+ {
+ var enc = (EncounterStatic) EncounterMatch;
+ if (enc.Shiny != null && (bool)enc.Shiny ^ pk6.IsShiny)
+ return new LegalityCheck(Severity.Invalid, "Encounter " + (enc.Shiny == true ? "must be" : "cannot be") + " shiny.");
+ }
+
string special = "";
if (pk6.Gen6)
{
diff --git a/Legality/Core.cs b/Legality/Core.cs
index 3be95b083..8a9454ab5 100644
--- a/Legality/Core.cs
+++ b/Legality/Core.cs
@@ -198,8 +198,10 @@ namespace PKHeX
continue;
if (e.Level != pk6.Met_Level)
continue;
- if (e.Shiny != null && e.Shiny != pk6.IsShiny)
- continue;
+
+ // Defer to EC/PID check
+ // if (e.Shiny != null && e.Shiny != pk6.IsShiny)
+ // continue;
// Defer ball check to later
// if (e.Gift && pk6.Ball != 4) // PokéBall
diff --git a/Legality/Tables.cs b/Legality/Tables.cs
index afcb3c4a3..c03db8fe7 100644
--- a/Legality/Tables.cs
+++ b/Legality/Tables.cs
@@ -1,57 +1,22 @@
-namespace PKHeX
+using System.Linq;
+
+namespace PKHeX
{
public static partial class Legal
{
// PKHeX Valid Array Storage
- #region Items
-
- internal static readonly int[] Items_Held =
- {
- 000, 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 017, 018, 019, 020, 021, 022,
- 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035,
- 036, 037, 038, 039, 040, 041, 042, 043, 044, 045, 046, 047, 048, 049, 050, 051, 052, 053, 054, 055, 056, 057,
- 058, 059, 060, 061, 062, 063, 064, 065, 066, 067, 068, 069, 070,
- 071, 072, 073, 074, 075, 076, 077, 078, 079, 080, 081, 082, 083, 084, 085, 086, 087, 088, 089, 090, 091, 092,
- 093, 094, 099, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
- 110, 112, 116, 117, 118, 119, 134, 135, 136, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161,
- 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174,
- 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
- 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
- 210, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232,
- 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244,
- 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266,
- 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
- 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301,
- 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
- 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 504, 537, 538, 539, 540, 541, 542, 543, 544,
- 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557,
- 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 577, 580, 581, 582, 583, 584,
- 585, 586, 587, 588, 589, 590, 591, 639, 640, 644, 645, 646, 647,
- 648, 649, 650, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670,
- 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683,
- 684, 685, 686, 687, 688, 699, 704, 708, 709, 710, 711, 715,
-
- // Appended ORAS Items (Orbs & Mega Stones)
- 534, 535,
- 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 767, 768, 769, 770,
- };
-
internal static readonly int[] Items_Ball =
{
000, 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012,
013, 014, 015, 016, 492, 493, 494, 495, 496, 497, 498, 499, 576,
};
-
internal static readonly int[] Items_CommonBall = {4, 3, 2, 1};
-
internal static readonly int[] Items_UncommonBall =
{
7, 576, 13, 492, 497, 14, 495, 493, 496, 494, 11, 498, 8, 6,
12, 15, 9, 5, 499, 10, 16
};
-
- #endregion
#region Games
@@ -170,7 +135,7 @@
internal static readonly ushort[] Pouch_Items_XY =
{
- 000, 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 055, 056,
+ 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 055, 056,
057, 058, 059, 060, 061, 062, 063, 064, 065, 066, 067, 068, 069, 070, 071, 072, 073, 074, 075,
076, 077, 078, 079, 080, 081, 082, 083, 084, 085, 086, 087, 088, 089, 090, 091, 092, 093, 094,
099, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 112, 116, 117, 118, 119, 135, 136,
@@ -188,9 +153,9 @@
699, 704, 710, 711, 715,
};
- internal static readonly ushort[] Pouch_Items_ORAS =
+ internal static readonly ushort[] Pouch_Items_AO =
{
- 000, 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 055, 056,
+ 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 055, 056,
057, 058, 059, 060, 061, 062, 063, 064, 068, 069, 070, 071, 072, 073, 074, 075,
076, 077, 078, 079, 080, 081, 082, 083, 084, 085, 086, 087, 088, 089, 090, 091, 092, 093, 094,
099, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 112, 116, 117, 118, 119, 135, 136,
@@ -214,7 +179,7 @@
internal static readonly ushort[] Pouch_Key_XY =
{
- 000, 216, 431, 442, 445, 446, 447, 450, 465, 466, 471, 628,
+ 216, 431, 442, 445, 446, 447, 450, 465, 466, 471, 628,
629, 631, 632, 638, 641, 642, 643, 689, 695, 696, 697, 698,
700, 701, 702, 703, 705, 706, 707, 712, 713, 714,
@@ -222,9 +187,9 @@
716, 717, // For the cheaters who want useless items...
};
- internal static readonly ushort[] Pouch_Key_ORAS =
+ internal static readonly ushort[] Pouch_Key_AO =
{
- 000, 216, 445, 446, 447, 465, 466, 471, 628,
+ 216, 445, 446, 447, 465, 466, 471, 628,
629, 631, 632, 638, 697,
// Illegal
@@ -242,7 +207,6 @@
internal static readonly ushort[] Pouch_TMHM_XY =
{
- 0,
328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345,
346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363,
364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381,
@@ -253,9 +217,8 @@
420, 421, 422, 423, 424,
};
- internal static readonly ushort[] Pouch_TMHM_ORAS =
+ internal static readonly ushort[] Pouch_TMHM_AO =
{
- 0,
328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345,
346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363,
364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381,
@@ -271,14 +234,14 @@
internal static readonly ushort[] Pouch_Medicine_XY =
{
- 000, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033,
+ 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033,
034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 044, 045, 046, 047, 048, 049, 050, 051,
052, 053, 054, 134, 504, 565, 566, 567, 568, 569, 570, 571, 591, 645, 708, 709,
};
- internal static readonly ushort[] Pouch_Medicine_ORAS =
+ internal static readonly ushort[] Pouch_Medicine_AO =
{
- 000, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033,
+ 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033,
034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 044, 045, 046, 047, 048, 049, 050, 051,
052, 053, 054, 134, 504, 565, 566, 567, 568, 569, 570, 571, 591, 645, 708, 709,
@@ -288,13 +251,15 @@
internal static readonly ushort[] Pouch_Berry_XY =
{
- 0, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
+ 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
208, 209, 210, 211, 212, 686, 687, 688,
};
+ internal static readonly ushort[] HeldItem_XY = new ushort[1].Concat(Pouch_Items_XY).Concat(Pouch_Medicine_XY).Concat(Pouch_Berry_XY).ToArray();
+ internal static readonly ushort[] HeldItem_AO = new ushort[1].Concat(Pouch_Items_AO).Concat(Pouch_Medicine_AO).Concat(Pouch_Berry_XY).ToArray();
#endregion
#region TMHM
@@ -345,8 +310,8 @@
// Legality
internal static readonly int[] Gen4EncounterTypes = { 1, 2, 4, 5, 7, 9, 10, 12, 23, 24 };
- internal static readonly int Struggle = 165;
- internal static readonly int Chatter = 448;
+ internal const int Struggle = 165;
+ internal const int Chatter = 448;
internal static readonly int[] InvalidSketch = {Struggle, Chatter};
internal static readonly int[] EggLocations = {60002, 30002};
internal static readonly int[] LightBall = {25, 26, 172};
diff --git a/Legality/Tables4.cs b/Legality/Tables4.cs
new file mode 100644
index 000000000..1500a39ab
--- /dev/null
+++ b/Legality/Tables4.cs
@@ -0,0 +1,70 @@
+using System.Linq;
+
+namespace PKHeX
+{
+ public static partial class Legal
+ {
+ // PKHeX Valid Array Storage
+ #region DP
+ internal static readonly ushort[] Pouch_Items_DP = {
+ 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 135, 136, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327
+ };
+ internal static readonly ushort[] Pouch_Key_DP = {
+ 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464
+ };
+ internal static readonly ushort[] Pouch_TMHM_DP = {
+ 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427
+ };
+ internal static readonly ushort[] Pouch_Mail_DP = {
+ 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148
+ };
+ internal static readonly ushort[] Pouch_Medicine_DP = {
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54
+ };
+ internal static readonly ushort[] Pouch_Berries_DP = {
+ 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212
+ };
+ internal static readonly ushort[] Pouch_Ball_DP = {
+ 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
+ };
+ internal static readonly ushort[] Pouch_Battle_DP = {
+ 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67
+ };
+ internal static readonly ushort[] HeldItems_DP = new ushort[1].Concat(Pouch_Items_DP).Concat(Pouch_Mail_DP).Concat(Pouch_Medicine_DP).Concat(Pouch_Berries_DP).Concat(Pouch_Ball_DP).ToArray();
+ #endregion
+
+ #region Pt
+ internal static readonly ushort[] Pouch_Items_Pt = {
+ 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 135, 136, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327
+ };
+ internal static readonly ushort[] Pouch_Key_Pt = {
+ 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467
+ };
+ internal static readonly ushort[] Pouch_TMHM_Pt = Pouch_TMHM_DP;
+ internal static readonly ushort[] Pouch_Mail_Pt = Pouch_Mail_DP;
+ internal static readonly ushort[] Pouch_Medicine_Pt = Pouch_Medicine_DP;
+ internal static readonly ushort[] Pouch_Berries_Pt = Pouch_Berries_DP;
+ internal static readonly ushort[] Pouch_Ball_Pt = Pouch_Ball_DP;
+ internal static readonly ushort[] Pouch_Battle_Pt = Pouch_Battle_DP;
+
+ internal static readonly ushort[] HeldItems_Pt = new ushort[1].Concat(Pouch_Items_Pt).Concat(Pouch_Mail_Pt).Concat(Pouch_Medicine_Pt).Concat(Pouch_Berries_Pt).Concat(Pouch_Ball_Pt).ToArray();
+ #endregion
+
+ #region HGSS
+ internal static readonly ushort[] Pouch_Items_HGSS = Pouch_Items_Pt;
+ internal static readonly ushort[] Pouch_Key_HGSS = {
+ 434, 435, 437, 444, 445, 446, 447, 450, 456, 464, 465, 466, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 501, 502, 503, 504, 532, 533, 534, 535, 536
+ };
+ internal static readonly ushort[] Pouch_TMHM_HGSS = Pouch_TMHM_DP;
+ internal static readonly ushort[] Pouch_Mail_HGSS = Pouch_Mail_DP;
+ internal static readonly ushort[] Pouch_Medicine_HGSS = Pouch_Medicine_DP;
+ internal static readonly ushort[] Pouch_Berries_HGSS = Pouch_Berries_DP;
+ internal static readonly ushort[] Pouch_Ball_HGSS = {
+ 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 492, 493, 494, 495, 496, 497, 498, 499, 500
+ };
+ internal static readonly ushort[] Pouch_Battle_HGSS = Pouch_Battle_DP;
+
+ internal static readonly ushort[] HeldItems_HGSS = new ushort[1].Concat(Pouch_Items_HGSS).Concat(Pouch_Mail_HGSS).Concat(Pouch_Medicine_HGSS).Concat(Pouch_Berries_HGSS).Concat(Pouch_Ball_Pt).ToArray();
+ #endregion
+ }
+}
diff --git a/Legality/Tables5.cs b/Legality/Tables5.cs
new file mode 100644
index 000000000..d6b09e99e
--- /dev/null
+++ b/Legality/Tables5.cs
@@ -0,0 +1,29 @@
+using System.Linq;
+
+namespace PKHeX
+{
+ public static partial class Legal
+ {
+ // PKHeX Valid Array Storage
+ internal static readonly ushort[] Pouch_Items_BW = {
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 116, 117, 118, 119, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 492, 493, 494, 495, 496, 497, 498, 499, 500, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 571, 572, 573, 575, 576, 577, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590,
+ };
+ internal static readonly ushort[] Pouch_Key_BW = {
+ 437, 442, 447, 450, 465, 466, 471, 504, 533, 574, 578, 579, 616, 617, 621, 623, 624, 625, 626,
+ };
+ internal static readonly ushort[] Pouch_TMHM_BW = {
+ 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 618, 619, 620, 420, 421, 422, 423, 424, 425
+ };
+ internal static readonly ushort[] Pouch_Medicine_BW = {
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 134, 504, 565, 566, 567, 568, 569, 570, 591
+ };
+ internal static readonly ushort[] Pouch_Berries_BW = {
+ 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212
+ };
+ internal static readonly ushort[] HeldItems_BW = new ushort[1].Concat(Pouch_Items_BW).Concat(Pouch_Medicine_BW).Concat(Pouch_Berries_BW).ToArray();
+
+ internal static readonly ushort[] Pouch_Key_B2W2 = {
+ 437, 442, 447, 450, 453, 458, 465, 466, 471, 504, 578, 616, 617, 621, 626, 627, 628, 630, 631, 632, 633, 634, 635, 636, 637, 638,
+ };
+ }
+}
diff --git a/Misc/PGT.cs b/Misc/PGT.cs
deleted file mode 100644
index 79ff137bc..000000000
--- a/Misc/PGT.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-using System;
-
-namespace PKHeX
-{
- public class PCD
- {
- internal const int Size = 0x358; // 856
-
- public byte[] Data;
- public PCD(byte[] data = null)
- {
- Data = data ?? new byte[Size];
-
- byte[] giftData = new byte[PGT.Size];
- Array.Copy(Data, 0, giftData, 0, PGT.Size);
- Gift = new PGT(giftData);
-
- Information = new byte[Data.Length - PGT.Size];
- Array.Copy(Data, PGT.Size, Information, 0, Information.Length);
- }
- public readonly PGT Gift;
-
- public readonly byte[] Information;
- /* Big thanks to Grovyle91's Pokémon Mystery Gift Editor, from which the structure was referenced.
- * http://projectpokemon.org/forums/member.php?829-Grovyle91
- * http://projectpokemon.org/forums/showthread.php?6524
- * See also: http://tccphreak.shiny-clique.net/debugger/pcdfiles.htm
- */
- }
- public class PGT
- {
- internal static int Size = 0x104; // 260
-
- public byte[] Data;
- public PGT(byte[] data = null)
- {
- Data = data ?? new byte[Size];
- byte[] ekdata = new byte[PK4.SIZE_PARTY];
- Array.Copy(Data, 8, ekdata, 0, ekdata.Length);
- // Decrypt PK4
- PK = new PK4(PKM.decryptArray(ekdata));
-
- Unknown = new byte[0x10];
- Array.Copy(Data, 0xF4, Unknown, 0, 0x10);
- }
-
- public byte CardType { get { return Data[0]; } set { Data[0] = value; } }
- // Unused 0x01
- public byte Slot { get { return Data[2]; } set { Data[2] = value; } }
- public byte Detail { get { return Data[3]; } set { Data[3] = value; } }
- public PK4 PK;
- public byte[] Unknown;
-
- public bool IsPokémon { get { return CardType == 1; } set { if (value) CardType = 1; } }
- public bool IsEgg { get { return CardType == 2; } set { if (value) CardType = 2; } }
- public bool IsManaphyEgg { get { return CardType == 7; } set { if (value) CardType = 7; } }
- public bool PokémonGift => IsPokémon || IsEgg || IsManaphyEgg;
-
- public PK4 convertToPK4(SAV6 SAV)
- {
- if (!PokémonGift)
- return null;
-
- PK4 pk4 = new PK4(PK.Data);
- if (!IsPokémon && Detail == 0)
- {
- pk4.OT_Name = "PKHeX";
- pk4.TID = 12345;
- pk4.SID = 54321;
- pk4.OT_Gender = (int)(Util.rnd32()%2);
- }
- if (IsManaphyEgg)
- {
- // Since none of this data is populated, fill in default info.
- pk4.Species = 490;
- // Level 1 Moves
- pk4.Move1 = 294;
- pk4.Move2 = 145;
- pk4.Move3 = 346;
- pk4.FatefulEncounter = true;
- pk4.Ball = 4;
- pk4.Version = 10; // Diamond
- pk4.Language = 2; // English
- pk4.Nickname = "MANAPHY";
- pk4.Egg_Location = 1; // Ranger (will be +3000 later)
- }
-
- // Generate IV
- uint seed = Util.rnd32();
- if (pk4.PID == 1) // Create Nonshiny
- {
- uint pid1 = PKM.LCRNG(ref seed) >> 16;
- uint pid2 = PKM.LCRNG(ref seed) >> 16;
-
- while ((pid1 ^ pid2 ^ pk4.TID ^ pk4.SID) < 8)
- {
- uint testPID = pid1 | pid2 << 16;
-
- // Call the ARNG to change the PID
- testPID = testPID * 0x6c078965 + 1;
-
- pid1 = testPID & 0xFFFF;
- pid2 = testPID >> 16;
- }
- pk4.PID = pid1 | (pid2 << 16);
- }
-
- // Generate IVs
- if (pk4.IV32 == 0)
- {
- uint iv1 = PKM.LCRNG(ref seed) >> 16;
- uint iv2 = PKM.LCRNG(ref seed) >> 16;
- pk4.IV32 = (iv1 | iv2 << 16) & 0x3FFFFFFF;
- }
-
- // Generate Met Info
- DateTime dt = DateTime.Now;
- if (IsPokémon)
- {
- pk4.Met_Location = pk4.Egg_Location + 3000;
- pk4.Egg_Location = 0;
- pk4.Met_Day = dt.Day;
- pk4.Met_Month = dt.Month;
- pk4.Met_Year = dt.Year - 2000;
- pk4.IsEgg = false;
- }
- else
- {
- pk4.Egg_Location = pk4.Egg_Location + 3000;
- pk4.Egg_Day = dt.Day;
- pk4.Egg_Month = dt.Month;
- pk4.Egg_Year = dt.Year - 2000;
- pk4.IsEgg = false;
- // Met Location is modified when transferred to pk5; don't worry about it.
- }
- if (pk4.Species == 201) // Never will be true; Unown was never distributed.
- pk4.AltForm = PKM.getUnownForm(pk4.PID);
-
- return pk4;
- }
- }
-}
diff --git a/Misc/PK3.cs b/Misc/PK3.cs
deleted file mode 100644
index 03fa7db7b..000000000
--- a/Misc/PK3.cs
+++ /dev/null
@@ -1,299 +0,0 @@
-using System;
-using System.Linq;
-
-namespace PKHeX
-{
- public class PK3 // 3rd Generation PKM File
- {
- internal const int SIZE_PARTY = 100;
- internal const int SIZE_STORED = 80;
- internal const int SIZE_BLOCK = 12;
-
- public PK3(byte[] decryptedData = null, string ident = null)
- {
- Data = (byte[])(decryptedData ?? new byte[SIZE_PARTY]).Clone();
- Identifier = ident;
- if (Data.Length != SIZE_PARTY)
- Array.Resize(ref Data, SIZE_PARTY);
- }
-
- // Internal Attributes set on creation
- public byte[] Data; // Raw Storage
- public string Identifier; // User or Form Custom Attribute
-
- // 0x20 Intro
- public uint PID { get { return BitConverter.ToUInt32(Data, 0x00); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x00); } }
- public uint EID { get { return BitConverter.ToUInt32(Data, 0x04); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x04); } }
- public ushort TID { get { return BitConverter.ToUInt16(Data, 0x04); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x04); } }
- public ushort SID { get { return BitConverter.ToUInt16(Data, 0x06); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x06); } }
- public string Nickname {
- get { return PKM.getG3Str(Data.Skip(0x08).Take(10).ToArray(), Japanese); }
- set { byte[] strdata = PKM.setG3Str(value, Japanese);
- if (strdata.Length > 10)
- Array.Resize(ref strdata, 10);
- strdata.CopyTo(Data, 0x08); } }
- public int Language { get { return BitConverter.ToUInt16(Data, 0x12); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x12); } }
- public string OT_Name {
- get { return PKM.getG3Str(Data.Skip(0x14).Take(7).ToArray(), Japanese); }
- set { byte[] strdata = PKM.setG3Str(value, Japanese);
- if (strdata.Length > 7)
- Array.Resize(ref strdata, 7);
- strdata.CopyTo(Data, 0x14); } }
- private byte Markings { get { return Data[0x1B]; } set { Data[0x1B] = value; } }
- public bool Circle { get { return (Markings & (1 << 0)) == 1 << 0; } set { Markings = (byte)(Markings & ~(1 << 0) | (value ? 1 << 0 : 0)); } }
- public bool Square { get { return (Markings & (1 << 1)) == 1 << 1; } set { Markings = (byte)(Markings & ~(1 << 1) | (value ? 1 << 1 : 0)); } }
- public bool Triangle { get { return (Markings & (1 << 2)) == 1 << 2; } set { Markings = (byte)(Markings & ~(1 << 2) | (value ? 1 << 2 : 0)); } }
- public bool Heart { get { return (Markings & (1 << 3)) == 1 << 3; } set { Markings = (byte)(Markings & ~(1 << 3) | (value ? 1 << 3 : 0)); } }
- public ushort Checksum { get { return BitConverter.ToUInt16(Data, 0x1C); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x1C); } }
- public ushort Sanity { get { return BitConverter.ToUInt16(Data, 0x1E); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x1E); } }
-
- #region Block A
- public int Species { get { return PKM.getG4Species(BitConverter.ToUInt16(Data, 0x20)); } set { BitConverter.GetBytes((ushort)PKM.getG3Species(value)).CopyTo(Data, 0x20); } }
- public ushort HeldItem { get { return BitConverter.ToUInt16(Data, 0x22); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x22); } }
- public uint EXP { get { return BitConverter.ToUInt32(Data, 0x24); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x24); } }
- private byte PPUps { get { return Data[0x28]; } set { Data[0x28] = value; } }
- public int Move1_PPUps { get { return (PPUps >> 0) & 3; } set { PPUps = (byte)((PPUps & ~(3 << 0)) | value); } }
- public int Move2_PPUps { get { return (PPUps >> 2) & 3; } set { PPUps = (byte)((PPUps & ~(3 << 2)) | value); } }
- public int Move3_PPUps { get { return (PPUps >> 4) & 3; } set { PPUps = (byte)((PPUps & ~(3 << 4)) | value); } }
- public int Move4_PPUps { get { return (PPUps >> 6) & 3; } set { PPUps = (byte)((PPUps & ~(3 << 6)) | value); } }
- public int Friendship { get { return Data[0x29]; } set { Data[0x29] = (byte)value; } }
- // Unused 0x2A 0x2B
- #endregion
-
- #region Block B
- public int Move1 { get { return BitConverter.ToUInt16(Data, 0x2C); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2C); } }
- public int Move2 { get { return BitConverter.ToUInt16(Data, 0x2E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2E); } }
- public int Move3 { get { return BitConverter.ToUInt16(Data, 0x30); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x30); } }
- public int Move4 { get { return BitConverter.ToUInt16(Data, 0x32); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x32); } }
- public int Move1_PP { get { return Data[0x34]; } set { Data[0x34] = (byte)value; } }
- public int Move2_PP { get { return Data[0x35]; } set { Data[0x35] = (byte)value; } }
- public int Move3_PP { get { return Data[0x36]; } set { Data[0x36] = (byte)value; } }
- public int Move4_PP { get { return Data[0x37]; } set { Data[0x37] = (byte)value; } }
- #endregion
-
- #region Block C
- public int EV_HP { get { return Data[0x38]; } set { Data[0x38] = (byte)value; } }
- public int EV_ATK { get { return Data[0x39]; } set { Data[0x39] = (byte)value; } }
- public int EV_DEF { get { return Data[0x3A]; } set { Data[0x3A] = (byte)value; } }
- public int EV_SPE { get { return Data[0x3B]; } set { Data[0x3B] = (byte)value; } }
- public int EV_SPA { get { return Data[0x3C]; } set { Data[0x3C] = (byte)value; } }
- public int EV_SPD { get { return Data[0x3D]; } set { Data[0x3D] = (byte)value; } }
- public int CNT_Cool { get { return Data[0x3E]; } set { Data[0x3E] = (byte)value; } }
- public int CNT_Beauty { get { return Data[0x3F]; } set { Data[0x3F] = (byte)value; } }
- public int CNT_Cute { get { return Data[0x40]; } set { Data[0x40] = (byte)value; } }
- public int CNT_Smart { get { return Data[0x41]; } set { Data[0x41] = (byte)value; } }
- public int CNT_Tough { get { return Data[0x42]; } set { Data[0x42] = (byte)value; } }
- public int CNT_Sheen { get { return Data[0x43]; } set { Data[0x43] = (byte)value; } }
- #endregion
-
- #region Block D
- private byte PKRS { get { return Data[0x44]; } set { Data[0x44] = value; } }
- public int PKRS_Days { get { return PKRS & 0xF; } set { PKRS = (byte)(PKRS & ~0xF | value); } }
- public int PKRS_Strain { get { return PKRS >> 4; } set { PKRS = (byte)(PKRS & 0xF | value << 4); } }
- public int Met_Location { get { return Data[0x45]; } set { Data[0x45] = (byte)value; } }
- // Origins
- private ushort Origins { get { return BitConverter.ToUInt16(Data, 0x46); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x46); } }
- public int Version { get { return (Origins >> 7) & 0xF; } set { Origins = (ushort)((Origins & ~0x780) | ((value & 0xF) << 7));} }
- public int Pokéball { get { return (Origins >> 11) & 0xF; } set { Origins = (ushort)((Origins & ~0x7800) | ((value & 0xF) << 11)); } }
- public int OT_Gender { get { return (Origins >> 15) & 1; } set { Origins = (ushort)(Origins & ~(1 << 15) | ((value & 1) << 15)); } }
-
- public uint IV32 { get { return BitConverter.ToUInt32(Data, 0x48); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x48); } }
- public int IV_HP { get { return (int)(IV32 >> 00) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 00)) | (uint)((value > 31 ? 31 : value) << 00)); } }
- public int IV_ATK { get { return (int)(IV32 >> 05) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 05)) | (uint)((value > 31 ? 31 : value) << 05)); } }
- public int IV_DEF { get { return (int)(IV32 >> 10) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 10)) | (uint)((value > 31 ? 31 : value) << 10)); } }
- public int IV_SPE { get { return (int)(IV32 >> 15) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 15)) | (uint)((value > 31 ? 31 : value) << 15)); } }
- public int IV_SPA { get { return (int)(IV32 >> 20) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 20)) | (uint)((value > 31 ? 31 : value) << 20)); } }
- public int IV_SPD { get { return (int)(IV32 >> 25) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 25)) | (uint)((value > 31 ? 31 : value) << 25)); } }
- public bool IsEgg { get { return ((IV32 >> 30) & 1) == 1; } set { IV32 = (uint)((IV32 & ~0x40000000) | (uint)(value ? 0x40000000 : 0)); } }
- public int Ability { get { return (int)((IV32 >> 31) & 1); } set { IV32 = (IV32 & 0x7FFFFFFF) | (value == 1 ? 0x80000000 : 0); } }
-
- private uint RIB0 { get { return BitConverter.ToUInt32(Data, 0x4C); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x4C); } }
- public int Cool_Ribbons { get { return (int)(RIB0 >> 00) & 7; } set { RIB0 = (uint)((RIB0 & ~(7 << 00)) | (uint)(value & 7)); } }
- public int Beauty_Ribbons{ get { return (int)(RIB0 >> 03) & 7; } set { RIB0 = (uint)((RIB0 & ~(7 << 03)) | (uint)(value & 7)); } }
- public int Cute_Ribbons { get { return (int)(RIB0 >> 06) & 7; } set { RIB0 = (uint)((RIB0 & ~(7 << 06)) | (uint)(value & 7)); } }
- public int Smart_Ribbons { get { return (int)(RIB0 >> 09) & 3; } set { RIB0 = (uint)((RIB0 & ~(7 << 09)) | (uint)(value & 7)); } }
- public int Tough_Ribbons { get { return (int)(RIB0 >> 12) & 3; } set { RIB0 = (uint)((RIB0 & ~(7 << 12)) | (uint)(value & 7)); } }
- public bool Champion { get { return (RIB0 & (1 << 15)) == 1 << 15; } set { RIB0 = (uint)(RIB0 & ~(1 << 15) | (uint)(value ? 1 << 0 : 0)); } }
- public bool Winning { get { return (RIB0 & (1 << 16)) == 1 << 16; } set { RIB0 = (uint)(RIB0 & ~(1 << 16) | (uint)(value ? 1 << 0 : 0)); } }
- public bool Victory { get { return (RIB0 & (1 << 17)) == 1 << 17; } set { RIB0 = (uint)(RIB0 & ~(1 << 17) | (uint)(value ? 1 << 0 : 0)); } }
- public bool Artist { get { return (RIB0 & (1 << 18)) == 1 << 18; } set { RIB0 = (uint)(RIB0 & ~(1 << 18) | (uint)(value ? 1 << 0 : 0)); } }
- public bool Effort { get { return (RIB0 & (1 << 19)) == 1 << 19; } set { RIB0 = (uint)(RIB0 & ~(1 << 19) | (uint)(value ? 1 << 0 : 0)); } }
- public bool Special1 { get { return (RIB0 & (1 << 20)) == 1 << 20; } set { RIB0 = (uint)(RIB0 & ~(1 << 20) | (uint)(value ? 1 << 0 : 0)); } }
- public bool Special2 { get { return (RIB0 & (1 << 21)) == 1 << 21; } set { RIB0 = (uint)(RIB0 & ~(1 << 21) | (uint)(value ? 1 << 0 : 0)); } }
- public bool Special3 { get { return (RIB0 & (1 << 22)) == 1 << 22; } set { RIB0 = (uint)(RIB0 & ~(1 << 22) | (uint)(value ? 1 << 0 : 0)); } }
- public bool Special4 { get { return (RIB0 & (1 << 23)) == 1 << 23; } set { RIB0 = (uint)(RIB0 & ~(1 << 23) | (uint)(value ? 1 << 0 : 0)); } }
- public bool Special5 { get { return (RIB0 & (1 << 24)) == 1 << 24; } set { RIB0 = (uint)(RIB0 & ~(1 << 24) | (uint)(value ? 1 << 0 : 0)); } }
- public bool Special6 { get { return (RIB0 & (1 << 25)) == 1 << 25; } set { RIB0 = (uint)(RIB0 & ~(1 << 25) | (uint)(value ? 1 << 0 : 0)); } }
- public bool Special7 { get { return (RIB0 & (1 << 26)) == 1 << 26; } set { RIB0 = (uint)(RIB0 & ~(1 << 26) | (uint)(value ? 1 << 0 : 0)); } }
- public bool Unused1 { get { return (RIB0 & (1 << 27)) == 1 << 27; } set { RIB0 = (uint)(RIB0 & ~(1 << 27) | (uint)(value ? 1 << 0 : 0)); } }
- public bool Unused2 { get { return (RIB0 & (1 << 28)) == 1 << 28; } set { RIB0 = (uint)(RIB0 & ~(1 << 28) | (uint)(value ? 1 << 0 : 0)); } }
- public bool Unused3 { get { return (RIB0 & (1 << 29)) == 1 << 29; } set { RIB0 = (uint)(RIB0 & ~(1 << 29) | (uint)(value ? 1 << 0 : 0)); } }
- public bool Unused4 { get { return (RIB0 & (1 << 30)) == 1 << 30; } set { RIB0 = (uint)(RIB0 & ~(1 << 30) | (uint)(value ? 1 << 0 : 0)); } }
- public bool Obedience { get { return (RIB0 & (1 << 31)) == 1 << 31; } set { RIB0 = (RIB0 & ~(1 << 31)) | (uint)(value ? 1 << 0 : 0); } }
- #endregion
-
- // Simple Generated Attributes
- public bool Japanese => Language == 1;
- public bool Gen3 => Version >= 1 && Version <= 5 || Version == 15;
-
- public int[] Moves
- {
- get { return new[] { Move1, Move2, Move3, Move4 }; }
- set
- {
- if (value.Length > 0) Move1 = value[0];
- if (value.Length > 1) Move2 = value[1];
- if (value.Length > 2) Move3 = value[2];
- if (value.Length > 3) Move4 = value[3];
- }
- }
-
- // Methods
- public void FixMoves()
- {
- if (Move4 != 0 && Move3 == 0)
- {
- Move3 = Move4;
- Move3_PP = Move4_PP;
- Move3_PPUps = Move4_PPUps;
- Move4 = Move4_PP = Move4_PPUps = 0;
- }
- if (Move3 != 0 && Move2 == 0)
- {
- Move2 = Move3;
- Move2_PP = Move3_PP;
- Move2_PPUps = Move3_PPUps;
- Move3 = Move3_PP = Move3_PPUps = 0;
- }
- if (Move2 != 0 && Move1 == 0)
- {
- Move1 = Move2;
- Move1_PP = Move2_PP;
- Move1_PPUps = Move2_PPUps;
- Move2 = Move2_PP = Move2_PPUps = 0;
- }
- }
-
- public PK4 convertToPK4()
- {
- DateTime moment = DateTime.Now;
- PK4 pk4 = new PK4 // Convert away!
- {
- PID = PID,
- Species = Species,
- TID = TID,
- SID = SID,
- EXP = IsEgg ? PKX.getEXP(5, Species) : EXP,
- IsEgg = false,
- Friendship = 40,
- Circle = Circle,
- Square = Square,
- Triangle = Triangle,
- Heart = Heart,
- Language = Language,
- EV_HP = EV_HP,
- EV_ATK = EV_ATK,
- EV_DEF = EV_DEF,
- EV_SPA = EV_SPA,
- EV_SPD = EV_SPD,
- EV_SPE = EV_SPE,
- CNT_Cool = CNT_Cool,
- CNT_Beauty = CNT_Beauty,
- CNT_Cute = CNT_Cute,
- CNT_Smart = CNT_Smart,
- CNT_Tough = CNT_Tough,
- CNT_Sheen = CNT_Sheen,
- FatefulEncounter = Obedience,
- Move1 = Move1,
- Move2 = Move2,
- Move3 = Move3,
- Move4 = Move4,
- Move1_PPUps = Move1_PPUps,
- Move2_PPUps = Move2_PPUps,
- Move3_PPUps = Move3_PPUps,
- Move4_PPUps = Move4_PPUps,
- Move1_PP = PKX.getMovePP(Move1, Move1_PPUps),
- Move2_PP = PKX.getMovePP(Move2, Move2_PPUps),
- Move3_PP = PKX.getMovePP(Move3, Move3_PPUps),
- Move4_PP = PKX.getMovePP(Move4, Move4_PPUps),
- IV_HP = IV_HP,
- IV_ATK = IV_ATK,
- IV_DEF = IV_DEF,
- IV_SPA = IV_SPA,
- IV_SPD = IV_SPD,
- IV_SPE = IV_SPE,
- Ability = PKM.Gen3Abilities[Species][Ability],
- Version = Version,
- Ball = Pokéball,
- PKRS_Strain = PKRS_Strain,
- PKRS_Days = PKRS_Days,
- OT_Gender = OT_Gender,
- Met_Year = moment.Year - 2000,
- Met_Month = moment.Month,
- Met_Day = moment.Day,
- Met_Location = 0x37, // Pal Park
- RIB6_4 = Champion,
- RIB6_5 = Winning,
- RIB6_6 = Victory,
- RIB6_7 = Artist,
- RIB7_0 = Effort,
- RIB7_1 = Special1, // Battle Champion Ribbon
- RIB7_2 = Special2, // Regional Champion Ribbon
- RIB7_3 = Special3, // National Champion Ribbon
- RIB7_4 = Special4, // Country Ribbon
- RIB7_5 = Special5, // National Ribbon
- RIB7_6 = Special6, // Earth Ribbon
- RIB7_7 = Special7, // World Ribbon
- };
-
- // Remaining Ribbons
- pk4.RIB4_0 |= Cool_Ribbons > 0;
- pk4.RIB4_1 |= Cool_Ribbons > 1;
- pk4.RIB4_2 |= Cool_Ribbons > 2;
- pk4.RIB4_3 |= Cool_Ribbons > 3;
- pk4.RIB4_4 |= Beauty_Ribbons > 0;
- pk4.RIB4_5 |= Beauty_Ribbons > 1;
- pk4.RIB4_6 |= Beauty_Ribbons > 2;
- pk4.RIB4_7 |= Beauty_Ribbons > 3;
- pk4.RIB5_0 |= Cute_Ribbons > 0;
- pk4.RIB5_1 |= Cute_Ribbons > 1;
- pk4.RIB5_2 |= Cute_Ribbons > 2;
- pk4.RIB5_3 |= Cute_Ribbons > 3;
- pk4.RIB5_4 |= Smart_Ribbons > 0;
- pk4.RIB5_5 |= Smart_Ribbons > 1;
- pk4.RIB5_6 |= Smart_Ribbons > 2;
- pk4.RIB5_7 |= Smart_Ribbons > 3;
- pk4.RIB6_0 |= Tough_Ribbons > 0;
- pk4.RIB6_1 |= Tough_Ribbons > 1;
- pk4.RIB6_2 |= Tough_Ribbons > 2;
- pk4.RIB6_3 |= Tough_Ribbons > 3;
-
- // Yay for reusing string buffers!
- PKM.G4TransferTrashBytes[pk4.Language].CopyTo(pk4.Data, 0x48 + 4);
- pk4.Nickname = IsEgg ? PKM.getSpeciesName(pk4.Species, pk4.Language) : Nickname;
- Array.Copy(pk4.Data, 0x48, pk4.Data, 0x68, 0x10);
- pk4.OT_Name = OT_Name;
-
- // Set Final Data
- pk4.Met_Level = PKX.getLevel(pk4.Species, pk4.EXP);
- pk4.Gender = PKM.getGender(pk4.Species, pk4.PID);
- pk4.IsNicknamed |= pk4.Nickname != PKM.getSpeciesName(pk4.Species, pk4.Language);
-
- // Unown Form
- if (Species == 201)
- pk4.AltForm = PKM.getUnownForm(PID);
-
- // Remove HM moves
- int[] banned = { 15, 19, 57, 70, 148, 249, 127, 291 };
- int[] newMoves = pk4.Moves;
- for (int i = 0; i < 4; i++)
- if (banned.Contains(newMoves[i]))
- newMoves[i] = 0;
- pk4.Moves = newMoves;
- pk4.FixMoves();
-
- pk4.RefreshChecksum();
- return pk4;
- }
- }
-}
diff --git a/Misc/PKX.cs b/Misc/PKX.cs
deleted file mode 100644
index 41c00d952..000000000
--- a/Misc/PKX.cs
+++ /dev/null
@@ -1,1518 +0,0 @@
-using System;
-using System.Drawing;
-using System.Drawing.Text;
-using System.Linq;
-
-namespace PKHeX
-{
- public class PKX
- {
- // C# PKX Function Library
- // No WinForm object related code, only to calculate information.
- // May require re-referencing to main form for string array referencing.
- // Relies on Util for some common operations.
-
- // Data
- internal static uint LCRNG(uint seed)
- {
- const uint a = 0x41C64E6D;
- const uint c = 0x00006073;
-
- return seed * a + c;
- }
- internal static uint LCRNG(ref uint seed)
- {
- const uint a = 0x41C64E6D;
- const uint c = 0x00006073;
-
- return seed = seed * a + c;
- }
- #region ExpTable
- internal static readonly uint[,] ExpTable =
- {
- {0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0},
- {8, 15, 4, 9, 6, 10},
- {27, 52, 13, 57, 21, 33},
- {64, 122, 32, 96, 51, 80},
- {125, 237, 65, 135, 100, 156},
- {216, 406, 112, 179, 172, 270},
- {343, 637, 178, 236, 274, 428},
- {512, 942, 276, 314, 409, 640},
- {729, 1326, 393, 419, 583, 911},
- {1000, 1800, 540, 560, 800, 1250},
- {1331, 2369, 745, 742, 1064, 1663},
- {1728, 3041, 967, 973, 1382, 2160},
- {2197, 3822, 1230, 1261, 1757, 2746},
- {2744, 4719, 1591, 1612, 2195, 3430},
- {3375, 5737, 1957, 2035, 2700, 4218},
- {4096, 6881, 2457, 2535, 3276, 5120},
- {4913, 8155, 3046, 3120, 3930, 6141},
- {5832, 9564, 3732, 3798, 4665, 7290},
- {6859, 11111, 4526, 4575, 5487, 8573},
- {8000, 12800, 5440, 5460, 6400, 10000},
- {9261, 14632, 6482, 6458, 7408, 11576},
- {10648, 16610, 7666, 7577, 8518, 13310},
- {12167, 18737, 9003, 8825, 9733, 15208},
- {13824, 21012, 10506, 10208, 11059, 17280},
- {15625, 23437, 12187, 11735, 12500, 19531},
- {17576, 26012, 14060, 13411, 14060, 21970},
- {19683, 28737, 16140, 15244, 15746, 24603},
- {21952, 31610, 18439, 17242, 17561, 27440},
- {24389, 34632, 20974, 19411, 19511, 30486},
- {27000, 37800, 23760, 21760, 21600, 33750},
- {29791, 41111, 26811, 24294, 23832, 37238},
- {32768, 44564, 30146, 27021, 26214, 40960},
- {35937, 48155, 33780, 29949, 28749, 44921},
- {39304, 51881, 37731, 33084, 31443, 49130},
- {42875, 55737, 42017, 36435, 34300, 53593},
- {46656, 59719, 46656, 40007, 37324, 58320},
- {50653, 63822, 50653, 43808, 40522, 63316},
- {54872, 68041, 55969, 47846, 43897, 68590},
- {59319, 72369, 60505, 52127, 47455, 74148},
- {64000, 76800, 66560, 56660, 51200, 80000},
- {68921, 81326, 71677, 61450, 55136, 86151},
- {74088, 85942, 78533, 66505, 59270, 92610},
- {79507, 90637, 84277, 71833, 63605, 99383},
- {85184, 95406, 91998, 77440, 68147, 106480},
- {91125, 100237, 98415, 83335, 72900, 113906},
- {97336, 105122, 107069, 89523, 77868, 121670},
- {103823, 110052, 114205, 96012, 83058, 129778},
- {110592, 115015, 123863, 102810, 88473, 138240},
- {117649, 120001, 131766, 109923, 94119, 147061},
- {125000, 125000, 142500, 117360, 100000, 156250},
- {132651, 131324, 151222, 125126, 106120, 165813},
- {140608, 137795, 163105, 133229, 112486, 175760},
- {148877, 144410, 172697, 141677, 119101, 186096},
- {157464, 151165, 185807, 150476, 125971, 196830},
- {166375, 158056, 196322, 159635, 133100, 207968},
- {175616, 165079, 210739, 169159, 140492, 219520},
- {185193, 172229, 222231, 179056, 148154, 231491},
- {195112, 179503, 238036, 189334, 156089, 243890},
- {205379, 186894, 250562, 199999, 164303, 256723},
- {216000, 194400, 267840, 211060, 172800, 270000},
- {226981, 202013, 281456, 222522, 181584, 283726},
- {238328, 209728, 300293, 234393, 190662, 297910},
- {250047, 217540, 315059, 246681, 200037, 312558},
- {262144, 225443, 335544, 259392, 209715, 327680},
- {274625, 233431, 351520, 272535, 219700, 343281},
- {287496, 241496, 373744, 286115, 229996, 359370},
- {300763, 249633, 390991, 300140, 240610, 375953},
- {314432, 257834, 415050, 314618, 251545, 393040},
- {328509, 267406, 433631, 329555, 262807, 410636},
- {343000, 276458, 459620, 344960, 274400, 428750},
- {357911, 286328, 479600, 360838, 286328, 447388},
- {373248, 296358, 507617, 377197, 298598, 466560},
- {389017, 305767, 529063, 394045, 311213, 486271},
- {405224, 316074, 559209, 411388, 324179, 506530},
- {421875, 326531, 582187, 429235, 337500, 527343},
- {438976, 336255, 614566, 447591, 351180, 548720},
- {456533, 346965, 639146, 466464, 365226, 570666},
- {474552, 357812, 673863, 485862, 379641, 593190},
- {493039, 367807, 700115, 505791, 394431, 616298},
- {512000, 378880, 737280, 526260, 409600, 640000},
- {531441, 390077, 765275, 547274, 425152, 664301},
- {551368, 400293, 804997, 568841, 441094, 689210},
- {571787, 411686, 834809, 590969, 457429, 714733},
- {592704, 423190, 877201, 613664, 474163, 740880},
- {614125, 433572, 908905, 636935, 491300, 767656},
- {636056, 445239, 954084, 660787, 508844, 795070},
- {658503, 457001, 987754, 685228, 526802, 823128},
- {681472, 467489, 1035837, 710266, 545177, 851840},
- {704969, 479378, 1071552, 735907, 563975, 881211},
- {729000, 491346, 1122660, 762160, 583200, 911250},
- {753571, 501878, 1160499, 789030, 602856, 941963},
- {778688, 513934, 1214753, 816525, 622950, 973360},
- {804357, 526049, 1254796, 844653, 643485, 1005446},
- {830584, 536557, 1312322, 873420, 664467, 1038230},
- {857375, 548720, 1354652, 902835, 685900, 1071718},
- {884736, 560922, 1415577, 932903, 707788, 1105920},
- {912673, 571333, 1460276, 963632, 730138, 1140841},
- {941192, 583539, 1524731, 995030, 752953, 1176490},
- {970299, 591882, 1571884, 1027103, 776239, 1212873},
- {1000000, 600000, 1640000, 1059860, 800000, 1250000},
- };
- #endregion
-
- internal static readonly string[][] SpeciesLang =
- {
- Util.getStringList("species", "ja"), // none
- Util.getStringList("species", "ja"), // 1
- Util.getStringList("species", "en"), // 2
- Util.getStringList("species", "fr"), // 3
- Util.getStringList("species", "it"), // 4
- Util.getStringList("species", "de"), // 5
- Util.getStringList("species", "es"), // none
- Util.getStringList("species", "es"), // 7
- Util.getStringList("species", "ko"), // 8
- };
-
- internal static string getSpeciesName(int species, int lang)
- {
- try { return SpeciesLang[lang][species]; }
- catch { return ""; }
- }
- internal static readonly PersonalInfo[] Personal = Legal.PersonalAO;
-
- // Stat Fetching
- internal static int getMovePP(int move, int ppup)
- {
- return getBasePP(move) * (5 + ppup) / 5;
- }
- internal static int getBasePP(int move)
- {
- byte[] movepptable =
- {
- 00,
- 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 20, 30, 35, 35, 20, 15, 20,
- 20, 25, 20, 30, 05, 10, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 10, 15, 30, 35,
- 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, 30, 25, 15, 30, 25, 05, 15, 10, 05, 20,
- 20, 20, 05, 35, 20, 25, 20, 20, 20, 15, 25, 15, 10, 20, 25, 10, 35, 30, 15, 10,
- 40, 10, 15, 30, 15, 20, 10, 15, 10, 05, 10, 10, 25, 10, 20, 40, 30, 30, 20, 20,
- 15, 10, 40, 15, 10, 30, 10, 20, 10, 40, 40, 20, 30, 30, 20, 30, 10, 10, 20, 05,
- 10, 30, 20, 20, 20, 05, 15, 10, 20, 10, 15, 35, 20, 15, 10, 10, 30, 15, 40, 20,
- 15, 10, 05, 10, 30, 10, 15, 20, 15, 40, 20, 10, 05, 15, 10, 10, 10, 15, 30, 30,
- 10, 10, 20, 10, 01, 01, 10, 25, 10, 05, 15, 25, 15, 10, 15, 30, 05, 40, 15, 10,
- 25, 10, 30, 10, 20, 10, 10, 10, 10, 10, 20, 05, 40, 05, 05, 15, 05, 10, 05, 10,
- 10, 10, 10, 20, 20, 40, 15, 10, 20, 20, 25, 05, 15, 10, 05, 20, 15, 20, 25, 20,
- 05, 30, 05, 10, 20, 40, 05, 20, 40, 20, 15, 35, 10, 05, 05, 05, 15, 05, 20, 05,
- 05, 15, 20, 10, 05, 05, 15, 10, 15, 15, 10, 10, 10, 20, 10, 10, 10, 10, 15, 15,
- 15, 10, 20, 20, 10, 20, 20, 20, 20, 20, 10, 10, 10, 20, 20, 05, 15, 10, 10, 15,
- 10, 20, 05, 05, 10, 10, 20, 05, 10, 20, 10, 20, 20, 20, 05, 05, 15, 20, 10, 15,
- 20, 15, 10, 10, 15, 10, 05, 05, 10, 15, 10, 05, 20, 25, 05, 40, 15, 05, 40, 15,
- 20, 20, 05, 15, 20, 20, 15, 15, 05, 10, 30, 20, 30, 15, 05, 40, 15, 05, 20, 05,
- 15, 25, 25, 15, 20, 15, 20, 15, 20, 10, 20, 20, 05, 05, 10, 05, 40, 10, 10, 05,
- 10, 10, 15, 10, 20, 15, 30, 10, 20, 05, 10, 10, 15, 10, 10, 05, 15, 05, 10, 10,
- 30, 20, 20, 10, 10, 05, 05, 10, 05, 20, 10, 20, 10, 15, 10, 20, 20, 20, 15, 15,
- 10, 15, 15, 15, 10, 10, 10, 20, 10, 30, 05, 10, 15, 10, 10, 05, 20, 30, 10, 30,
- 15, 15, 15, 15, 30, 10, 20, 15, 10, 10, 20, 15, 05, 05, 15, 15, 05, 10, 05, 20,
- 05, 15, 20, 05, 20, 20, 20, 20, 10, 20, 10, 15, 20, 15, 10, 10, 05, 10, 05, 05,
- 10, 05, 05, 10, 05, 05, 05, 15, 10, 10, 10, 10, 10, 10, 15, 20, 15, 10, 15, 10,
- 15, 10, 20, 10, 15, 10, 20, 20, 20, 20, 20, 15, 15, 15, 15, 15, 15, 20, 15, 10,
- 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 05, 05, 15, 05, 10, 10, 10,
- 20, 20, 20, 10, 10, 30, 15, 15, 10, 15, 25, 10, 15, 10, 10, 10, 20, 10, 10, 10,
- 10, 10, 15, 15, 05, 05, 10, 10, 10, 05, 05, 10, 05, 05, 15, 10, 05, 05, 05, 10,
- 10, 10, 10, 20, 25, 10, 20, 30, 25, 20, 20, 15, 20, 15, 20, 20, 10, 10, 10, 10,
- 10, 20, 10, 30, 15, 10, 10, 10, 20, 20, 05, 05, 05, 20, 10, 10, 20, 15, 20, 20,
- 10, 20, 30, 10, 10, 40, 40, 30, 20, 40, 20, 20, 10, 10, 10, 10, 05, 10, 10, 05,
- 05
- };
- if (move < 0) move = 0;
- return movepptable[move];
- }
- internal static byte[] getRandomEVs()
- {
- byte[] evs = new byte[6];
- do {
- evs[0] = (byte)Math.Min(Util.rnd32() % 300, 252); // bias two to get maybe 252
- evs[1] = (byte)Math.Min(Util.rnd32() % 300, 252);
- evs[2] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1]), 252);
- evs[3] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1] - evs[2]), 252);
- evs[4] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1] - evs[2] - evs[3]), 252);
- evs[5] = (byte)Math.Min(510 - evs[0] - evs[1] - evs[2] - evs[3] - evs[4], 252);
- } while (evs.Sum(b => b) > 510); // recalculate random EVs...
- Util.Shuffle(evs);
- return evs;
- }
- internal static byte getBaseFriendship(int species)
- {
- return Personal[species].BaseFriendship;
- }
- internal static int getLevel(int species, uint exp)
- {
- int growth = Personal[species].EXPGrowth;
- int tl = 1; // Initial Level. Iterate upwards to find the level
- while (ExpTable[++tl, growth] <= exp)
- if (tl == 100) return 100;
- return --tl;
- }
- internal static bool getIsShiny(uint PID, uint TID, uint SID)
- {
- uint PSV = getPSV(PID);
- uint TSV = getTSV(TID, SID);
- return TSV == PSV;
- }
- internal static uint getEXP(int level, int species)
- {
- if (level <= 1) return 0;
- if (level > 100) level = 100;
- return ExpTable[level, Personal[species].EXPGrowth];
- }
- internal static byte[] getAbilities(int species, int formnum)
- {
- return Personal[Personal[species].FormeIndex(species, formnum)].Abilities;
- }
- internal static int getAbilityNumber(int species, int ability, int formnum)
- {
- byte[] spec_abilities = Personal[Personal[species].FormeIndex(species, formnum)].Abilities;
- int abilval = Array.IndexOf(spec_abilities, (byte)ability);
- if (abilval >= 0)
- return 1 << abilval;
- return -1;
- }
- internal static int getGender(string s)
- {
- if (s == null)
- return -1;
- if (s == "♂" || s == "M")
- return 0;
- if (s == "♀" || s == "F")
- return 1;
- return 2;
- }
-
- internal static string[] getCountryRegionText(int country, int region, string lang)
- {
- // Get Language we're fetching for
- int index = Array.IndexOf(new[] { "ja", "en", "fr", "de", "it", "es", "zh", "ko"}, lang);
- // Return value storage
- string[] data = new string[2]; // country, region
-
- // Get Country Text
- try
- {
- string[] inputCSV = Util.getStringList("countries");
- // Set up our Temporary Storage
- string[] unsortedList = new string[inputCSV.Length - 1];
- int[] indexes = new int[inputCSV.Length - 1];
-
- // Gather our data from the input file
- for (int i = 1; i < inputCSV.Length; i++)
- {
- string[] countryData = inputCSV[i].Split(',');
- if (countryData.Length <= 1) continue;
- indexes[i - 1] = Convert.ToInt32(countryData[0]);
- unsortedList[i - 1] = countryData[index + 1];
- }
-
- int countrynum = Array.IndexOf(indexes, country);
- data[0] = unsortedList[countrynum];
- }
- catch { data[0] = "Illegal"; }
-
- // Get Region Text
- try
- {
- string[] inputCSV = Util.getStringList("sr_" + country.ToString("000"));
- // Set up our Temporary Storage
- string[] unsortedList = new string[inputCSV.Length - 1];
- int[] indexes = new int[inputCSV.Length - 1];
-
- // Gather our data from the input file
- for (int i = 1; i < inputCSV.Length; i++)
- {
- string[] countryData = inputCSV[i].Split(',');
- if (countryData.Length <= 1) continue;
- indexes[i - 1] = Convert.ToInt32(countryData[0]);
- unsortedList[i - 1] = countryData[index + 1];
- }
-
- int regionnum = Array.IndexOf(indexes, region);
- data[1] = unsortedList[regionnum];
- }
- catch { data[1] = "Illegal"; }
- return data;
- }
- internal static string getLocation(bool eggmet, int gameorigin, int locval)
- {
- if (gameorigin < 13 && gameorigin > 6 && eggmet)
- {
- if (locval < 2000) return Main.metHGSS_00000[locval];
- if (locval < 3000) return Main.metHGSS_02000[locval % 2000];
- return Main.metHGSS_03000[locval % 3000];
- }
- if (gameorigin < 24)
- {
- if (locval < 30000) return Main.metBW2_00000[locval];
- if (locval < 40000) return Main.metBW2_30000[locval % 10000 - 1];
- if (locval < 60000) return Main.metBW2_40000[locval % 10000 - 1];
- return Main.metBW2_60000[locval % 10000 - 1];
- }
- if (gameorigin > 23)
- {
- if (locval < 30000) return Main.metXY_00000[locval];
- if (locval < 40000) return Main.metXY_30000[locval % 10000 - 1];
- if (locval < 60000) return Main.metXY_40000[locval % 10000 - 1];
- return Main.metXY_60000[locval % 10000 - 1];
- }
- return null; // Shouldn't happen.
- }
- 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;
- }
- internal static string getFileName(PK6 pk6)
- {
- return
- $"{pk6.Species.ToString("000")}{(pk6.IsShiny ? " ★" : "")} - {pk6.Nickname} - {pk6.Checksum.ToString("X4")}{pk6.EncryptionConstant.ToString("X8")}.pk6";
- }
- 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);
- }
- internal static ushort[] getStats(int species, int level, int nature, int form,
- int HP_EV, int ATK_EV, int DEF_EV, int SPA_EV, int SPD_EV, int SPE_EV,
- int HP_IV, int ATK_IV, int DEF_IV, int SPA_IV, int SPD_IV, int SPE_IV)
- {
- PersonalInfo p = Personal[Personal[species].FormeIndex(species, form)];
- // Calculate Stats
- ushort[] stats = new ushort[6]; // Stats are stored as ushorts in the PKX structure. We'll cap them as such.
- stats[0] = (ushort)(p.HP == 1 ? 1 : (HP_IV + 2 * p.HP + HP_EV / 4 + 100) * level / 100 + 10);
- stats[1] = (ushort)((ATK_IV + 2 * p.ATK + ATK_EV / 4) * level / 100 + 5);
- stats[2] = (ushort)((DEF_IV + 2 * p.DEF + DEF_EV / 4) * level / 100 + 5);
- stats[4] = (ushort)((SPA_IV + 2 * p.SPA + SPA_EV / 4) * level / 100 + 5);
- stats[5] = (ushort)((SPD_IV + 2 * p.SPD + SPD_EV / 4) * level / 100 + 5);
- stats[3] = (ushort)((SPE_IV + 2 * p.SPE + SPE_EV / 4) * level / 100 + 5);
-
- // Account for nature
- int incr = nature / 5 + 1;
- int decr = nature % 5 + 1;
- if (incr == decr) return stats; // if neutral return stats without mod
- stats[incr] *= 11; stats[incr] /= 10;
- stats[decr] *= 9; stats[decr] /= 10;
-
- // Return Result
- return stats;
- }
-
-
- // PKX Manipulation
- internal static readonly byte[][] blockPosition =
- {
- new byte[] {0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 2, 3, 1, 1, 2, 3, 2, 3, 1, 1, 2, 3, 2, 3},
- new byte[] {1, 1, 2, 3, 2, 3, 0, 0, 0, 0, 0, 0, 2, 3, 1, 1, 3, 2, 2, 3, 1, 1, 3, 2},
- new byte[] {2, 3, 1, 1, 3, 2, 2, 3, 1, 1, 3, 2, 0, 0, 0, 0, 0, 0, 3, 2, 3, 2, 1, 1},
- new byte[] {3, 2, 3, 2, 1, 1, 3, 2, 3, 2, 1, 1, 3, 2, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0},
- };
- internal static readonly byte[] blockPositionInvert =
- {
- 0, 1, 2, 4, 3, 5, 6, 7, 12, 18, 13, 19, 8, 10, 14, 20, 16, 22, 9, 11, 15, 21, 17, 23
- };
- internal static byte[] shuffleArray(byte[] data, uint sv)
- {
- byte[] sdata = new byte[data.Length];
- Array.Copy(data, sdata, 8); // Copy unshuffled bytes
-
- // Shuffle Away!
- for (int block = 0; block < 4; block++)
- Array.Copy(data, 8 + 56*blockPosition[block][sv], sdata, 8 + 56*block, 56);
-
- // Fill the Battle Stats back
- if (data.Length > 232)
- Array.Copy(data, 232, sdata, 232, 28);
-
- return sdata;
- }
- internal static byte[] decryptArray(byte[] ekx)
- {
- byte[] pkx = (byte[])ekx.Clone();
-
- uint pv = BitConverter.ToUInt32(pkx, 0);
- uint sv = (pv >> 0xD & 0x1F) % 24;
-
- uint seed = pv;
-
- // Decrypt Blocks with RNG Seed
- for (int i = 8; i < 232; i += 2)
- BitConverter.GetBytes((ushort)(BitConverter.ToUInt16(pkx, i) ^ LCRNG(ref seed) >> 16)).CopyTo(pkx, i);
-
- // Deshuffle
- pkx = shuffleArray(pkx, sv);
-
- // Decrypt the Party Stats
- seed = pv;
- if (pkx.Length <= 232) return pkx;
- for (int i = 232; i < 260; i += 2)
- BitConverter.GetBytes((ushort)(BitConverter.ToUInt16(pkx, i) ^ LCRNG(ref seed) >> 16)).CopyTo(pkx, i);
-
- return pkx;
- }
- internal static byte[] encryptArray(byte[] pkx)
- {
- // Shuffle
- uint pv = BitConverter.ToUInt32(pkx, 0);
- uint sv = (pv >> 0xD & 0x1F) % 24;
-
- byte[] ekx = (byte[])pkx.Clone();
-
- ekx = shuffleArray(ekx, blockPositionInvert[sv]);
-
- uint seed = pv;
-
- // Encrypt Blocks with RNG Seed
- for (int i = 8; i < 232; i += 2)
- BitConverter.GetBytes((ushort)(BitConverter.ToUInt16(ekx, i) ^ LCRNG(ref seed) >> 16)).CopyTo(ekx, i);
-
- // If no party stats, return.
- if (ekx.Length <= 232) return ekx;
-
- // Encrypt the Party Stats
- seed = pv;
- for (int i = 232; i < 260; i += 2)
- BitConverter.GetBytes((ushort)(BitConverter.ToUInt16(ekx, i) ^ LCRNG(ref seed) >> 16)).CopyTo(ekx, i);
-
- // Done
- return ekx;
- }
- internal static ushort getCHK(byte[] data)
- {
- ushort chk = 0;
- for (int i = 8; i < 232; i += 2) // Loop through the entire PKX
- chk += BitConverter.ToUInt16(data, i);
-
- return chk;
- }
- internal static bool verifychk(byte[] input)
- {
- ushort checksum = 0;
- if (input.Length == 100 || input.Length == 80) // Gen 3 Files
- {
- for (int i = 32; i < 80; i += 2)
- checksum += BitConverter.ToUInt16(input, i);
-
- return checksum == BitConverter.ToUInt16(input, 28);
- }
-
- if (input.Length == 236 || input.Length == 220 || input.Length == 136) // Gen 4/5
- Array.Resize(ref input, 136);
- else if (input.Length == 232 || input.Length == 260) // Gen 6
- Array.Resize(ref input, 232);
- else throw new ArgumentException("Wrong sized input array to verifychecksum");
-
- ushort chk = 0;
- for (int i = 8; i < input.Length; i += 2)
- chk += BitConverter.ToUInt16(input, i);
-
- return chk == BitConverter.ToUInt16(input, 0x6);
- }
-
- internal static uint getPSV(uint PID)
- {
- return (PID >> 16 ^ PID & 0xFFFF) >> 4;
- }
- internal static uint getTSV(uint TID, uint SID)
- {
- return (TID ^ SID) >> 4;
- }
- internal static uint getRandomPID(int species, int cg, int origin, int nature, int form)
- {
- int gt = Personal[species].Gender;
- if (origin >= 24)
- return Util.rnd32();
-
- bool g3unown = origin <= 5 && species == 201;
- while (true) // Loop until we find a suitable PID
- {
- uint pid = Util.rnd32();
-
- // Gen 3/4: Nature derived from PID
- if (origin <= 15 && pid%25 != nature)
- continue;
-
- // Gen 3 Unown: Letter/form derived from PID
- if (g3unown)
- {
- uint pidLetter = ((pid & 0x3000000) >> 18 | (pid & 0x30000) >> 12 | (pid & 0x300) >> 6 | pid & 0x3) % 28;
- if (pidLetter != form)
- continue;
- }
-
- // Gen 3/4/5: Gender derived from PID
- uint gv = pid & 0xFF;
- if (gt == 255 || gt == 254 || gt == 0) // Set Gender(less)
- return pid; // PID can be anything
- if (cg == 1 && gv <= gt) // Female
- return pid; // PID Passes
- if (cg == 0 && gv > gt) // Male
- return pid; // PID Passes
- }
- }
-
- // SAV Manipulation
- /// Calculates the CRC16-CCITT checksum over an input byte array.
- /// Input byte array
- /// Checksum
- internal static ushort ccitt16(byte[] data)
- {
- const ushort init = 0xFFFF;
- const ushort poly = 0x1021;
-
- ushort crc = init;
- foreach (byte b in data)
- {
- crc ^= (ushort)(b << 8);
- for (int j = 0; j < 8; j++)
- {
- bool flag = (crc & 0x8000) > 0;
- crc <<= 1;
- if (flag)
- crc ^= poly;
- }
- }
- return crc;
- }
- /// Simple check to see if the save is valid.
- /// Input binary file
- /// True/False
- internal static bool verifyG6SAV(byte[] savefile)
- {
- // Dynamic handling of checksums regardless of save size.
-
- int verificationOffset = savefile.Length - 0x200 + 0x10;
- if (BitConverter.ToUInt32(savefile, verificationOffset) != SAV6.BEEF)
- verificationOffset -= 0x200; // No savegames have more than 0x3D blocks, maybe in the future?
-
- int count = (savefile.Length - verificationOffset - 0x8) / 8;
- verificationOffset += 4;
- int[] Lengths = new int[count];
- ushort[] BlockIDs = new ushort[count];
- ushort[] Checksums = new ushort[count];
- int[] Start = new int[count];
- int CurrentPosition = 0;
- for (int i = 0; i < count; i++)
- {
- Start[i] = CurrentPosition;
- Lengths[i] = BitConverter.ToInt32(savefile, verificationOffset + 0 + 8 * i);
- BlockIDs[i] = BitConverter.ToUInt16(savefile, verificationOffset + 4 + 8 * i);
- Checksums[i] = BitConverter.ToUInt16(savefile, verificationOffset + 6 + 8 * i);
-
- CurrentPosition += Lengths[i] % 0x200 == 0 ? Lengths[i] : 0x200 - Lengths[i] % 0x200 + Lengths[i];
-
- if ((BlockIDs[i] != 0) || i == 0) continue;
- count = i;
- break;
- }
- // Verify checksums
- for (int i = 0; i < count; i++)
- {
- ushort chk = ccitt16(savefile.Skip(Start[i]).Take(Lengths[i]).ToArray());
- ushort old = BitConverter.ToUInt16(savefile, verificationOffset + 6 + i * 8);
-
- if (chk != old)
- return false;
- }
- return true;
- }
- /// Verbose check to see if the save is valid.
- /// Input binary file
- /// String containing invalid blocks.
- internal static string verifyG6CHK(byte[] savefile)
- {
- string rv = "";
- int invalid = 0;
- // Dynamic handling of checksums regardless of save size.
-
- int verificationOffset = savefile.Length - 0x200 + 0x10;
- if (BitConverter.ToUInt32(savefile, verificationOffset) != SAV6.BEEF)
- verificationOffset -= 0x200; // No savegames have more than 0x3D blocks, maybe in the future?
-
- int count = (savefile.Length - verificationOffset - 0x8) / 8;
- verificationOffset += 4;
- int[] Lengths = new int[count];
- ushort[] BlockIDs = new ushort[count];
- ushort[] Checksums = new ushort[count];
- int[] Start = new int[count];
- int CurrentPosition = 0;
- for (int i = 0; i < count; i++)
- {
- Start[i] = CurrentPosition;
- Lengths[i] = BitConverter.ToInt32(savefile, verificationOffset + 0 + 8 * i);
- BlockIDs[i] = BitConverter.ToUInt16(savefile, verificationOffset + 4 + 8 * i);
- Checksums[i] = BitConverter.ToUInt16(savefile, verificationOffset + 6 + 8 * i);
-
- CurrentPosition += Lengths[i] % 0x200 == 0 ? Lengths[i] : 0x200 - Lengths[i] % 0x200 + Lengths[i];
-
- if (BlockIDs[i] != 0 || i == 0) continue;
- count = i;
- break;
- }
- // Apply checksums
- for (int i = 0; i < count; i++)
- {
- ushort chk = ccitt16(savefile.Skip(Start[i]).Take(Lengths[i]).ToArray());
- ushort old = BitConverter.ToUInt16(savefile, verificationOffset + 6 + i * 8);
-
- if (chk == old) continue;
-
- invalid++;
- rv += $"Invalid: {i.ToString("X2")} @ Region {Start[i].ToString("X5") + Environment.NewLine}";
- }
- // Return Outputs
- rv += $"SAV: {count - invalid}/{count + Environment.NewLine}";
- return rv;
- }
- /// Fix checksums in the input save file.
- /// Input binary file
- /// Fixed save file.
- internal static void writeG6CHK(byte[] savefile)
- {
- // Dynamic handling of checksums regardless of save size.
-
- int verificationOffset = savefile.Length - 0x200 + 0x10;
- if (BitConverter.ToUInt32(savefile, verificationOffset) != SAV6.BEEF)
- verificationOffset -= 0x200; // No savegames have more than 0x3D blocks, maybe in the future?
-
- int count = (savefile.Length - verificationOffset - 0x8) / 8;
- verificationOffset += 4;
- int[] Lengths = new int[count];
- ushort[] BlockIDs = new ushort[count];
- ushort[] Checksums = new ushort[count];
- int[] Start = new int[count];
- int CurrentPosition = 0;
- for (int i = 0; i < count; i++)
- {
- Start[i] = CurrentPosition;
- Lengths[i] = BitConverter.ToInt32(savefile, verificationOffset + 0 + 8 * i);
- BlockIDs[i] = BitConverter.ToUInt16(savefile, verificationOffset + 4 + 8 * i);
- Checksums[i] = BitConverter.ToUInt16(savefile, verificationOffset + 6 + 8 * i);
-
- CurrentPosition += Lengths[i]%0x200 == 0 ? Lengths[i] : 0x200 - Lengths[i]%0x200 + Lengths[i];
-
- if (BlockIDs[i] != 0 || i == 0) continue;
- count = i;
- break;
- }
- // Apply checksums
- for (int i = 0; i < count; i++)
- {
- byte[] array = savefile.Skip(Start[i]).Take(Lengths[i]).ToArray();
- BitConverter.GetBytes(ccitt16(array)).CopyTo(savefile, verificationOffset + 6 + i * 8);
- }
- }
-
- // Data Requests
- internal static Image getSprite(int species, int form, int gender, int item, bool isegg, bool shiny)
- {
- if (species == 0)
- return (Image)Properties.Resources.ResourceManager.GetObject("_0");
- if (new[] { 664, 665, 414, 493 }.Contains(species)) // Species who show their default sprite regardless of Form
- form = 0;
-
- string file = "_" + species;
- if (form > 0) // Alt Form Handling
- file = file + "_" + form;
- else if (gender == 1 && new[] { 592, 593, 521, 668 }.Contains(species)) // Frillish & Jellicent, Unfezant & Pyroar
- file = file + "_" + gender;
-
- // Redrawing logic
- Image baseImage = (Image)Properties.Resources.ResourceManager.GetObject(file);
- if (baseImage == null)
- {
- if (species < 722)
- {
- baseImage = Util.LayerImage(
- (Image)Properties.Resources.ResourceManager.GetObject("_" + species),
- Properties.Resources.unknown,
- 0, 0, .5);
- }
- else
- baseImage = Properties.Resources.unknown;
- }
- if (isegg)
- {
- // Start with a partially transparent species by layering the species with partial opacity onto a blank image.
- baseImage = Util.LayerImage((Image)Properties.Resources.ResourceManager.GetObject("_0"), baseImage, 0, 0, 0.33);
- // Add the egg layer over-top with full opacity.
- baseImage = Util.LayerImage(baseImage, (Image)Properties.Resources.ResourceManager.GetObject("egg"), 0, 0, 1);
- }
- if (shiny)
- {
- // Add shiny star to top left of image.
- baseImage = Util.LayerImage(baseImage, Properties.Resources.rare_icon, 0, 0, 0.7);
- }
- if (item > 0)
- {
- Image itemimg = (Image)Properties.Resources.ResourceManager.GetObject("item_" + item) ?? Properties.Resources.helditem;
- // Redraw
- baseImage = Util.LayerImage(baseImage, itemimg, 22 + (15 - itemimg.Width) / 2, 15 + (15 - itemimg.Height), 1);
- }
- return baseImage;
- }
- internal static Image getSprite(PK6 pk6)
- {
- return getSprite(pk6.Species, pk6.AltForm, pk6.Gender, pk6.HeldItem, pk6.IsEgg, pk6.IsShiny);
- }
- internal static Image getSprite(byte[] data)
- {
- return new PK6(data).Sprite;
- }
-
- // Font Related
- [System.Runtime.InteropServices.DllImport("gdi32.dll")]
- internal static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [System.Runtime.InteropServices.In] ref uint pcFonts);
- internal static readonly PrivateFontCollection s_FontCollection = new PrivateFontCollection();
- internal static FontFamily[] FontFamilies
- {
- get
- {
- if (s_FontCollection.Families.Length == 0) setPKXFont();
- return s_FontCollection.Families;
- }
- }
- internal static Font getPKXFont(float size)
- {
- return new Font(FontFamilies[0], size);
- }
- internal static void setPKXFont()
- {
- try
- {
- byte[] fontData = Properties.Resources.pgldings_normalregular;
- IntPtr fontPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(fontData.Length);
- System.Runtime.InteropServices.Marshal.Copy(fontData, 0, fontPtr, fontData.Length);
- s_FontCollection.AddMemoryFont(fontPtr, Properties.Resources.pgldings_normalregular.Length); uint dummy = 0;
- AddFontMemResourceEx(fontPtr, (uint)Properties.Resources.pgldings_normalregular.Length, IntPtr.Zero, ref dummy);
- System.Runtime.InteropServices.Marshal.FreeCoTaskMem(fontPtr);
- }
- catch { Util.Error("Unable to add ingame font."); }
- }
-
- // Personal.dat
- internal static string[] getFormList(int species, string[] t, string[] f, string[] g)
- {
- // Mega List
- if (Array.IndexOf(new[]
- { // XY
- 003, 009, 065, 094, 115, 127, 130, 142, 181, 212, 214, 229, 248, 257, 282, 303, 306, 308, 310, 354, 359, 380, 381, 445, 448, 460,
- // ORAS
- 015, 018, 080, 208, 254, 260, 302, 319, 323, 334, 362, 373, 376, 384, 428, 475, 531, 719,
- }, species) > -1) { // ...
- return new[]
- {
- t[000], // Normal
- f[723], // Mega
- };}
- // MegaXY List
- switch (species)
- {
- case 6:
- case 150:
- return new[]
- {
- t[000], // Normal
- f[724], // Mega X
- f[725], // Mega Y
- };
- case 025:
- return new[]
- {
- t[000], // Normal
- f[729], // Rockstar
- f[730], // Belle
- f[731], // Pop
- f[732], // PhD
- f[733], // Libre
- f[734], // Cosplay
- };
- case 201:
- return new[]
- {
- "A", "B", "C", "D", "E",
- "F", "G", "H", "I", "J",
- "K", "L", "M", "N", "O",
- "P", "Q", "R", "S", "T",
- "U", "V", "W", "X", "Y",
- "Z",
- "!", "?",
- };
- case 351:
- return new[]
- {
- t[000], // Normal
- f[789], // Sunny
- f[790], // Rainy
- f[791], // Snowy
- };
- case 382:
- case 383:
- return new[]
- {
- t[000], // Normal
- f[800], // Primal
- };
- case 386:
- return new[]
- {
- t[000], // Normal
- f[802], // Attack
- f[803], // Defense
- f[804], // Speed
- };
-
- case 412:
- case 413:
- case 414:
- return new[]
- {
- f[412], // Plant
- f[805], // Sandy
- f[806], // Trash
- };
-
- case 421:
- return new[]
- {
- f[421], // Overcast
- f[809], // Sunshine
- };
-
- case 422:
- case 423:
- return new[]
- {
- f[422], // West
- f[811], // East
- };
-
- case 479:
- return new[]
- {
- t[000], // Normal
- f[817], // Heat
- f[818], // Wash
- f[819], // Frost
- f[820], // Fan
- f[821], // Mow
- };
-
- case 487:
- return new[]
- {
- f[487], // Altered
- f[822], // Origin
- };
-
- case 492:
- return new[]
- {
- f[492], // Land
- f[823], // Sky
- };
-
- case 493:
- return new[]
- {
- t[00], // Normal
- t[01], // Fighting
- t[02], // Flying
- t[03], // Poison
- t[04], // etc
- t[05],
- t[06],
- t[07],
- t[08],
- t[09],
- t[10],
- t[11],
- t[12],
- t[13],
- t[14],
- t[15],
- t[16],
- t[17],
- };
-
- case 550:
- return new[]
- {
- f[550], // Red
- f[842], // Blue
- };
-
- case 555:
- return new[]
- {
- f[555], // Standard
- f[843], // Zen
- };
-
- case 585:
- case 586:
- return new[]
- {
- f[585], // Spring
- f[844], // Summer
- f[845], // Autumn
- f[846], // Winter
- };
-
- case 641:
- case 642:
- case 645:
- return new[]
- {
- f[641], // Incarnate
- f[852], // Therian
- };
-
- case 646:
- return new[]
- {
- t[000], // Normal
- f[853], // White
- f[854], // Black
- };
-
- case 647:
- return new[]
- {
- f[647], // Ordinary
- f[855], // Resolute
- };
-
- case 648:
- return new[]
- {
- f[648], // Aria
- f[856], // Pirouette
- };
-
- case 649:
- return new[]
- {
- t[000], // Normal
- t[010], // Douse
- t[012], // Shock
- t[009], // Burn
- t[014], // Chill
- };
-
- case 664:
- case 665:
- case 666:
- return new[]
- {
- f[666], // Icy Snow
- f[861], // Polar
- f[862], // Tundra
- f[863], // Continental
- f[864], // Garden
- f[865], // Elegant
- f[866], // Meadow
- f[867], // Modern
- f[868], // Marine
- f[869], // Archipelago
- f[870], // High-Plains
- f[871], // Sandstorm
- f[872], // River
- f[873], // Monsoon
- f[874], // Savannah
- f[875], // Sun
- f[876], // Ocean
- f[877], // Jungle
- f[878], // Fancy
- f[879], // Poké Ball
- };
-
- case 669:
- case 671:
- return new[]
- {
- f[669], // Red
- f[884], // Yellow
- f[885], // Orange
- f[886], // Blue
- f[887], // White
- };
-
- case 670:
- return new[]
- {
- f[669], // Red
- f[884], // Yellow
- f[885], // Orange
- f[886], // Blue
- f[887], // White
- f[888], // Eternal
- };
-
- case 676:
- return new[]
- {
- f[676], // Natural
- f[893], // Heart
- f[894], // Star
- f[895], // Diamond
- f[896], // Deputante
- f[897], // Matron
- f[898], // Dandy
- f[899], // La Reine
- f[900], // Kabuki
- f[901], // Pharaoh
- };
-
- case 678:
- return new[]
- {
- g[000], // Male
- g[001], // Female
- };
-
- case 681:
- return new[]
- {
- f[681], // Shield
- f[903], // Blade
- };
-
- case 710:
- case 711:
- return new[]
- {
- f[904], // Small
- f[710], // Average
- f[905], // Large
- f[906], // Super
- };
-
- case 716:
- return new[]
- {
- t[000], // Normal
- f[910], // Active
- };
-
- case 720:
- return new[]
- {
- t[000], // Normal
- f[912], // Unbound
- };
- }
- return new[] {""};
- }
- internal static int getDexFormIndexXY(int species, int formct)
- {
- if (formct < 1 || species < 0)
- return -1; // invalid
- switch (species)
- {
- case 201: return 000; // 28 Unown
- case 386: return 028; // 4 Deoxys
- case 492: return 032; // 2 Shaymin
- case 487: return 034; // 2 Giratina
- case 479: return 036; // 6 Rotom
- case 422: return 042; // 2 Shellos
- case 423: return 044; // 2 Gastrodon
- case 412: return 046; // 3 Burmy
- case 413: return 049; // 3 Wormadam
- case 351: return 052; // 4 Castform
- case 421: return 056; // 2 Cherrim
- case 585: return 058; // 4 Deerling
- case 586: return 062; // 4 Sawsbuck
- case 648: return 066; // 2 Meloetta
- case 555: return 068; // 2 Darmanitan
- case 550: return 070; // 2 Basculin
- case 646: return 072; // 3 Kyurem
- case 647: return 075; // 2 Keldeo
- case 642: return 077; // 2 Thundurus
- case 641: return 079; // 2 Tornadus
- case 645: return 081; // 2 Landorus
- case 666: return 083; // 20 Vivillion
- case 669: return 103; // 5 Flabébé
- case 670: return 108; // 6 Floette
- case 671: return 114; // 5 Florges
- case 710: return 119; // 4 Pumpkaboo
- case 711: return 123; // 4 Gourgeist
- case 681: return 127; // 2 Aegislash
- case 716: return 129; // 2 Xerneas
- case 003: return 131; // 2 Venusaur
- case 006: return 133; // 3 Charizard
- case 009: return 136; // 2 Blastoise
- case 065: return 138; // 2 Alakazam
- case 094: return 140; // 2 Gengar
- case 115: return 142; // 2 Kangaskhan
- case 127: return 144; // 2 Pinsir
- case 130: return 146; // 2 Gyarados
- case 142: return 148; // 2 Aerodactyl
- case 150: return 150; // 3 Mewtwo
- case 181: return 153; // 2 Ampharos
- case 212: return 155; // 2 Scizor
- case 214: return 157; // 2 Heracros
- case 229: return 159; // 2 Houndoom
- case 248: return 161; // 2 Tyranitar
- case 257: return 163; // 2 Blaziken
- case 282: return 165; // 2 Gardevoir
- case 303: return 167; // 2 Mawile
- case 306: return 169; // 2 Aggron
- case 308: return 171; // 2 Medicham
- case 310: return 173; // 2 Manetric
- case 354: return 175; // 2 Banette
- case 359: return 177; // 2 Absol
- case 380: return 179; // 2 Latias
- case 381: return 181; // 2 Latios
- case 445: return 183; // 2 Garchomp
- case 448: return 185; // 2 Lucario
- case 460: return 187; // 2 Abomasnow
- default: return -1;
- }
- }
- internal static int getDexFormIndexORAS(int species, int formct)
- {
- if (formct < 1 || species < 0)
- return -1; // invalid
- switch (species)
- {
- case 025: return 189; // 7 Pikachu
- case 720: return 196; // 2 Hoopa
- case 015: return 198; // 2 Beedrill
- case 018: return 200; // 2 Pidgeot
- case 080: return 202; // 2 Slowbro
- case 208: return 204; // 2 Steelix
- case 254: return 206; // 2 Sceptile
- case 360: return 208; // 2 Swampert
- case 302: return 210; // 2 Sableye
- case 319: return 212; // 2 Sharpedo
- case 323: return 214; // 2 Camerupt
- case 334: return 216; // 2 Altaria
- case 362: return 218; // 2 Glalie
- case 373: return 220; // 2 Salamence
- case 376: return 222; // 2 Metagross
- case 384: return 224; // 2 Rayquaza
- case 428: return 226; // 2 Lopunny
- case 475: return 228; // 2 Gallade
- case 531: return 230; // 2 Audino
- case 719: return 232; // 2 Diancie
- case 382: return 234; // 2 Kyogre
- case 383: return 236; // 2 Groudon
- case 493: return 238; // 18 Arceus
- case 649: return 256; // 5 Genesect
- case 676: return 261; // 10 Furfrou
- default: return getDexFormIndexXY(species, formct);
- }
- }
-
- /// Calculate the Hidden Power Type of the entered IVs.
- /// Order: HP,ATK,DEF,SPEED,SPA,SPD
- /// Hidden Power Type
- internal static int getHPType(int[] ivs)
- {
- return 15 * ((ivs[0] & 1) + 2 * (ivs[1] & 1) + 4 * (ivs[2] & 1) + 8 * (ivs[3] & 1) + 16 * (ivs[4] & 1) + 32 * (ivs[5] & 1)) / 63;
- }
- internal static int[] setHPIVs(int type, int[] ivs)
- {
- for (int i = 0; i < 6; i++)
- ivs[i] = (ivs[i] & 0x1E) + hpivs[type, i];
- return ivs;
- }
- internal static readonly int[,] hpivs = {
- { 1, 1, 0, 0, 0, 0 }, // Fighting
- { 0, 0, 0, 0, 0, 1 }, // Flying
- { 1, 1, 0, 0, 0, 1 }, // Poison
- { 1, 1, 1, 0, 0, 1 }, // Ground
- { 1, 1, 0, 1, 0, 0 }, // Rock
- { 1, 0, 0, 1, 0, 1 }, // Bug
- { 1, 0, 1, 1, 0, 1 }, // Ghost
- { 1, 1, 1, 1, 0, 1 }, // Steel
- { 1, 0, 1, 0, 1, 0 }, // Fire
- { 1, 0, 0, 0, 1, 1 }, // Water
- { 1, 0, 1, 0, 1, 1 }, // Grass
- { 1, 1, 1, 0, 1, 1 }, // Electric
- { 1, 0, 1, 1, 1, 0 }, // Psychic
- { 1, 0, 0, 1, 1, 1 }, // Ice
- { 1, 0, 1, 1, 1, 1 }, // Dragon
- { 1, 1, 1, 1, 1, 1 }, // Dark
- };
-
- internal static readonly string[] StatNames = { "HP", "Atk", "Def", "SpA", "SpD", "Spe" };
- public class ShowdownSet
- {
- // String to Values
- public static readonly string[] types = Util.getStringList("types", "en");
- public static readonly string[] forms = Util.getStringList("forms", "en");
- private static readonly string[] species = Util.getStringList("species", "en");
- private static readonly string[] items = Util.getStringList("items", "en");
- private static readonly string[] natures = Util.getStringList("natures", "en");
- private static readonly string[] moves = Util.getStringList("moves", "en");
- private static readonly string[] abilities = Util.getStringList("abilities", "en");
- private static readonly string[] hptypes = types.Skip(1).ToArray();
-
- // Default Set Data
- public string Nickname;
- public int Species;
- public string Form;
- public string Gender;
- public int Item;
- public int Ability;
- public int Level;
- public bool Shiny;
- public int Friendship;
- public int Nature;
- public int[] EVs;
- public int[] IVs;
- public int[] Moves;
-
- // Parsing Utility
- public ShowdownSet(string input = null)
- {
- if (input == null)
- return;
-
- Nickname = null;
- Species = -1;
- Form = null;
- Gender = null;
- Item = 0;
- Ability = 0;
- Level = 100;
- Shiny = false;
- Friendship = 255;
- Nature = 0;
- EVs = new int[6];
- IVs = new[] { 31, 31, 31, 31, 31, 31 };
- Moves = new int[4];
-
- string[] lines = input.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None);
- for (int i = 0; i < lines.Length; i++) lines[i] = lines[i].Replace("'", "’").Trim(); // Sanitize apostrophes
-
- if (lines.Length < 3) return;
-
- // Seek for start of set
- int start = -1;
- for (int i = 0; i < lines.Length; i++)
- if (lines[i].Contains(" @ ")) { start = i; break; }
- lines = lines.Skip(start).Take(lines.Length - start).ToArray();
-
- // Abort if no text is found
- if (start == -1)
- {
- // Try to parse the first line if it does not have any item
- string ld = lines[0];
- // Gender Detection
- string last3 = ld.Substring(ld.Length - 3);
- if (last3 == "(M)" || last3 == "(F)")
- {
- Gender = last3.Substring(1, 1);
- ld = ld.Substring(0, ld.Length - 3);
- }
- // Nickname Detection
- string spec = ld;
- if (spec.Contains("("))
- {
- int index = spec.LastIndexOf("(", StringComparison.Ordinal);
- string n1 = spec.Substring(0, index - 1);
- string n2 = spec.Substring(index).Replace("(", "").Replace(")", "").Replace(" ", "");
-
- bool inverted = Array.IndexOf(species, n2.Replace(" ", "")) > -1 || (Species = Array.IndexOf(species, n2.Split('-')[0])) > 0;
- spec = inverted ? n2 : n1;
- Nickname = inverted ? n1 : n2;
- }
- Species = Array.IndexOf(species, spec.Replace(" ", ""));
- if (
- (Species = Array.IndexOf(species, spec)) < 0 // Not an Edge Case
- &&
- (Species = Array.IndexOf(species, spec.Replace(" ", ""))) < 0 // Has Form
- )
- {
- string[] tmp = spec.Split(new[] { "-" }, StringSplitOptions.None);
- if (tmp.Length < 2) return;
- Species = Array.IndexOf(species, tmp[0].Replace(" ", ""));
- Form = tmp[1].Replace(" ", "");
- if (tmp.Length > 2)
- Form += " " + tmp[2];
- }
- if (Species < -1)
- return;
- lines = lines.Skip(1).Take(lines.Length - 1).ToArray();
- }
- int movectr = 0;
- // Detect relevant data
- foreach (string line in lines)
- {
- if (line.Length < 2) continue;
- if (line.Contains("- "))
- {
- string moveString = line.Substring(2);
- if (moveString.Contains("Hidden Power"))
- {
- if (moveString.Length > 13) // Defined Hidden Power
- {
- string type = moveString.Remove(0, 13).Replace("[", "").Replace("]", ""); // Trim out excess data
- int hpVal = Array.IndexOf(hptypes, type); // Get HP Type
- if (hpVal >= 0) IVs = setHPIVs(hpVal, IVs); // Get IVs
- }
- moveString = "Hidden Power";
- }
- Moves[movectr++] = Array.IndexOf(moves, moveString);
- if (movectr == 4)
- break; // End of moves
- continue;
- }
-
- string[] brokenline = line.Split(new[] { ": " }, StringSplitOptions.None);
- switch (brokenline[0])
- {
- case "Trait":
- case "Ability": { Ability = Array.IndexOf(abilities, brokenline[1]); break; }
- case "Level": { Level = Util.ToInt32(brokenline[1]); break; }
- case "Shiny": { Shiny = brokenline[1] == "Yes"; break; }
- case "Happiness": { Friendship = Util.ToInt32(brokenline[1]); break; }
- case "EVs":
- {
- // Get EV list String
- string[] evlist = brokenline[1].Replace("SAtk", "SpA").Replace("SDef", "SpD").Replace("Spd", "Spe").Split(new[] { " / ", " " }, StringSplitOptions.None);
- for (int i = 0; i < evlist.Length / 2; i++)
- EVs[Array.IndexOf(StatNames, evlist[1 + i * 2])] = (byte)Util.ToInt32(evlist[0 + 2 * i]);
- break;
- }
- case "IVs":
- {
- // Get IV list String
- string[] ivlist = brokenline[1].Split(new[] { " / ", " " }, StringSplitOptions.None);
- for (int i = 0; i < ivlist.Length / 2; i++)
- IVs[Array.IndexOf(StatNames, ivlist[1 + i * 2])] = (byte)Util.ToInt32(ivlist[0 + 2 * i]);
- break;
- }
- default:
- {
- // Either Nature or Gender ItemSpecies
- if (brokenline[0].Contains(" @ "))
- {
- string[] ld = line.Split(new[] { " @ " }, StringSplitOptions.None);
- Item = Array.IndexOf(items, ld.Last());
- // Gender Detection
- string last3 = ld[0].Substring(ld[0].Length - 3);
- if (last3 == "(M)" || last3 == "(F)")
- {
- Gender = last3.Substring(1, 1);
- ld[0] = ld[0].Substring(0, ld[ld.Length - 2].Length - 3);
- }
- // Nickname Detection
- string spec = ld[0];
- if (spec.Contains("("))
- {
- int index = spec.LastIndexOf("(", StringComparison.Ordinal);
- string n1 = spec.Substring(0, index - 1);
- string n2 = spec.Substring(index).Replace("(", "").Replace(")", "").Replace(" ", "");
-
- bool inverted = Array.IndexOf(species, n2.Replace(" ", "")) > -1 || (Species = Array.IndexOf(species, n2.Split('-')[0])) > 0;
- spec = inverted ? n2 : n1;
- Nickname = inverted ? n1 : n2;
- }
- if (
- (Species = Array.IndexOf(species, spec)) < 0 // Not an Edge Case
- &&
- (Species = Array.IndexOf(species, spec.Replace(" ", ""))) < 0 // Has Form
- )
- {
- string[] tmp = spec.Split(new[] { "-" }, StringSplitOptions.None);
- Species = Array.IndexOf(species, tmp[0].Replace(" ", ""));
- Form = tmp[1].Replace(" ", "");
- if (tmp.Length > 2)
- Form += " " + tmp[2];
- }
- }
- else if (brokenline[0].Contains("Nature"))
- Nature = Array.IndexOf(natures, line.Split(' ')[0]);
- else // Fallback
- Species = Array.IndexOf(species, line.Split('(')[0]);
- } break;
- }
- }
- }
- public string getText()
- {
- if (Species == 0 || Species > 722)
- return "";
-
- // First Line: Name, Nickname, Gender, Item
- string result = string.Format(species[Species] != Nickname ? "{0} ({1})" : "{1}", Nickname,
- species[Species] + ((Form ?? "") != "" ? "-" + Form.Replace("Mega ", "Mega-") : "")) // Species (& Form if necessary)
- + Gender + (Item != 0 ? " @ " + items[Item] : "") + Environment.NewLine;
-
- // IVs
- string[] ivstr = new string[6];
- int ivctr = 0;
- int[] sIVs = { IVs[0], IVs[1], IVs[2], IVs[4], IVs[5], IVs[3] }; // Reorganize speed
- for (int i = 0; i < 6; i++)
- {
- if (sIVs[i] == 31) continue;
- ivstr[ivctr++] += $"{sIVs[i]} {StatNames[i]}";
- }
- if (ivctr > 0)
- result += "IVs: " + string.Join(" / ", ivstr.Take(ivctr)) + Environment.NewLine;
-
- // EVs
- string[] evstr = new string[6];
- int[] sEVs = { EVs[0], EVs[1], EVs[2], EVs[4], EVs[5], EVs[3] }; // Reorganize speed
- int evctr = 0;
- for (int i = 0; i < 6; i++)
- {
- if (sEVs[i] == 0) continue;
- evstr[evctr++] += $"{sEVs[i]} {StatNames[i]}";
- }
- if (evctr > 0)
- result += "EVs: " + string.Join(" / ", evstr.Take(evctr)) + Environment.NewLine;
-
- // Secondary Stats
- result += "Ability: " + abilities[Ability] + Environment.NewLine;
- result += "Level: " + Level + Environment.NewLine;
- if (Shiny)
- result += "Shiny: Yes" + Environment.NewLine;
-
- result += natures[Nature] + " Nature" + Environment.NewLine;
- // Add in Moves
- string[] MoveLines = new string[Moves.Length];
- int movectr = 0;
- foreach (int move in Moves.Where(move => move != 0 && move < moves.Length))
- {
- MoveLines[movectr] += "- " + moves[move];
- if (move == 237)
- MoveLines[movectr] += $" [{hptypes[getHPType(IVs)]}]";
- movectr++;
- }
- result += string.Join(Environment.NewLine, MoveLines.Take(movectr));
-
- return result;
- }
- }
- 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, ShowdownSet.types, ShowdownSet.forms, new [] {"", "F", ""})[pk6.AltForm] : "",
- };
- if (Set.Form == "F") Set.Gender = "";
- return Set.getText();
- }
- }
-}
diff --git a/Misc/QR.cs b/Misc/QR.cs
index 4107d64eb..ebf8dc130 100644
--- a/Misc/QR.cs
+++ b/Misc/QR.cs
@@ -1,5 +1,8 @@
using System;
using System.Drawing;
+using System.IO;
+using System.Net;
+using System.Web;
using System.Windows.Forms;
namespace PKHeX
@@ -41,5 +44,57 @@ namespace PKHeX
try { Clipboard.SetImage(PB_QR.BackgroundImage); }
catch { Util.Alert("Failed to set Image to Clipboard"); }
}
+
+ // QR Utility
+ internal static byte[] getQRData()
+ {
+ // Fetch data from QR code...
+ string address;
+ try { address = Clipboard.GetText(); }
+ catch { Util.Alert("No text (url) in clipboard."); return null; }
+ try { if (address.Length < 4 || address.Substring(0, 3) != "htt") { Util.Alert("Clipboard text is not a valid URL:", address); return null; } }
+ catch { Util.Alert("Clipboard text is not a valid URL:", address); return null; }
+ string webURL = "http://api.qrserver.com/v1/read-qr-code/?fileurl=" + HttpUtility.UrlEncode(address);
+ try
+ {
+ HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(webURL);
+ HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse();
+ var reader = new StreamReader(httpWebReponse.GetResponseStream());
+ string data = reader.ReadToEnd();
+ if (data.Contains("could not find")) { Util.Alert("Reader could not find QR data in the image."); return null; }
+ if (data.Contains("filetype not supported")) { Util.Alert("Input URL is not valid. Double check that it is an image (jpg/png).", address); return null; }
+ // Quickly convert the json response to a data string
+ string pkstr = data.Substring(data.IndexOf("#", StringComparison.Ordinal) + 1); // Trim intro
+ pkstr = pkstr.Substring(0, pkstr.IndexOf("\",\"error\":null}]}]", StringComparison.Ordinal)); // Trim outro
+ if (pkstr.Contains("nQR-Code:")) pkstr = pkstr.Substring(0, pkstr.IndexOf("nQR-Code:", StringComparison.Ordinal)); // Remove multiple QR codes in same image
+ pkstr = pkstr.Replace("\\", ""); // Rectify response
+
+ try { return Convert.FromBase64String(pkstr); }
+ catch { Util.Alert("QR string to Data failed.", pkstr); return null; }
+ }
+ catch { Util.Alert("Unable to connect to the internet to decode QR code."); return null; }
+ }
+ internal static Image getQRImage(byte[] data, string server)
+ {
+ string qrdata = Convert.ToBase64String(data);
+ string message = server + qrdata;
+ string webURL = "http://chart.apis.google.com/chart?chs=365x365&cht=qr&chl=" + HttpUtility.UrlEncode(message);
+
+ try
+ {
+ HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(webURL);
+ HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse();
+ Stream stream = httpWebReponse.GetResponseStream();
+ if (stream != null) return Image.FromStream(stream);
+ }
+ catch
+ {
+ if (DialogResult.Yes != Util.Prompt(MessageBoxButtons.YesNo, "Unable to connect to the internet to receive QR code.", "Copy QR URL to Clipboard?"))
+ return null;
+ try { Clipboard.SetText(webURL); }
+ catch { Util.Alert("Failed to set text to Clipboard"); }
+ }
+ return null;
+ }
}
}
\ No newline at end of file
diff --git a/Misc/SAV4.cs b/Misc/SAV4.cs
deleted file mode 100644
index d3b491e27..000000000
--- a/Misc/SAV4.cs
+++ /dev/null
@@ -1,178 +0,0 @@
-using System;
-using System.Linq;
-
-namespace PKHeX
-{
- public class SAV4 : PKM
- {
- internal const int SIZERAW = 0x80000; // 512KB
- internal static int getIsG4SAV(byte[] data)
- {
- int version = -1;
- if (BitConverter.ToUInt16(data, 0xC0FE) == ccitt16(data.Take(0xC0EC).ToArray()))
- version = 0; // DP
- else if (BitConverter.ToUInt16(data, 0xCF2A) == ccitt16(data.Take(0xCF18).ToArray()))
- version = 1; // PT
- else if (BitConverter.ToUInt16(data, 0xF626) == ccitt16(data.Take(0xF618).ToArray()))
- version = 2; // HGSS
- return version;
- }
-
- // Global Settings
- // Save Data Attributes
- public readonly byte[] Data;
- public bool Edited;
- public readonly bool Exportable;
- public readonly byte[] BAK;
- public string FileName, FilePath;
- public SAV4(byte[] data = null)
- {
- Data = (byte[])(data ?? new byte[SIZERAW]).Clone();
- BAK = (byte[])Data.Clone();
- Exportable = !Data.SequenceEqual(new byte[Data.Length]);
-
- // Get Version
- int version = getIsG4SAV(Data);
- getActiveBlock(version);
- getSAVOffsets(version);
- }
-
- private int generalBlock = -1;
- private int storageBlock = -1;
- private void getActiveBlock(int version)
- {
- if (version < 0)
- return;
- int ofs = 0;
-
- if (version == 0) ofs = 0xC0F0; // DP
- else if (version == 1) ofs = 0xCF1C; // PT
- else if (version == 2) ofs = 0xF626; // HGSS
- generalBlock = BitConverter.ToUInt16(Data, ofs) >= BitConverter.ToUInt16(Data, ofs + 0x40000) ? 0 : 1;
-
- if (version == 0) ofs = 0x1E2D0; // DP
- else if (version == 1) ofs = 0x1F100; // PT
- else if (version == 2) ofs = 0x21A00; // HGSS
- storageBlock = BitConverter.ToUInt16(Data, ofs) >= BitConverter.ToUInt16(Data, ofs + 0x40000) ? 0 : 1;
- }
- private void getSAVOffsets(int version)
- {
- if (version < 0)
- return;
-
- switch (version)
- {
- case 0: // DP
- Party = 0x98 + 0x40000 * generalBlock;
- Box = 0xC104 + 0x40000 * storageBlock;
- break;
- case 1: // PT
- Party = 0xA0 + 0x40000 * generalBlock;
- Box = 0xCF34 + 0x40000 * storageBlock;
- break;
- case 2: // HGSS
- Party = 0x98 + 0x40000 * generalBlock;
- Box = 0xF704 + 0x40000 * storageBlock;
- break;
- }
- }
-
- private int Box, Party = -1;
-
- public int PartyCount
- {
- get { return Data[Party - 4]; }
- set { Data[Party - 4] = (byte)value; }
- }
-
- public int BoxCount
- {
- get { return Data[Box - 4]; }
- set { Data[Box - 4] = (byte)value; }
- }
- public PK4[] BoxData
- {
- get
- {
- PK4[] data = new PK4[18 * 30];
- for (int i = 0; i < data.Length; i++)
- {
- data[i] = getPK4Stored(Box + PK4.SIZE_STORED * i);
- data[i].Identifier = $"B{(i / 30 + 1).ToString("00")}:{(i % 30 + 1).ToString("00")}";
- }
- return data;
- }
- set
- {
- if (value == null)
- throw new ArgumentNullException();
- if (value.Length != 18 * 30)
- throw new ArgumentException("Expected 540, got " + value.Length);
-
- for (int i = 0; i < value.Length; i++)
- setPK4Stored(value[i], Box + PK4.SIZE_STORED * i);
- }
- }
- public PK4[] PartyData
- {
- get
- {
- PK4[] data = new PK4[PartyCount];
- for (int i = 0; i < data.Length; i++)
- data[i] = getPK4Party(Party + PK4.SIZE_PARTY * i);
- return data;
- }
- set
- {
- if (value == null)
- throw new ArgumentNullException();
- if (value.Length == 0 || value.Length > 6)
- throw new ArgumentException("Expected 1-6, got " + value.Length);
- if (value[0].Species == 0)
- throw new ArgumentException("Can't have an empty first slot." + value.Length);
-
- PK4[] newParty = value.Where(pk => pk.Species != 0).ToArray();
-
- PartyCount = newParty.Length;
- Array.Resize(ref newParty, 6);
-
- for (int i = PartyCount; i < newParty.Length; i++)
- newParty[i] = new PK4();
- for (int i = 0; i < newParty.Length; i++)
- setPK4Party(newParty[i], Party + PK4.SIZE_PARTY * i);
- }
- }
-
- public PK4 getPK4Party(int offset)
- {
- return new PK4(decryptArray(getData(offset, PK4.SIZE_PARTY)));
- }
- public PK4 getPK4Stored(int offset)
- {
- return new PK4(decryptArray(getData(offset, PK4.SIZE_STORED)));
- }
- public void setPK4Party(PK4 pk4, int offset)
- {
- if (pk4 == null) return;
-
- setData(pk4.EncryptedPartyData, offset);
- Edited = true;
- }
- public void setPK4Stored(PK4 pk4, int offset)
- {
- if (pk4 == null) return;
-
- setData(pk4.EncryptedBoxData, offset);
- Edited = true;
- }
- public byte[] getData(int Offset, int Length)
- {
- return Data.Skip(Offset).Take(Length).ToArray();
- }
- public void setData(byte[] input, int Offset)
- {
- input.CopyTo(Data, Offset);
- Edited = true;
- }
- }
-}
diff --git a/Misc/SAV5.cs b/Misc/SAV5.cs
deleted file mode 100644
index 7f29c58f2..000000000
--- a/Misc/SAV5.cs
+++ /dev/null
@@ -1,204 +0,0 @@
-using System;
-using System.Linq;
-
-namespace PKHeX
-{
- public class SAV5 : PKM
- {
- internal const int SIZERAW = 0x80000; // 512KB
- internal const int SIZE1 = 0x24000; // B/W
- internal const int SIZE2 = 0x26000; // B2/W2
-
- internal static int getIsG5SAV(byte[] data)
- {
- ushort chk1 = BitConverter.ToUInt16(data, SIZE1 - 0x100 + 0x8C + 0xE);
- ushort actual1 = ccitt16(data.Skip(SIZE1 - 0x100).Take(0x8C).ToArray());
- if (chk1 == actual1)
- return 0;
- ushort chk2 = BitConverter.ToUInt16(data, SIZE2 - 0x100 + 0x94 + 0xE);
- ushort actual2 = ccitt16(data.Skip(SIZE2 - 0x100).Take(0x94).ToArray());
- if (chk2 == actual2)
- return 1;
- return -1;
- }
-
- // Global Settings
- // Save Data Attributes
- public readonly byte[] Data;
- public bool Edited;
- public readonly bool Exportable;
- public readonly byte[] BAK;
- public string FileName, FilePath;
- public SAV5(byte[] data = null)
- {
- Data = (byte[])(data ?? new byte[SIZERAW]).Clone();
- BAK = (byte[])Data.Clone();
- Exportable = !Data.SequenceEqual(new byte[Data.Length]);
-
- // Get Version
- int version = getIsG5SAV(Data);
- if (version < 0) // Invalidate Data
- Data = null;
-
- // Different Offsets for different games.
- BattleBox = version == 1 ? 0x20A00 : 0x20900;
- }
-
- private const int Box = 0x400;
- private const int Party = 0x18E00;
- private readonly int BattleBox;
- private const int Trainer = 0x19400;
- private const int Wondercard = 0x1C800;
- private const int wcSeed = 0x1D290;
-
- public int PartyCount
- {
- get { return Data[Party]; }
- set { Data[Party] = (byte)value; }
- }
-
- public PK5[] BoxData
- {
- get
- {
- PK5[] data = new PK5[24 * 30];
- for (int i = 0; i < data.Length; i++)
- {
- data[i] = getPK5Stored(Box + i/30 * 0x10 + PK5.SIZE_STORED * i);
- data[i].Identifier = $"B{(i / 30 + 1).ToString("00")}:{(i % 30 + 1).ToString("00")}";
- }
- return data;
- }
- set
- {
- if (value == null)
- throw new ArgumentNullException();
- if (value.Length != 24 * 30)
- throw new ArgumentException("Expected 720, got " + value.Length);
-
- for (int i = 0; i < value.Length; i++)
- setPK5Stored(value[i], Box + i/30 * 0x10 + PK5.SIZE_STORED * i);
- }
- }
- public PK5[] PartyData
- {
- get
- {
- PK5[] data = new PK5[PartyCount];
- for (int i = 0; i < data.Length; i++)
- data[i] = getPK5Party(Party + 8 + PK5.SIZE_PARTY * i);
- return data;
- }
- set
- {
- if (value == null)
- throw new ArgumentNullException();
- if (value.Length == 0 || value.Length > 6)
- throw new ArgumentException("Expected 1-6, got " + value.Length);
- if (value[0].Species == 0)
- throw new ArgumentException("Can't have an empty first slot." + value.Length);
-
- PK5[] newParty = value.Where(pk => pk.Species != 0).ToArray();
-
- PartyCount = newParty.Length;
- Array.Resize(ref newParty, 6);
-
- for (int i = PartyCount; i < newParty.Length; i++)
- newParty[i] = new PK5();
- for (int i = 0; i < newParty.Length; i++)
- setPK5Party(newParty[i], Party + 8 + PK5.SIZE_PARTY * i);
- }
- }
- public PK5[] BattleBoxData
- {
- get
- {
- PK5[] data = new PK5[6];
- for (int i = 0; i < data.Length; i++)
- {
- data[i] = getPK5Stored(BattleBox + PK5.SIZE_STORED * i);
- if (data[i].Species == 0)
- return data.Take(i).ToArray();
- }
- return data;
- }
- }
-
- public class MysteryGift
- {
- public readonly PGF[] Cards = new PGF[12];
- public readonly bool[] UsedFlags = new bool[0x800];
- public uint Seed;
- }
- public MysteryGift WondercardInfo
- {
- get
- {
- uint seed = BitConverter.ToUInt32(Data, wcSeed);
- MysteryGift Info = new MysteryGift { Seed = seed };
- byte[] wcData = Data.Skip(Wondercard).Take(0xA90).ToArray(); // Encrypted, Decrypt
- for (int i = 0; i < wcData.Length; i += 2)
- BitConverter.GetBytes((ushort)(BitConverter.ToUInt16(wcData, i) ^ LCRNG(ref seed) >> 16)).CopyTo(wcData, i);
-
- // 0x100 Bytes for Used Flags
- for (int i = 0; i < Info.UsedFlags.Length; i++)
- Info.UsedFlags[i] = (wcData[i/8] >> i%8 & 0x1) == 1;
- // 12 PGFs
- for (int i = 0; i < Info.Cards.Length; i++)
- Info.Cards[i] = new PGF(Data.Skip(0x100 + i*PGF.Size).Take(PGF.Size).ToArray());
-
- return Info;
- }
- set
- {
- MysteryGift Info = value;
- byte[] wcData = new byte[0xA90];
-
- // Toss back into byte[]
- for (int i = 0; i < Info.UsedFlags.Length; i++)
- if (Info.UsedFlags[i])
- wcData[i/8] |= (byte)(1 << (i & 7));
- for (int i = 0; i < Info.Cards.Length; i++)
- Info.Cards[i].Data.CopyTo(wcData, 0x100 + i*PGF.Size);
-
- // Decrypted, Encrypt
- uint seed = Info.Seed;
- for (int i = 0; i < wcData.Length; i += 2)
- BitConverter.GetBytes((ushort)(BitConverter.ToUInt16(wcData, i) ^ LCRNG(ref seed) >> 16)).CopyTo(wcData, i);
- BitConverter.GetBytes(Info.Seed).CopyTo(Data, wcSeed);
- }
- }
-
- public PK5 getPK5Party(int offset)
- {
- return new PK5(decryptArray(getData(offset, PK5.SIZE_PARTY)));
- }
- public PK5 getPK5Stored(int offset)
- {
- return new PK5(decryptArray(getData(offset, PK5.SIZE_STORED)));
- }
- public void setPK5Party(PK5 pk5, int offset)
- {
- if (pk5 == null) return;
-
- setData(pk5.EncryptedPartyData, offset);
- Edited = true;
- }
- public void setPK5Stored(PK5 pk5, int offset)
- {
- if (pk5 == null) return;
-
- setData(pk5.EncryptedBoxData, offset);
- Edited = true;
- }
- public byte[] getData(int Offset, int Length)
- {
- return Data.Skip(Offset).Take(Length).ToArray();
- }
- public void setData(byte[] input, int Offset)
- {
- input.CopyTo(Data, Offset);
- Edited = true;
- }
- }
-}
diff --git a/Misc/Util.cs b/Misc/Util.cs
index 1702d2dda..f2fb81b6f 100644
--- a/Misc/Util.cs
+++ b/Misc/Util.cs
@@ -149,6 +149,7 @@ namespace PKHeX
internal static string[] getStringList(string f)
{
object txt = Properties.Resources.ResourceManager.GetObject(f); // Fetch File, \n to list.
+ if (txt == null) return new string[0];
string[] rawlist = ((string)txt).Split('\n');
for (int i = 0; i < rawlist.Length; i++)
rawlist[i] = rawlist[i].Trim();
@@ -157,6 +158,7 @@ namespace PKHeX
internal static string[] getStringList(string f, string l)
{
object txt = Properties.Resources.ResourceManager.GetObject("text_" + f + "_" + l); // Fetch File, \n to list.
+ if (txt == null) return new string[0];
string[] rawlist = ((string)txt).Split('\n');
for (int i = 0; i < rawlist.Length; i++)
rawlist[i] = rawlist[i].Trim();
@@ -473,57 +475,5 @@ namespace PKHeX
}
return cbList;
}
-
- // QR Utility
- internal static byte[] getQRData()
- {
- // Fetch data from QR code...
- string address;
- try { address = Clipboard.GetText(); }
- catch { Alert("No text (url) in clipboard."); return null; }
- try { if (address.Length < 4 || address.Substring(0, 3) != "htt") { Alert("Clipboard text is not a valid URL:", address); return null; } }
- catch { Alert("Clipboard text is not a valid URL:", address); return null; }
- string webURL = "http://api.qrserver.com/v1/read-qr-code/?fileurl=" + System.Web.HttpUtility.UrlEncode(address);
- try
- {
- System.Net.HttpWebRequest httpWebRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(webURL);
- System.Net.HttpWebResponse httpWebReponse = (System.Net.HttpWebResponse)httpWebRequest.GetResponse();
- var reader = new StreamReader(httpWebReponse.GetResponseStream());
- string data = reader.ReadToEnd();
- if (data.Contains("could not find")) { Alert("Reader could not find QR data in the image."); return null; }
- if (data.Contains("filetype not supported")) { Alert("Input URL is not valid. Double check that it is an image (jpg/png).", address); return null; }
- // Quickly convert the json response to a data string
- string pkstr = data.Substring(data.IndexOf("#", StringComparison.Ordinal) + 1); // Trim intro
- pkstr = pkstr.Substring(0, pkstr.IndexOf("\",\"error\":null}]}]", StringComparison.Ordinal)); // Trim outro
- if (pkstr.Contains("nQR-Code:")) pkstr = pkstr.Substring(0, pkstr.IndexOf("nQR-Code:", StringComparison.Ordinal)); // Remove multiple QR codes in same image
- pkstr = pkstr.Replace("\\", ""); // Rectify response
-
- try { return Convert.FromBase64String(pkstr); }
- catch { Alert("QR string to Data failed.", pkstr); return null; }
- }
- catch { Alert("Unable to connect to the internet to decode QR code."); return null;}
- }
- internal static Image getQRImage(byte[] data, string server)
- {
- string qrdata = Convert.ToBase64String(data);
- string message = server + qrdata;
- string webURL = "http://chart.apis.google.com/chart?chs=365x365&cht=qr&chl=" + System.Web.HttpUtility.UrlEncode(message);
-
- try
- {
- System.Net.HttpWebRequest httpWebRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(webURL);
- System.Net.HttpWebResponse httpWebReponse = (System.Net.HttpWebResponse)httpWebRequest.GetResponse();
- Stream stream = httpWebReponse.GetResponseStream();
- if (stream != null) return Image.FromStream(stream);
- }
- catch
- {
- if (DialogResult.Yes != Prompt(MessageBoxButtons.YesNo, "Unable to connect to the internet to receive QR code.", "Copy QR URL to Clipboard?"))
- return null;
- try { Clipboard.SetText(webURL); }
- catch { Alert("Failed to set text to Clipboard"); }
- }
- return null;
- }
}
}
\ No newline at end of file
diff --git a/MysteryGifts/MysteryGift.cs b/MysteryGifts/MysteryGift.cs
new file mode 100644
index 000000000..ae40ce583
--- /dev/null
+++ b/MysteryGifts/MysteryGift.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Linq;
+
+namespace PKHeX
+{
+ public abstract class MysteryGift
+ {
+ internal static MysteryGift getMysteryGift(byte[] data, string ext)
+ {
+ if (data.Length == WC6.SizeFull && ext == ".wc6full")
+ return new WC6(data);
+ if (data.Length == WC6.Size && ext == ".wc6")
+ return new WC6(data);
+ if (data.Length == PGF.Size && ext == ".pgf")
+ return new PGF(data);
+ if (data.Length == PGT.Size && ext == ".pgt")
+ return new PGT(data);
+ if (data.Length == PCD.Size && ext == ".pcd")
+ return new PCD(data);
+ return null;
+ }
+
+ public abstract string Extension { get; }
+ public virtual byte[] Data { get; set; }
+ public abstract PKM convertToPKM(SaveFile SAV);
+
+ // Properties
+ public abstract bool GiftUsed { get; set; }
+ public abstract string CardTitle { get; set; }
+ public abstract int CardID { get; set; }
+
+ public abstract bool IsItem { get; set; }
+ public abstract int Item { get; set; }
+
+ public abstract bool IsPokémon { get; set; }
+ public virtual int Quantity { get { return 1; } set { } }
+ public bool Empty => Data.SequenceEqual(new byte[Data.Length]);
+
+ public string getCardHeader() => (CardID > 0 ? $"Card #: {CardID.ToString("0000")}" : "N/A") + $" - {CardTitle.Trim()}" + Environment.NewLine;
+ }
+}
diff --git a/Misc/PGF.cs b/MysteryGifts/PGF.cs
similarity index 89%
rename from Misc/PGF.cs
rename to MysteryGifts/PGF.cs
index 6ed875563..22892e310 100644
--- a/Misc/PGF.cs
+++ b/MysteryGifts/PGF.cs
@@ -3,14 +3,16 @@ using System.Text;
namespace PKHeX
{
- public class PGF
+ public class PGF : MysteryGift
{
internal const int Size = 0xCC;
+ public override string Extension => ".pgf";
- public byte[] Data;
public PGF(byte[] data = null)
{
- Data = data ?? new byte[Size];
+ Data = (byte[])(data?.Clone() ?? new byte[Size]);
+ if (data == null) Data = new byte[Size];
+ else Data = (byte[])data.Clone();
}
public ushort TID { get { return BitConverter.ToUInt16(Data, 0x00); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x00); } }
@@ -49,7 +51,7 @@ namespace PKHeX
public int Language { get { return Data[0x1D]; } set { Data[0x1D] = (byte)value; } }
public string Nickname
{
- get { return PKM.TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x1E, 0x16)); }
+ get { return PKX.TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x1E, 0x16)); }
set { Encoding.Unicode.GetBytes(value.PadRight(0xB, (char)0xFFFF)).CopyTo(Data, 0x1E); }
}
public int Nature { get { return Data[0x34]; } set { Data[0x34] = (byte)value; } }
@@ -73,27 +75,32 @@ namespace PKHeX
public int IV_SPD { get { return Data[0x48]; } set { Data[0x48] = (byte)value; } }
// Unused 0x49
public string OT {
- get { return PKM.TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x4A, 0x10)); }
+ get { return PKX.TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x4A, 0x10)); }
set { Encoding.Unicode.GetBytes(value.PadRight(0x08, (char)0xFFFF)).CopyTo(Data, 0x4A); } }
public int OTGender { get { return Data[0x5A]; } set { Data[0x5A] = (byte)value; } }
public int Level { get { return Data[0x5B]; } set { Data[0x5C] = (byte)value; } }
public bool IsEgg { get { return Data[0x5C] == 1; } set { Data[0x5C] = (byte)(value ? 1 : 0); } }
// Unused 0x5D 0x5E 0x5F
+ public override string CardTitle
+ {
+ get { return PKX.TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x60, 0x4A)); }
+ set { Encoding.Unicode.GetBytes((value + '\uFFFF').PadRight(0x4A/2, '\0')).CopyTo(Data, 0x60); }
+ }
// Card Attributes
- public ushort Item { get { return BitConverter.ToUInt16(Data, 0x00); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x00); } }
+ public override int Item { get { return BitConverter.ToUInt16(Data, 0x00); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x00); } }
public ushort Year { get { return BitConverter.ToUInt16(Data, 0xAE); } set { BitConverter.GetBytes(value).CopyTo(Data, 0xAE); } }
public byte Month { get { return Data[0xAD]; } set { Data[0xAD] = value; } }
public byte Day { get { return Data[0xAC]; } set { Data[0xAC] = value; } }
- public int CardID
+ public override int CardID
{
get { return BitConverter.ToUInt16(Data, 0xB0); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xB0); }
}
public int CardLocation { get { return Data[0xB2]; } set { Data[0xB2] = (byte)value; } }
public int CardType { get { return Data[0xB3]; } set { Data[0xB3] = (byte)value; } }
- public bool GiftUsed { get { return Data[0xB4] >> 1 > 0; } set { Data[0xB4] = (byte)(Data[0xB4] & ~2 | (value ? 2 : 0)); } }
+ public override bool GiftUsed { get { return Data[0xB4] >> 1 > 0; } set { Data[0xB4] = (byte)(Data[0xB4] & ~2 | (value ? 2 : 0)); } }
public bool MultiObtain { get { return Data[0xB4] == 1; } set { Data[0xB4] = (byte)(value ? 1 : 0); } }
// Meta Accessible Properties
@@ -111,11 +118,11 @@ namespace PKHeX
if (value.Length > 3) Move4 = value[3];
}
}
- public bool IsPokémon { get { return CardType == 1; } set { if (value) CardType = 1; } }
- public bool IsItem { get { return CardType == 2; } set { if (value) CardType = 2; } }
+ public override bool IsPokémon { get { return CardType == 1; } set { if (value) CardType = 1; } }
+ public override bool IsItem { get { return CardType == 2; } set { if (value) CardType = 2; } }
public bool IsPower { get { return CardType == 3; } set { if (value) CardType = 3; } }
- public PK5 convertToPK5(SAV6 SAV)
+ public override PKM convertToPKM(SaveFile SAV)
{
if (!IsPokémon)
return null;
@@ -179,21 +186,21 @@ namespace PKHeX
RIB7_3 = RIB1_5, // National Champ Ribbon
RIB2_5 = RIB1_6, // World Champ Ribbon
- Friendship = PKX.getBaseFriendship(Species),
+ OT_Friendship = PKX.getBaseFriendship(Species),
FatefulEncounter = true,
};
if (OTGender == 3) // User's
{
- pk.TID = 12345;
- pk.SID = 54321;
- pk.OT_Name = "PKHeX";
+ pk.TID = SAV.TID;
+ pk.SID = SAV.SID;
+ pk.OT_Name = SAV.OT;
pk.OT_Gender = 1; // Red PKHeX OT
}
else
{
- pk.TID = TID;
- pk.SID = SID;
- pk.OT_Name = OT.Length > 0 ? OT : "PKHeX";
+ pk.TID = IsEgg ? SAV.TID : TID;
+ pk.SID = IsEgg ? SAV.SID : SID;
+ pk.OT_Name = OT.Length > 0 ? OT : SAV.OT;
pk.OT_Gender = OTGender % 2; // %2 just in case?
}
pk.IsNicknamed = IsNicknamed;
diff --git a/MysteryGifts/PGT.cs b/MysteryGifts/PGT.cs
new file mode 100644
index 000000000..d3fb13a51
--- /dev/null
+++ b/MysteryGifts/PGT.cs
@@ -0,0 +1,209 @@
+using System;
+using System.Linq;
+
+namespace PKHeX
+{
+ /* Big thanks to Grovyle91's Pokémon Mystery Gift Editor, from which the structure was referenced.
+ * http://projectpokemon.org/forums/member.php?829-Grovyle91
+ * http://projectpokemon.org/forums/showthread.php?6524
+ * See also: http://tccphreak.shiny-clique.net/debugger/pcdfiles.htm
+ */
+ public class PCD : MysteryGift
+ {
+ internal const int Size = 0x358; // 856
+ public override string Extension => ".pcd";
+
+ public PCD(byte[] data = null)
+ {
+ Data = (byte[])(data?.Clone() ?? new byte[Size]);
+
+ byte[] giftData = new byte[PGT.Size];
+ Array.Copy(Data, 0, giftData, 0, PGT.Size);
+ Gift = new PGT(giftData);
+
+ Information = new byte[Data.Length - PGT.Size];
+ Array.Copy(Data, PGT.Size, Information, 0, Information.Length);
+ }
+ public readonly PGT Gift;
+
+ public readonly byte[] Information;
+ public override bool GiftUsed { get { return Gift.GiftUsed; } set { Gift.GiftUsed = value; } }
+ public override bool IsPokémon { get { return Gift.IsPokémon; } set { Gift.IsPokémon = value; } }
+ public override bool IsItem { get { return Gift.IsItem; } set { Gift.IsItem = value; } }
+ public override int Item { get { return Gift.Item; } set { Gift.Item = value; } }
+ public override int CardID
+ {
+ get { return BitConverter.ToUInt16(Data, 0x150); }
+ set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x150); }
+ }
+ public override string CardTitle
+ {
+ get { return PKX.array2strG4(Data.Skip(0x104).Take(0x48).ToArray()); }
+ set
+ {
+ byte[] data = PKX.str2arrayG4(value);
+ int len = data.Length;
+ Array.Resize(ref data, 0x48);
+ for (int i = 0; i < len; i++)
+ data[i] = 0xFF;
+ data.CopyTo(Data, 0x104);
+ }
+ }
+
+ public override PKM convertToPKM(SaveFile SAV)
+ {
+ return Gift.convertToPKM(SAV);
+ }
+ }
+ public class PGT : MysteryGift
+ {
+ internal const int Size = 0x104; // 260
+ public override string Extension => ".pgt";
+
+ private enum GiftType
+ {
+ Pokémon = 1,
+ PokémonEgg = 2,
+ Item = 3,
+ Rule = 4,
+ Seal = 5,
+ Accessory = 6,
+ ManaphyEgg = 7,
+ MemberCard = 8,
+ OaksLetter = 9,
+ AzureFlute = 10,
+ PokétchApp = 11,
+ Ribbon = 12,
+ PokéWalkerArea = 14
+ }
+
+ public override string CardTitle { get { return "Raw Gift (PGT)"; } set { } }
+ public override int CardID { get { return -1; } set { } }
+ public override bool GiftUsed { get { return false; } set { } }
+
+ public PGT(byte[] data = null)
+ {
+ refreshData((byte[])(data?.Clone() ?? new byte[Size]));
+ }
+ public void refreshData(byte[] data)
+ {
+ byte[] ekdata = new byte[PKX.SIZE_4PARTY];
+ Array.Copy(data, 8, ekdata, 0, ekdata.Length);
+ bool empty = ekdata.SequenceEqual(new byte[ekdata.Length]);
+ PK = new PK4(empty ? ekdata : PKX.decryptArray45(ekdata));
+
+ Unknown = new byte[0x10];
+ Array.Copy(data, 0xF4, Unknown, 0, 0x10);
+ RAW = data;
+ }
+
+ public byte CardType { get { return Data[0]; } set { Data[0] = value; } }
+ // Unused 0x01
+ public byte Slot { get { return Data[2]; } set { Data[2] = value; } }
+ public byte Detail { get { return Data[3]; } set { Data[3] = value; } }
+ public override int Item { get { return BitConverter.ToUInt16(Data, 0x4); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x4); } }
+ private PK4 PK;
+ private byte[] Unknown;
+ private byte[] RAW;
+
+ public override byte[] Data
+ {
+ get { return RAW; }
+ set
+ {
+ refreshData(value);
+ }
+ }
+
+ private GiftType Type { get { return (GiftType)Data[0]; } set {Data[0] = (byte)value; } }
+ public bool IsHatched => Type == GiftType.Pokémon;
+ public bool IsEgg => Type == GiftType.PokémonEgg;
+ public bool IsManaphyEgg => Type == GiftType.ManaphyEgg;
+ public override bool IsItem { get { return Type == GiftType.Item; } set { if (value) CardType = (int)GiftType.Item; } }
+ public override bool IsPokémon { get { return Type == GiftType.Pokémon || Type == GiftType.PokémonEgg || Type == GiftType.ManaphyEgg; } set { } }
+
+ public override PKM convertToPKM(SaveFile SAV)
+ {
+ if (!IsPokémon)
+ return null;
+
+ PK4 pk4 = new PK4(PK.Data);
+ if (!IsHatched && Detail == 0)
+ {
+ pk4.OT_Name = SAV.OT;
+ pk4.TID = SAV.TID;
+ pk4.SID = SAV.SID;
+ pk4.OT_Gender = SAV.Gender;
+ }
+ if (IsManaphyEgg)
+ {
+ // Since none of this data is populated, fill in default info.
+ pk4.Species = 490;
+ // Level 1 Moves
+ pk4.Move1 = 294;
+ pk4.Move2 = 145;
+ pk4.Move3 = 346;
+ pk4.FatefulEncounter = true;
+ pk4.Ball = 4;
+ pk4.Version = 10; // Diamond
+ pk4.Language = 2; // English
+ pk4.Nickname = "MANAPHY";
+ pk4.Egg_Location = 1; // Ranger (will be +3000 later)
+ }
+
+ // Generate IV
+ uint seed = Util.rnd32();
+ if (pk4.PID == 1 || IsManaphyEgg) // Create Nonshiny
+ {
+ uint pid1 = PKX.LCRNG(ref seed) >> 16;
+ uint pid2 = PKX.LCRNG(ref seed) >> 16;
+
+ while ((pid1 ^ pid2 ^ pk4.TID ^ pk4.SID) < 8)
+ {
+ uint testPID = pid1 | pid2 << 16;
+
+ // Call the ARNG to change the PID
+ testPID = testPID * 0x6c078965 + 1;
+
+ pid1 = testPID & 0xFFFF;
+ pid2 = testPID >> 16;
+ }
+ pk4.PID = pid1 | (pid2 << 16);
+ }
+
+ // Generate IVs
+ if (pk4.IV32 == 0)
+ {
+ uint iv1 = PKX.LCRNG(ref seed) >> 16;
+ uint iv2 = PKX.LCRNG(ref seed) >> 16;
+ pk4.IV32 = (iv1 | iv2 << 16) & 0x3FFFFFFF;
+ }
+
+ // Generate Met Info
+ DateTime dt = DateTime.Now;
+ if (IsPokémon)
+ {
+ pk4.Met_Location = pk4.Egg_Location + 3000;
+ pk4.Egg_Location = 0;
+ pk4.Met_Day = dt.Day;
+ pk4.Met_Month = dt.Month;
+ pk4.Met_Year = dt.Year - 2000;
+ pk4.IsEgg = false;
+ }
+ else
+ {
+ pk4.Egg_Location = pk4.Egg_Location + 3000;
+ pk4.Egg_Day = dt.Day;
+ pk4.Egg_Month = dt.Month;
+ pk4.Egg_Year = dt.Year - 2000;
+ pk4.IsEgg = false;
+ // Met Location is modified when transferred to pk5; don't worry about it.
+ }
+ if (pk4.Species == 201) // Never will be true; Unown was never distributed.
+ pk4.AltForm = PKX.getUnownForm(pk4.PID);
+ if (IsEgg || IsManaphyEgg)
+ pk4.IsEgg = true;
+ return pk4;
+ }
+ }
+}
diff --git a/Misc/WC6.cs b/MysteryGifts/WC6.cs
similarity index 96%
rename from Misc/WC6.cs
rename to MysteryGifts/WC6.cs
index b9c959230..3e3eb7af3 100644
--- a/Misc/WC6.cs
+++ b/MysteryGifts/WC6.cs
@@ -4,16 +4,16 @@ using System.Text;
namespace PKHeX
{
- public partial class WC6
+ public class WC6 : MysteryGift
{
internal const int Size = 0x108;
internal const int SizeFull = 0x310;
internal const uint EonTicketConst = 0x225D73C2;
+ public override string Extension => ".wc6";
- public readonly byte[] Data;
public WC6(byte[] data = null)
{
- Data = data ?? new byte[Size];
+ Data = (byte[])(data?.Clone() ?? new byte[Size]);
if (Data.Length == SizeFull)
{
Data = Data.Skip(SizeFull - Size).ToArray();
@@ -23,12 +23,12 @@ namespace PKHeX
Day = (uint)now.Day;
}
}
-
+
// General Card Properties
- public int CardID {
+ public override int CardID {
get { return BitConverter.ToUInt16(Data, 0); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0); } }
- public string CardTitle { // Max len 36 char, followed by null terminator
+ public override string CardTitle { // Max len 36 char, followed by null terminator
get { return Util.TrimFromZero(Encoding.Unicode.GetString(Data, 2, 72)); }
set { Encoding.Unicode.GetBytes(value.PadRight(36, '\0')).CopyTo(Data, 2); } }
private uint Date {
@@ -46,20 +46,20 @@ namespace PKHeX
public int CardLocation { get { return Data[0x50]; } set { Data[0x50] = (byte)value; } }
public int CardType { get { return Data[0x51]; } set { Data[0x51] = (byte)value; } }
- public bool GiftUsed { get { return Data[0x52] >> 1 > 0; } set { Data[0x52] = (byte)(Data[0x52] & ~2 | (value ? 2 : 0)); } }
+ public override bool GiftUsed { get { return Data[0x52] >> 1 > 0; } set { Data[0x52] = (byte)(Data[0x52] & ~2 | (value ? 2 : 0)); } }
public bool MultiObtain { get { return Data[0x53] == 1; } set { Data[0x53] = (byte)(value ? 1 : 0); } }
// Item Properties
- public bool IsItem { get { return CardType == 1; } set { if (value) CardType = 1; } }
- public int Item {
+ public override bool IsItem { get { return CardType == 1; } set { if (value) CardType = 1; } }
+ public override int Item {
get { return BitConverter.ToUInt16(Data, 0x68); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x68); } }
- public int Quantity {
+ public override int Quantity {
get { return BitConverter.ToUInt16(Data, 0x70); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x70); } }
// Pokémon Properties
- public bool IsPokémon { get { return CardType == 0; } set { if (value) CardType = 0; } }
+ public override bool IsPokémon { get { return CardType == 0; } set { if (value) CardType = 0; } }
public int TID {
get { return BitConverter.ToUInt16(Data, 0x68); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x68); } }
@@ -207,7 +207,7 @@ namespace PKHeX
}
}
- public PK6 convertToPK6(SAV6 SAV)
+ public override PKM convertToPKM(SaveFile SAV)
{
if (!IsPokémon)
return null;
diff --git a/PKHeX.csproj b/PKHeX.csproj
index fb7e71c5f..e34f532fb 100644
--- a/PKHeX.csproj
+++ b/PKHeX.csproj
@@ -71,24 +71,32 @@
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
Form
QR.cs
-
-
-
-
+
+
+
+
+
+
+
Form
@@ -101,7 +109,7 @@
About.cs
-
+
Form
@@ -125,11 +133,13 @@
True
Resources.resx
-
+
+
+
Form
-
- SAV_BerryFieldORAS.cs
+
+ SAV_PokeBlockORAS.cs
Form
@@ -149,11 +159,11 @@
SAV_SecretBase.cs
-
+
Form
-
- SAV_EventFlagsORAS.cs
+
+ SAV_EventFlags.cs
Form
@@ -175,12 +185,6 @@
SAV_BoxLayout.cs
-
- Form
-
-
- SAV_EventFlagsXY.cs
-
Form
@@ -238,12 +242,14 @@
QR.cs
+ Designer
f2-Text.cs
About.cs
+ Designer
f1-Main.cs
@@ -255,8 +261,8 @@
f3-MemoryAmie.cs
-
- SAV_BerryFieldORAS.cs
+
+ SAV_PokeBlockORAS.cs
SAV_Database.cs
@@ -267,8 +273,8 @@
SAV_SecretBase.cs
-
- SAV_EventFlagsORAS.cs
+
+ SAV_EventFlags.cs
frmReport.cs
@@ -284,9 +290,6 @@
SAV_BoxLayout.cs
-
- SAV_EventFlagsXY.cs
-
SAV_HallOfFame.cs
@@ -313,6 +316,7 @@
SplashScreen.cs
+ Designer
@@ -370,6 +374,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -391,6 +416,9 @@
+
+
+
diff --git a/PKM/PK3.cs b/PKM/PK3.cs
new file mode 100644
index 000000000..d2e9f9a29
--- /dev/null
+++ b/PKM/PK3.cs
@@ -0,0 +1,299 @@
+using System;
+using System.Linq;
+
+namespace PKHeX
+{
+ public class PK3 : PKM // 3rd Generation PKM File
+ {
+ public override int SIZE_PARTY => PKX.SIZE_3PARTY;
+ public override int SIZE_STORED => PKX.SIZE_3STORED;
+ public override int Format => 3;
+ public PK3(byte[] decryptedData = null, string ident = null)
+ {
+ Data = (byte[])(decryptedData ?? new byte[SIZE_PARTY]).Clone();
+ PKMConverter.checkEncrypted(ref Data);
+ Identifier = ident;
+ if (Data.Length != SIZE_PARTY)
+ Array.Resize(ref Data, SIZE_PARTY);
+ }
+ public override PKM Clone() { return new PK3(Data); }
+
+ // Future Attributes
+ public override uint EncryptionConstant { get { return PID; } set { } }
+ public override int Nature { get { return (int)(PID % 25); } set { } }
+ public override int AltForm { get { return -1; } set { } }
+ public override bool IsNicknamed { get { return Nickname != PKX.getSpeciesName(Species, Language); } set { } }
+ public override int Gender { get { return PKX.getGender(Species, PID); } set { } }
+ public override int Characteristic => -1;
+ public override int CurrentFriendship { get { return OT_Friendship; } set { OT_Friendship = value; } }
+ public override int Ability { get { return PKX.Gen3Abilities[Species][AbilityNumber]; } set { } }
+ public override int CurrentHandler { get { return 0; } set { } }
+ public override int Egg_Location { get { return 0; } set { } }
+ public override int Met_Level { get { return -1; } set { } }
+
+ // 0x20 Intro
+ public override uint PID { get { return BitConverter.ToUInt32(Data, 0x00); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x00); } }
+ public override int TID { get { return BitConverter.ToUInt16(Data, 0x04); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x04); } }
+ public override int SID { get { return BitConverter.ToUInt16(Data, 0x06); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x06); } }
+ public override string Nickname {
+ get { return PKX.getG3Str(Data.Skip(0x08).Take(10).ToArray(), Japanese); }
+ set { byte[] strdata = PKX.setG3Str(value, Japanese);
+ if (strdata.Length > 10)
+ Array.Resize(ref strdata, 10);
+ strdata.CopyTo(Data, 0x08); } }
+ public override int Language { get { return BitConverter.ToUInt16(Data, 0x12); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x12); } }
+ public override string OT_Name {
+ get { return PKX.getG3Str(Data.Skip(0x14).Take(7).ToArray(), Japanese); }
+ set { byte[] strdata = PKX.setG3Str(value, Japanese);
+ if (strdata.Length > 7)
+ Array.Resize(ref strdata, 7);
+ strdata.CopyTo(Data, 0x14); } }
+
+ public override byte MarkByte { get { return Data[0x1B]; } protected set { Data[0x1B] = value; } }
+ public override ushort Checksum { get { return BitConverter.ToUInt16(Data, 0x1C); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x1C); } }
+ public override ushort Sanity { get { return BitConverter.ToUInt16(Data, 0x1E); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x1E); } }
+
+ #region Block A
+ public override int Species { get { return PKX.getG4Species(BitConverter.ToUInt16(Data, 0x20)); } set { BitConverter.GetBytes((ushort)PKX.getG3Species(value)).CopyTo(Data, 0x20); } }
+ public override int HeldItem { get { return BitConverter.ToUInt16(Data, 0x22); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x22); } }
+ public override uint EXP { get { return BitConverter.ToUInt32(Data, 0x24); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x24); } }
+ private byte PPUps { get { return Data[0x28]; } set { Data[0x28] = value; } }
+ public override int Move1_PPUps { get { return (PPUps >> 0) & 3; } set { PPUps = (byte)((PPUps & ~(3 << 0)) | value); } }
+ public override int Move2_PPUps { get { return (PPUps >> 2) & 3; } set { PPUps = (byte)((PPUps & ~(3 << 2)) | value); } }
+ public override int Move3_PPUps { get { return (PPUps >> 4) & 3; } set { PPUps = (byte)((PPUps & ~(3 << 4)) | value); } }
+ public override int Move4_PPUps { get { return (PPUps >> 6) & 3; } set { PPUps = (byte)((PPUps & ~(3 << 6)) | value); } }
+ public override int OT_Friendship { get { return Data[0x29]; } set { Data[0x29] = (byte)value; } }
+ // Unused 0x2A 0x2B
+ #endregion
+
+ #region Block B
+ public override int Move1 { get { return BitConverter.ToUInt16(Data, 0x2C); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2C); } }
+ public override int Move2 { get { return BitConverter.ToUInt16(Data, 0x2E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2E); } }
+ public override int Move3 { get { return BitConverter.ToUInt16(Data, 0x30); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x30); } }
+ public override int Move4 { get { return BitConverter.ToUInt16(Data, 0x32); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x32); } }
+ public override int Move1_PP { get { return Data[0x34]; } set { Data[0x34] = (byte)value; } }
+ public override int Move2_PP { get { return Data[0x35]; } set { Data[0x35] = (byte)value; } }
+ public override int Move3_PP { get { return Data[0x36]; } set { Data[0x36] = (byte)value; } }
+ public override int Move4_PP { get { return Data[0x37]; } set { Data[0x37] = (byte)value; } }
+ #endregion
+
+ #region Block C
+ public override int EV_HP { get { return Data[0x38]; } set { Data[0x38] = (byte)value; } }
+ public override int EV_ATK { get { return Data[0x39]; } set { Data[0x39] = (byte)value; } }
+ public override int EV_DEF { get { return Data[0x3A]; } set { Data[0x3A] = (byte)value; } }
+ public override int EV_SPE { get { return Data[0x3B]; } set { Data[0x3B] = (byte)value; } }
+ public override int EV_SPA { get { return Data[0x3C]; } set { Data[0x3C] = (byte)value; } }
+ public override int EV_SPD { get { return Data[0x3D]; } set { Data[0x3D] = (byte)value; } }
+ public override int CNT_Cool { get { return Data[0x3E]; } set { Data[0x3E] = (byte)value; } }
+ public override int CNT_Beauty { get { return Data[0x3F]; } set { Data[0x3F] = (byte)value; } }
+ public override int CNT_Cute { get { return Data[0x40]; } set { Data[0x40] = (byte)value; } }
+ public override int CNT_Smart { get { return Data[0x41]; } set { Data[0x41] = (byte)value; } }
+ public override int CNT_Tough { get { return Data[0x42]; } set { Data[0x42] = (byte)value; } }
+ public override int CNT_Sheen { get { return Data[0x43]; } set { Data[0x43] = (byte)value; } }
+ #endregion
+
+ #region Block D
+ private byte PKRS { get { return Data[0x44]; } set { Data[0x44] = value; } }
+ public override int PKRS_Days { get { return PKRS & 0xF; } set { PKRS = (byte)(PKRS & ~0xF | value); } }
+ public override int PKRS_Strain { get { return PKRS >> 4; } set { PKRS = (byte)(PKRS & 0xF | value << 4); } }
+ public override int Met_Location { get { return Data[0x45]; } set { Data[0x45] = (byte)value; } }
+ // Origins
+ private ushort Origins { get { return BitConverter.ToUInt16(Data, 0x46); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x46); } }
+ public override int Version { get { return (Origins >> 7) & 0xF; } set { Origins = (ushort)((Origins & ~0x780) | ((value & 0xF) << 7));} }
+ public override int Ball { get { return (Origins >> 11) & 0xF; } set { Origins = (ushort)((Origins & ~0x7800) | ((value & 0xF) << 11)); } }
+ public override int OT_Gender { get { return (Origins >> 15) & 1; } set { Origins = (ushort)(Origins & ~(1 << 15) | ((value & 1) << 15)); } }
+
+ public uint IV32 { get { return BitConverter.ToUInt32(Data, 0x48); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x48); } }
+ public override int IV_HP { get { return (int)(IV32 >> 00) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 00)) | (uint)((value > 31 ? 31 : value) << 00)); } }
+ public override int IV_ATK { get { return (int)(IV32 >> 05) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 05)) | (uint)((value > 31 ? 31 : value) << 05)); } }
+ public override int IV_DEF { get { return (int)(IV32 >> 10) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 10)) | (uint)((value > 31 ? 31 : value) << 10)); } }
+ public override int IV_SPE { get { return (int)(IV32 >> 15) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 15)) | (uint)((value > 31 ? 31 : value) << 15)); } }
+ public override int IV_SPA { get { return (int)(IV32 >> 20) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 20)) | (uint)((value > 31 ? 31 : value) << 20)); } }
+ public override int IV_SPD { get { return (int)(IV32 >> 25) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 25)) | (uint)((value > 31 ? 31 : value) << 25)); } }
+ public override bool IsEgg { get { return ((IV32 >> 30) & 1) == 1; } set { IV32 = (uint)((IV32 & ~0x40000000) | (uint)(value ? 0x40000000 : 0)); } }
+ public int AbilityNumber { get { return (int)((IV32 >> 31) & 1); } set { IV32 = (IV32 & 0x7FFFFFFF) | (value == 1 ? 0x80000000 : 0); } }
+
+ private uint RIB0 { get { return BitConverter.ToUInt32(Data, 0x4C); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x4C); } }
+ public int Cool_Ribbons { get { return (int)(RIB0 >> 00) & 7; } set { RIB0 = (uint)((RIB0 & ~(7 << 00)) | (uint)(value & 7)); } }
+ public int Beauty_Ribbons{ get { return (int)(RIB0 >> 03) & 7; } set { RIB0 = (uint)((RIB0 & ~(7 << 03)) | (uint)(value & 7)); } }
+ public int Cute_Ribbons { get { return (int)(RIB0 >> 06) & 7; } set { RIB0 = (uint)((RIB0 & ~(7 << 06)) | (uint)(value & 7)); } }
+ public int Smart_Ribbons { get { return (int)(RIB0 >> 09) & 3; } set { RIB0 = (uint)((RIB0 & ~(7 << 09)) | (uint)(value & 7)); } }
+ public int Tough_Ribbons { get { return (int)(RIB0 >> 12) & 3; } set { RIB0 = (uint)((RIB0 & ~(7 << 12)) | (uint)(value & 7)); } }
+ public bool Champion { get { return (RIB0 & (1 << 15)) == 1 << 15; } set { RIB0 = (uint)(RIB0 & ~(1 << 15) | (uint)(value ? 1 << 0 : 0)); } }
+ public bool Winning { get { return (RIB0 & (1 << 16)) == 1 << 16; } set { RIB0 = (uint)(RIB0 & ~(1 << 16) | (uint)(value ? 1 << 0 : 0)); } }
+ public bool Victory { get { return (RIB0 & (1 << 17)) == 1 << 17; } set { RIB0 = (uint)(RIB0 & ~(1 << 17) | (uint)(value ? 1 << 0 : 0)); } }
+ public bool Artist { get { return (RIB0 & (1 << 18)) == 1 << 18; } set { RIB0 = (uint)(RIB0 & ~(1 << 18) | (uint)(value ? 1 << 0 : 0)); } }
+ public bool Effort { get { return (RIB0 & (1 << 19)) == 1 << 19; } set { RIB0 = (uint)(RIB0 & ~(1 << 19) | (uint)(value ? 1 << 0 : 0)); } }
+ public bool Special1 { get { return (RIB0 & (1 << 20)) == 1 << 20; } set { RIB0 = (uint)(RIB0 & ~(1 << 20) | (uint)(value ? 1 << 0 : 0)); } }
+ public bool Special2 { get { return (RIB0 & (1 << 21)) == 1 << 21; } set { RIB0 = (uint)(RIB0 & ~(1 << 21) | (uint)(value ? 1 << 0 : 0)); } }
+ public bool Special3 { get { return (RIB0 & (1 << 22)) == 1 << 22; } set { RIB0 = (uint)(RIB0 & ~(1 << 22) | (uint)(value ? 1 << 0 : 0)); } }
+ public bool Special4 { get { return (RIB0 & (1 << 23)) == 1 << 23; } set { RIB0 = (uint)(RIB0 & ~(1 << 23) | (uint)(value ? 1 << 0 : 0)); } }
+ public bool Special5 { get { return (RIB0 & (1 << 24)) == 1 << 24; } set { RIB0 = (uint)(RIB0 & ~(1 << 24) | (uint)(value ? 1 << 0 : 0)); } }
+ public bool Special6 { get { return (RIB0 & (1 << 25)) == 1 << 25; } set { RIB0 = (uint)(RIB0 & ~(1 << 25) | (uint)(value ? 1 << 0 : 0)); } }
+ public bool Special7 { get { return (RIB0 & (1 << 26)) == 1 << 26; } set { RIB0 = (uint)(RIB0 & ~(1 << 26) | (uint)(value ? 1 << 0 : 0)); } }
+ public bool Unused1 { get { return (RIB0 & (1 << 27)) == 1 << 27; } set { RIB0 = (uint)(RIB0 & ~(1 << 27) | (uint)(value ? 1 << 0 : 0)); } }
+ public bool Unused2 { get { return (RIB0 & (1 << 28)) == 1 << 28; } set { RIB0 = (uint)(RIB0 & ~(1 << 28) | (uint)(value ? 1 << 0 : 0)); } }
+ public bool Unused3 { get { return (RIB0 & (1 << 29)) == 1 << 29; } set { RIB0 = (uint)(RIB0 & ~(1 << 29) | (uint)(value ? 1 << 0 : 0)); } }
+ public bool Unused4 { get { return (RIB0 & (1 << 30)) == 1 << 30; } set { RIB0 = (uint)(RIB0 & ~(1 << 30) | (uint)(value ? 1 << 0 : 0)); } }
+ public override bool FatefulEncounter { get { return (RIB0 & (1 << 31)) == 1 << 31; } set { RIB0 = (RIB0 & ~(1 << 31)) | (uint)(value ? 1 << 0 : 0); } }
+ #endregion
+
+ public override int Stat_Level { get { return Data[0x54]; } set { Data[0x54] = (byte)value; } }
+ public override int Stat_HPCurrent { get { return BitConverter.ToUInt16(Data, 0x56); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x56); } }
+ public override int Stat_HPMax { get { return BitConverter.ToUInt16(Data, 0x58); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x58); } }
+ public override int Stat_ATK { get { return BitConverter.ToUInt16(Data, 0x5A); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x5A); } }
+ public override int Stat_DEF { get { return BitConverter.ToUInt16(Data, 0x5C); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x5C); } }
+ public override int Stat_SPE { get { return BitConverter.ToUInt16(Data, 0x5E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x5E); } }
+ public override int Stat_SPA { get { return BitConverter.ToUInt16(Data, 0x60); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x60); } }
+ public override int Stat_SPD { get { return BitConverter.ToUInt16(Data, 0x62); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x62); } }
+
+ // Generated Attributes
+ public override int PSV => (int)((PID >> 16 ^ PID & 0xFFFF) >> 3);
+ public override int TSV => (TID ^ SID) >> 3;
+ public bool Japanese => Language == 1;
+
+ public override byte[] Encrypt()
+ {
+ throw new NotImplementedException();
+ }
+ public override bool getGenderIsValid()
+ {
+ int gv = PKX.Personal[Species].Gender;
+
+ if (gv == 255)
+ return Gender == 2;
+ if (gv == 254)
+ return Gender == 0;
+ if (gv == 0)
+ return Gender == 1;
+ if (gv <= (PID & 0xFF))
+ return Gender == 0;
+ if ((PID & 0xFF) < gv)
+ return Gender == 1;
+
+ return false;
+ }
+
+ public PK4 convertToPK4()
+ {
+ DateTime moment = DateTime.Now;
+ PK4 pk4 = new PK4 // Convert away!
+ {
+ PID = PID,
+ Species = Species,
+ TID = TID,
+ SID = SID,
+ EXP = IsEgg ? PKX.getEXP(5, Species) : EXP,
+ IsEgg = false,
+ OT_Friendship = 40,
+ Circle = Circle,
+ Square = Square,
+ Triangle = Triangle,
+ Heart = Heart,
+ Language = Language,
+ EV_HP = EV_HP,
+ EV_ATK = EV_ATK,
+ EV_DEF = EV_DEF,
+ EV_SPA = EV_SPA,
+ EV_SPD = EV_SPD,
+ EV_SPE = EV_SPE,
+ CNT_Cool = CNT_Cool,
+ CNT_Beauty = CNT_Beauty,
+ CNT_Cute = CNT_Cute,
+ CNT_Smart = CNT_Smart,
+ CNT_Tough = CNT_Tough,
+ CNT_Sheen = CNT_Sheen,
+ FatefulEncounter = FatefulEncounter,
+ Move1 = Move1,
+ Move2 = Move2,
+ Move3 = Move3,
+ Move4 = Move4,
+ Move1_PPUps = Move1_PPUps,
+ Move2_PPUps = Move2_PPUps,
+ Move3_PPUps = Move3_PPUps,
+ Move4_PPUps = Move4_PPUps,
+ Move1_PP = PKX.getMovePP(Move1, Move1_PPUps),
+ Move2_PP = PKX.getMovePP(Move2, Move2_PPUps),
+ Move3_PP = PKX.getMovePP(Move3, Move3_PPUps),
+ Move4_PP = PKX.getMovePP(Move4, Move4_PPUps),
+ IV_HP = IV_HP,
+ IV_ATK = IV_ATK,
+ IV_DEF = IV_DEF,
+ IV_SPA = IV_SPA,
+ IV_SPD = IV_SPD,
+ IV_SPE = IV_SPE,
+ Ability = PKX.Gen3Abilities[Species][Ability],
+ Version = Version,
+ Ball = Ball,
+ PKRS_Strain = PKRS_Strain,
+ PKRS_Days = PKRS_Days,
+ OT_Gender = OT_Gender,
+ Met_Year = moment.Year - 2000,
+ Met_Month = moment.Month,
+ Met_Day = moment.Day,
+ Met_Location = 0x37, // Pal Park
+ RIB6_4 = Champion,
+ RIB6_5 = Winning,
+ RIB6_6 = Victory,
+ RIB6_7 = Artist,
+ RIB7_0 = Effort,
+ RIB7_1 = Special1, // Battle Champion Ribbon
+ RIB7_2 = Special2, // Regional Champion Ribbon
+ RIB7_3 = Special3, // National Champion Ribbon
+ RIB7_4 = Special4, // Country Ribbon
+ RIB7_5 = Special5, // National Ribbon
+ RIB7_6 = Special6, // Earth Ribbon
+ RIB7_7 = Special7, // World Ribbon
+ };
+
+ // Remaining Ribbons
+ pk4.RIB4_0 |= Cool_Ribbons > 0;
+ pk4.RIB4_1 |= Cool_Ribbons > 1;
+ pk4.RIB4_2 |= Cool_Ribbons > 2;
+ pk4.RIB4_3 |= Cool_Ribbons > 3;
+ pk4.RIB4_4 |= Beauty_Ribbons > 0;
+ pk4.RIB4_5 |= Beauty_Ribbons > 1;
+ pk4.RIB4_6 |= Beauty_Ribbons > 2;
+ pk4.RIB4_7 |= Beauty_Ribbons > 3;
+ pk4.RIB5_0 |= Cute_Ribbons > 0;
+ pk4.RIB5_1 |= Cute_Ribbons > 1;
+ pk4.RIB5_2 |= Cute_Ribbons > 2;
+ pk4.RIB5_3 |= Cute_Ribbons > 3;
+ pk4.RIB5_4 |= Smart_Ribbons > 0;
+ pk4.RIB5_5 |= Smart_Ribbons > 1;
+ pk4.RIB5_6 |= Smart_Ribbons > 2;
+ pk4.RIB5_7 |= Smart_Ribbons > 3;
+ pk4.RIB6_0 |= Tough_Ribbons > 0;
+ pk4.RIB6_1 |= Tough_Ribbons > 1;
+ pk4.RIB6_2 |= Tough_Ribbons > 2;
+ pk4.RIB6_3 |= Tough_Ribbons > 3;
+
+ // Yay for reusing string buffers!
+ PKX.G4TransferTrashBytes[pk4.Language].CopyTo(pk4.Data, 0x48 + 4);
+ pk4.Nickname = IsEgg ? PKX.getSpeciesName(pk4.Species, pk4.Language) : Nickname;
+ Array.Copy(pk4.Data, 0x48, pk4.Data, 0x68, 0x10);
+ pk4.OT_Name = OT_Name;
+
+ // Set Final Data
+ pk4.Met_Level = PKX.getLevel(pk4.Species, pk4.EXP);
+ pk4.Gender = PKX.getGender(pk4.Species, pk4.PID);
+ pk4.IsNicknamed |= pk4.Nickname != PKX.getSpeciesName(pk4.Species, pk4.Language);
+
+ // Unown Form
+ if (Species == 201)
+ pk4.AltForm = PKX.getUnownForm(PID);
+
+ // Remove HM moves
+ int[] banned = { 15, 19, 57, 70, 148, 249, 127, 291 };
+ int[] newMoves = pk4.Moves;
+ for (int i = 0; i < 4; i++)
+ if (banned.Contains(newMoves[i]))
+ newMoves[i] = 0;
+ pk4.Moves = newMoves;
+ pk4.FixMoves();
+
+ pk4.RefreshChecksum();
+ return pk4;
+ }
+ }
+}
diff --git a/Misc/PK4.cs b/PKM/PK4.cs
similarity index 65%
rename from Misc/PK4.cs
rename to PKM/PK4.cs
index 3f6408822..007cb2b38 100644
--- a/Misc/PK4.cs
+++ b/PKM/PK4.cs
@@ -3,57 +3,58 @@ using System.Linq;
namespace PKHeX
{
- public class PK4 // 4th Generation PKM File
+ public class PK4 : PKM // 4th Generation PKM File
{
- internal const int SIZE_PARTY = 236;
- internal const int SIZE_STORED = 136;
- internal const int SIZE_BLOCK = 32;
-
+ internal static readonly byte[] ExtraBytes =
+ {
+ 0x42, 0x43, 0x5E, 0x63, 0x64, 0x65, 0x66, 0x67, 0x87
+ };
+ public override int SIZE_PARTY => PKX.SIZE_4PARTY;
+ public override int SIZE_STORED => PKX.SIZE_4STORED;
+ public override int Format => 4;
public PK4(byte[] decryptedData = null, string ident = null)
{
Data = (byte[])(decryptedData ?? new byte[SIZE_PARTY]).Clone();
+ PKMConverter.checkEncrypted(ref Data);
Identifier = ident;
if (Data.Length != SIZE_PARTY)
Array.Resize(ref Data, SIZE_PARTY);
}
+ public override PKM Clone() { return new PK4(Data); }
- // Internal Attributes set on creation
- public byte[] Data; // Raw Storage
- public string Identifier; // User or Form Custom Attribute
+ // Future Attributes
+ public override uint EncryptionConstant { get { return PID; } set { } }
+ public override int Nature { get { return (int)(PID%25); } set { } }
+ public override int CurrentFriendship { get { return OT_Friendship; } set { OT_Friendship = value; } }
+ public override int CurrentHandler { get { return 0; } set { } }
// Structure
- public uint PID { get { return BitConverter.ToUInt32(Data, 0x00); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x00); } }
- public ushort Sanity { get { return BitConverter.ToUInt16(Data, 0x04); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x04); } }
- public ushort Checksum { get { return BitConverter.ToUInt16(Data, 0x06); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x06); } }
-
+ public override uint PID { get { return BitConverter.ToUInt32(Data, 0x00); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x00); } }
+ public override ushort Sanity { get { return BitConverter.ToUInt16(Data, 0x04); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x04); } }
+ public override ushort Checksum { get { return BitConverter.ToUInt16(Data, 0x06); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x06); } }
+
#region Block A
- public int Species { get { return BitConverter.ToUInt16(Data, 0x08); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x08); } }
- public int HeldItem { get { return BitConverter.ToUInt16(Data, 0x0A); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0A); } }
- public int TID { get { return BitConverter.ToUInt16(Data, 0x0C); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0C); } }
- public int SID { get { return BitConverter.ToUInt16(Data, 0x0E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0E); } }
- public uint EXP { get { return BitConverter.ToUInt32(Data, 0x10); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x10); } }
- public int Friendship { get { return Data[0x14]; } set { Data[0x14] = (byte)value; } }
- public int Ability { get { return Data[0x15]; } set { Data[0x15] = (byte)value; } }
- public byte Markings { get { return Data[0x16]; } set { Data[0x16] = value; } }
- public bool Circle { get { return (Markings & (1 << 0)) == 1 << 0; } set { Markings = (byte)(Markings & ~(1 << 0) | (value ? 1 << 0 : 0)); } }
- public bool Triangle { get { return (Markings & (1 << 1)) == 1 << 1; } set { Markings = (byte)(Markings & ~(1 << 1) | (value ? 1 << 1 : 0)); } }
- public bool Square { get { return (Markings & (1 << 2)) == 1 << 2; } set { Markings = (byte)(Markings & ~(1 << 2) | (value ? 1 << 2 : 0)); } }
- public bool Heart { get { return (Markings & (1 << 3)) == 1 << 3; } set { Markings = (byte)(Markings & ~(1 << 3) | (value ? 1 << 3 : 0)); } }
- public bool Star { get { return (Markings & (1 << 4)) == 1 << 4; } set { Markings = (byte)(Markings & ~(1 << 4) | (value ? 1 << 4 : 0)); } }
- public bool Diamond { get { return (Markings & (1 << 5)) == 1 << 5; } set { Markings = (byte)(Markings & ~(1 << 5) | (value ? 1 << 5 : 0)); } }
- public int Language { get { return Data[0x17]; } set { Data[0x17] = (byte)value; } }
- public int EV_HP { get { return Data[0x18]; } set { Data[0x18] = (byte)value; } }
- public int EV_ATK { get { return Data[0x19]; } set { Data[0x19] = (byte)value; } }
- public int EV_DEF { get { return Data[0x1A]; } set { Data[0x1A] = (byte)value; } }
- public int EV_SPE { get { return Data[0x1B]; } set { Data[0x1B] = (byte)value; } }
- public int EV_SPA { get { return Data[0x1C]; } set { Data[0x1C] = (byte)value; } }
- public int EV_SPD { get { return Data[0x1D]; } set { Data[0x1D] = (byte)value; } }
- public int CNT_Cool { get { return Data[0x1E]; } set { Data[0x1E] = (byte)value; } }
- public int CNT_Beauty { get { return Data[0x1F]; } set { Data[0x1F] = (byte)value; } }
- public int CNT_Cute { get { return Data[0x20]; } set { Data[0x20] = (byte)value; } }
- public int CNT_Smart { get { return Data[0x21]; } set { Data[0x21] = (byte)value; } }
- public int CNT_Tough { get { return Data[0x22]; } set { Data[0x22] = (byte)value; } }
- public int CNT_Sheen { get { return Data[0x23]; } set { Data[0x23] = (byte)value; } }
+ public override int Species { get { return BitConverter.ToUInt16(Data, 0x08); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x08); } }
+ public override int HeldItem { get { return BitConverter.ToUInt16(Data, 0x0A); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0A); } }
+ public override int TID { get { return BitConverter.ToUInt16(Data, 0x0C); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0C); } }
+ public override int SID { get { return BitConverter.ToUInt16(Data, 0x0E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0E); } }
+ public override uint EXP { get { return BitConverter.ToUInt32(Data, 0x10); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x10); } }
+ public override int OT_Friendship { get { return Data[0x14]; } set { Data[0x14] = (byte)value; } }
+ public override int Ability { get { return Data[0x15]; } set { Data[0x15] = (byte)value; } }
+ public override byte MarkByte { get { return Data[0x16]; } protected set { Data[0x16] = value; } }
+ public override int Language { get { return Data[0x17]; } set { Data[0x17] = (byte)value; } }
+ public override int EV_HP { get { return Data[0x18]; } set { Data[0x18] = (byte)value; } }
+ public override int EV_ATK { get { return Data[0x19]; } set { Data[0x19] = (byte)value; } }
+ public override int EV_DEF { get { return Data[0x1A]; } set { Data[0x1A] = (byte)value; } }
+ public override int EV_SPE { get { return Data[0x1B]; } set { Data[0x1B] = (byte)value; } }
+ public override int EV_SPA { get { return Data[0x1C]; } set { Data[0x1C] = (byte)value; } }
+ public override int EV_SPD { get { return Data[0x1D]; } set { Data[0x1D] = (byte)value; } }
+ public override int CNT_Cool { get { return Data[0x1E]; } set { Data[0x1E] = (byte)value; } }
+ public override int CNT_Beauty { get { return Data[0x1F]; } set { Data[0x1F] = (byte)value; } }
+ public override int CNT_Cute { get { return Data[0x20]; } set { Data[0x20] = (byte)value; } }
+ public override int CNT_Smart { get { return Data[0x21]; } set { Data[0x21] = (byte)value; } }
+ public override int CNT_Tough { get { return Data[0x22]; } set { Data[0x22] = (byte)value; } }
+ public override int CNT_Sheen { get { return Data[0x23]; } set { Data[0x23] = (byte)value; } }
private byte RIB0 { get { return Data[0x24]; } set { Data[0x24] = value; } } // Sinnoh 1
public bool RIB0_0 { get { return (RIB0 & (1 << 0)) == 1 << 0; } set { RIB0 = (byte)(RIB0 & ~(1 << 0) | (value ? 1 << 0 : 0)); } } // Sinnoh Champ Ribbon
@@ -94,27 +95,27 @@ namespace PKHeX
#endregion
#region Block B
- public int Move1 { get { return BitConverter.ToUInt16(Data, 0x28); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x28); } }
- public int Move2 { get { return BitConverter.ToUInt16(Data, 0x2A); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2A); } }
- public int Move3 { get { return BitConverter.ToUInt16(Data, 0x2C); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2C); } }
- public int Move4 { get { return BitConverter.ToUInt16(Data, 0x2E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2E); } }
- public int Move1_PP { get { return Data[0x30]; } set { Data[0x30] = (byte)value; } }
- public int Move2_PP { get { return Data[0x31]; } set { Data[0x31] = (byte)value; } }
- public int Move3_PP { get { return Data[0x32]; } set { Data[0x32] = (byte)value; } }
- public int Move4_PP { get { return Data[0x33]; } set { Data[0x33] = (byte)value; } }
- public int Move1_PPUps { get { return Data[0x34]; } set { Data[0x34] = (byte)value; } }
- public int Move2_PPUps { get { return Data[0x35]; } set { Data[0x35] = (byte)value; } }
- public int Move3_PPUps { get { return Data[0x36]; } set { Data[0x36] = (byte)value; } }
- public int Move4_PPUps { get { return Data[0x37]; } set { Data[0x37] = (byte)value; } }
+ public override int Move1 { get { return BitConverter.ToUInt16(Data, 0x28); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x28); } }
+ public override int Move2 { get { return BitConverter.ToUInt16(Data, 0x2A); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2A); } }
+ public override int Move3 { get { return BitConverter.ToUInt16(Data, 0x2C); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2C); } }
+ public override int Move4 { get { return BitConverter.ToUInt16(Data, 0x2E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2E); } }
+ public override int Move1_PP { get { return Data[0x30]; } set { Data[0x30] = (byte)value; } }
+ public override int Move2_PP { get { return Data[0x31]; } set { Data[0x31] = (byte)value; } }
+ public override int Move3_PP { get { return Data[0x32]; } set { Data[0x32] = (byte)value; } }
+ public override int Move4_PP { get { return Data[0x33]; } set { Data[0x33] = (byte)value; } }
+ public override int Move1_PPUps { get { return Data[0x34]; } set { Data[0x34] = (byte)value; } }
+ public override int Move2_PPUps { get { return Data[0x35]; } set { Data[0x35] = (byte)value; } }
+ public override int Move3_PPUps { get { return Data[0x36]; } set { Data[0x36] = (byte)value; } }
+ public override int Move4_PPUps { get { return Data[0x37]; } set { Data[0x37] = (byte)value; } }
public uint IV32 { get { return BitConverter.ToUInt32(Data, 0x38); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x38); } }
- public int IV_HP { get { return (int)(IV32 >> 00) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 00)) | (uint)((value > 31 ? 31 : value) << 00)); } }
- public int IV_ATK { get { return (int)(IV32 >> 05) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 05)) | (uint)((value > 31 ? 31 : value) << 05)); } }
- public int IV_DEF { get { return (int)(IV32 >> 10) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 10)) | (uint)((value > 31 ? 31 : value) << 10)); } }
- public int IV_SPE { get { return (int)(IV32 >> 15) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 15)) | (uint)((value > 31 ? 31 : value) << 15)); } }
- public int IV_SPA { get { return (int)(IV32 >> 20) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 20)) | (uint)((value > 31 ? 31 : value) << 20)); } }
- public int IV_SPD { get { return (int)(IV32 >> 25) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 25)) | (uint)((value > 31 ? 31 : value) << 25)); } }
- public bool IsEgg { get { return ((IV32 >> 30) & 1) == 1; } set { IV32 = (uint)((IV32 & ~0x40000000) | (uint)(value ? 0x40000000 : 0)); } }
- public bool IsNicknamed { get { return ((IV32 >> 31) & 1) == 1; } set { IV32 = (IV32 & 0x7FFFFFFF) | (value ? 0x80000000 : 0); } }
+ public override int IV_HP { get { return (int)(IV32 >> 00) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 00)) | (uint)((value > 31 ? 31 : value) << 00)); } }
+ public override int IV_ATK { get { return (int)(IV32 >> 05) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 05)) | (uint)((value > 31 ? 31 : value) << 05)); } }
+ public override int IV_DEF { get { return (int)(IV32 >> 10) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 10)) | (uint)((value > 31 ? 31 : value) << 10)); } }
+ public override int IV_SPE { get { return (int)(IV32 >> 15) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 15)) | (uint)((value > 31 ? 31 : value) << 15)); } }
+ public override int IV_SPA { get { return (int)(IV32 >> 20) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 20)) | (uint)((value > 31 ? 31 : value) << 20)); } }
+ public override int IV_SPD { get { return (int)(IV32 >> 25) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 25)) | (uint)((value > 31 ? 31 : value) << 25)); } }
+ public override bool IsEgg { get { return ((IV32 >> 30) & 1) == 1; } set { IV32 = (uint)((IV32 & ~0x40000000) | (uint)(value ? 0x40000000 : 0)); } }
+ public override bool IsNicknamed { get { return ((IV32 >> 31) & 1) == 1; } set { IV32 = (IV32 & 0x7FFFFFFF) | (value ? 0x80000000 : 0); } }
private byte RIB4 { get { return Data[0x3C]; } set { Data[0x3C] = value; } } // Hoenn 1a
public bool RIB4_0 { get { return (RIB4 & (1 << 0)) == 1 << 0; } set { RIB4 = (byte)(RIB4 & ~(1 << 0) | (value ? 1 << 0 : 0)); } } // Cool Ribbon
@@ -153,18 +154,18 @@ namespace PKHeX
public bool RIB7_6 { get { return (RIB7 & (1 << 6)) == 1 << 6; } set { RIB7 = (byte)(RIB7 & ~(1 << 6) | (value ? 1 << 6 : 0)); } } // Earth Ribbon
public bool RIB7_7 { get { return (RIB7 & (1 << 7)) == 1 << 7; } set { RIB7 = (byte)(RIB7 & ~(1 << 7) | (value ? 1 << 7 : 0)); } } // World Ribbon
- public bool FatefulEncounter { get { return (Data[0x40] & 1) == 1; } set { Data[0x40] = (byte)(Data[0x40] & ~0x01 | (value ? 1 : 0)); } }
- public int Gender { get { return (Data[0x40] >> 1) & 0x3; } set { Data[0x40] = (byte)(Data[0x40] & ~0x06 | (value << 1)); } }
- public int AltForm { get { return Data[0x40] >> 3; } set { Data[0x40] = (byte)(Data[0x40] & 0x07 | (value << 3)); } }
+ public override bool FatefulEncounter { get { return (Data[0x40] & 1) == 1; } set { Data[0x40] = (byte)(Data[0x40] & ~0x01 | (value ? 1 : 0)); } }
+ public override int Gender { get { return (Data[0x40] >> 1) & 0x3; } set { Data[0x40] = (byte)(Data[0x40] & ~0x06 | (value << 1)); } }
+ public override int AltForm { get { return Data[0x40] >> 3; } set { Data[0x40] = (byte)(Data[0x40] & 0x07 | (value << 3)); } }
// 0x43-0x47 Unused
#endregion
#region Block C
- public string Nickname
+ public override string Nickname
{
get
{
- return PKM.array2strG4(Data.Skip(0x48).Take(22).ToArray())
+ return PKX.array2strG4(Data.Skip(0x48).Take(22).ToArray())
.Replace("\uE08F", "\u2640") // nidoran
.Replace("\uE08E", "\u2642") // nidoran
.Replace("\u2019", "\u0027"); // farfetch'd
@@ -177,11 +178,11 @@ namespace PKHeX
.Replace("\u2640", "\uE08F") // nidoran
.Replace("\u2642", "\uE08E") // nidoran
.Replace("\u0027", "\u2019"); // farfetch'd
- PKM.str2arrayG4(TempNick).CopyTo(Data, 0x48);
+ PKX.str2arrayG4(TempNick).CopyTo(Data, 0x48);
}
}
// 0x5E unused
- public int Version { get { return Data[0x5F]; } set { Data[0x5F] = (byte)value; } }
+ public override int Version { get { return Data[0x5F]; } set { Data[0x5F] = (byte)value; } }
private byte RIB8 { get { return Data[0x60]; } set { Data[0x60] = value; } } // Sinnoh 3
public bool RIB8_0 { get { return (RIB8 & (1 << 0)) == 1 << 0; } set { RIB8 = (byte)(RIB8 & ~(1 << 0) | (value ? 1 << 0 : 0)); } } // Cool Ribbon
public bool RIB8_1 { get { return (RIB8 & (1 << 1)) == 1 << 1; } set { RIB8 = (byte)(RIB8 & ~(1 << 1) | (value ? 1 << 1 : 0)); } } // Cool Ribbon Great
@@ -222,11 +223,11 @@ namespace PKHeX
#endregion
#region Block D
- public string OT_Name
+ public override string OT_Name
{
get
{
- return PKM.array2strG4(Data.Skip(0x68).Take(16).ToArray())
+ return PKX.array2strG4(Data.Skip(0x68).Take(16).ToArray())
.Replace("\uE08F", "\u2640") // Nidoran ♂
.Replace("\uE08E", "\u2642") // Nidoran ♀
.Replace("\u2019", "\u0027"); // Farfetch'd
@@ -239,65 +240,85 @@ namespace PKHeX
.Replace("\u2640", "\uE08F") // Nidoran ♂
.Replace("\u2642", "\uE08E") // Nidoran ♀
.Replace("\u0027", "\u2019"); // Farfetch'd
- PKM.str2arrayG4(TempNick).CopyTo(Data, 0x68);
+ PKX.str2arrayG4(TempNick).CopyTo(Data, 0x68);
+ }
+ }
+ public override int Egg_Year { get { return Data[0x78]; } set { Data[0x78] = (byte)value; } }
+ public override int Egg_Month { get { return Data[0x79]; } set { Data[0x79] = (byte)value; } }
+ public override int Egg_Day { get { return Data[0x7A]; } set { Data[0x7A] = (byte)value; } }
+ public override int Met_Year { get { return Data[0x7B]; } set { Data[0x7B] = (byte)value; } }
+ public override int Met_Month { get { return Data[0x7C]; } set { Data[0x7C] = (byte)value; } }
+ public override int Met_Day { get { return Data[0x7D]; } set { Data[0x7D] = (byte)value; } }
+
+ public override int Egg_Location
+ {
+ get
+ {
+ ushort hgssloc = BitConverter.ToUInt16(Data, 0x44);
+ if (hgssloc != 0)
+ return hgssloc;
+ return BitConverter.ToUInt16(Data, 0x7E);
+ }
+ set
+ {
+ if (PtHGSS)
+ {
+ BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x44);
+ BitConverter.GetBytes(0x7D0).CopyTo(Data, 0x7E);
+ }
+ else
+ {
+ BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x44);
+ BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x7E);
+ }
+ }
+ }
+ public override int Met_Location
+ {
+ get
+ {
+ ushort hgssloc = BitConverter.ToUInt16(Data, 0x46);
+ if (hgssloc != 0)
+ return hgssloc;
+ return BitConverter.ToUInt16(Data, 0x80);
+ }
+ set
+ {
+ if (PtHGSS)
+ {
+ BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x46);
+ BitConverter.GetBytes(0x7D0).CopyTo(Data, 0x80);
+ }
+ else
+ {
+ BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x46);
+ BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x80);
+ }
}
}
- public int Egg_Year { get { return Data[0x78]; } set { Data[0x78] = (byte)value; } }
- public int Egg_Month { get { return Data[0x79]; } set { Data[0x79] = (byte)value; } }
- public int Egg_Day { get { return Data[0x7A]; } set { Data[0x7A] = (byte)value; } }
- public int Met_Year { get { return Data[0x7B]; } set { Data[0x7B] = (byte)value; } }
- public int Met_Month { get { return Data[0x7C]; } set { Data[0x7C] = (byte)value; } }
- public int Met_Day { get { return Data[0x7D]; } set { Data[0x7D] = (byte)value; } }
- public int Egg_Location { get { return BitConverter.ToUInt16(Data, 0x7E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x7E); } }
- public int Met_Location { get { return BitConverter.ToUInt16(Data, 0x80); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x80); } }
private byte PKRS { get { return Data[0x82]; } set { Data[0x82] = value; } }
- public int PKRS_Days { get { return PKRS & 0xF; } set { PKRS = (byte)(PKRS & ~0xF | value); } }
- public int PKRS_Strain { get { return PKRS >> 4; } set { PKRS = (byte)(PKRS & 0xF | (value << 4)); } }
- public int Ball { get { return Data[0x83]; } set { Data[0x83] = (byte)value; } }
- public int Met_Level { get { return Data[0x84] & ~0x80; } set { Data[0x84] = (byte)((Data[0x84] & 0x80) | value); } }
- public int OT_Gender { get { return Data[0x84] >> 7; } set { Data[0x84] = (byte)((Data[0x84] & ~0x80) | value << 7); } }
- public int EncounterType { get { return Data[0x85]; } set { Data[0x85] = (byte)value; } }
+ public override int PKRS_Days { get { return PKRS & 0xF; } set { PKRS = (byte)(PKRS & ~0xF | value); } }
+ public override int PKRS_Strain { get { return PKRS >> 4; } set { PKRS = (byte)(PKRS & 0xF | (value << 4)); } }
+ public override int Ball { get { return Data[0x83]; } set { Data[0x83] = (byte)value; } }
+ public override int Met_Level { get { return Data[0x84] & ~0x80; } set { Data[0x84] = (byte)((Data[0x84] & 0x80) | value); } }
+ public override int OT_Gender { get { return Data[0x84] >> 7; } set { Data[0x84] = (byte)((Data[0x84] & ~0x80) | value << 7); } }
+ public override int EncounterType { get { return Data[0x85]; } set { Data[0x85] = (byte)value; } }
public int HGSSBall { get { return Data[0x86]; } set { Data[0x86] = (byte)value; } }
// Unused 0x87
#endregion
- // Simple Generated Attributes
- public int[] IVs
- {
- get { return new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; }
- set
- {
- if (value == null || value.Length != 6) return;
- IV_HP = value[0]; IV_ATK = value[1]; IV_DEF = value[2];
- IV_SPE = value[3]; IV_SPA = value[4]; IV_SPD = value[5];
- }
- }
- public int[] EVs => new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD };
- public int PSV => (int)((PID >> 16 ^ PID & 0xFFFF) >> 3);
- public int TSV => (TID ^ SID) >> 3;
- public bool IsShiny => TSV == PSV;
- public bool PKRS_Infected => PKRS_Strain > 0;
- public bool PKRS_Cured => PKRS_Days == 0 && PKRS_Strain > 0;
- public bool Gen4 => Version >= 10 && Version < 12 || Version >= 7 && Version <= 8;
- public bool Gen3 => Version >= 1 && Version <= 5 || Version == 15;
- public bool GenU => !(Gen4 || Gen3);
+ public override int Stat_Level { get { return Data[0x8C]; } set { Data[0x8C] = (byte)value; } }
+ public override int Stat_HPCurrent { get { return BitConverter.ToUInt16(Data, 0x8E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x8E); } }
+ public override int Stat_HPMax { get { return BitConverter.ToUInt16(Data, 0x90); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x90); } }
+ public override int Stat_ATK { get { return BitConverter.ToUInt16(Data, 0x92); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x92); } }
+ public override int Stat_DEF { get { return BitConverter.ToUInt16(Data, 0x94); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x94); } }
+ public override int Stat_SPE { get { return BitConverter.ToUInt16(Data, 0x96); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x96); } }
+ public override int Stat_SPA { get { return BitConverter.ToUInt16(Data, 0x98); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x98); } }
+ public override int Stat_SPD { get { return BitConverter.ToUInt16(Data, 0x9A); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x9A); } }
- public int[] Moves
- {
- get { return new[] { Move1, Move2, Move3, Move4 }; }
- set
- {
- if (value.Length > 0) Move1 = value[0];
- if (value.Length > 1) Move2 = value[1];
- if (value.Length > 2) Move3 = value[2];
- if (value.Length > 3) Move4 = value[3];
- }
- }
-
- // Complex Generated Attributes
- public byte[] EncryptedPartyData => Encrypt().Take(SIZE_PARTY).ToArray();
- public byte[] EncryptedBoxData => Encrypt().Take(SIZE_STORED).ToArray();
- public int Characteristic
+ public override int PSV => (int)((PID >> 16 ^ PID & 0xFFFF) >> 3);
+ public override int TSV => (TID ^ SID) >> 3;
+ public override int Characteristic
{
get
{
@@ -315,40 +336,9 @@ namespace PKHeX
return pm6stat * 5 + maxIV % 5;
}
}
- public int PotentialRating
- {
- get
- {
- int ivTotal = IVs.Sum();
- if (ivTotal <= 90)
- return 0;
- if (ivTotal <= 120)
- return 1;
- return ivTotal <= 150 ? 2 : 3;
- }
- }
- public string FileName => $"{Species.ToString("000")}{(IsShiny ? " ★" : "")} - {Nickname} - {Checksum.ToString("X4")}{PID.ToString("X8")}.pkm";
- public bool ChecksumValid => Checksum == CalculateChecksum();
-
+
// Methods
- public void RefreshChecksum()
- {
- Checksum = CalculateChecksum();
- }
- public ushort CalculateChecksum()
- {
- ushort chk = 0;
- for (int i = 8; i < SIZE_STORED; i += 2) // Loop through the entire PK6
- chk += BitConverter.ToUInt16(Data, i);
-
- return chk;
- }
- public byte[] Write()
- {
- RefreshChecksum();
- return Data;
- }
- public bool getGenderIsValid()
+ public override bool getGenderIsValid()
{
int gv = PKX.Personal[Species].Gender;
@@ -365,34 +355,10 @@ namespace PKHeX
return false;
}
- public void FixMoves()
+ public override byte[] Encrypt()
{
- if (Move4 != 0 && Move3 == 0)
- {
- Move3 = Move4;
- Move3_PP = Move4_PP;
- Move3_PPUps = Move4_PPUps;
- Move4 = Move4_PP = Move4_PPUps = 0;
- }
- if (Move3 != 0 && Move2 == 0)
- {
- Move2 = Move3;
- Move2_PP = Move3_PP;
- Move2_PPUps = Move3_PPUps;
- Move3 = Move3_PP = Move3_PPUps = 0;
- }
- if (Move2 != 0 && Move1 == 0)
- {
- Move1 = Move2;
- Move1_PP = Move2_PP;
- Move1_PPUps = Move2_PPUps;
- Move2 = Move2_PP = Move2_PPUps = 0;
- }
- }
- public byte[] Encrypt()
- {
- Checksum = CalculateChecksum();
- return PKM.encryptArray(Data);
+ RefreshChecksum();
+ return PKX.encryptArray45(Data);
}
public PK5 convertToPK5()
@@ -406,7 +372,7 @@ namespace PKHeX
PK5 pk5 = new PK5(Data) // Convert away!
{
HeldItem = 0,
- Friendship = 70,
+ OT_Friendship = 70,
// Apply new met date
Met_Year = moment.Year - 2000,
Met_Month = moment.Month,
@@ -420,7 +386,7 @@ namespace PKHeX
pk5.Move4_PP = PKX.getMovePP(pk5.Move4_PP, pk5.Move4_PPUps);
// Disassociate Nature and PID
- pk5.Nature = (int)(pk5.PID % 0x19);
+ pk5.Nature = (int)(pk5.PID % 25);
// Delete Platinum/HGSS Met Location Data
BitConverter.GetBytes((uint)0).CopyTo(pk5.Data, 0x44);
diff --git a/Misc/PK5.cs b/PKM/PK5.cs
similarity index 71%
rename from Misc/PK5.cs
rename to PKM/PK5.cs
index 432f13d57..89c5c389a 100644
--- a/Misc/PK5.cs
+++ b/PKM/PK5.cs
@@ -6,55 +6,55 @@ namespace PKHeX
{
public class PK5 : PKM // 5th Generation PKM File
{
- internal const int SIZE_PARTY = 220;
- internal const int SIZE_STORED = 136;
- internal const int SIZE_BLOCK = 32;
-
+ internal static readonly byte[] ExtraBytes =
+ {
+ 0x42, 0x43, 0x5E, 0x63, 0x64, 0x65, 0x66, 0x67, 0x87
+ };
+ public override int SIZE_PARTY => PKX.SIZE_5PARTY;
+ public override int SIZE_STORED => PKX.SIZE_5STORED;
+ public override int Format => 5;
public PK5(byte[] decryptedData = null, string ident = null)
{
Data = (byte[])(decryptedData ?? new byte[SIZE_PARTY]).Clone();
+ PKMConverter.checkEncrypted(ref Data);
Identifier = ident;
if (Data.Length != SIZE_PARTY)
Array.Resize(ref Data, SIZE_PARTY);
}
+ public override PKM Clone() { return new PK5(Data); }
- // Internal Attributes set on creation
- public byte[] Data; // Raw Storage
- public string Identifier; // User or Form Custom Attribute
+ // Future Attributes
+ public override uint EncryptionConstant { get { return PID; } set { } }
+ public override int CurrentFriendship { get { return OT_Friendship; } set { OT_Friendship = value; } }
+ public override int CurrentHandler { get { return 0; } set { } }
// Structure
- public uint PID { get { return BitConverter.ToUInt32(Data, 0x00); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x00); } }
- public ushort Sanity { get { return BitConverter.ToUInt16(Data, 0x04); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x04); } }
- public ushort Checksum { get { return BitConverter.ToUInt16(Data, 0x06); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x06); } }
+ public override uint PID { get { return BitConverter.ToUInt32(Data, 0x00); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x00); } }
+ public override ushort Sanity { get { return BitConverter.ToUInt16(Data, 0x04); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x04); } }
+ public override ushort Checksum { get { return BitConverter.ToUInt16(Data, 0x06); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x06); } }
#region Block A
- public int Species { get { return BitConverter.ToUInt16(Data, 0x08); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x08); } }
- public int HeldItem { get { return BitConverter.ToUInt16(Data, 0x0A); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0A); } }
- public int TID { get { return BitConverter.ToUInt16(Data, 0x0C); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0C); } }
- public int SID { get { return BitConverter.ToUInt16(Data, 0x0E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0E); } }
- public uint EXP { get { return BitConverter.ToUInt32(Data, 0x10); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x10); } }
- public int Friendship { get { return Data[0x14]; } set { Data[0x14] = (byte)value; } }
- public int Ability { get { return Data[0x15]; } set { Data[0x15] = (byte)value; } }
- public byte Markings { get { return Data[0x16]; } set { Data[0x16] = value; } }
- public bool Circle { get { return (Markings & (1 << 0)) == 1 << 0; } set { Markings = (byte)(Markings & ~(1 << 0) | (value ? 1 << 0 : 0)); } }
- public bool Triangle { get { return (Markings & (1 << 1)) == 1 << 1; } set { Markings = (byte)(Markings & ~(1 << 1) | (value ? 1 << 1 : 0)); } }
- public bool Square { get { return (Markings & (1 << 2)) == 1 << 2; } set { Markings = (byte)(Markings & ~(1 << 2) | (value ? 1 << 2 : 0)); } }
- public bool Heart { get { return (Markings & (1 << 3)) == 1 << 3; } set { Markings = (byte)(Markings & ~(1 << 3) | (value ? 1 << 3 : 0)); } }
- public bool Star { get { return (Markings & (1 << 4)) == 1 << 4; } set { Markings = (byte)(Markings & ~(1 << 4) | (value ? 1 << 4 : 0)); } }
- public bool Diamond { get { return (Markings & (1 << 5)) == 1 << 5; } set { Markings = (byte)(Markings & ~(1 << 5) | (value ? 1 << 5 : 0)); } }
- public int Language { get { return Data[0x17]; } set { Data[0x17] = (byte)value; } }
- public int EV_HP { get { return Data[0x18]; } set { Data[0x18] = (byte)value; } }
- public int EV_ATK { get { return Data[0x19]; } set { Data[0x19] = (byte)value; } }
- public int EV_DEF { get { return Data[0x1A]; } set { Data[0x1A] = (byte)value; } }
- public int EV_SPE { get { return Data[0x1B]; } set { Data[0x1B] = (byte)value; } }
- public int EV_SPA { get { return Data[0x1C]; } set { Data[0x1C] = (byte)value; } }
- public int EV_SPD { get { return Data[0x1D]; } set { Data[0x1D] = (byte)value; } }
- public int CNT_Cool { get { return Data[0x1E]; } set { Data[0x1E] = (byte)value; } }
- public int CNT_Beauty { get { return Data[0x1F]; } set { Data[0x1F] = (byte)value; } }
- public int CNT_Cute { get { return Data[0x20]; } set { Data[0x20] = (byte)value; } }
- public int CNT_Smart { get { return Data[0x21]; } set { Data[0x21] = (byte)value; } }
- public int CNT_Tough { get { return Data[0x22]; } set { Data[0x22] = (byte)value; } }
- public int CNT_Sheen { get { return Data[0x23]; } set { Data[0x23] = (byte)value; } }
+ public override int Species { get { return BitConverter.ToUInt16(Data, 0x08); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x08); } }
+ public override int HeldItem { get { return BitConverter.ToUInt16(Data, 0x0A); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0A); } }
+ public override int TID { get { return BitConverter.ToUInt16(Data, 0x0C); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0C); } }
+ public override int SID { get { return BitConverter.ToUInt16(Data, 0x0E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0E); } }
+ public override uint EXP { get { return BitConverter.ToUInt32(Data, 0x10); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x10); } }
+ public override int OT_Friendship { get { return Data[0x14]; } set { Data[0x14] = (byte)value; } }
+ public override int Ability { get { return Data[0x15]; } set { Data[0x15] = (byte)value; } }
+ public override byte MarkByte { get { return Data[0x16]; } protected set { Data[0x16] = value; } }
+ public override int Language { get { return Data[0x17]; } set { Data[0x17] = (byte)value; } }
+ public override int EV_HP { get { return Data[0x18]; } set { Data[0x18] = (byte)value; } }
+ public override int EV_ATK { get { return Data[0x19]; } set { Data[0x19] = (byte)value; } }
+ public override int EV_DEF { get { return Data[0x1A]; } set { Data[0x1A] = (byte)value; } }
+ public override int EV_SPE { get { return Data[0x1B]; } set { Data[0x1B] = (byte)value; } }
+ public override int EV_SPA { get { return Data[0x1C]; } set { Data[0x1C] = (byte)value; } }
+ public override int EV_SPD { get { return Data[0x1D]; } set { Data[0x1D] = (byte)value; } }
+ public override int CNT_Cool { get { return Data[0x1E]; } set { Data[0x1E] = (byte)value; } }
+ public override int CNT_Beauty { get { return Data[0x1F]; } set { Data[0x1F] = (byte)value; } }
+ public override int CNT_Cute { get { return Data[0x20]; } set { Data[0x20] = (byte)value; } }
+ public override int CNT_Smart { get { return Data[0x21]; } set { Data[0x21] = (byte)value; } }
+ public override int CNT_Tough { get { return Data[0x22]; } set { Data[0x22] = (byte)value; } }
+ public override int CNT_Sheen { get { return Data[0x23]; } set { Data[0x23] = (byte)value; } }
private byte RIB0 { get { return Data[0x24]; } set { Data[0x24] = value; } } // Sinnoh 1
public bool RIB0_0 { get { return (RIB0 & (1 << 0)) == 1 << 0; } set { RIB0 = (byte)(RIB0 & ~(1 << 0) | (value ? 1 << 0 : 0)); } } // Sinnoh Champ Ribbon
@@ -95,27 +95,27 @@ namespace PKHeX
#endregion
#region Block B
- public int Move1 { get { return BitConverter.ToUInt16(Data, 0x28); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x28); } }
- public int Move2 { get { return BitConverter.ToUInt16(Data, 0x2A); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2A); } }
- public int Move3 { get { return BitConverter.ToUInt16(Data, 0x2C); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2C); } }
- public int Move4 { get { return BitConverter.ToUInt16(Data, 0x2E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2E); } }
- public int Move1_PP { get { return Data[0x30]; } set { Data[0x30] = (byte)value; } }
- public int Move2_PP { get { return Data[0x31]; } set { Data[0x31] = (byte)value; } }
- public int Move3_PP { get { return Data[0x32]; } set { Data[0x32] = (byte)value; } }
- public int Move4_PP { get { return Data[0x33]; } set { Data[0x33] = (byte)value; } }
- public int Move1_PPUps { get { return Data[0x34]; } set { Data[0x34] = (byte)value; } }
- public int Move2_PPUps { get { return Data[0x35]; } set { Data[0x35] = (byte)value; } }
- public int Move3_PPUps { get { return Data[0x36]; } set { Data[0x36] = (byte)value; } }
- public int Move4_PPUps { get { return Data[0x37]; } set { Data[0x37] = (byte)value; } }
+ public override int Move1 { get { return BitConverter.ToUInt16(Data, 0x28); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x28); } }
+ public override int Move2 { get { return BitConverter.ToUInt16(Data, 0x2A); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2A); } }
+ public override int Move3 { get { return BitConverter.ToUInt16(Data, 0x2C); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2C); } }
+ public override int Move4 { get { return BitConverter.ToUInt16(Data, 0x2E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2E); } }
+ public override int Move1_PP { get { return Data[0x30]; } set { Data[0x30] = (byte)value; } }
+ public override int Move2_PP { get { return Data[0x31]; } set { Data[0x31] = (byte)value; } }
+ public override int Move3_PP { get { return Data[0x32]; } set { Data[0x32] = (byte)value; } }
+ public override int Move4_PP { get { return Data[0x33]; } set { Data[0x33] = (byte)value; } }
+ public override int Move1_PPUps { get { return Data[0x34]; } set { Data[0x34] = (byte)value; } }
+ public override int Move2_PPUps { get { return Data[0x35]; } set { Data[0x35] = (byte)value; } }
+ public override int Move3_PPUps { get { return Data[0x36]; } set { Data[0x36] = (byte)value; } }
+ public override int Move4_PPUps { get { return Data[0x37]; } set { Data[0x37] = (byte)value; } }
private uint IV32 { get { return BitConverter.ToUInt32(Data, 0x38); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x38); } }
- public int IV_HP { get { return (int)(IV32 >> 00) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 00)) | (uint)((value > 31 ? 31 : value) << 00)); } }
- public int IV_ATK { get { return (int)(IV32 >> 05) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 05)) | (uint)((value > 31 ? 31 : value) << 05)); } }
- public int IV_DEF { get { return (int)(IV32 >> 10) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 10)) | (uint)((value > 31 ? 31 : value) << 10)); } }
- public int IV_SPE { get { return (int)(IV32 >> 15) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 15)) | (uint)((value > 31 ? 31 : value) << 15)); } }
- public int IV_SPA { get { return (int)(IV32 >> 20) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 20)) | (uint)((value > 31 ? 31 : value) << 20)); } }
- public int IV_SPD { get { return (int)(IV32 >> 25) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 25)) | (uint)((value > 31 ? 31 : value) << 25)); } }
- public bool IsEgg { get { return ((IV32 >> 30) & 1) == 1; } set { IV32 = (uint)((IV32 & ~0x40000000) | (uint)(value ? 0x40000000 : 0)); } }
- public bool IsNicknamed { get { return ((IV32 >> 31) & 1) == 1; } set { IV32 = (IV32 & 0x7FFFFFFF) | (value ? 0x80000000 : 0); } }
+ public override int IV_HP { get { return (int)(IV32 >> 00) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 00)) | (uint)((value > 31 ? 31 : value) << 00)); } }
+ public override int IV_ATK { get { return (int)(IV32 >> 05) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 05)) | (uint)((value > 31 ? 31 : value) << 05)); } }
+ public override int IV_DEF { get { return (int)(IV32 >> 10) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 10)) | (uint)((value > 31 ? 31 : value) << 10)); } }
+ public override int IV_SPE { get { return (int)(IV32 >> 15) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 15)) | (uint)((value > 31 ? 31 : value) << 15)); } }
+ public override int IV_SPA { get { return (int)(IV32 >> 20) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 20)) | (uint)((value > 31 ? 31 : value) << 20)); } }
+ public override int IV_SPD { get { return (int)(IV32 >> 25) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 25)) | (uint)((value > 31 ? 31 : value) << 25)); } }
+ public override bool IsEgg { get { return ((IV32 >> 30) & 1) == 1; } set { IV32 = (uint)((IV32 & ~0x40000000) | (uint)(value ? 0x40000000 : 0)); } }
+ public override bool IsNicknamed { get { return ((IV32 >> 31) & 1) == 1; } set { IV32 = (IV32 & 0x7FFFFFFF) | (value ? 0x80000000 : 0); } }
private byte RIB4 { get { return Data[0x3C]; } set { Data[0x3C] = value; } } // Hoenn 1a
public bool RIB4_0 { get { return (RIB4 & (1 << 0)) == 1 << 0; } set { RIB4 = (byte)(RIB4 & ~(1 << 0) | (value ? 1 << 0 : 0)); } } // Cool Ribbon
@@ -154,21 +154,21 @@ namespace PKHeX
public bool RIB7_6 { get { return (RIB7 & (1 << 6)) == 1 << 6; } set { RIB7 = (byte)(RIB7 & ~(1 << 6) | (value ? 1 << 6 : 0)); } } // Earth Ribbon
public bool RIB7_7 { get { return (RIB7 & (1 << 7)) == 1 << 7; } set { RIB7 = (byte)(RIB7 & ~(1 << 7) | (value ? 1 << 7 : 0)); } } // World Ribbon
- public bool FatefulEncounter { get { return (Data[0x40] & 1) == 1; } set { Data[0x40] = (byte)(Data[0x40] & ~0x01 | (value ? 1 : 0)); } }
- public int Gender { get { return (Data[0x40] >> 1) & 0x3; } set { Data[0x40] = (byte)(Data[0x40] & ~0x06 | (value << 1)); } }
- public int AltForm { get { return Data[0x40] >> 3; } set { Data[0x40] = (byte)(Data[0x40] & 0x07 | (value << 3)); } }
- public int Nature { get { return Data[0x41]; } set { Data[0x41] = (byte)value; } }
+ public override bool FatefulEncounter { get { return (Data[0x40] & 1) == 1; } set { Data[0x40] = (byte)(Data[0x40] & ~0x01 | (value ? 1 : 0)); } }
+ public override int Gender { get { return (Data[0x40] >> 1) & 0x3; } set { Data[0x40] = (byte)(Data[0x40] & ~0x06 | (value << 1)); } }
+ public override int AltForm { get { return Data[0x40] >> 3; } set { Data[0x40] = (byte)(Data[0x40] & 0x07 | (value << 3)); } }
+ public override int Nature { get { return Data[0x41]; } set { Data[0x41] = (byte)value; } }
public bool HiddenAbility { get { return (Data[0x41] & 1) == 1; } set { Data[0x41] = (byte)(Data[0x41] & ~0x01 | (value ? 1 : 0)); } }
public bool NPokémon { get { return (Data[0x41] & 2) == 2; } set { Data[0x41] = (byte)(Data[0x41] & ~0x02 | (value ? 2 : 0)); } }
// 0x43-0x47 Unused
#endregion
#region Block C
- public string Nickname
+ public override string Nickname
{
get
{
- return TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x48, 22))
+ return PKX.TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x48, 22))
.Replace("\uE08F", "\u2640") // nidoran
.Replace("\uE08E", "\u2642") // nidoran
.Replace("\u2019", "\u0027"); // farfetch'd
@@ -186,7 +186,7 @@ namespace PKHeX
}
}
// 0x5E unused
- public int Version { get { return Data[0x5F]; } set { Data[0x5F] = (byte)value; } }
+ public override int Version { get { return Data[0x5F]; } set { Data[0x5F] = (byte)value; } }
private byte RIB8 { get { return Data[0x60]; } set { Data[0x60] = value; } } // Sinnoh 3
public bool RIB8_0 { get { return (RIB8 & (1 << 0)) == 1 << 0; } set { RIB8 = (byte)(RIB8 & ~(1 << 0) | (value ? 1 << 0 : 0)); } } // Cool Ribbon
public bool RIB8_1 { get { return (RIB8 & (1 << 1)) == 1 << 1; } set { RIB8 = (byte)(RIB8 & ~(1 << 1) | (value ? 1 << 1 : 0)); } } // Cool Ribbon Great
@@ -227,11 +227,11 @@ namespace PKHeX
#endregion
#region Block D
- public string OT_Name
+ public override string OT_Name
{
get
{
- return TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x68, 16))
+ return PKX.TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x68, 16))
.Replace("\uE08F", "\u2640") // Nidoran ♂
.Replace("\uE08E", "\u2642") // Nidoran ♀
.Replace("\u2019", "\u0027"); // farfetch'd
@@ -248,60 +248,37 @@ namespace PKHeX
Encoding.Unicode.GetBytes(TempNick).CopyTo(Data, 0x68);
}
}
- public int Egg_Year { get { return Data[0x78]; } set { Data[0x78] = (byte)value; } }
- public int Egg_Month { get { return Data[0x79]; } set { Data[0x79] = (byte)value; } }
- public int Egg_Day { get { return Data[0x7A]; } set { Data[0x7A] = (byte)value; } }
- public int Met_Year { get { return Data[0x7B]; } set { Data[0x7B] = (byte)value; } }
- public int Met_Month { get { return Data[0x7C]; } set { Data[0x7C] = (byte)value; } }
- public int Met_Day { get { return Data[0x7D]; } set { Data[0x7D] = (byte)value; } }
- public int Egg_Location { get { return BitConverter.ToUInt16(Data, 0x7E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x7E); } }
- public int Met_Location { get { return BitConverter.ToUInt16(Data, 0x80); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x80); } }
+ public override int Egg_Year { get { return Data[0x78]; } set { Data[0x78] = (byte)value; } }
+ public override int Egg_Month { get { return Data[0x79]; } set { Data[0x79] = (byte)value; } }
+ public override int Egg_Day { get { return Data[0x7A]; } set { Data[0x7A] = (byte)value; } }
+ public override int Met_Year { get { return Data[0x7B]; } set { Data[0x7B] = (byte)value; } }
+ public override int Met_Month { get { return Data[0x7C]; } set { Data[0x7C] = (byte)value; } }
+ public override int Met_Day { get { return Data[0x7D]; } set { Data[0x7D] = (byte)value; } }
+ public override int Egg_Location { get { return BitConverter.ToUInt16(Data, 0x7E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x7E); } }
+ public override int Met_Location { get { return BitConverter.ToUInt16(Data, 0x80); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x80); } }
private byte PKRS { get { return Data[0x82]; } set { Data[0x82] = value; } }
- public int PKRS_Days { get { return PKRS & 0xF; } set { PKRS = (byte)(PKRS & ~0xF | value); } }
- public int PKRS_Strain { get { return PKRS >> 4; } set { PKRS = (byte)(PKRS & 0xF | (value << 4)); } }
- public int Ball { get { return Data[0x83]; } set { Data[0x83] = (byte)value; } }
- public int Met_Level { get { return Data[0x84] & ~0x80; } set { Data[0x84] = (byte)((Data[0x84] & 0x80) | value); } }
- public int OT_Gender { get { return Data[0x84] >> 7; } set { Data[0x84] = (byte)((Data[0x84] & ~0x80) | value << 7); } }
- public int EncounterType { get { return Data[0x85]; } set { Data[0x85] = (byte)value; } }
+ public override int PKRS_Days { get { return PKRS & 0xF; } set { PKRS = (byte)(PKRS & ~0xF | value); } }
+ public override int PKRS_Strain { get { return PKRS >> 4; } set { PKRS = (byte)(PKRS & 0xF | (value << 4)); } }
+ public override int Ball { get { return Data[0x83]; } set { Data[0x83] = (byte)value; } }
+ public override int Met_Level { get { return Data[0x84] & ~0x80; } set { Data[0x84] = (byte)((Data[0x84] & 0x80) | value); } }
+ public override int OT_Gender { get { return Data[0x84] >> 7; } set { Data[0x84] = (byte)((Data[0x84] & ~0x80) | value << 7); } }
+ public override int EncounterType { get { return Data[0x85]; } set { Data[0x85] = (byte)value; } }
// 0x86-0x87 Unused
#endregion
- // Simple Generated Attributes
- public int[] IVs
- {
- get { return new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; }
- set
- {
- if (value == null || value.Length != 6) return;
- IV_HP = value[0]; IV_ATK = value[1]; IV_DEF = value[2];
- IV_SPE = value[3]; IV_SPA = value[4]; IV_SPD = value[5];
- }
- }
- public int[] EVs => new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD };
- public int PSV => (int)((PID >> 16 ^ PID & 0xFFFF) >> 3);
- public int TSV => (TID ^ SID) >> 3;
- public bool IsShiny => TSV == PSV;
- public bool PKRS_Infected => PKRS_Strain > 0;
- public bool PKRS_Cured => PKRS_Days == 0 && PKRS_Strain > 0;
- public bool Gen5 => Version >= 20 && Version <= 23;
- public bool Gen4 => Version >= 10 && Version < 12 || Version >= 7 && Version <= 8;
- public bool Gen3 => Version >= 1 && Version <= 5 || Version == 15;
- public bool GenU => !(Gen5 || Gen4 || Gen3);
+ public override int Stat_Level { get { return Data[0x8C]; } set { Data[0x8C] = (byte)value; } }
+ public override int Stat_HPCurrent { get { return BitConverter.ToUInt16(Data, 0x8E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x8E); } }
+ public override int Stat_HPMax { get { return BitConverter.ToUInt16(Data, 0x90); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x90); } }
+ public override int Stat_ATK { get { return BitConverter.ToUInt16(Data, 0x92); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x92); } }
+ public override int Stat_DEF { get { return BitConverter.ToUInt16(Data, 0x94); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x94); } }
+ public override int Stat_SPE { get { return BitConverter.ToUInt16(Data, 0x96); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x96); } }
+ public override int Stat_SPA { get { return BitConverter.ToUInt16(Data, 0x98); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x98); } }
+ public override int Stat_SPD { get { return BitConverter.ToUInt16(Data, 0x9A); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x9A); } }
- public int[] Moves {
- get { return new[] {Move1, Move2, Move3, Move4}; }
- set {
- if (value.Length > 0) Move1 = value[0];
- if (value.Length > 1) Move2 = value[1];
- if (value.Length > 2) Move3 = value[2];
- if (value.Length > 3) Move4 = value[3]; } }
-
- // Complex Generated Attributes
- public byte[] EncryptedPartyData => Encrypt().Take(SIZE_PARTY).ToArray();
- public byte[] EncryptedBoxData => Encrypt().Take(SIZE_STORED).ToArray();
- public byte[] DecryptedPartyData => Data.Take(SIZE_PARTY).ToArray();
- public byte[] DecryptedBoxData => Data.Take(SIZE_STORED).ToArray();
- public int Characteristic
+ // Generated Attributes
+ public override int PSV => (int)((PID >> 16 ^ PID & 0xFFFF) >> 3);
+ public override int TSV => (TID ^ SID) >> 3;
+ public override int Characteristic
{
get
{
@@ -319,40 +296,9 @@ namespace PKHeX
return pm6stat * 5 + maxIV % 5;
}
}
- public int PotentialRating
- {
- get
- {
- int ivTotal = IVs.Sum();
- if (ivTotal <= 90)
- return 0;
- if (ivTotal <= 120)
- return 1;
- return ivTotal <= 150 ? 2 : 3;
- }
- }
- public string FileName => $"{Species.ToString("000")}{(IsShiny ? " ★" : "")} - {Nickname} - {Checksum.ToString("X4")}{PID.ToString("X8")}.pkm";
- public bool ChecksumValid => Checksum == CalculateChecksum();
-
+
// Methods
- public void RefreshChecksum()
- {
- Checksum = CalculateChecksum();
- }
- public ushort CalculateChecksum()
- {
- ushort chk = 0;
- for (int i = 8; i < SIZE_STORED; i += 2) // Loop through the entire PK5
- chk += BitConverter.ToUInt16(Data, i);
-
- return chk;
- }
- public byte[] Write()
- {
- RefreshChecksum();
- return Data;
- }
- public bool getGenderIsValid()
+ public override bool getGenderIsValid()
{
int gv = PKX.Personal[Species].Gender;
if (gv == 255 && Gender == 2)
@@ -367,34 +313,10 @@ namespace PKHeX
return true;
return false;
}
- public void FixMoves()
+ public override byte[] Encrypt()
{
- if (Move4 != 0 && Move3 == 0)
- {
- Move3 = Move4;
- Move3_PP = Move4_PP;
- Move3_PPUps = Move4_PPUps;
- Move4 = Move4_PP = Move4_PPUps = 0;
- }
- if (Move3 != 0 && Move2 == 0)
- {
- Move2 = Move3;
- Move2_PP = Move3_PP;
- Move2_PPUps = Move3_PPUps;
- Move3 = Move3_PP = Move3_PPUps = 0;
- }
- if (Move2 != 0 && Move1 == 0)
- {
- Move1 = Move2;
- Move1_PP = Move2_PP;
- Move1_PPUps = Move2_PPUps;
- Move2 = Move2_PP = Move2_PPUps = 0;
- }
- }
- public byte[] Encrypt()
- {
- Checksum = CalculateChecksum();
- return encryptArray(Data);
+ RefreshChecksum();
+ return PKX.encryptArray45(Data);
}
public PK6 convertToPK6()
@@ -581,16 +503,16 @@ namespace PKHeX
pk6.Data[0x34] = (byte)bx34;
// Write Transfer Location - location is dependent on 3DS system that transfers.
- pk6.Country = Converter.Country;
- pk6.Region = Converter.Region;
- pk6.ConsoleRegion = Converter.ConsoleRegion;
+ pk6.Country = PKMConverter.Country;
+ pk6.Region = PKMConverter.Region;
+ pk6.ConsoleRegion = PKMConverter.ConsoleRegion;
// Write the Memories, Friendship, and Origin!
pk6.CurrentHandler = 1;
- pk6.HT_Name = Converter.OT_Name;
- pk6.HT_Gender = Converter.OT_Gender;
- pk6.Geo1_Region = Converter.Region;
- pk6.Geo1_Country = Converter.Country;
+ pk6.HT_Name = PKMConverter.OT_Name;
+ pk6.HT_Gender = PKMConverter.OT_Gender;
+ pk6.Geo1_Region = PKMConverter.Region;
+ pk6.Geo1_Country = PKMConverter.Country;
pk6.HT_Intensity = 1;
pk6.HT_Memory = 4;
pk6.HT_Feeling = (int)(Util.rnd32() % 10);
diff --git a/Misc/PK6.cs b/PKM/PK6.cs
similarity index 70%
rename from Misc/PK6.cs
rename to PKM/PK6.cs
index c4f0b1103..329bc1960 100644
--- a/Misc/PK6.cs
+++ b/PKM/PK6.cs
@@ -1,104 +1,99 @@
using System;
-using System.Drawing;
using System.Linq;
using System.Text;
namespace PKHeX
{
- public class PK6 : PKX
+ public class PK6 : PKM
{
- internal const int SIZE_PARTY = 0x104;
- internal const int SIZE_STORED = 0xE8;
-
+ internal static readonly byte[] ExtraBytes =
+ {
+ 0x36, 0x37, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x58, 0x59, 0x73, 0x90, 0x91, 0x9E, 0x9F, 0xA0, 0xA1, 0xA7, 0xAA, 0xAB, 0xAC, 0xAD, 0xC8, 0xC9, 0xD7, 0xE4, 0xE5, 0xE6, 0xE7
+ };
+ public override int SIZE_PARTY => PKX.SIZE_6PARTY;
+ public override int SIZE_STORED => PKX.SIZE_6STORED;
+ public override int Format => 6;
public PK6(byte[] decryptedData = null, string ident = null)
{
Data = (byte[])(decryptedData ?? new byte[SIZE_PARTY]).Clone();
+ PKMConverter.checkEncrypted(ref Data);
Identifier = ident;
if (Data.Length != SIZE_PARTY)
Array.Resize(ref Data, SIZE_PARTY);
}
-
- // Internal Attributes set on creation
- public byte[] Data; // Raw Storage
- public string Identifier; // User or Form Custom Attribute
+ public override PKM Clone() { return new PK6(Data); }
// Structure
#region Block A
- public uint EncryptionConstant
+ public override uint EncryptionConstant
{
get { return BitConverter.ToUInt32(Data, 0x00); }
set { BitConverter.GetBytes(value).CopyTo(Data, 0x00); }
}
- public ushort Sanity
+ public override ushort Sanity
{
get { return BitConverter.ToUInt16(Data, 0x04); }
set { BitConverter.GetBytes(value).CopyTo(Data, 0x04); } // Should always be zero...
}
- public ushort Checksum
+ public override ushort Checksum
{
get { return BitConverter.ToUInt16(Data, 0x06); }
set { BitConverter.GetBytes(value).CopyTo(Data, 0x06); }
}
- public int Species
+ public override int Species
{
get { return BitConverter.ToUInt16(Data, 0x08); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x08); }
}
- public int HeldItem
+ public override int HeldItem
{
get { return BitConverter.ToUInt16(Data, 0x0A); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0A); }
}
- public int TID
+ public override int TID
{
get { return BitConverter.ToUInt16(Data, 0x0C); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0C); }
}
- public int SID
+ public override int SID
{
get { return BitConverter.ToUInt16(Data, 0x0E); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0E); }
}
- public uint EXP
+ public override uint EXP
{
get { return BitConverter.ToUInt32(Data, 0x10); }
set { BitConverter.GetBytes(value).CopyTo(Data, 0x10); }
}
- public int Ability { get { return Data[0x14]; } set { Data[0x14] = (byte)value; } }
+ public override int Ability { get { return Data[0x14]; } set { Data[0x14] = (byte)value; } }
public int AbilityNumber { get { return Data[0x15]; } set { Data[0x15] = (byte)value; } }
public int TrainingBagHits { get { return Data[0x16]; } set { Data[0x16] = (byte)value; } }
- public int TrainingBag { get { return Data[0x17]; } set { Data[0x17] = (byte)value; } }
- public uint PID
+ public int TrainingBag { get { return Data[0x17]; } set { Data[0x17] = (byte)value; } }
+ public override uint PID
{
get { return BitConverter.ToUInt32(Data, 0x18); }
set { BitConverter.GetBytes(value).CopyTo(Data, 0x18); }
}
- public int Nature { get { return Data[0x1C]; } set { Data[0x1C] = (byte)value; } }
- public bool FatefulEncounter { get { return (Data[0x1D] & 1) == 1; } set { Data[0x1D] = (byte)(Data[0x1D] & ~0x01 | (value ? 1 : 0)); } }
- public int Gender { get { return (Data[0x1D] >> 1) & 0x3; } set { Data[0x1D] = (byte)(Data[0x1D] & ~0x06 | (value << 1)); } }
- public int AltForm { get { return Data[0x1D] >> 3; } set { Data[0x1D] = (byte)(Data[0x1D] & 0x07 | (value << 3)); } }
- public int EV_HP { get { return Data[0x1E]; } set { Data[0x1E] = (byte)value; } }
- public int EV_ATK { get { return Data[0x1F]; } set { Data[0x1F] = (byte)value; } }
- public int EV_DEF { get { return Data[0x20]; } set { Data[0x20] = (byte)value; } }
- public int EV_SPE { get { return Data[0x21]; } set { Data[0x21] = (byte)value; } }
- public int EV_SPA { get { return Data[0x22]; } set { Data[0x22] = (byte)value; } }
- public int EV_SPD { get { return Data[0x23]; } set { Data[0x23] = (byte)value; } }
- public int CNT_Cool { get { return Data[0x24]; } set { Data[0x24] = (byte)value; } }
- public int CNT_Beauty { get { return Data[0x25]; } set { Data[0x25] = (byte)value; } }
- public int CNT_Cute { get { return Data[0x26]; } set { Data[0x26] = (byte)value; } }
- public int CNT_Smart { get { return Data[0x27]; } set { Data[0x27] = (byte)value; } }
- public int CNT_Tough { get { return Data[0x28]; } set { Data[0x28] = (byte)value; } }
- public int CNT_Sheen { get { return Data[0x29]; } set { Data[0x29] = (byte)value; } }
- public byte Markings { get { return Data[0x2A]; } set { Data[0x2A] = value; } }
- public bool Circle { get { return (Markings & (1 << 0)) == 1 << 0; } set { Markings = (byte)(Markings & ~(1 << 0) | (value ? 1 << 0 : 0)); } }
- public bool Triangle { get { return (Markings & (1 << 1)) == 1 << 1; } set { Markings = (byte)(Markings & ~(1 << 1) | (value ? 1 << 1 : 0)); } }
- public bool Square { get { return (Markings & (1 << 2)) == 1 << 2; } set { Markings = (byte)(Markings & ~(1 << 2) | (value ? 1 << 2 : 0)); } }
- public bool Heart { get { return (Markings & (1 << 3)) == 1 << 3; } set { Markings = (byte)(Markings & ~(1 << 3) | (value ? 1 << 3 : 0)); } }
- public bool Star { get { return (Markings & (1 << 4)) == 1 << 4; } set { Markings = (byte)(Markings & ~(1 << 4) | (value ? 1 << 4 : 0)); } }
- public bool Diamond { get { return (Markings & (1 << 5)) == 1 << 5; } set { Markings = (byte)(Markings & ~(1 << 5) | (value ? 1 << 5 : 0)); } }
+ public override int Nature { get { return Data[0x1C]; } set { Data[0x1C] = (byte)value; } }
+ public override bool FatefulEncounter { get { return (Data[0x1D] & 1) == 1; } set { Data[0x1D] = (byte)(Data[0x1D] & ~0x01 | (value ? 1 : 0)); } }
+ public override int Gender { get { return (Data[0x1D] >> 1) & 0x3; } set { Data[0x1D] = (byte)(Data[0x1D] & ~0x06 | (value << 1)); } }
+ public override int AltForm { get { return Data[0x1D] >> 3; } set { Data[0x1D] = (byte)(Data[0x1D] & 0x07 | (value << 3)); } }
+ public override int EV_HP { get { return Data[0x1E]; } set { Data[0x1E] = (byte)value; } }
+ public override int EV_ATK { get { return Data[0x1F]; } set { Data[0x1F] = (byte)value; } }
+ public override int EV_DEF { get { return Data[0x20]; } set { Data[0x20] = (byte)value; } }
+ public override int EV_SPE { get { return Data[0x21]; } set { Data[0x21] = (byte)value; } }
+ public override int EV_SPA { get { return Data[0x22]; } set { Data[0x22] = (byte)value; } }
+ public override int EV_SPD { get { return Data[0x23]; } set { Data[0x23] = (byte)value; } }
+ public override int CNT_Cool { get { return Data[0x24]; } set { Data[0x24] = (byte)value; } }
+ public override int CNT_Beauty { get { return Data[0x25]; } set { Data[0x25] = (byte)value; } }
+ public override int CNT_Cute { get { return Data[0x26]; } set { Data[0x26] = (byte)value; } }
+ public override int CNT_Smart { get { return Data[0x27]; } set { Data[0x27] = (byte)value; } }
+ public override int CNT_Tough { get { return Data[0x28]; } set { Data[0x28] = (byte)value; } }
+ public override int CNT_Sheen { get { return Data[0x29]; } set { Data[0x29] = (byte)value; } }
+ public override byte MarkByte { get { return Data[0x2A]; } protected set { Data[0x2A] = value; } }
private byte PKRS { get { return Data[0x2B]; } set { Data[0x2B] = value; } }
- public int PKRS_Days { get { return PKRS & 0xF; } set { PKRS = (byte)(PKRS & ~0xF | value); } }
- public int PKRS_Strain { get { return PKRS >> 4; } set { PKRS = (byte)(PKRS & 0xF | value << 4); } }
+ public override int PKRS_Days { get { return PKRS & 0xF; } set { PKRS = (byte)(PKRS & ~0xF | value); } }
+ public override int PKRS_Strain { get { return PKRS >> 4; } set { PKRS = (byte)(PKRS & 0xF | value << 4); } }
private byte ST1 { get { return Data[0x2C]; } set { Data[0x2C] = value; } }
public bool Unused0 { get { return (ST1 & (1 << 0)) == 1 << 0; } set { ST1 = (byte)(ST1 & ~(1 << 0) | (value ? 1 << 0 : 0)); } }
public bool Unused1 { get { return (ST1 & (1 << 1)) == 1 << 1; } set { ST1 = (byte)(ST1 & ~(1 << 1) | (value ? 1 << 1 : 0)); } }
@@ -209,7 +204,7 @@ namespace PKHeX
public byte _0x3F { get { return Data[0x3F]; } set { Data[0x3F] = value; } }
#endregion
#region Block B
- public string Nickname
+ public override string Nickname
{
get
{
@@ -230,50 +225,50 @@ namespace PKHeX
Encoding.Unicode.GetBytes(TempNick).CopyTo(Data, 0x40);
}
}
- public int Move1
+ public override int Move1
{
get { return BitConverter.ToUInt16(Data, 0x5A); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x5A); }
}
- public int Move2
+ public override int Move2
{
get { return BitConverter.ToUInt16(Data, 0x5C); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x5C); }
}
- public int Move3
+ public override int Move3
{
get { return BitConverter.ToUInt16(Data, 0x5E); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x5E); }
}
- public int Move4
+ public override int Move4
{
get { return BitConverter.ToUInt16(Data, 0x60); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x60); }
}
- public int Move1_PP { get { return Data[0x62]; } set { Data[0x62] = (byte)value; } }
- public int Move2_PP { get { return Data[0x63]; } set { Data[0x63] = (byte)value; } }
- public int Move3_PP { get { return Data[0x64]; } set { Data[0x64] = (byte)value; } }
- public int Move4_PP { get { return Data[0x65]; } set { Data[0x65] = (byte)value; } }
- public int Move1_PPUps { get { return Data[0x66]; } set { Data[0x66] = (byte)value; } }
- public int Move2_PPUps { get { return Data[0x67]; } set { Data[0x67] = (byte)value; } }
- public int Move3_PPUps { get { return Data[0x68]; } set { Data[0x68] = (byte)value; } }
- public int Move4_PPUps { get { return Data[0x69]; } set { Data[0x69] = (byte)value; } }
- public int RelearnMove1
+ public override int Move1_PP { get { return Data[0x62]; } set { Data[0x62] = (byte)value; } }
+ public override int Move2_PP { get { return Data[0x63]; } set { Data[0x63] = (byte)value; } }
+ public override int Move3_PP { get { return Data[0x64]; } set { Data[0x64] = (byte)value; } }
+ public override int Move4_PP { get { return Data[0x65]; } set { Data[0x65] = (byte)value; } }
+ public override int Move1_PPUps { get { return Data[0x66]; } set { Data[0x66] = (byte)value; } }
+ public override int Move2_PPUps { get { return Data[0x67]; } set { Data[0x67] = (byte)value; } }
+ public override int Move3_PPUps { get { return Data[0x68]; } set { Data[0x68] = (byte)value; } }
+ public override int Move4_PPUps { get { return Data[0x69]; } set { Data[0x69] = (byte)value; } }
+ public override int RelearnMove1
{
get { return BitConverter.ToUInt16(Data, 0x6A); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x6A); }
}
- public int RelearnMove2
+ public override int RelearnMove2
{
get { return BitConverter.ToUInt16(Data, 0x6C); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x6C); }
}
- public int RelearnMove3
+ public override int RelearnMove3
{
get { return BitConverter.ToUInt16(Data, 0x6E); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x6E); }
}
- public int RelearnMove4
+ public override int RelearnMove4
{
get { return BitConverter.ToUInt16(Data, 0x70); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x70); }
@@ -281,14 +276,14 @@ namespace PKHeX
public bool SecretSuperTraining { get { return Data[0x72] == 1; } set { Data[0x72] = (byte)((Data[0x72] & ~1) | (value ? 1 : 0)); } }
public byte _0x73 { get { return Data[0x73]; } set { Data[0x73] = value; } }
private uint IV32 { get { return BitConverter.ToUInt32(Data, 0x74); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x74); } }
- public int IV_HP { get { return (int)(IV32 >> 00) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 00)) | (uint)((value > 31 ? 31 : value) << 00)); } }
- public int IV_ATK { get { return (int)(IV32 >> 05) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 05)) | (uint)((value > 31 ? 31 : value) << 05)); } }
- public int IV_DEF { get { return (int)(IV32 >> 10) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 10)) | (uint)((value > 31 ? 31 : value) << 10)); } }
- public int IV_SPE { get { return (int)(IV32 >> 15) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 15)) | (uint)((value > 31 ? 31 : value) << 15)); } }
- public int IV_SPA { get { return (int)(IV32 >> 20) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 20)) | (uint)((value > 31 ? 31 : value) << 20)); } }
- public int IV_SPD { get { return (int)(IV32 >> 25) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 25)) | (uint)((value > 31 ? 31 : value) << 25)); } }
- public bool IsEgg { get { return ((IV32 >> 30) & 1) == 1; } set { IV32 = (uint)((IV32 & ~0x40000000) | (uint)(value ? 0x40000000 : 0)); } }
- public bool IsNicknamed { get { return ((IV32 >> 31) & 1) == 1; } set { IV32 = (IV32 & 0x7FFFFFFF) | (value ? 0x80000000 : 0); } }
+ public override int IV_HP { get { return (int)(IV32 >> 00) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 00)) | (uint)((value > 31 ? 31 : value) << 00)); } }
+ public override int IV_ATK { get { return (int)(IV32 >> 05) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 05)) | (uint)((value > 31 ? 31 : value) << 05)); } }
+ public override int IV_DEF { get { return (int)(IV32 >> 10) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 10)) | (uint)((value > 31 ? 31 : value) << 10)); } }
+ public override int IV_SPE { get { return (int)(IV32 >> 15) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 15)) | (uint)((value > 31 ? 31 : value) << 15)); } }
+ public override int IV_SPA { get { return (int)(IV32 >> 20) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 20)) | (uint)((value > 31 ? 31 : value) << 20)); } }
+ public override int IV_SPD { get { return (int)(IV32 >> 25) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 25)) | (uint)((value > 31 ? 31 : value) << 25)); } }
+ public override bool IsEgg { get { return ((IV32 >> 30) & 1) == 1; } set { IV32 = (uint)((IV32 & ~0x40000000) | (uint)(value ? 0x40000000 : 0)); } }
+ public override bool IsNicknamed { get { return ((IV32 >> 31) & 1) == 1; } set { IV32 = (IV32 & 0x7FFFFFFF) | (value ? 0x80000000 : 0); } }
#endregion
#region Block C
public string HT_Name
@@ -313,7 +308,7 @@ namespace PKHeX
}
}
public int HT_Gender { get { return Data[0x92]; } set { Data[0x92] = (byte)value; } }
- public int CurrentHandler { get { return Data[0x93]; } set { Data[0x93] = (byte)value; } }
+ public override int CurrentHandler { get { return Data[0x93]; } set { Data[0x93] = (byte)value; } }
public int Geo1_Region { get { return Data[0x94]; } set { Data[0x94] = (byte)value; } }
public int Geo1_Country { get { return Data[0x95]; } set { Data[0x95] = (byte)value; } }
public int Geo2_Region { get { return Data[0x96]; } set { Data[0x96] = (byte)value; } }
@@ -343,7 +338,7 @@ namespace PKHeX
public byte Enjoyment { get { return Data[0xAF]; } set { Data[0xAF] = value; } }
#endregion
#region Block D
- public string OT_Name
+ public override string OT_Name
{
get
{
@@ -364,44 +359,44 @@ namespace PKHeX
Encoding.Unicode.GetBytes(TempNick).CopyTo(Data, 0xB0);
}
}
- public int OT_Friendship { get { return Data[0xCA]; } set { Data[0xCA] = (byte)value; } }
- public int OT_Affection { get { return Data[0xCB]; } set { Data[0xCB] = (byte)value; } }
+ public override int OT_Friendship { get { return Data[0xCA]; } set { Data[0xCA] = (byte)value; } }
+ public override int OT_Affection { get { return Data[0xCB]; } set { Data[0xCB] = (byte)value; } }
public int OT_Intensity { get { return Data[0xCC]; } set { Data[0xCC] = (byte)value; } }
public int OT_Memory { get { return Data[0xCD]; } set { Data[0xCD] = (byte)value; } }
public int OT_TextVar { get { return BitConverter.ToUInt16(Data, 0xCE); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xCE); } }
public int OT_Feeling { get { return Data[0xD0]; } set { Data[0xD0] = (byte)value; } }
- public int Egg_Year { get { return Data[0xD1]; } set { Data[0xD1] = (byte)value; } }
- public int Egg_Month { get { return Data[0xD2]; } set { Data[0xD2] = (byte)value; } }
- public int Egg_Day { get { return Data[0xD3]; } set { Data[0xD3] = (byte)value; } }
- public int Met_Year { get { return Data[0xD4]; } set { Data[0xD4] = (byte)value; } }
- public int Met_Month { get { return Data[0xD5]; } set { Data[0xD5] = (byte)value; } }
- public int Met_Day { get { return Data[0xD6]; } set { Data[0xD6] = (byte)value; } }
+ public override int Egg_Year { get { return Data[0xD1]; } set { Data[0xD1] = (byte)value; } }
+ public override int Egg_Month { get { return Data[0xD2]; } set { Data[0xD2] = (byte)value; } }
+ public override int Egg_Day { get { return Data[0xD3]; } set { Data[0xD3] = (byte)value; } }
+ public override int Met_Year { get { return Data[0xD4]; } set { Data[0xD4] = (byte)value; } }
+ public override int Met_Month { get { return Data[0xD5]; } set { Data[0xD5] = (byte)value; } }
+ public override int Met_Day { get { return Data[0xD6]; } set { Data[0xD6] = (byte)value; } }
public byte _0xD7 { get { return Data[0xD7]; } set { Data[0xD7] = value; } }
- public int Egg_Location { get { return BitConverter.ToUInt16(Data, 0xD8); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xD8); } }
- public int Met_Location { get { return BitConverter.ToUInt16(Data, 0xDA); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xDA); } }
- public int Ball { get { return Data[0xDC]; } set { Data[0xDC] = (byte)value; } }
- public int Met_Level { get { return Data[0xDD] & ~0x80; } set { Data[0xDD] = (byte)((Data[0xDD] & 0x80) | value); } }
- public int OT_Gender { get { return Data[0xDD] >> 7; } set { Data[0xDD] = (byte)((Data[0xDD] & ~0x80) | (value << 7)); } }
- public int EncounterType { get { return Data[0xDE]; } set { Data[0xDE] = (byte)value; } }
- public int Version { get { return Data[0xDF]; } set { Data[0xDF] = (byte)value; } }
+ public override int Egg_Location { get { return BitConverter.ToUInt16(Data, 0xD8); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xD8); } }
+ public override int Met_Location { get { return BitConverter.ToUInt16(Data, 0xDA); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xDA); } }
+ public override int Ball { get { return Data[0xDC]; } set { Data[0xDC] = (byte)value; } }
+ public override int Met_Level { get { return Data[0xDD] & ~0x80; } set { Data[0xDD] = (byte)((Data[0xDD] & 0x80) | value); } }
+ public override int OT_Gender { get { return Data[0xDD] >> 7; } set { Data[0xDD] = (byte)((Data[0xDD] & ~0x80) | (value << 7)); } }
+ public override int EncounterType { get { return Data[0xDE]; } set { Data[0xDE] = (byte)value; } }
+ public override int Version { get { return Data[0xDF]; } set { Data[0xDF] = (byte)value; } }
public int Country { get { return Data[0xE0]; } set { Data[0xE0] = (byte)value; } }
public int Region { get { return Data[0xE1]; } set { Data[0xE1] = (byte)value; } }
public int ConsoleRegion { get { return Data[0xE2]; } set { Data[0xE2] = (byte)value; } }
- public int Language { get { return Data[0xE3]; } set { Data[0xE3] = (byte)value; } }
+ public override int Language { get { return Data[0xE3]; } set { Data[0xE3] = (byte)value; } }
#endregion
#region Battle Stats
- public int Stat_Level { get { return Data[0xEC]; } set { Data[0xEC] = (byte)value; } }
- public int Stat_HPCurrent { get { return BitConverter.ToUInt16(Data, 0xF0); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xF0); } }
- public int Stat_HPMax { get { return BitConverter.ToUInt16(Data, 0xF2); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xF2); } }
- public int Stat_ATK { get { return BitConverter.ToUInt16(Data, 0xF4); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xF4); } }
- public int Stat_DEF { get { return BitConverter.ToUInt16(Data, 0xF6); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xF6); } }
- public int Stat_SPE { get { return BitConverter.ToUInt16(Data, 0xF8); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xF8); } }
- public int Stat_SPA { get { return BitConverter.ToUInt16(Data, 0xFA); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xFA); } }
- public int Stat_SPD { get { return BitConverter.ToUInt16(Data, 0xFC); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xFC); } }
+ public override int Stat_Level { get { return Data[0xEC]; } set { Data[0xEC] = (byte)value; } }
+ public override int Stat_HPCurrent { get { return BitConverter.ToUInt16(Data, 0xF0); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xF0); } }
+ public override int Stat_HPMax { get { return BitConverter.ToUInt16(Data, 0xF2); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xF2); } }
+ public override int Stat_ATK { get { return BitConverter.ToUInt16(Data, 0xF4); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xF4); } }
+ public override int Stat_DEF { get { return BitConverter.ToUInt16(Data, 0xF6); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xF6); } }
+ public override int Stat_SPE { get { return BitConverter.ToUInt16(Data, 0xF8); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xF8); } }
+ public override int Stat_SPA { get { return BitConverter.ToUInt16(Data, 0xFA); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xFA); } }
+ public override int Stat_SPD { get { return BitConverter.ToUInt16(Data, 0xFC); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xFC); } }
#endregion
// Simple Generated Attributes
- public int CurrentFriendship {
+ public override int CurrentFriendship {
get { return CurrentHandler == 0 ? OT_Friendship : HT_Friendship; }
set { if (CurrentHandler == 0) OT_Friendship = value; else HT_Friendship = value; }
}
@@ -410,41 +405,12 @@ namespace PKHeX
get { return CurrentHandler == 1 ? OT_Friendship : HT_Friendship; }
set { if (CurrentHandler == 1) OT_Friendship = value; else HT_Friendship = value; }
}
-
- public int[] IVs {
- get { return new[] {IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD}; }
- set { if (value == null || value.Length != 6) return;
- IV_HP = value[0]; IV_ATK = value[1]; IV_DEF = value[2];
- IV_SPE = value[3]; IV_SPA = value[4]; IV_SPD = value[5]; } }
- public int[] EVs => new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD };
- public int[] CNTs => new[] { CNT_Cool, CNT_Beauty, CNT_Cute, CNT_Smart, CNT_Tough, CNT_Sheen };
- public int PSV => (int)((PID >> 16 ^ PID & 0xFFFF) >> 4);
- public int TSV => (TID ^ SID) >> 4;
- public bool IsShiny => TSV == PSV;
- public bool PKRS_Infected => PKRS_Strain > 0;
- public bool PKRS_Cured => PKRS_Days == 0 && PKRS_Strain > 0;
+
+ public override int PSV => (int)((PID >> 16 ^ PID & 0xFFFF) >> 4);
+ public override int TSV => (TID ^ SID) >> 4;
public bool IsUntraded => string.IsNullOrWhiteSpace(HT_Name);
public bool IsUntradedEvent6 => Geo1_Country == 0 && Geo1_Region == 0 && Met_Location / 10000 == 4 && Gen6;
- public bool Gen6 => Version >= 24 && Version <= 29;
- public bool XY => Version == (int)GameVersion.X || Version == (int)GameVersion.Y;
- public bool AO => Version == (int)GameVersion.AS || Version == (int)GameVersion.OR;
- public bool SM => Version == (int)GameVersion.SN || Version == (int)GameVersion.MN;
- public bool Gen5 => Version >= 20 && Version <= 23;
- public bool Gen4 => Version >= 7 && Version <= 12 && Version != 9;
- public bool Gen3 => Version >= 1 && Version <= 5 || Version == 15;
- public bool GenU => !(Gen6 || Gen5 || Gen4 || Gen3);
-
- public int[] Moves
- {
- get { return new[] { Move1, Move2, Move3, Move4 }; }
- set
- {
- if (value.Length > 0) Move1 = value[0];
- if (value.Length > 1) Move2 = value[1];
- if (value.Length > 2) Move3 = value[2];
- if (value.Length > 3) Move4 = value[3];
- }
- }
+
public int[] RelearnMoves
{
get { return new[] { RelearnMove1, RelearnMove2, RelearnMove3, RelearnMove4 }; }
@@ -456,31 +422,10 @@ namespace PKHeX
if (value.Length > 3) RelearnMove4 = value[3];
}
}
- public int CurrentLevel => getLevel(Species, EXP);
// Complex Generated Attributes
- public Image Sprite => getSprite(this);
- public string ShowdownText => getShowdownText(this);
- public string[] QRText => getQRText(this);
- public byte[] EncryptedPartyData => Encrypt().Take(SIZE_PARTY).ToArray();
- public byte[] EncryptedBoxData => Encrypt().Take(SIZE_STORED).ToArray();
- public byte[] DecryptedPartyData => Data.Take(SIZE_PARTY).ToArray();
- public byte[] DecryptedBoxData => Data.Take(SIZE_STORED).ToArray();
- public int HPType
- {
- get { return 15 * ((IV_HP & 1) + 2 * (IV_ATK & 1) + 4 * (IV_DEF & 1) + 8 * (IV_SPE & 1) + 16 * (IV_SPA & 1) + 32 * (IV_SPD & 1)) / 63; }
- set
- {
- IV_HP = (IV_HP & ~1) + hpivs[value, 0];
- IV_ATK = (IV_ATK & ~1) + hpivs[value, 1];
- IV_DEF = (IV_DEF & ~1) + hpivs[value, 2];
- IV_SPE = (IV_SPE & ~1) + hpivs[value, 3];
- IV_SPA = (IV_SPA & ~1) + hpivs[value, 4];
- IV_SPD = (IV_SPD & ~1) + hpivs[value, 5];
- }
- }
- public int Characteristic
+ public override int Characteristic
{
get
{
@@ -495,86 +440,27 @@ namespace PKHeX
return pm6stat*5 + maxIV%5;
}
}
- public int PotentialRating
- {
- get
- {
- int ivTotal = IVs.Sum();
- if (ivTotal <= 90)
- return 0;
- if (ivTotal <= 120)
- return 1;
- return ivTotal <= 150 ? 2 : 3;
- }
- }
- public string FileName => getFileName(this);
- public bool ChecksumValid => Checksum == CalculateChecksum();
// Methods
- public void RefreshChecksum()
+ public override byte[] Encrypt()
{
Checksum = CalculateChecksum();
+ return PKX.encryptArray(Data);
}
- public ushort CalculateChecksum()
+ public override bool getGenderIsValid()
{
- ushort chk = 0;
- for (int i = 8; i < SIZE_STORED; i += 2) // Loop through the entire PK6
- chk += BitConverter.ToUInt16(Data, i);
+ int gv = PKX.Personal[Species].Gender;
- return chk;
- }
- public byte[] Write()
- {
- RefreshChecksum();
- return Data;
- }
- public byte[] Encrypt()
- {
- Checksum = CalculateChecksum();
- return encryptArray(Data);
- }
- public void CalculateStats()
- {
- ushort[] Stats = getStats(this);
- Stat_HPMax = Stat_HPCurrent = Stats[0];
- Stat_ATK = Stats[1];
- Stat_DEF = Stats[2];
- Stat_SPE = Stats[3];
- Stat_SPA = Stats[4];
- Stat_SPD = Stats[5];
+ if (gv == 255)
+ return Gender == 2;
+ if (gv == 254)
+ return Gender == 0;
+ if (gv == 0)
+ return Gender == 1;
+ return true;
}
// General User-error Fixes
- public void FixMoves()
- {
- while (true)
- {
- if (Move4 != 0 && Move3 == 0)
- {
- Move3 = Move4;
- Move3_PP = Move4_PP;
- Move3_PPUps = Move4_PPUps;
- Move4 = Move4_PP = Move4_PPUps = 0;
- }
- if (Move3 != 0 && Move2 == 0)
- {
- Move2 = Move3;
- Move2_PP = Move3_PP;
- Move2_PPUps = Move3_PPUps;
- Move3 = Move3_PP = Move3_PPUps = 0;
- continue;
- }
- if (Move2 != 0 && Move1 == 0)
- {
- Move1 = Move2;
- Move1_PP = Move2_PP;
- Move1_PPUps = Move2_PPUps;
- Move2 = Move2_PP = Move2_PPUps = 0;
- continue;
- }
- break;
- }
- }
public void FixRelearn()
{
while (true)
@@ -743,7 +629,7 @@ namespace PKHeX
return;
// Reset
- HT_Friendship = getBaseFriendship(Species);
+ HT_Friendship = PKX.getBaseFriendship(Species);
HT_Affection = 0;
}
diff --git a/PKM/PKM.cs b/PKM/PKM.cs
new file mode 100644
index 000000000..c97495089
--- /dev/null
+++ b/PKM/PKM.cs
@@ -0,0 +1,278 @@
+using System;
+using System.Drawing;
+using System.Linq;
+
+namespace PKHeX
+{
+ public abstract class PKM
+ {
+ public abstract int SIZE_PARTY { get; }
+ public abstract int SIZE_STORED { get; }
+ public string Extension => "pk" + Format;
+
+ // Internal Attributes set on creation
+ public byte[] Data; // Raw Storage
+ public string Identifier; // User or Form Custom Attribute
+
+ public byte[] EncryptedPartyData => Encrypt().Take(SIZE_PARTY).ToArray();
+ public byte[] EncryptedBoxData => Encrypt().Take(SIZE_STORED).ToArray();
+ public byte[] DecryptedPartyData => Write().Take(SIZE_PARTY).ToArray();
+ public byte[] DecryptedBoxData => Write().Take(SIZE_STORED).ToArray();
+
+ public ushort CalculateChecksum()
+ {
+ ushort chk = 0;
+ for (int i = 8; i < SIZE_STORED; i += 2) // Loop through the entire PK5
+ chk += BitConverter.ToUInt16(Data, i);
+
+ return chk;
+ }
+ public abstract byte[] Encrypt();
+ public abstract int Format { get; }
+ public byte[] Write()
+ {
+ RefreshChecksum();
+ return Data;
+ }
+
+ // Surface Properties
+ public abstract int Species { get; set; }
+ public abstract string Nickname { get; set; }
+ public abstract int HeldItem { get; set; }
+ public abstract int Gender { get; set; }
+ public abstract int Nature { get; set; }
+ public abstract int Ability { get; set; }
+ public abstract int CurrentFriendship { get; set; }
+ public abstract int AltForm { get; set; }
+ public abstract bool IsEgg { get; set; }
+ public abstract bool IsNicknamed { get; set; }
+ public abstract uint EXP { get; set; }
+ public abstract int TID { get; set; }
+ public abstract string OT_Name { get; set; }
+ public abstract int OT_Gender { get; set; }
+ public abstract int Ball { get; set; }
+ public abstract int Met_Level { get; set; }
+
+ // Battle
+ public abstract int Move1 { get; set; }
+ public abstract int Move2 { get; set; }
+ public abstract int Move3 { get; set; }
+ public abstract int Move4 { get; set; }
+ public abstract int Move1_PP { get; set; }
+ public abstract int Move2_PP { get; set; }
+ public abstract int Move3_PP { get; set; }
+ public abstract int Move4_PP { get; set; }
+ public abstract int Move1_PPUps { get; set; }
+ public abstract int Move2_PPUps { get; set; }
+ public abstract int Move3_PPUps { get; set; }
+ public abstract int Move4_PPUps { get; set; }
+ public abstract int EV_HP { get; set; }
+ public abstract int EV_ATK { get; set; }
+ public abstract int EV_DEF { get; set; }
+ public abstract int EV_SPE { get; set; }
+ public abstract int EV_SPA { get; set; }
+ public abstract int EV_SPD { get; set; }
+ public abstract int IV_HP { get; set; }
+ public abstract int IV_ATK { get; set; }
+ public abstract int IV_DEF { get; set; }
+ public abstract int IV_SPE { get; set; }
+ public abstract int IV_SPA { get; set; }
+ public abstract int IV_SPD { get; set; }
+ public abstract int Stat_Level { get; set; }
+ public abstract int Stat_HPMax { get; set; }
+ public abstract int Stat_HPCurrent { get; set; }
+ public abstract int Stat_ATK { get; set; }
+ public abstract int Stat_DEF { get; set; }
+ public abstract int Stat_SPE { get; set; }
+ public abstract int Stat_SPA { get; set; }
+ public abstract int Stat_SPD { get; set; }
+
+ // Hidden Properties
+ public abstract int Version { get; set; }
+ public abstract int SID { get; set; }
+ public abstract int PKRS_Strain { get; set; }
+ public abstract int PKRS_Days { get; set; }
+ public abstract int CNT_Cool { get; set; }
+ public abstract int CNT_Beauty { get; set; }
+ public abstract int CNT_Cute { get; set; }
+ public abstract int CNT_Smart { get; set; }
+ public abstract int CNT_Tough { get; set; }
+ public abstract int CNT_Sheen { get; set; }
+
+ public abstract uint EncryptionConstant { get; set; }
+ public abstract uint PID { get; set; }
+ public abstract ushort Sanity { get; set; }
+ public abstract ushort Checksum { get; set; }
+
+ // Misc Properties
+ public abstract int Language { get; set; }
+ public abstract bool FatefulEncounter { get; set; }
+ public abstract int TSV { get; }
+ public abstract int PSV { get; }
+ public abstract int Characteristic { get; }
+ public abstract byte MarkByte { get; protected set; }
+ public abstract int Met_Location { get; set; }
+ public abstract int Egg_Location { get; set; }
+ public abstract int OT_Friendship { get; set; }
+
+ // Future Properties
+ public virtual int Met_Year { get { return 0; } set { } }
+ public virtual int Met_Month { get { return 0; } set { } }
+ public virtual int Met_Day { get { return 0; } set { } }
+ public virtual int Egg_Year { get { return 0; } set { } }
+ public virtual int Egg_Month { get { return 0; } set { } }
+ public virtual int Egg_Day { get { return 0; } set { } }
+ public virtual int OT_Affection { get { return 0; } set { } }
+ public virtual int RelearnMove1 { get { return 0; } set { } }
+ public virtual int RelearnMove2 { get { return 0; } set { } }
+ public virtual int RelearnMove3 { get { return 0; } set { } }
+ public virtual int RelearnMove4 { get { return 0; } set { } }
+ public virtual int EncounterType { get { return 0; } set { } }
+
+ // Exposed but not Present in all
+ public abstract int CurrentHandler { get; set; }
+
+ // Derived
+ public bool IsShiny => TSV == PSV;
+ public bool Gen6 => Version >= 24 && Version <= 29;
+ public bool XY => Version == (int)GameVersion.X || Version == (int)GameVersion.Y;
+ public bool AO => Version == (int)GameVersion.AS || Version == (int)GameVersion.OR;
+ public bool SM => Version == (int)GameVersion.SN || Version == (int)GameVersion.MN;
+ public bool PtHGSS => new[] {GameVersion.Pt, GameVersion.HG, GameVersion.SS}.Contains((GameVersion)Version);
+ public bool Gen5 => Version >= 20 && Version <= 23;
+ public bool Gen4 => Version >= 10 && Version < 12 || Version >= 7 && Version <= 8;
+ public bool Gen3 => Version >= 1 && Version <= 5 || Version == 15;
+ public bool GenU => !(Gen6 || Gen5 || Gen4 || Gen3);
+ public bool PKRS_Infected => PKRS_Strain > 0;
+ public bool PKRS_Cured => PKRS_Days == 0 && PKRS_Strain > 0;
+ public bool ChecksumValid => Checksum == CalculateChecksum();
+ public int CurrentLevel => PKX.getLevel(Species, EXP);
+ public bool Circle { get { return Markings[0]; } set { Markings[0] = value; } }
+ public bool Triangle { get { return Markings[1]; } set { Markings[1] = value; } }
+ public bool Square { get { return Markings[2]; } set { Markings[2] = value; } }
+ public bool Heart { get { return Markings[3]; } set { Markings[3] = value; } }
+ public bool Star { get { return Markings[4]; } set { Markings[4] = value; } }
+ public bool Diamond { get { return Markings[5]; } set { Markings[5] = value; } }
+ public Image Sprite => PKX.getSprite(this);
+ public string ShowdownText => ShowdownSet.getShowdownText(this);
+ public string[] QRText => PKX.getQRText(this);
+ public string FileName => PKX.getFileName(this);
+ public int[] IVs
+ {
+ get { return new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; }
+ set
+ {
+ if (value?.Length != 6) return;
+ IV_HP = value[0]; IV_ATK = value[1]; IV_DEF = value[2];
+ IV_SPE = value[3]; IV_SPA = value[4]; IV_SPD = value[5];
+ }
+ }
+ public int[] EVs
+ {
+ get { return new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD }; }
+ set
+ {
+ if (value?.Length != 6) return;
+ EV_HP = value[0]; EV_ATK = value[1]; EV_DEF = value[2];
+ EV_SPE = value[3]; EV_SPA = value[4]; EV_SPD = value[5];
+ }
+ }
+ public int[] Moves
+ {
+ get { return new[] { Move1, Move2, Move3, Move4 }; }
+ set { if (value?.Length != 4) return; Move1 = value[0]; Move2 = value[1]; Move3 = value[2]; Move4 = value[3]; }
+ }
+
+ public bool[] Markings
+ {
+ get
+ {
+ bool[] mark = new bool[8];
+ for (int i = 0; i < 8; i++)
+ mark[i] = ((MarkByte >> i) & 1) == 1;
+ return mark;
+ }
+ set
+ {
+ if (value.Length > 8)
+ return;
+ byte b = 0;
+ for (int i = 0; i < value.Length; i++)
+ b |= (byte)(value[i] ? 1 << i : 0);
+ MarkByte = b;
+ }
+ }
+
+ public int[] CNTs
+ {
+ get { return new[] { CNT_Cool, CNT_Beauty, CNT_Cute, CNT_Smart, CNT_Tough, CNT_Sheen }; }
+ set { if (value?.Length != 6) return; CNT_Cool = value[0]; CNT_Beauty = value[1]; CNT_Cute = value[2]; CNT_Smart = value[3]; CNT_Tough = value[4]; CNT_Sheen = value[5]; }
+ }
+ public int HPType
+ {
+ get { return 15 * ((IV_HP & 1) + 2 * (IV_ATK & 1) + 4 * (IV_DEF & 1) + 8 * (IV_SPE & 1) + 16 * (IV_SPA & 1) + 32 * (IV_SPD & 1)) / 63; }
+ set
+ {
+ IV_HP = (IV_HP & ~1) + PKX.hpivs[value, 0];
+ IV_ATK = (IV_ATK & ~1) + PKX.hpivs[value, 1];
+ IV_DEF = (IV_DEF & ~1) + PKX.hpivs[value, 2];
+ IV_SPE = (IV_SPE & ~1) + PKX.hpivs[value, 3];
+ IV_SPA = (IV_SPA & ~1) + PKX.hpivs[value, 4];
+ IV_SPD = (IV_SPD & ~1) + PKX.hpivs[value, 5];
+ }
+ }
+
+ // Methods
+ public abstract bool getGenderIsValid();
+ public void RefreshChecksum() { Checksum = CalculateChecksum(); }
+ public void FixMoves()
+ {
+ if (Move4 != 0 && Move3 == 0)
+ {
+ Move3 = Move4;
+ Move3_PP = Move4_PP;
+ Move3_PPUps = Move4_PPUps;
+ Move4 = Move4_PP = Move4_PPUps = 0;
+ }
+ if (Move3 != 0 && Move2 == 0)
+ {
+ Move2 = Move3;
+ Move2_PP = Move3_PP;
+ Move2_PPUps = Move3_PPUps;
+ Move3 = Move3_PP = Move3_PPUps = 0;
+ }
+ if (Move2 != 0 && Move1 == 0)
+ {
+ Move1 = Move2;
+ Move1_PP = Move2_PP;
+ Move1_PPUps = Move2_PPUps;
+ Move2 = Move2_PP = Move2_PPUps = 0;
+ }
+ }
+ public int PotentialRating
+ {
+ get
+ {
+ int ivTotal = IVs.Sum();
+ if (ivTotal <= 90)
+ return 0;
+ if (ivTotal <= 120)
+ return 1;
+ return ivTotal <= 150 ? 2 : 3;
+ }
+ }
+
+ public void CalculateStats()
+ {
+ ushort[] Stats = PKX.getStats(this);
+ Stat_HPMax = Stat_HPCurrent = Stats[0];
+ Stat_ATK = Stats[1];
+ Stat_DEF = Stats[2];
+ Stat_SPE = Stats[3];
+ Stat_SPA = Stats[4];
+ Stat_SPD = Stats[5];
+ }
+
+ public abstract PKM Clone();
+ }
+}
diff --git a/PKM/PKMConverter.cs b/PKM/PKMConverter.cs
new file mode 100644
index 000000000..46ac92d85
--- /dev/null
+++ b/PKM/PKMConverter.cs
@@ -0,0 +1,138 @@
+using System;
+
+namespace PKHeX
+{
+ internal static class PKMConverter
+ {
+ internal static int Country = 31;
+ internal static int Region = 7;
+ internal static int ConsoleRegion = 1;
+ internal static string OT_Name = "PKHeX";
+ internal static int OT_Gender;
+
+ internal static void updateConfig(int SUBREGION, int COUNTRY, int _3DSREGION, string TRAINERNAME, int TRAINERGENDER)
+ {
+ Region = SUBREGION;
+ Country = COUNTRY;
+ ConsoleRegion = _3DSREGION;
+ OT_Name = TRAINERNAME;
+ OT_Gender = TRAINERGENDER;
+ }
+
+ private static int getPKMDataFormat(byte[] data)
+ {
+ if (!PKX.getIsPKM(data.Length))
+ return -1;
+
+ switch (data.Length)
+ {
+ case PKX.SIZE_3PARTY:
+ case PKX.SIZE_3STORED:
+ return 3;
+ case PKX.SIZE_4PARTY:
+ case PKX.SIZE_4STORED:
+ case PKX.SIZE_5PARTY:
+ if ((BitConverter.ToUInt16(data, 0x80) >= 0x3333 || data[0x5F] >= 0x10) && BitConverter.ToUInt16(data, 0x46) == 0) // PK5
+ return 5;
+ return 4;
+ case PKX.SIZE_6STORED:
+ return 6;
+ case PKX.SIZE_6PARTY: // collision with PGT, same size.
+ if (BitConverter.ToUInt16(data, 0x4) != 0) // Bad Sanity?
+ return -1;
+ if (BitConverter.ToUInt16(data, 0x58) != 0) // Encrypted?
+ {
+ PKX.getCHK(data);
+ for (int i = data.Length - 0x10; i < data.Length; i++) // 0x10 of 00's at the end != PK6
+ if (data[i] != 0)
+ break;
+ return 6;
+ }
+ return -1;
+ }
+ return -1;
+ }
+ internal static PKM getPKMfromBytes(byte[] data)
+ {
+ checkEncrypted(ref data);
+ switch (getPKMDataFormat(data))
+ {
+ case 3:
+ return new PK3(data);
+ case 4:
+ return new PK4(data);
+ case 5:
+ return new PK5(data);
+ case 6:
+ return new PK6(data);
+ default:
+ return null;
+ }
+ }
+ internal static PKM convertToFormat(PKM pk, int Format, out string comment)
+ {
+ if (pk == null)
+ {
+ comment = "Null input. Aborting.";
+ return null;
+ }
+ if (pk.Format == Format)
+ {
+ comment = "No need to convert, current format matches requested format.";
+ return pk;
+ }
+ if (pk.Format > Format)
+ {
+ comment = "Cannot convert a PKM backwards." + Environment.NewLine
+ + "Current Format: " + pk.Format + Environment.NewLine
+ + "Desired Format: " + Format;
+ return null;
+ }
+ string currentFormat = pk.Format.ToString();
+ PKM pkm = pk.Clone();
+ if (pkm.IsEgg) // force hatch
+ {
+ pkm.IsEgg = false;
+ if (pkm.AO)
+ pkm.Met_Location = 318; // Battle Resort
+ else if (pkm.XY)
+ pkm.Met_Location = 38; // Route 7
+ else if (pkm.Gen5)
+ pkm.Met_Location = 16; // Route 16
+ else
+ pkm.Met_Location = 30001; // Pokétransfer
+ }
+ if (pkm.Format == 3 && Format > 3)
+ pkm = (pkm as PK3).convertToPK4();
+ if (pkm.Format == 4 && Format > 4)
+ pkm = (pkm as PK4).convertToPK5();
+ if (pkm.Format == 5 && Format > 5)
+ pkm = (pkm as PK5).convertToPK6();
+ comment = $"Converted from pk{currentFormat} to pk{Format}";
+ return pkm;
+ }
+ internal static void checkEncrypted(ref byte[] pkm)
+ {
+ int format = getPKMDataFormat(pkm);
+ ushort chk = 0;
+ switch (format)
+ {
+ case 3: // TOneverDO, nobody exports encrypted pk3s
+ return;
+ case 4:
+ case 5:
+ for (int i = 8; i < PKX.SIZE_4STORED; i += 2)
+ chk += BitConverter.ToUInt16(pkm, i);
+ if (chk != BitConverter.ToUInt16(pkm, 0x06))
+ pkm = PKX.decryptArray45(pkm);
+ return;
+ case 6:
+ if (BitConverter.ToUInt16(pkm, 0xC8) != 0 && BitConverter.ToUInt16(pkm, 0x58) != 0)
+ pkm = PKX.decryptArray(pkm);
+ return;
+ default:
+ return; // bad!
+ }
+ }
+ }
+}
diff --git a/Misc/PKM.cs b/PKM/PKX.cs
similarity index 63%
rename from Misc/PKM.cs
rename to PKM/PKX.cs
index 8dc08e37e..ce0a66a5b 100644
--- a/Misc/PKM.cs
+++ b/PKM/PKX.cs
@@ -1,10 +1,42 @@
using System;
+using System.Drawing;
+using System.Drawing.Text;
using System.Linq;
+using System.Runtime.InteropServices;
+using PKHeX.Properties;
namespace PKHeX
{
- public class PKM // Past Gen
+ internal static class PKX
{
+ internal const int SIZE_3PARTY = 100;
+ internal const int SIZE_3STORED = 80;
+ internal const int SIZE_3BLOCK = 12;
+
+ internal const int SIZE_4PARTY = 236;
+ internal const int SIZE_4STORED = 136;
+ internal const int SIZE_4BLOCK = 32;
+
+ internal const int SIZE_5PARTY = 220;
+ internal const int SIZE_5STORED = 136;
+ internal const int SIZE_5BLOCK = 32;
+
+ internal const int SIZE_6PARTY = 0x104;
+ internal const int SIZE_6STORED = 0xE8;
+ internal const int SIZE_6BLOCK = 56;
+
+ internal static bool getIsPKM(long len)
+ {
+ return new[] {SIZE_3STORED, SIZE_3PARTY, SIZE_4STORED, SIZE_4PARTY, SIZE_5PARTY, SIZE_6STORED, SIZE_6PARTY}.Contains((int)len);
+ }
+
+
+ // C# PKX Function Library
+ // No WinForm object related code, only to calculate information.
+ // May require re-referencing to main form for string array referencing.
+ // Relies on Util for some common operations.
+
+ // Data
internal static uint LCRNG(uint seed)
{
const uint a = 0x41C64E6D;
@@ -19,29 +51,387 @@ namespace PKHeX
return seed = seed * a + c;
}
-
- internal static readonly string[] speclang_ja = Util.getStringList("species", "ja");
- internal static readonly string[] speclang_en = Util.getStringList("species", "en");
- internal static readonly string[] speclang_fr = Util.getStringList("species", "fr");
- internal static readonly string[] speclang_it = Util.getStringList("species", "it");
- internal static readonly string[] speclang_de = Util.getStringList("species", "de");
- internal static readonly string[] speclang_es = Util.getStringList("species", "es");
-
- internal static int getSAVGeneration(byte[] data)
+ #region ExpTable
+ internal static readonly uint[,] ExpTable =
{
- if (SAV4.getIsG4SAV(data) != -1)
- return 4;
- if (SAV5.getIsG5SAV(data) != -1)
- return 5;
+ {0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0},
+ {8, 15, 4, 9, 6, 10},
+ {27, 52, 13, 57, 21, 33},
+ {64, 122, 32, 96, 51, 80},
+ {125, 237, 65, 135, 100, 156},
+ {216, 406, 112, 179, 172, 270},
+ {343, 637, 178, 236, 274, 428},
+ {512, 942, 276, 314, 409, 640},
+ {729, 1326, 393, 419, 583, 911},
+ {1000, 1800, 540, 560, 800, 1250},
+ {1331, 2369, 745, 742, 1064, 1663},
+ {1728, 3041, 967, 973, 1382, 2160},
+ {2197, 3822, 1230, 1261, 1757, 2746},
+ {2744, 4719, 1591, 1612, 2195, 3430},
+ {3375, 5737, 1957, 2035, 2700, 4218},
+ {4096, 6881, 2457, 2535, 3276, 5120},
+ {4913, 8155, 3046, 3120, 3930, 6141},
+ {5832, 9564, 3732, 3798, 4665, 7290},
+ {6859, 11111, 4526, 4575, 5487, 8573},
+ {8000, 12800, 5440, 5460, 6400, 10000},
+ {9261, 14632, 6482, 6458, 7408, 11576},
+ {10648, 16610, 7666, 7577, 8518, 13310},
+ {12167, 18737, 9003, 8825, 9733, 15208},
+ {13824, 21012, 10506, 10208, 11059, 17280},
+ {15625, 23437, 12187, 11735, 12500, 19531},
+ {17576, 26012, 14060, 13411, 14060, 21970},
+ {19683, 28737, 16140, 15244, 15746, 24603},
+ {21952, 31610, 18439, 17242, 17561, 27440},
+ {24389, 34632, 20974, 19411, 19511, 30486},
+ {27000, 37800, 23760, 21760, 21600, 33750},
+ {29791, 41111, 26811, 24294, 23832, 37238},
+ {32768, 44564, 30146, 27021, 26214, 40960},
+ {35937, 48155, 33780, 29949, 28749, 44921},
+ {39304, 51881, 37731, 33084, 31443, 49130},
+ {42875, 55737, 42017, 36435, 34300, 53593},
+ {46656, 59719, 46656, 40007, 37324, 58320},
+ {50653, 63822, 50653, 43808, 40522, 63316},
+ {54872, 68041, 55969, 47846, 43897, 68590},
+ {59319, 72369, 60505, 52127, 47455, 74148},
+ {64000, 76800, 66560, 56660, 51200, 80000},
+ {68921, 81326, 71677, 61450, 55136, 86151},
+ {74088, 85942, 78533, 66505, 59270, 92610},
+ {79507, 90637, 84277, 71833, 63605, 99383},
+ {85184, 95406, 91998, 77440, 68147, 106480},
+ {91125, 100237, 98415, 83335, 72900, 113906},
+ {97336, 105122, 107069, 89523, 77868, 121670},
+ {103823, 110052, 114205, 96012, 83058, 129778},
+ {110592, 115015, 123863, 102810, 88473, 138240},
+ {117649, 120001, 131766, 109923, 94119, 147061},
+ {125000, 125000, 142500, 117360, 100000, 156250},
+ {132651, 131324, 151222, 125126, 106120, 165813},
+ {140608, 137795, 163105, 133229, 112486, 175760},
+ {148877, 144410, 172697, 141677, 119101, 186096},
+ {157464, 151165, 185807, 150476, 125971, 196830},
+ {166375, 158056, 196322, 159635, 133100, 207968},
+ {175616, 165079, 210739, 169159, 140492, 219520},
+ {185193, 172229, 222231, 179056, 148154, 231491},
+ {195112, 179503, 238036, 189334, 156089, 243890},
+ {205379, 186894, 250562, 199999, 164303, 256723},
+ {216000, 194400, 267840, 211060, 172800, 270000},
+ {226981, 202013, 281456, 222522, 181584, 283726},
+ {238328, 209728, 300293, 234393, 190662, 297910},
+ {250047, 217540, 315059, 246681, 200037, 312558},
+ {262144, 225443, 335544, 259392, 209715, 327680},
+ {274625, 233431, 351520, 272535, 219700, 343281},
+ {287496, 241496, 373744, 286115, 229996, 359370},
+ {300763, 249633, 390991, 300140, 240610, 375953},
+ {314432, 257834, 415050, 314618, 251545, 393040},
+ {328509, 267406, 433631, 329555, 262807, 410636},
+ {343000, 276458, 459620, 344960, 274400, 428750},
+ {357911, 286328, 479600, 360838, 286328, 447388},
+ {373248, 296358, 507617, 377197, 298598, 466560},
+ {389017, 305767, 529063, 394045, 311213, 486271},
+ {405224, 316074, 559209, 411388, 324179, 506530},
+ {421875, 326531, 582187, 429235, 337500, 527343},
+ {438976, 336255, 614566, 447591, 351180, 548720},
+ {456533, 346965, 639146, 466464, 365226, 570666},
+ {474552, 357812, 673863, 485862, 379641, 593190},
+ {493039, 367807, 700115, 505791, 394431, 616298},
+ {512000, 378880, 737280, 526260, 409600, 640000},
+ {531441, 390077, 765275, 547274, 425152, 664301},
+ {551368, 400293, 804997, 568841, 441094, 689210},
+ {571787, 411686, 834809, 590969, 457429, 714733},
+ {592704, 423190, 877201, 613664, 474163, 740880},
+ {614125, 433572, 908905, 636935, 491300, 767656},
+ {636056, 445239, 954084, 660787, 508844, 795070},
+ {658503, 457001, 987754, 685228, 526802, 823128},
+ {681472, 467489, 1035837, 710266, 545177, 851840},
+ {704969, 479378, 1071552, 735907, 563975, 881211},
+ {729000, 491346, 1122660, 762160, 583200, 911250},
+ {753571, 501878, 1160499, 789030, 602856, 941963},
+ {778688, 513934, 1214753, 816525, 622950, 973360},
+ {804357, 526049, 1254796, 844653, 643485, 1005446},
+ {830584, 536557, 1312322, 873420, 664467, 1038230},
+ {857375, 548720, 1354652, 902835, 685900, 1071718},
+ {884736, 560922, 1415577, 932903, 707788, 1105920},
+ {912673, 571333, 1460276, 963632, 730138, 1140841},
+ {941192, 583539, 1524731, 995030, 752953, 1176490},
+ {970299, 591882, 1571884, 1027103, 776239, 1212873},
+ {1000000, 600000, 1640000, 1059860, 800000, 1250000},
+ };
+ #endregion
+
+ internal static readonly string[][] SpeciesLang =
+ {
+ Util.getStringList("species", "ja"), // none
+ Util.getStringList("species", "ja"), // 1
+ Util.getStringList("species", "en"), // 2
+ Util.getStringList("species", "fr"), // 3
+ Util.getStringList("species", "it"), // 4
+ Util.getStringList("species", "de"), // 5
+ Util.getStringList("species", "es"), // none
+ Util.getStringList("species", "es"), // 7
+ Util.getStringList("species", "ko"), // 8
+ };
+
+ internal static string getSpeciesName(int species, int lang)
+ {
+ try { return SpeciesLang[lang][species]; }
+ catch { return ""; }
+ }
+ internal static readonly PersonalInfo[] Personal = Legal.PersonalAO;
+
+ // Stat Fetching
+ internal static int getMovePP(int move, int ppup)
+ {
+ return getBasePP(move) * (5 + ppup) / 5;
+ }
+ internal static int getBasePP(int move)
+ {
+ byte[] movepptable =
+ {
+ 00,
+ 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 20, 30, 35, 35, 20, 15, 20,
+ 20, 25, 20, 30, 05, 10, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 10, 15, 30, 35,
+ 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, 30, 25, 15, 30, 25, 05, 15, 10, 05, 20,
+ 20, 20, 05, 35, 20, 25, 20, 20, 20, 15, 25, 15, 10, 20, 25, 10, 35, 30, 15, 10,
+ 40, 10, 15, 30, 15, 20, 10, 15, 10, 05, 10, 10, 25, 10, 20, 40, 30, 30, 20, 20,
+ 15, 10, 40, 15, 10, 30, 10, 20, 10, 40, 40, 20, 30, 30, 20, 30, 10, 10, 20, 05,
+ 10, 30, 20, 20, 20, 05, 15, 10, 20, 10, 15, 35, 20, 15, 10, 10, 30, 15, 40, 20,
+ 15, 10, 05, 10, 30, 10, 15, 20, 15, 40, 20, 10, 05, 15, 10, 10, 10, 15, 30, 30,
+ 10, 10, 20, 10, 01, 01, 10, 25, 10, 05, 15, 25, 15, 10, 15, 30, 05, 40, 15, 10,
+ 25, 10, 30, 10, 20, 10, 10, 10, 10, 10, 20, 05, 40, 05, 05, 15, 05, 10, 05, 10,
+ 10, 10, 10, 20, 20, 40, 15, 10, 20, 20, 25, 05, 15, 10, 05, 20, 15, 20, 25, 20,
+ 05, 30, 05, 10, 20, 40, 05, 20, 40, 20, 15, 35, 10, 05, 05, 05, 15, 05, 20, 05,
+ 05, 15, 20, 10, 05, 05, 15, 10, 15, 15, 10, 10, 10, 20, 10, 10, 10, 10, 15, 15,
+ 15, 10, 20, 20, 10, 20, 20, 20, 20, 20, 10, 10, 10, 20, 20, 05, 15, 10, 10, 15,
+ 10, 20, 05, 05, 10, 10, 20, 05, 10, 20, 10, 20, 20, 20, 05, 05, 15, 20, 10, 15,
+ 20, 15, 10, 10, 15, 10, 05, 05, 10, 15, 10, 05, 20, 25, 05, 40, 15, 05, 40, 15,
+ 20, 20, 05, 15, 20, 20, 15, 15, 05, 10, 30, 20, 30, 15, 05, 40, 15, 05, 20, 05,
+ 15, 25, 25, 15, 20, 15, 20, 15, 20, 10, 20, 20, 05, 05, 10, 05, 40, 10, 10, 05,
+ 10, 10, 15, 10, 20, 15, 30, 10, 20, 05, 10, 10, 15, 10, 10, 05, 15, 05, 10, 10,
+ 30, 20, 20, 10, 10, 05, 05, 10, 05, 20, 10, 20, 10, 15, 10, 20, 20, 20, 15, 15,
+ 10, 15, 15, 15, 10, 10, 10, 20, 10, 30, 05, 10, 15, 10, 10, 05, 20, 30, 10, 30,
+ 15, 15, 15, 15, 30, 10, 20, 15, 10, 10, 20, 15, 05, 05, 15, 15, 05, 10, 05, 20,
+ 05, 15, 20, 05, 20, 20, 20, 20, 10, 20, 10, 15, 20, 15, 10, 10, 05, 10, 05, 05,
+ 10, 05, 05, 10, 05, 05, 05, 15, 10, 10, 10, 10, 10, 10, 15, 20, 15, 10, 15, 10,
+ 15, 10, 20, 10, 15, 10, 20, 20, 20, 20, 20, 15, 15, 15, 15, 15, 15, 20, 15, 10,
+ 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 05, 05, 15, 05, 10, 10, 10,
+ 20, 20, 20, 10, 10, 30, 15, 15, 10, 15, 25, 10, 15, 10, 10, 10, 20, 10, 10, 10,
+ 10, 10, 15, 15, 05, 05, 10, 10, 10, 05, 05, 10, 05, 05, 15, 10, 05, 05, 05, 10,
+ 10, 10, 10, 20, 25, 10, 20, 30, 25, 20, 20, 15, 20, 15, 20, 20, 10, 10, 10, 10,
+ 10, 20, 10, 30, 15, 10, 10, 10, 20, 20, 05, 05, 05, 20, 10, 10, 20, 15, 20, 20,
+ 10, 20, 30, 10, 10, 40, 40, 30, 20, 40, 20, 20, 10, 10, 10, 10, 05, 10, 10, 05,
+ 05
+ };
+ if (move < 0) move = 0;
+ return movepptable[move];
+ }
+ internal static byte[] getRandomEVs()
+ {
+ byte[] evs = new byte[6];
+ do {
+ evs[0] = (byte)Math.Min(Util.rnd32() % 300, 252); // bias two to get maybe 252
+ evs[1] = (byte)Math.Min(Util.rnd32() % 300, 252);
+ evs[2] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1]), 252);
+ evs[3] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1] - evs[2]), 252);
+ evs[4] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1] - evs[2] - evs[3]), 252);
+ evs[5] = (byte)Math.Min(510 - evs[0] - evs[1] - evs[2] - evs[3] - evs[4], 252);
+ } while (evs.Sum(b => b) > 510); // recalculate random EVs...
+ Util.Shuffle(evs);
+ return evs;
+ }
+ internal static byte getBaseFriendship(int species)
+ {
+ return Personal[species].BaseFriendship;
+ }
+ internal static int getLevel(int species, uint exp)
+ {
+ int growth = Personal[species].EXPGrowth;
+ int tl = 1; // Initial Level. Iterate upwards to find the level
+ while (ExpTable[++tl, growth] <= exp)
+ if (tl == 100) return 100;
+ return --tl;
+ }
+ internal static bool getIsShiny(uint PID, uint TID, uint SID)
+ {
+ uint PSV = getPSV(PID);
+ uint TSV = getTSV(TID, SID);
+ return TSV == PSV;
+ }
+ internal static uint getEXP(int level, int species)
+ {
+ if (level <= 1) return 0;
+ if (level > 100) level = 100;
+ return ExpTable[level, Personal[species].EXPGrowth];
+ }
+ internal static byte[] getAbilities(int species, int formnum)
+ {
+ return Personal[Personal[species].FormeIndex(species, formnum)].Abilities;
+ }
+ internal static int getAbilityNumber(int species, int ability, int formnum)
+ {
+ byte[] spec_abilities = Personal[Personal[species].FormeIndex(species, formnum)].Abilities;
+ int abilval = Array.IndexOf(spec_abilities, (byte)ability);
+ if (abilval >= 0)
+ return 1 << abilval;
return -1;
}
- internal static string TrimFromFFFF(string input)
+ internal static int getGender(string s)
{
- int index = input.IndexOf((char)0xFFFF);
- return index < 0 ? input : input.Substring(0, index);
+ if (s == null)
+ return -1;
+ if (s == "♂" || s == "M")
+ return 0;
+ if (s == "♀" || s == "F")
+ return 1;
+ return 2;
}
- // Past Gen Manipulation
+ internal static string[] getCountryRegionText(int country, int region, string lang)
+ {
+ // Get Language we're fetching for
+ int index = Array.IndexOf(new[] { "ja", "en", "fr", "de", "it", "es", "zh", "ko"}, lang);
+ // Return value storage
+ string[] data = new string[2]; // country, region
+
+ // Get Country Text
+ try
+ {
+ string[] inputCSV = Util.getStringList("countries");
+ // Set up our Temporary Storage
+ string[] unsortedList = new string[inputCSV.Length - 1];
+ int[] indexes = new int[inputCSV.Length - 1];
+
+ // Gather our data from the input file
+ for (int i = 1; i < inputCSV.Length; i++)
+ {
+ string[] countryData = inputCSV[i].Split(',');
+ if (countryData.Length <= 1) continue;
+ indexes[i - 1] = Convert.ToInt32(countryData[0]);
+ unsortedList[i - 1] = countryData[index + 1];
+ }
+
+ int countrynum = Array.IndexOf(indexes, country);
+ data[0] = unsortedList[countrynum];
+ }
+ catch { data[0] = "Illegal"; }
+
+ // Get Region Text
+ try
+ {
+ string[] inputCSV = Util.getStringList("sr_" + country.ToString("000"));
+ // Set up our Temporary Storage
+ string[] unsortedList = new string[inputCSV.Length - 1];
+ int[] indexes = new int[inputCSV.Length - 1];
+
+ // Gather our data from the input file
+ for (int i = 1; i < inputCSV.Length; i++)
+ {
+ string[] countryData = inputCSV[i].Split(',');
+ if (countryData.Length <= 1) continue;
+ indexes[i - 1] = Convert.ToInt32(countryData[0]);
+ unsortedList[i - 1] = countryData[index + 1];
+ }
+
+ int regionnum = Array.IndexOf(indexes, region);
+ data[1] = unsortedList[regionnum];
+ }
+ catch { data[1] = "Illegal"; }
+ return data;
+ }
+
+ internal static string getLocation(PKM pk, bool egg)
+ {
+ return getLocation(egg, pk.Version, egg ? pk.Egg_Location : pk.Met_Location, pk.Format);
+ }
+ internal static string getLocation(bool eggmet, int gameorigin, int locval, int format)
+ {
+ if (gameorigin < 0x10 && (eggmet || format < 5))
+ {
+ if (locval < 2000) return Main.metHGSS_00000[locval];
+ if (locval < 3000) return Main.metHGSS_02000[locval % 2000];
+ return Main.metHGSS_03000[locval % 3000];
+ }
+ if (gameorigin < 24)
+ {
+ if (locval < 30000) return Main.metBW2_00000[locval];
+ if (locval < 40000) return Main.metBW2_30000[locval % 10000 - 1];
+ if (locval < 60000) return Main.metBW2_40000[locval % 10000 - 1];
+ return Main.metBW2_60000[locval % 10000 - 1];
+ }
+ if (gameorigin > 23)
+ {
+ if (locval < 30000) return Main.metXY_00000[locval];
+ if (locval < 40000) return Main.metXY_30000[locval % 10000 - 1];
+ if (locval < 60000) return Main.metXY_40000[locval % 10000 - 1];
+ return Main.metXY_60000[locval % 10000 - 1];
+ }
+ return null; // Shouldn't happen.
+ }
+ internal static string[] getQRText(PKM pkm)
+ {
+ string[] response = new string[3];
+ // Summarize
+ string filename = pkm.Nickname;
+ if (pkm.Nickname != Main.specieslist[pkm.Species] && Main.specieslist[pkm.Species] != null)
+ filename += $" ({Main.specieslist[pkm.Species]})";
+ response[0] = $"{filename} [{Main.abilitylist[pkm.Ability]}] lv{pkm.Stat_Level} @ {Main.itemlist[pkm.HeldItem]} -- {Main.natures[pkm.Nature]}";
+ response[1] = $"{Main.movelist[pkm.Move1]} / {Main.movelist[pkm.Move2]} / {Main.movelist[pkm.Move3]} / {Main.movelist[pkm.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 + pkm.IV_HP.ToString("00"),
+ Environment.NewLine + pkm.IV_ATK.ToString("00"),
+ Environment.NewLine + pkm.IV_DEF.ToString("00"),
+ Environment.NewLine + pkm.IV_SPA.ToString("00"),
+ Environment.NewLine + pkm.IV_SPD.ToString("00"),
+ Environment.NewLine + pkm.IV_SPE.ToString("00"),
+ Environment.NewLine + pkm.EV_HP,
+ Environment.NewLine + pkm.EV_ATK,
+ Environment.NewLine + pkm.EV_DEF,
+ Environment.NewLine + pkm.EV_SPA,
+ Environment.NewLine + pkm.EV_SPD,
+ Environment.NewLine + pkm.EV_SPE);
+
+ return response;
+ }
+ internal static string getFileName(PKM pkm)
+ {
+ return
+ $"{pkm.Species.ToString("000")}{(pkm.IsShiny ? " ★" : "")} - {pkm.Nickname} - {pkm.Checksum.ToString("X4")}{pkm.EncryptionConstant.ToString("X8")}.{pkm.Extension}";
+ }
+ internal static ushort[] getStats(PKM pkm)
+ {
+ return getStats(pkm.Species, pkm.Stat_Level, pkm.Nature, pkm.AltForm,
+ pkm.EV_HP, pkm.EV_ATK, pkm.EV_DEF, pkm.EV_SPA, pkm.EV_SPD, pkm.EV_SPE,
+ pkm.IV_HP, pkm.IV_ATK, pkm.IV_DEF, pkm.IV_SPA, pkm.IV_SPD, pkm.IV_SPE);
+ }
+ internal static ushort[] getStats(int species, int level, int nature, int form,
+ int HP_EV, int ATK_EV, int DEF_EV, int SPA_EV, int SPD_EV, int SPE_EV,
+ int HP_IV, int ATK_IV, int DEF_IV, int SPA_IV, int SPD_IV, int SPE_IV)
+ {
+ PersonalInfo p = Personal[Personal[species].FormeIndex(species, form)];
+ // Calculate Stats
+ ushort[] stats = new ushort[6]; // Stats are stored as ushorts in the PKX structure. We'll cap them as such.
+ stats[0] = (ushort)(p.HP == 1 ? 1 : (HP_IV + 2 * p.HP + HP_EV / 4 + 100) * level / 100 + 10);
+ stats[1] = (ushort)((ATK_IV + 2 * p.ATK + ATK_EV / 4) * level / 100 + 5);
+ stats[2] = (ushort)((DEF_IV + 2 * p.DEF + DEF_EV / 4) * level / 100 + 5);
+ stats[4] = (ushort)((SPA_IV + 2 * p.SPA + SPA_EV / 4) * level / 100 + 5);
+ stats[5] = (ushort)((SPD_IV + 2 * p.SPD + SPD_EV / 4) * level / 100 + 5);
+ stats[3] = (ushort)((SPE_IV + 2 * p.SPE + SPE_EV / 4) * level / 100 + 5);
+
+ // Account for nature
+ int incr = nature / 5 + 1;
+ int decr = nature % 5 + 1;
+ if (incr == decr) return stats; // if neutral return stats without mod
+ stats[incr] *= 11; stats[incr] /= 10;
+ stats[decr] *= 9; stats[decr] /= 10;
+
+ // Return Result
+ return stats;
+ }
+
+
+ // PKX Manipulation
internal static readonly byte[][] blockPosition =
{
new byte[] {0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 2, 3, 1, 1, 2, 3, 2, 3, 1, 1, 2, 3, 2, 3},
@@ -49,6 +439,7 @@ namespace PKHeX
new byte[] {2, 3, 1, 1, 3, 2, 2, 3, 1, 1, 3, 2, 0, 0, 0, 0, 0, 0, 3, 2, 3, 2, 1, 1},
new byte[] {3, 2, 3, 2, 1, 1, 3, 2, 3, 2, 1, 1, 3, 2, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0},
};
+
internal static readonly byte[] blockPositionInvert =
{
0, 1, 2, 4, 3, 5, 6, 7, 12, 18, 13, 19, 8, 10, 14, 20, 16, 22, 9, 11, 15, 21, 17, 23
@@ -58,6 +449,584 @@ namespace PKHeX
byte[] sdata = new byte[data.Length];
Array.Copy(data, sdata, 8); // Copy unshuffled bytes
+ // Shuffle Away!
+ for (int block = 0; block < 4; block++)
+ Array.Copy(data, 8 + 56*blockPosition[block][sv], sdata, 8 + 56*block, 56);
+
+ // Fill the Battle Stats back
+ if (data.Length > 232)
+ Array.Copy(data, 232, sdata, 232, 28);
+
+ return sdata;
+ }
+ internal static byte[] decryptArray(byte[] ekx)
+ {
+ byte[] pkx = (byte[])ekx.Clone();
+
+ uint pv = BitConverter.ToUInt32(pkx, 0);
+ uint sv = (pv >> 0xD & 0x1F) % 24;
+
+ uint seed = pv;
+
+ // Decrypt Blocks with RNG Seed
+ for (int i = 8; i < 232; i += 2)
+ BitConverter.GetBytes((ushort)(BitConverter.ToUInt16(pkx, i) ^ LCRNG(ref seed) >> 16)).CopyTo(pkx, i);
+
+ // Deshuffle
+ pkx = shuffleArray(pkx, sv);
+
+ // Decrypt the Party Stats
+ seed = pv;
+ if (pkx.Length <= 232) return pkx;
+ for (int i = 232; i < 260; i += 2)
+ BitConverter.GetBytes((ushort)(BitConverter.ToUInt16(pkx, i) ^ LCRNG(ref seed) >> 16)).CopyTo(pkx, i);
+
+ return pkx;
+ }
+ internal static byte[] encryptArray(byte[] pkx)
+ {
+ // Shuffle
+ uint pv = BitConverter.ToUInt32(pkx, 0);
+ uint sv = (pv >> 0xD & 0x1F) % 24;
+
+ byte[] ekx = (byte[])pkx.Clone();
+
+ ekx = shuffleArray(ekx, blockPositionInvert[sv]);
+
+ uint seed = pv;
+
+ // Encrypt Blocks with RNG Seed
+ for (int i = 8; i < 232; i += 2)
+ BitConverter.GetBytes((ushort)(BitConverter.ToUInt16(ekx, i) ^ LCRNG(ref seed) >> 16)).CopyTo(ekx, i);
+
+ // If no party stats, return.
+ if (ekx.Length <= 232) return ekx;
+
+ // Encrypt the Party Stats
+ seed = pv;
+ for (int i = 232; i < 260; i += 2)
+ BitConverter.GetBytes((ushort)(BitConverter.ToUInt16(ekx, i) ^ LCRNG(ref seed) >> 16)).CopyTo(ekx, i);
+
+ // Done
+ return ekx;
+ }
+ internal static ushort getCHK(byte[] data)
+ {
+ ushort chk = 0;
+ for (int i = 8; i < 232; i += 2) // Loop through the entire PKX
+ chk += BitConverter.ToUInt16(data, i);
+
+ return chk;
+ }
+ internal static bool verifychk(byte[] input)
+ {
+ ushort checksum = 0;
+ if (input.Length == 100 || input.Length == 80) // Gen 3 Files
+ {
+ for (int i = 32; i < 80; i += 2)
+ checksum += BitConverter.ToUInt16(input, i);
+
+ return checksum == BitConverter.ToUInt16(input, 28);
+ }
+
+ if (input.Length == 236 || input.Length == 220 || input.Length == 136) // Gen 4/5
+ Array.Resize(ref input, 136);
+ else if (input.Length == 232 || input.Length == 260) // Gen 6
+ Array.Resize(ref input, 232);
+ else throw new ArgumentException("Wrong sized input array to verifychecksum");
+
+ ushort chk = 0;
+ for (int i = 8; i < input.Length; i += 2)
+ chk += BitConverter.ToUInt16(input, i);
+
+ return chk == BitConverter.ToUInt16(input, 0x6);
+ }
+
+ internal static uint getPSV(uint PID)
+ {
+ return (PID >> 16 ^ PID & 0xFFFF) >> 4;
+ }
+ internal static uint getTSV(uint TID, uint SID)
+ {
+ return (TID ^ SID) >> 4;
+ }
+ internal static uint getRandomPID(int species, int cg, int origin, int nature, int form)
+ {
+ int gt = Personal[species].Gender;
+ if (origin >= 24)
+ return Util.rnd32();
+
+ bool g3unown = origin <= 5 && species == 201;
+ while (true) // Loop until we find a suitable PID
+ {
+ uint pid = Util.rnd32();
+
+ // Gen 3/4: Nature derived from PID
+ if (origin <= 15 && pid%25 != nature)
+ continue;
+
+ // Gen 3 Unown: Letter/form derived from PID
+ if (g3unown)
+ {
+ uint pidLetter = ((pid & 0x3000000) >> 18 | (pid & 0x30000) >> 12 | (pid & 0x300) >> 6 | pid & 0x3) % 28;
+ if (pidLetter != form)
+ continue;
+ }
+
+ // Gen 3/4/5: Gender derived from PID
+ uint gv = pid & 0xFF;
+ if (gt == 255 || gt == 254 || gt == 0) // Set Gender(less)
+ return pid; // PID can be anything
+ if (cg == 1 && gv <= gt) // Female
+ return pid; // PID Passes
+ if (cg == 0 && gv > gt) // Male
+ return pid; // PID Passes
+ }
+ }
+
+ // Data Requests
+ internal static Image getSprite(int species, int form, int gender, int item, bool isegg, bool shiny)
+ {
+ if (species == 0)
+ return (Image)Resources.ResourceManager.GetObject("_0");
+ if (new[] { 664, 665, 414, 493 }.Contains(species)) // Species who show their default sprite regardless of Form
+ form = 0;
+
+ string file = "_" + species;
+ if (form > 0) // Alt Form Handling
+ file = file + "_" + form;
+ else if (gender == 1 && new[] { 592, 593, 521, 668 }.Contains(species)) // Frillish & Jellicent, Unfezant & Pyroar
+ file = file + "_" + gender;
+
+ // Redrawing logic
+ Image baseImage = (Image)Resources.ResourceManager.GetObject(file);
+ if (baseImage == null)
+ {
+ if (species < 722)
+ {
+ baseImage = Util.LayerImage(
+ (Image)Resources.ResourceManager.GetObject("_" + species),
+ Resources.unknown,
+ 0, 0, .5);
+ }
+ else
+ baseImage = Resources.unknown;
+ }
+ if (isegg)
+ {
+ // Start with a partially transparent species by layering the species with partial opacity onto a blank image.
+ baseImage = Util.LayerImage((Image)Resources.ResourceManager.GetObject("_0"), baseImage, 0, 0, 0.33);
+ // Add the egg layer over-top with full opacity.
+ baseImage = Util.LayerImage(baseImage, (Image)Resources.ResourceManager.GetObject("egg"), 0, 0, 1);
+ }
+ if (shiny)
+ {
+ // Add shiny star to top left of image.
+ baseImage = Util.LayerImage(baseImage, Resources.rare_icon, 0, 0, 0.7);
+ }
+ if (item > 0)
+ {
+ Image itemimg = (Image)Resources.ResourceManager.GetObject("item_" + item) ?? Resources.helditem;
+ // Redraw
+ baseImage = Util.LayerImage(baseImage, itemimg, 22 + (15 - itemimg.Width) / 2, 15 + (15 - itemimg.Height), 1);
+ }
+ return baseImage;
+ }
+ internal static Image getSprite(PKM pkm)
+ {
+ return getSprite(pkm.Species, pkm.AltForm, pkm.Gender, pkm.HeldItem, pkm.IsEgg, pkm.IsShiny);
+ }
+
+ // Font Related
+ [DllImport("gdi32.dll")]
+ private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [In] ref uint pcFonts);
+ private static readonly PrivateFontCollection s_FontCollection = new PrivateFontCollection();
+ private static FontFamily[] FontFamilies
+ {
+ get
+ {
+ if (s_FontCollection.Families.Length == 0) setPKXFont();
+ return s_FontCollection.Families;
+ }
+ }
+ internal static Font getPKXFont(float size)
+ {
+ return new Font(FontFamilies[0], size);
+ }
+ private static void setPKXFont()
+ {
+ try
+ {
+ byte[] fontData = Resources.pgldings_normalregular;
+ IntPtr fontPtr = Marshal.AllocCoTaskMem(fontData.Length);
+ Marshal.Copy(fontData, 0, fontPtr, fontData.Length);
+ s_FontCollection.AddMemoryFont(fontPtr, Resources.pgldings_normalregular.Length); uint dummy = 0;
+ AddFontMemResourceEx(fontPtr, (uint)Resources.pgldings_normalregular.Length, IntPtr.Zero, ref dummy);
+ Marshal.FreeCoTaskMem(fontPtr);
+ }
+ catch { Util.Error("Unable to add ingame font."); }
+ }
+
+ // Personal.dat
+ internal static string[] getFormList(int species, string[] t, string[] f, string[] g)
+ {
+ // Mega List
+ if (Array.IndexOf(new[]
+ { // XY
+ 003, 009, 065, 094, 115, 127, 130, 142, 181, 212, 214, 229, 248, 257, 282, 303, 306, 308, 310, 354, 359, 380, 381, 445, 448, 460,
+ // ORAS
+ 015, 018, 080, 208, 254, 260, 302, 319, 323, 334, 362, 373, 376, 384, 428, 475, 531, 719,
+ }, species) > -1) { // ...
+ return new[]
+ {
+ t[000], // Normal
+ f[723], // Mega
+ };}
+ // MegaXY List
+ switch (species)
+ {
+ case 6:
+ case 150:
+ return new[]
+ {
+ t[000], // Normal
+ f[724], // Mega X
+ f[725], // Mega Y
+ };
+ case 025:
+ return new[]
+ {
+ t[000], // Normal
+ f[729], // Rockstar
+ f[730], // Belle
+ f[731], // Pop
+ f[732], // PhD
+ f[733], // Libre
+ f[734], // Cosplay
+ };
+ case 201:
+ return new[]
+ {
+ "A", "B", "C", "D", "E",
+ "F", "G", "H", "I", "J",
+ "K", "L", "M", "N", "O",
+ "P", "Q", "R", "S", "T",
+ "U", "V", "W", "X", "Y",
+ "Z",
+ "!", "?",
+ };
+ case 351:
+ return new[]
+ {
+ t[000], // Normal
+ f[789], // Sunny
+ f[790], // Rainy
+ f[791], // Snowy
+ };
+ case 382:
+ case 383:
+ return new[]
+ {
+ t[000], // Normal
+ f[800], // Primal
+ };
+ case 386:
+ return new[]
+ {
+ t[000], // Normal
+ f[802], // Attack
+ f[803], // Defense
+ f[804], // Speed
+ };
+
+ case 412:
+ case 413:
+ case 414:
+ return new[]
+ {
+ f[412], // Plant
+ f[805], // Sandy
+ f[806], // Trash
+ };
+
+ case 421:
+ return new[]
+ {
+ f[421], // Overcast
+ f[809], // Sunshine
+ };
+
+ case 422:
+ case 423:
+ return new[]
+ {
+ f[422], // West
+ f[811], // East
+ };
+
+ case 479:
+ return new[]
+ {
+ t[000], // Normal
+ f[817], // Heat
+ f[818], // Wash
+ f[819], // Frost
+ f[820], // Fan
+ f[821], // Mow
+ };
+
+ case 487:
+ return new[]
+ {
+ f[487], // Altered
+ f[822], // Origin
+ };
+
+ case 492:
+ return new[]
+ {
+ f[492], // Land
+ f[823], // Sky
+ };
+
+ case 493:
+ return new[]
+ {
+ t[00], // Normal
+ t[01], // Fighting
+ t[02], // Flying
+ t[03], // Poison
+ t[04], // etc
+ t[05],
+ t[06],
+ t[07],
+ t[08],
+ t[09],
+ t[10],
+ t[11],
+ t[12],
+ t[13],
+ t[14],
+ t[15],
+ t[16],
+ t[17],
+ };
+
+ case 550:
+ return new[]
+ {
+ f[550], // Red
+ f[842], // Blue
+ };
+
+ case 555:
+ return new[]
+ {
+ f[555], // Standard
+ f[843], // Zen
+ };
+
+ case 585:
+ case 586:
+ return new[]
+ {
+ f[585], // Spring
+ f[844], // Summer
+ f[845], // Autumn
+ f[846], // Winter
+ };
+
+ case 641:
+ case 642:
+ case 645:
+ return new[]
+ {
+ f[641], // Incarnate
+ f[852], // Therian
+ };
+
+ case 646:
+ return new[]
+ {
+ t[000], // Normal
+ f[853], // White
+ f[854], // Black
+ };
+
+ case 647:
+ return new[]
+ {
+ f[647], // Ordinary
+ f[855], // Resolute
+ };
+
+ case 648:
+ return new[]
+ {
+ f[648], // Aria
+ f[856], // Pirouette
+ };
+
+ case 649:
+ return new[]
+ {
+ t[000], // Normal
+ t[010], // Douse
+ t[012], // Shock
+ t[009], // Burn
+ t[014], // Chill
+ };
+
+ case 664:
+ case 665:
+ case 666:
+ return new[]
+ {
+ f[666], // Icy Snow
+ f[861], // Polar
+ f[862], // Tundra
+ f[863], // Continental
+ f[864], // Garden
+ f[865], // Elegant
+ f[866], // Meadow
+ f[867], // Modern
+ f[868], // Marine
+ f[869], // Archipelago
+ f[870], // High-Plains
+ f[871], // Sandstorm
+ f[872], // River
+ f[873], // Monsoon
+ f[874], // Savannah
+ f[875], // Sun
+ f[876], // Ocean
+ f[877], // Jungle
+ f[878], // Fancy
+ f[879], // Poké Ball
+ };
+
+ case 669:
+ case 671:
+ return new[]
+ {
+ f[669], // Red
+ f[884], // Yellow
+ f[885], // Orange
+ f[886], // Blue
+ f[887], // White
+ };
+
+ case 670:
+ return new[]
+ {
+ f[669], // Red
+ f[884], // Yellow
+ f[885], // Orange
+ f[886], // Blue
+ f[887], // White
+ f[888], // Eternal
+ };
+
+ case 676:
+ return new[]
+ {
+ f[676], // Natural
+ f[893], // Heart
+ f[894], // Star
+ f[895], // Diamond
+ f[896], // Deputante
+ f[897], // Matron
+ f[898], // Dandy
+ f[899], // La Reine
+ f[900], // Kabuki
+ f[901], // Pharaoh
+ };
+
+ case 678:
+ return new[]
+ {
+ g[000], // Male
+ g[001], // Female
+ };
+
+ case 681:
+ return new[]
+ {
+ f[681], // Shield
+ f[903], // Blade
+ };
+
+ case 710:
+ case 711:
+ return new[]
+ {
+ f[904], // Small
+ f[710], // Average
+ f[905], // Large
+ f[906], // Super
+ };
+
+ case 716:
+ return new[]
+ {
+ t[000], // Normal
+ f[910], // Active
+ };
+
+ case 720:
+ return new[]
+ {
+ t[000], // Normal
+ f[912], // Unbound
+ };
+ }
+ return new[] {""};
+ }
+
+ /// Calculate the Hidden Power Type of the entered IVs.
+ /// Order: HP,ATK,DEF,SPEED,SPA,SPD
+ /// Hidden Power Type
+ internal static int getHPType(int[] ivs)
+ {
+ return 15 * ((ivs[0] & 1) + 2 * (ivs[1] & 1) + 4 * (ivs[2] & 1) + 8 * (ivs[3] & 1) + 16 * (ivs[4] & 1) + 32 * (ivs[5] & 1)) / 63;
+ }
+ internal static int[] setHPIVs(int type, int[] ivs)
+ {
+ for (int i = 0; i < 6; i++)
+ ivs[i] = (ivs[i] & 0x1E) + hpivs[type, i];
+ return ivs;
+ }
+ internal static readonly int[,] hpivs = {
+ { 1, 1, 0, 0, 0, 0 }, // Fighting
+ { 0, 0, 0, 0, 0, 1 }, // Flying
+ { 1, 1, 0, 0, 0, 1 }, // Poison
+ { 1, 1, 1, 0, 0, 1 }, // Ground
+ { 1, 1, 0, 1, 0, 0 }, // Rock
+ { 1, 0, 0, 1, 0, 1 }, // Bug
+ { 1, 0, 1, 1, 0, 1 }, // Ghost
+ { 1, 1, 1, 1, 0, 1 }, // Steel
+ { 1, 0, 1, 0, 1, 0 }, // Fire
+ { 1, 0, 0, 0, 1, 1 }, // Water
+ { 1, 0, 1, 0, 1, 1 }, // Grass
+ { 1, 1, 1, 0, 1, 1 }, // Electric
+ { 1, 0, 1, 1, 1, 0 }, // Psychic
+ { 1, 0, 0, 1, 1, 1 }, // Ice
+ { 1, 0, 1, 1, 1, 1 }, // Dragon
+ { 1, 1, 1, 1, 1, 1 }, // Dark
+ };
+
+ internal static string TrimFromFFFF(string input)
+ {
+ int index = input.IndexOf((char)0xFFFF);
+ return index < 0 ? input : input.Substring(0, index);
+ }
+
+ // Past Gen Manipulation
+
+ internal static byte[] shuffleArray45(byte[] data, uint sv)
+ {
+ byte[] sdata = new byte[data.Length];
+ Array.Copy(data, sdata, 8); // Copy unshuffled bytes
+
// Shuffle Away!
for (int block = 0; block < 4; block++)
Array.Copy(data, 8 + 32 * blockPosition[block][sv], sdata, 8 + 32 * block, 32);
@@ -68,7 +1037,8 @@ namespace PKHeX
return sdata;
}
- internal static byte[] decryptArray(byte[] ekm)
+
+ internal static byte[] decryptArray45(byte[] ekm)
{
byte[] pkm = (byte[])ekm.Clone();
@@ -83,17 +1053,18 @@ namespace PKHeX
BitConverter.GetBytes((ushort)(BitConverter.ToUInt16(pkm, i) ^ LCRNG(ref seed) >> 16)).CopyTo(pkm, i);
// Deshuffle
- pkm = shuffleArray(pkm, sv);
+ pkm = shuffleArray45(pkm, sv);
// Decrypt the Party Stats
seed = pv;
if (pkm.Length <= 136) return pkm;
- for (int i = 136; i < 236; i += 2)
+ for (int i = 136; i < pkm.Length; i += 2)
BitConverter.GetBytes((ushort)(BitConverter.ToUInt16(pkm, i) ^ LCRNG(ref seed) >> 16)).CopyTo(pkm, i);
return pkm;
}
- internal static byte[] encryptArray(byte[] pkm)
+
+ internal static byte[] encryptArray45(byte[] pkm)
{
uint pv = BitConverter.ToUInt32(pkm, 0);
uint sv = ((pv & 0x3E000) >> 0xD) % 24;
@@ -101,7 +1072,7 @@ namespace PKHeX
uint chk = BitConverter.ToUInt16(pkm, 6);
byte[] ekm = (byte[])pkm.Clone();
- ekm = shuffleArray(ekm, blockPositionInvert[sv]);
+ ekm = shuffleArray45(ekm, blockPositionInvert[sv]);
uint seed = chk;
@@ -114,48 +1085,13 @@ namespace PKHeX
// Encrypt the Party Stats
seed = pv;
- for (int i = 136; i < 236; i += 2)
+ for (int i = 136; i < ekm.Length; i += 2)
BitConverter.GetBytes((ushort)(BitConverter.ToUInt16(ekm, i) ^ LCRNG(ref seed) >> 16)).CopyTo(ekm, i);
// Done
return ekm;
}
- ///
- /// Checks to see if the PKM file is encrypted; if so, decrypts.
- ///
- /// Input byte array
- internal static void checkEncrypted(ref byte[] pkm)
- {
- if (pkm.Length != PK4.SIZE_STORED && pkm.Length != PK4.SIZE_PARTY && pkm.Length != PK5.SIZE_PARTY)
- return; // bad
-
- ushort chk = 0;
- for (int i = 8; i < PK4.SIZE_STORED; i += 2) // Loop through the entire PKM
- chk += BitConverter.ToUInt16(pkm, i);
- pkm = chk != BitConverter.ToUInt16(pkm, 0x06) ? decryptArray(pkm) : pkm;
- }
-
- /// Calculates the CRC16-CCITT checksum over an input byte array.
- /// Input byte array
- /// Checksum
- internal static ushort ccitt16(byte[] chunk)
- {
- ushort crc = 0xFFFF;
- foreach (byte t in chunk)
- {
- crc ^= (ushort)(t << 8);
- for (int j = 0; j < 8; j++)
- {
- if ((crc & 0x8000) > 0)
- crc = (ushort)(crc << 1 ^ 0x1021);
- else
- crc <<= 1;
- }
- }
- return crc;
- }
-
internal static int getUnownForm(uint PID)
{
byte[] data = BitConverter.GetBytes(PID);
@@ -167,6 +1103,7 @@ namespace PKHeX
int index = Array.IndexOf(G4Values, val);
return index > -1 ? G4Chars[index] : (ushort)0xFFFF;
}
+
internal static ushort char2valG4(ushort chr)
{
int index = Array.IndexOf(G4Chars, chr);
@@ -186,6 +1123,7 @@ namespace PKHeX
}
return s;
}
+
internal static byte[] str2arrayG4(string str)
{
byte[] strdata = new byte[str.Length * 2 + 2]; // +2 for 0xFFFF
@@ -204,11 +1142,13 @@ namespace PKHeX
// Gen3 && 3->4 Conversion has two character tables, and translates to the same character map.
internal static ushort getG4Val(byte val, bool jp) { return jp ? G34_4J[val] : G34_4E[val]; }
internal static ushort getG3Char(byte val, bool jp) { return val2charG4(getG4Val(val, jp)); }
+
internal static byte setG3Char(ushort chr, bool jp)
{
int index = Array.IndexOf(jp ? G34_4J : G34_4E, char2valG4(chr));
return (byte)(index > -1 ? index : 0xFF);
}
+
internal static string getG3Str(byte[] strdata, bool jp)
{
return strdata
@@ -217,6 +1157,7 @@ namespace PKHeX
.TakeWhile(chr => chr != 0xFF) // Stop if Terminator
.Aggregate("", (current, chr) => current + (char)chr);
}
+
internal static byte[] setG3Str(string str, bool jp)
{
byte[] strdata = new byte[str.Length + 1]; // +1 for 0xFF
@@ -237,6 +1178,7 @@ namespace PKHeX
int index = Array.IndexOf(oldindex, g3index);
return newindex[index > -1 ? index : 0];
}
+
internal static int getG3Species(int g4index)
{
int index = Array.IndexOf(newindex, g4index);
@@ -245,7 +1187,7 @@ namespace PKHeX
internal static int getGender(int species, uint PID)
{
- int genderratio = PKX.Personal[species].Gender;
+ int genderratio = Personal[species].Gender;
switch (genderratio)
{
case 255: return 2;
@@ -254,25 +1196,6 @@ namespace PKHeX
default: return (PID & 0xFF) <= genderratio ? 1 : 0;
}
}
-
- internal static string getSpeciesName(int species, int language)
- {
- try
- {
- return new[]
- {
- speclang_ja[species].ToUpper(),
- speclang_en[species].ToUpper(),
- speclang_fr[species].ToUpper(),
- speclang_it[species].ToUpper(),
- speclang_de[species].ToUpper(),
- speclang_ja[species].ToLower(),
- speclang_es[species].ToUpper(),
- }[language];
- }
- catch { return ""; }
- }
-
#region Gen 3 Species Table
internal static readonly int[] newindex =
{
@@ -295,6 +1218,7 @@ namespace PKHeX
345,346,347,348,280,281,282,371,372,373,374,375,376,377,378,379,382,383,384,380,381,
385,386,358,
};
+
internal static readonly int[] oldindex =
{
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,
@@ -318,7 +1242,7 @@ namespace PKHeX
};
#endregion
#region Gen 3 Ability Table
- internal static readonly byte[][] Gen3Abilities =
+ internal static readonly byte[][] Gen3Abilities =
{
new byte[] {0x00, 0x00}, // 000
new byte[] {0x41, 0x41}, // 001
@@ -708,8 +1632,10 @@ namespace PKHeX
new byte[] {0x20, 0x20}, // 385
new byte[] {0x2e, 0x2e}, // 386
};
+
#endregion
#region Gen 3/4 Character Tables (Val->Unicode)
+
internal static readonly ushort[] G4Values =
{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
@@ -868,6 +1794,7 @@ namespace PKHeX
3396, 3397, 3398, 3399, 3400, 3401, 3402, 3403, 3404, 3405, 3406, 3407, 3408, 3409, 3425, 3426, 3427, 3428,
3429, 65535
};
+
internal static readonly ushort[] G4Chars =
{
12288, 12353, 12354, 12355, 12356, 12357, 12358, 12359, 12360, 12361, 12362, 12363,
@@ -1058,6 +1985,7 @@ namespace PKHeX
4365, 4366, 4367, 4368, 4369, 4370, 4449, 4450, 4451, 4452, 4453, 4454, 4455, 4456, 4457, 4461, 4462, 4466,
4467, 4469, 47252, 49968, 50108, 50388, 52012, 65535
};
+
internal static readonly ushort[] G34_4E =
{
478, 351, 352, 353, 358, 359, 360, 361, 362, 363, 020, 365, 366, 369, 370,
@@ -1078,6 +2006,7 @@ namespace PKHeX
337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 289,
452, 355, 373, 379, 387, 405, 411
};
+
internal static readonly ushort[] G34_4J =
{
001, 003, 005, 007, 009, 011, 012, 014, 016, 018, 020, 022, 024, 026, 028,
@@ -1101,54 +2030,14 @@ namespace PKHeX
#endregion
internal static readonly byte[][] G4TransferTrashBytes = {
- new byte[] { }, // Unused
- new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
- new byte[] { 0x18, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0xA1, 0x0C, 0x02, 0xE0, 0xFF },
- new byte[] { 0x74, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xA1, 0x0C, 0x02, 0xE0, 0xFF },
- new byte[] { 0x54, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0xA1, 0x0C, 0x02, 0xE0, 0xFF },
- new byte[] { 0x74, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xA1, 0x0C, 0x02, 0xE0, 0xFF },
- new byte[] { }, // Unused
- new byte[] { 0x74, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xA1, 0x0C, 0x02, 0xE0, 0xFF },
- };
- }
- public class Converter
- {
- internal static int Country = 31;
- internal static int Region = 7;
- internal static int ConsoleRegion = 1;
- internal static string OT_Name = "PKHeX";
- internal static int OT_Gender;
-
- internal static PK6 ConvertPKMtoPK6(byte[] input)
- {
- // Detect Input Generation
- if (input.Length == 100 || input.Length == 80) // PK3
- return new PK3(input).convertToPK4().convertToPK5().convertToPK6();
- if (input.Length != 136 && input.Length != 236 && input.Length != 220) // Invalid
- return null;
- if ((BitConverter.ToUInt16(input, 0x80) >= 0x3333 || input[0x5F] >= 0x10) && BitConverter.ToUInt16(input, 0x46) == 0) // PK5
- return new PK5(input).convertToPK6();
- return new PK4(input).convertToPK5().convertToPK6(); // PK4
- }
- internal static PK5 ConvertPKMtoPK5(byte[] input)
- {
- // Detect Input Generation
- if (input.Length == 100 || input.Length == 80) // PK3
- return new PK3(input).convertToPK4().convertToPK5();
- if (input.Length != 136 && input.Length != 236 && input.Length != 220) // Invalid
- return null;
- if ((BitConverter.ToUInt16(input, 0x80) >= 0x3333 || input[0x5F] >= 0x10) && BitConverter.ToUInt16(input, 0x46) == 0) // PK5
- return new PK5(input);
- return new PK4(input).convertToPK5(); // PK4
- }
-
- internal static void updateConfig(int SUBREGION, int COUNTRY, int _3DSREGION, string TRAINERNAME, int TRAINERGENDER)
- {
- Region = SUBREGION;
- Country = COUNTRY;
- ConsoleRegion = _3DSREGION;
- OT_Name = TRAINERNAME;
- OT_Gender = TRAINERGENDER;
- }
+ new byte[] { }, // Unused
+ new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+ new byte[] { 0x18, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0xA1, 0x0C, 0x02, 0xE0, 0xFF },
+ new byte[] { 0x74, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xA1, 0x0C, 0x02, 0xE0, 0xFF },
+ new byte[] { 0x54, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0xA1, 0x0C, 0x02, 0xE0, 0xFF },
+ new byte[] { 0x74, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xA1, 0x0C, 0x02, 0xE0, 0xFF },
+ new byte[] { }, // Unused
+ new byte[] { 0x74, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xA1, 0x0C, 0x02, 0xE0, 0xFF },
+ };
}
}
diff --git a/PKM/ShowdownSet.cs b/PKM/ShowdownSet.cs
new file mode 100644
index 000000000..36920b6f4
--- /dev/null
+++ b/PKM/ShowdownSet.cs
@@ -0,0 +1,281 @@
+using System;
+using System.Linq;
+
+namespace PKHeX
+{
+ public class ShowdownSet
+ {
+ // String to Values
+ internal static readonly string[] StatNames = { "HP", "Atk", "Def", "SpA", "SpD", "Spe" };
+ public static readonly string[] types = Util.getStringList("types", "en");
+ public static readonly string[] forms = Util.getStringList("forms", "en");
+ private static readonly string[] species = Util.getStringList("species", "en");
+ private static readonly string[] items = Util.getStringList("items", "en");
+ private static readonly string[] natures = Util.getStringList("natures", "en");
+ private static readonly string[] moves = Util.getStringList("moves", "en");
+ private static readonly string[] abilities = Util.getStringList("abilities", "en");
+ private static readonly string[] hptypes = types.Skip(1).ToArray();
+
+ // Default Set Data
+ public string Nickname;
+ public int Species;
+ public string Form;
+ public string Gender;
+ public int Item;
+ public int Ability;
+ public int Level;
+ public bool Shiny;
+ public int Friendship;
+ public int Nature;
+ public int[] EVs;
+ public int[] IVs;
+ public int[] Moves;
+
+ // Parsing Utility
+ public ShowdownSet(string input = null)
+ {
+ if (input == null)
+ return;
+
+ Nickname = null;
+ Species = -1;
+ Form = null;
+ Gender = null;
+ Item = 0;
+ Ability = 0;
+ Level = 100;
+ Shiny = false;
+ Friendship = 255;
+ Nature = 0;
+ EVs = new int[6];
+ IVs = new[] { 31, 31, 31, 31, 31, 31 };
+ Moves = new int[4];
+
+ string[] lines = input.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None);
+ for (int i = 0; i < lines.Length; i++) lines[i] = lines[i].Replace("'", "’").Trim(); // Sanitize apostrophes
+
+ if (lines.Length < 3) return;
+
+ // Seek for start of set
+ int start = -1;
+ for (int i = 0; i < lines.Length; i++)
+ if (lines[i].Contains(" @ ")) { start = i; break; }
+ lines = lines.Skip(start).Take(lines.Length - start).ToArray();
+
+ // Abort if no text is found
+ if (start == -1)
+ {
+ // Try to parse the first line if it does not have any item
+ string ld = lines[0];
+ // Gender Detection
+ string last3 = ld.Substring(ld.Length - 3);
+ if (last3 == "(M)" || last3 == "(F)")
+ {
+ Gender = last3.Substring(1, 1);
+ ld = ld.Substring(0, ld.Length - 3);
+ }
+ // Nickname Detection
+ string spec = ld;
+ if (spec.Contains("("))
+ {
+ int index = spec.LastIndexOf("(", StringComparison.Ordinal);
+ string n1 = spec.Substring(0, index - 1);
+ string n2 = spec.Substring(index).Replace("(", "").Replace(")", "").Replace(" ", "");
+
+ bool inverted = Array.IndexOf(species, n2.Replace(" ", "")) > -1 || (Species = Array.IndexOf(species, n2.Split('-')[0])) > 0;
+ spec = inverted ? n2 : n1;
+ Nickname = inverted ? n1 : n2;
+ }
+ Species = Array.IndexOf(species, spec.Replace(" ", ""));
+ if (
+ (Species = Array.IndexOf(species, spec)) < 0 // Not an Edge Case
+ &&
+ (Species = Array.IndexOf(species, spec.Replace(" ", ""))) < 0 // Has Form
+ )
+ {
+ string[] tmp = spec.Split(new[] { "-" }, StringSplitOptions.None);
+ if (tmp.Length < 2) return;
+ Species = Array.IndexOf(species, tmp[0].Replace(" ", ""));
+ Form = tmp[1].Replace(" ", "");
+ if (tmp.Length > 2)
+ Form += " " + tmp[2];
+ }
+ if (Species < -1)
+ return;
+ lines = lines.Skip(1).Take(lines.Length - 1).ToArray();
+ }
+ int movectr = 0;
+ // Detect relevant data
+ foreach (string line in lines)
+ {
+ if (line.Length < 2) continue;
+ if (line.Contains("- "))
+ {
+ string moveString = line.Substring(2);
+ if (moveString.Contains("Hidden Power"))
+ {
+ if (moveString.Length > 13) // Defined Hidden Power
+ {
+ string type = moveString.Remove(0, 13).Replace("[", "").Replace("]", ""); // Trim out excess data
+ int hpVal = Array.IndexOf(hptypes, type); // Get HP Type
+ if (hpVal >= 0) IVs = PKX.setHPIVs(hpVal, IVs); // Get IVs
+ }
+ moveString = "Hidden Power";
+ }
+ Moves[movectr++] = Array.IndexOf(moves, moveString);
+ if (movectr == 4)
+ break; // End of moves
+ continue;
+ }
+
+ string[] brokenline = line.Split(new[] { ": " }, StringSplitOptions.None);
+ switch (brokenline[0])
+ {
+ case "Trait":
+ case "Ability": { Ability = Array.IndexOf(abilities, brokenline[1]); break; }
+ case "Level": { Level = Util.ToInt32(brokenline[1]); break; }
+ case "Shiny": { Shiny = brokenline[1] == "Yes"; break; }
+ case "Happiness": { Friendship = Util.ToInt32(brokenline[1]); break; }
+ case "EVs":
+ {
+ // Get EV list String
+ string[] evlist = brokenline[1].Replace("SAtk", "SpA").Replace("SDef", "SpD").Replace("Spd", "Spe").Split(new[] { " / ", " " }, StringSplitOptions.None);
+ for (int i = 0; i < evlist.Length / 2; i++)
+ EVs[Array.IndexOf(StatNames, evlist[1 + i * 2])] = (byte)Util.ToInt32(evlist[0 + 2 * i]);
+ break;
+ }
+ case "IVs":
+ {
+ // Get IV list String
+ string[] ivlist = brokenline[1].Split(new[] { " / ", " " }, StringSplitOptions.None);
+ for (int i = 0; i < ivlist.Length / 2; i++)
+ IVs[Array.IndexOf(StatNames, ivlist[1 + i * 2])] = (byte)Util.ToInt32(ivlist[0 + 2 * i]);
+ break;
+ }
+ default:
+ {
+ // Either Nature or Gender ItemSpecies
+ if (brokenline[0].Contains(" @ "))
+ {
+ string[] ld = line.Split(new[] { " @ " }, StringSplitOptions.None);
+ Item = Array.IndexOf(items, ld.Last());
+ // Gender Detection
+ string last3 = ld[0].Substring(ld[0].Length - 3);
+ if (last3 == "(M)" || last3 == "(F)")
+ {
+ Gender = last3.Substring(1, 1);
+ ld[0] = ld[0].Substring(0, ld[ld.Length - 2].Length - 3);
+ }
+ // Nickname Detection
+ string spec = ld[0];
+ if (spec.Contains("("))
+ {
+ int index = spec.LastIndexOf("(", StringComparison.Ordinal);
+ string n1 = spec.Substring(0, index - 1);
+ string n2 = spec.Substring(index).Replace("(", "").Replace(")", "").Replace(" ", "");
+
+ bool inverted = Array.IndexOf(species, n2.Replace(" ", "")) > -1 || (Species = Array.IndexOf(species, n2.Split('-')[0])) > 0;
+ spec = inverted ? n2 : n1;
+ Nickname = inverted ? n1 : n2;
+ }
+ if (
+ (Species = Array.IndexOf(species, spec)) < 0 // Not an Edge Case
+ &&
+ (Species = Array.IndexOf(species, spec.Replace(" ", ""))) < 0 // Has Form
+ )
+ {
+ string[] tmp = spec.Split(new[] { "-" }, StringSplitOptions.None);
+ Species = Array.IndexOf(species, tmp[0].Replace(" ", ""));
+ Form = tmp[1].Replace(" ", "");
+ if (tmp.Length > 2)
+ Form += " " + tmp[2];
+ }
+ }
+ else if (brokenline[0].Contains("Nature"))
+ Nature = Array.IndexOf(natures, line.Split(' ')[0]);
+ else // Fallback
+ Species = Array.IndexOf(species, line.Split('(')[0]);
+ }
+ break;
+ }
+ }
+ }
+ public string getText()
+ {
+ if (Species == 0 || Species > 722)
+ return "";
+
+ // First Line: Name, Nickname, Gender, Item
+ string result = string.Format(species[Species] != Nickname ? "{0} ({1})" : "{1}", Nickname,
+ species[Species] + ((Form ?? "") != "" ? "-" + Form.Replace("Mega ", "Mega-") : "")) // Species (& Form if necessary)
+ + Gender + (Item != 0 ? " @ " + items[Item] : "") + Environment.NewLine;
+
+ // IVs
+ string[] ivstr = new string[6];
+ int ivctr = 0;
+ int[] sIVs = { IVs[0], IVs[1], IVs[2], IVs[4], IVs[5], IVs[3] }; // Reorganize speed
+ for (int i = 0; i < 6; i++)
+ {
+ if (sIVs[i] == 31) continue;
+ ivstr[ivctr++] += $"{sIVs[i]} {StatNames[i]}";
+ }
+ if (ivctr > 0)
+ result += "IVs: " + string.Join(" / ", ivstr.Take(ivctr)) + Environment.NewLine;
+
+ // EVs
+ string[] evstr = new string[6];
+ int[] sEVs = { EVs[0], EVs[1], EVs[2], EVs[4], EVs[5], EVs[3] }; // Reorganize speed
+ int evctr = 0;
+ for (int i = 0; i < 6; i++)
+ {
+ if (sEVs[i] == 0) continue;
+ evstr[evctr++] += $"{sEVs[i]} {StatNames[i]}";
+ }
+ if (evctr > 0)
+ result += "EVs: " + string.Join(" / ", evstr.Take(evctr)) + Environment.NewLine;
+
+ // Secondary Stats
+ result += "Ability: " + abilities[Ability] + Environment.NewLine;
+ result += "Level: " + Level + Environment.NewLine;
+ if (Shiny)
+ result += "Shiny: Yes" + Environment.NewLine;
+
+ result += natures[Nature] + " Nature" + Environment.NewLine;
+ // Add in Moves
+ string[] MoveLines = new string[Moves.Length];
+ int movectr = 0;
+ foreach (int move in Moves.Where(move => move != 0 && move < moves.Length))
+ {
+ MoveLines[movectr] += "- " + moves[move];
+ if (move == 237)
+ MoveLines[movectr] += $" [{hptypes[PKX.getHPType(IVs)]}]";
+ movectr++;
+ }
+ result += string.Join(Environment.NewLine, MoveLines.Take(movectr));
+
+ return result;
+ }
+ internal static string getShowdownText(PKM pkm)
+ {
+ if (pkm.Species == 0) return "";
+ ShowdownSet Set = new ShowdownSet
+ {
+ Nickname = pkm.Nickname,
+ Species = pkm.Species,
+ Item = pkm.HeldItem,
+ Ability = pkm.Ability,
+ EVs = pkm.EVs,
+ IVs = pkm.IVs,
+ Moves = pkm.Moves,
+ Nature = pkm.Nature,
+ Gender = new[] { " (M)", " (F)", "" }[pkm.Gender],
+ Friendship = pkm.CurrentFriendship,
+ Level = PKX.getLevel(pkm.Species, pkm.EXP),
+ Shiny = pkm.IsShiny,
+ Form = pkm.AltForm > 0 ? PKX.getFormList(pkm.Species, types, forms, new[] { "", "F", "" })[pkm.AltForm] : "",
+ };
+ if (Set.Form == "F") Set.Gender = "";
+ return Set.getText();
+ }
+ }
+}
diff --git a/PKX/f1-Main.Designer.cs b/PKX/f1-Main.Designer.cs
index 56bd6582f..53014fead 100644
--- a/PKX/f1-Main.Designer.cs
+++ b/PKX/f1-Main.Designer.cs
@@ -179,30 +179,24 @@
this.CB_Move2 = new System.Windows.Forms.ComboBox();
this.CB_Move1 = new System.Windows.Forms.ComboBox();
this.Tab_OTMisc = new System.Windows.Forms.TabPage();
- this.CHK_Diamond = new System.Windows.Forms.CheckBox();
- this.CHK_Star = new System.Windows.Forms.CheckBox();
- this.CHK_Heart = new System.Windows.Forms.CheckBox();
- this.CHK_Square = new System.Windows.Forms.CheckBox();
this.TB_EC = new System.Windows.Forms.TextBox();
this.GB_nOT = new System.Windows.Forms.GroupBox();
this.Label_CTGender = new System.Windows.Forms.Label();
this.TB_OTt2 = new System.Windows.Forms.TextBox();
this.Label_PrevOT = new System.Windows.Forms.Label();
- this.CHK_Triangle = new System.Windows.Forms.CheckBox();
- this.CHK_Circle = new System.Windows.Forms.CheckBox();
this.BTN_RerollEC = new System.Windows.Forms.Button();
this.BTN_History = new System.Windows.Forms.Button();
this.BTN_Ribbons = new System.Windows.Forms.Button();
this.GB_Markings = new System.Windows.Forms.GroupBox();
- this.PB_MarkPentagon = new System.Windows.Forms.PictureBox();
- this.PB_MarkCured = new System.Windows.Forms.PictureBox();
- this.PB_MarkShiny = new System.Windows.Forms.PictureBox();
this.PB_Mark6 = new System.Windows.Forms.PictureBox();
- this.PB_Mark5 = new System.Windows.Forms.PictureBox();
- this.PB_Mark4 = new System.Windows.Forms.PictureBox();
+ this.PB_MarkPentagon = new System.Windows.Forms.PictureBox();
this.PB_Mark3 = new System.Windows.Forms.PictureBox();
+ this.PB_Mark5 = new System.Windows.Forms.PictureBox();
+ this.PB_MarkCured = new System.Windows.Forms.PictureBox();
this.PB_Mark2 = new System.Windows.Forms.PictureBox();
+ this.PB_MarkShiny = new System.Windows.Forms.PictureBox();
this.PB_Mark1 = new System.Windows.Forms.PictureBox();
+ this.PB_Mark4 = new System.Windows.Forms.PictureBox();
this.GB_ExtraBytes = new System.Windows.Forms.GroupBox();
this.TB_ExtraByte = new System.Windows.Forms.MaskedTextBox();
this.CB_ExtraBytes = new System.Windows.Forms.ComboBox();
@@ -215,7 +209,6 @@
this.Label_SID = new System.Windows.Forms.Label();
this.Label_TID = new System.Windows.Forms.Label();
this.Label_EncryptionConstant = new System.Windows.Forms.Label();
- this.Label_Diamond = new System.Windows.Forms.Label();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.Menu_File = new System.Windows.Forms.ToolStripMenuItem();
this.Menu_Open = new System.Windows.Forms.ToolStripMenuItem();
@@ -312,7 +305,6 @@
this.ppkx5 = new System.Windows.Forms.PictureBox();
this.ppkx6 = new System.Windows.Forms.PictureBox();
this.Tab_Other = new System.Windows.Forms.TabPage();
- this.B_OpenSecretBase = new System.Windows.Forms.Button();
this.GB_Daycare = new System.Windows.Forms.GroupBox();
this.L_XP2 = new System.Windows.Forms.Label();
this.L_XP1 = new System.Windows.Forms.Label();
@@ -344,19 +336,22 @@
this.TB_GameSync = new System.Windows.Forms.TextBox();
this.B_SaveBoxBin = new System.Windows.Forms.Button();
this.B_VerifyCHK = new System.Windows.Forms.Button();
- this.B_OpenHallofFame = new System.Windows.Forms.Button();
- this.B_OUTPasserby = new System.Windows.Forms.Button();
- this.B_OpenPokepuffs = new System.Windows.Forms.Button();
- this.B_OpenBoxLayout = new System.Windows.Forms.Button();
- this.B_OpenOPowers = new System.Windows.Forms.Button();
- this.B_OpenItemPouch = new System.Windows.Forms.Button();
- this.B_OpenEventFlags = new System.Windows.Forms.Button();
- this.B_OpenWondercards = new System.Windows.Forms.Button();
- this.B_OpenTrainerInfo = new System.Windows.Forms.Button();
- this.B_OpenBerryField = new System.Windows.Forms.Button();
- this.B_OpenPokedex = new System.Windows.Forms.Button();
this.GB_SAVtools = new System.Windows.Forms.GroupBox();
+ this.FLP_SAVtools = new System.Windows.Forms.FlowLayoutPanel();
+ this.B_OpenPokepuffs = new System.Windows.Forms.Button();
+ this.B_OpenItemPouch = new System.Windows.Forms.Button();
+ this.B_OpenTrainerInfo = new System.Windows.Forms.Button();
+ this.B_OUTPasserby = new System.Windows.Forms.Button();
+ this.B_OpenBoxLayout = new System.Windows.Forms.Button();
+ this.B_OpenWondercards = new System.Windows.Forms.Button();
this.B_OpenSuperTraining = new System.Windows.Forms.Button();
+ this.B_OpenHallofFame = new System.Windows.Forms.Button();
+ this.B_OpenOPowers = new System.Windows.Forms.Button();
+ this.B_OpenEventFlags = new System.Windows.Forms.Button();
+ this.B_OpenPokedex = new System.Windows.Forms.Button();
+ this.B_OpenBerryField = new System.Windows.Forms.Button();
+ this.B_OpenSecretBase = new System.Windows.Forms.Button();
+ this.B_Pokeblocks = new System.Windows.Forms.Button();
this.dragout = new System.Windows.Forms.PictureBox();
this.mnuL = new System.Windows.Forms.ContextMenuStrip(this.components);
this.mnuLLegality = new System.Windows.Forms.ToolStripMenuItem();
@@ -383,15 +378,15 @@
this.Tab_OTMisc.SuspendLayout();
this.GB_nOT.SuspendLayout();
this.GB_Markings.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.PB_MarkPentagon)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.PB_MarkCured)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.PB_MarkShiny)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Mark6)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.PB_Mark5)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.PB_Mark4)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.PB_MarkPentagon)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Mark3)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.PB_Mark5)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.PB_MarkCured)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Mark2)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.PB_MarkShiny)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Mark1)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.PB_Mark4)).BeginInit();
this.GB_ExtraBytes.SuspendLayout();
this.GB_OT.SuspendLayout();
this.menuStrip1.SuspendLayout();
@@ -460,6 +455,7 @@
((System.ComponentModel.ISupportInitialize)(this.subepkx3)).BeginInit();
this.Tab_SAV.SuspendLayout();
this.GB_SAVtools.SuspendLayout();
+ this.FLP_SAVtools.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dragout)).BeginInit();
this.mnuL.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.PB_Legal)).BeginInit();
@@ -1002,10 +998,10 @@
// TB_AbilityNumber
//
this.TB_AbilityNumber.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.TB_AbilityNumber.Location = new System.Drawing.Point(206, 153);
+ this.TB_AbilityNumber.Location = new System.Drawing.Point(229, 153);
this.TB_AbilityNumber.Mask = "0";
this.TB_AbilityNumber.Name = "TB_AbilityNumber";
- this.TB_AbilityNumber.Size = new System.Drawing.Size(20, 20);
+ this.TB_AbilityNumber.Size = new System.Drawing.Size(19, 20);
this.TB_AbilityNumber.TabIndex = 14;
this.TB_AbilityNumber.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.TB_AbilityNumber.Visible = false;
@@ -1032,7 +1028,7 @@
"Item"});
this.DEV_Ability.Location = new System.Drawing.Point(105, 153);
this.DEV_Ability.Name = "DEV_Ability";
- this.DEV_Ability.Size = new System.Drawing.Size(100, 21);
+ this.DEV_Ability.Size = new System.Drawing.Size(122, 21);
this.DEV_Ability.TabIndex = 14;
this.DEV_Ability.Visible = false;
//
@@ -2243,14 +2239,8 @@
// Tab_OTMisc
//
this.Tab_OTMisc.AllowDrop = true;
- this.Tab_OTMisc.Controls.Add(this.CHK_Diamond);
- this.Tab_OTMisc.Controls.Add(this.CHK_Star);
- this.Tab_OTMisc.Controls.Add(this.CHK_Heart);
- this.Tab_OTMisc.Controls.Add(this.CHK_Square);
this.Tab_OTMisc.Controls.Add(this.TB_EC);
this.Tab_OTMisc.Controls.Add(this.GB_nOT);
- this.Tab_OTMisc.Controls.Add(this.CHK_Triangle);
- this.Tab_OTMisc.Controls.Add(this.CHK_Circle);
this.Tab_OTMisc.Controls.Add(this.BTN_RerollEC);
this.Tab_OTMisc.Controls.Add(this.BTN_History);
this.Tab_OTMisc.Controls.Add(this.BTN_Ribbons);
@@ -2258,7 +2248,6 @@
this.Tab_OTMisc.Controls.Add(this.GB_ExtraBytes);
this.Tab_OTMisc.Controls.Add(this.GB_OT);
this.Tab_OTMisc.Controls.Add(this.Label_EncryptionConstant);
- this.Tab_OTMisc.Controls.Add(this.Label_Diamond);
this.Tab_OTMisc.Location = new System.Drawing.Point(4, 22);
this.Tab_OTMisc.Name = "Tab_OTMisc";
this.Tab_OTMisc.Padding = new System.Windows.Forms.Padding(3);
@@ -2267,48 +2256,6 @@
this.Tab_OTMisc.Text = "OT/Misc";
this.Tab_OTMisc.UseVisualStyleBackColor = true;
//
- // CHK_Diamond
- //
- this.CHK_Diamond.AutoSize = true;
- this.CHK_Diamond.Location = new System.Drawing.Point(205, 228);
- this.CHK_Diamond.Name = "CHK_Diamond";
- this.CHK_Diamond.Size = new System.Drawing.Size(15, 14);
- this.CHK_Diamond.TabIndex = 13;
- this.CHK_Diamond.TextAlign = System.Drawing.ContentAlignment.TopLeft;
- this.CHK_Diamond.UseVisualStyleBackColor = true;
- this.CHK_Diamond.Visible = false;
- //
- // CHK_Star
- //
- this.CHK_Star.Location = new System.Drawing.Point(205, 213);
- this.CHK_Star.Name = "CHK_Star";
- this.CHK_Star.Size = new System.Drawing.Size(38, 17);
- this.CHK_Star.TabIndex = 13;
- this.CHK_Star.Text = "★";
- this.CHK_Star.UseVisualStyleBackColor = true;
- this.CHK_Star.Visible = false;
- //
- // CHK_Heart
- //
- this.CHK_Heart.Location = new System.Drawing.Point(205, 199);
- this.CHK_Heart.Name = "CHK_Heart";
- this.CHK_Heart.Size = new System.Drawing.Size(37, 17);
- this.CHK_Heart.TabIndex = 12;
- this.CHK_Heart.Text = " ♥";
- this.CHK_Heart.UseVisualStyleBackColor = true;
- this.CHK_Heart.Visible = false;
- //
- // CHK_Square
- //
- this.CHK_Square.Location = new System.Drawing.Point(29, 227);
- this.CHK_Square.Name = "CHK_Square";
- this.CHK_Square.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
- this.CHK_Square.Size = new System.Drawing.Size(38, 17);
- this.CHK_Square.TabIndex = 11;
- this.CHK_Square.Text = "■";
- this.CHK_Square.UseVisualStyleBackColor = true;
- this.CHK_Square.Visible = false;
- //
// TB_EC
//
this.TB_EC.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
@@ -2367,28 +2314,6 @@
this.Label_PrevOT.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.Label_PrevOT.Click += new System.EventHandler(this.clickCT);
//
- // CHK_Triangle
- //
- this.CHK_Triangle.Location = new System.Drawing.Point(29, 213);
- this.CHK_Triangle.Name = "CHK_Triangle";
- this.CHK_Triangle.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
- this.CHK_Triangle.Size = new System.Drawing.Size(38, 17);
- this.CHK_Triangle.TabIndex = 10;
- this.CHK_Triangle.Text = "▲";
- this.CHK_Triangle.UseVisualStyleBackColor = true;
- this.CHK_Triangle.Visible = false;
- //
- // CHK_Circle
- //
- this.CHK_Circle.Location = new System.Drawing.Point(27, 193);
- this.CHK_Circle.Name = "CHK_Circle";
- this.CHK_Circle.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
- this.CHK_Circle.Size = new System.Drawing.Size(40, 28);
- this.CHK_Circle.TabIndex = 9;
- this.CHK_Circle.Text = "●";
- this.CHK_Circle.UseVisualStyleBackColor = true;
- this.CHK_Circle.Visible = false;
- //
// BTN_RerollEC
//
this.BTN_RerollEC.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F);
@@ -2422,15 +2347,15 @@
//
// GB_Markings
//
- this.GB_Markings.Controls.Add(this.PB_MarkPentagon);
- this.GB_Markings.Controls.Add(this.PB_MarkCured);
- this.GB_Markings.Controls.Add(this.PB_MarkShiny);
this.GB_Markings.Controls.Add(this.PB_Mark6);
- this.GB_Markings.Controls.Add(this.PB_Mark5);
- this.GB_Markings.Controls.Add(this.PB_Mark4);
+ this.GB_Markings.Controls.Add(this.PB_MarkPentagon);
this.GB_Markings.Controls.Add(this.PB_Mark3);
+ this.GB_Markings.Controls.Add(this.PB_Mark5);
+ this.GB_Markings.Controls.Add(this.PB_MarkCured);
this.GB_Markings.Controls.Add(this.PB_Mark2);
+ this.GB_Markings.Controls.Add(this.PB_MarkShiny);
this.GB_Markings.Controls.Add(this.PB_Mark1);
+ this.GB_Markings.Controls.Add(this.PB_Mark4);
this.GB_Markings.Location = new System.Drawing.Point(68, 188);
this.GB_Markings.Name = "GB_Markings";
this.GB_Markings.Size = new System.Drawing.Size(135, 58);
@@ -2438,6 +2363,19 @@
this.GB_Markings.TabStop = false;
this.GB_Markings.Text = "Markings";
//
+ // PB_Mark6
+ //
+ this.PB_Mark6.Image = ((System.Drawing.Image)(resources.GetObject("PB_Mark6.Image")));
+ this.PB_Mark6.InitialImage = ((System.Drawing.Image)(resources.GetObject("PB_Mark6.InitialImage")));
+ this.PB_Mark6.Location = new System.Drawing.Point(110, 36);
+ this.PB_Mark6.Margin = new System.Windows.Forms.Padding(1);
+ this.PB_Mark6.Name = "PB_Mark6";
+ this.PB_Mark6.Size = new System.Drawing.Size(20, 20);
+ this.PB_Mark6.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
+ this.PB_Mark6.TabIndex = 5;
+ this.PB_Mark6.TabStop = false;
+ this.PB_Mark6.Click += new System.EventHandler(this.clickMarking);
+ //
// PB_MarkPentagon
//
this.PB_MarkPentagon.Image = ((System.Drawing.Image)(resources.GetObject("PB_MarkPentagon.Image")));
@@ -2449,6 +2387,32 @@
this.PB_MarkPentagon.TabIndex = 8;
this.PB_MarkPentagon.TabStop = false;
//
+ // PB_Mark3
+ //
+ this.PB_Mark3.Image = ((System.Drawing.Image)(resources.GetObject("PB_Mark3.Image")));
+ this.PB_Mark3.InitialImage = ((System.Drawing.Image)(resources.GetObject("PB_Mark3.InitialImage")));
+ this.PB_Mark3.Location = new System.Drawing.Point(47, 36);
+ this.PB_Mark3.Margin = new System.Windows.Forms.Padding(1);
+ this.PB_Mark3.Name = "PB_Mark3";
+ this.PB_Mark3.Size = new System.Drawing.Size(20, 20);
+ this.PB_Mark3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
+ this.PB_Mark3.TabIndex = 2;
+ this.PB_Mark3.TabStop = false;
+ this.PB_Mark3.Click += new System.EventHandler(this.clickMarking);
+ //
+ // PB_Mark5
+ //
+ this.PB_Mark5.Image = ((System.Drawing.Image)(resources.GetObject("PB_Mark5.Image")));
+ this.PB_Mark5.InitialImage = ((System.Drawing.Image)(resources.GetObject("PB_Mark5.InitialImage")));
+ this.PB_Mark5.Location = new System.Drawing.Point(89, 36);
+ this.PB_Mark5.Margin = new System.Windows.Forms.Padding(1);
+ this.PB_Mark5.Name = "PB_Mark5";
+ this.PB_Mark5.Size = new System.Drawing.Size(20, 20);
+ this.PB_Mark5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
+ this.PB_Mark5.TabIndex = 4;
+ this.PB_Mark5.TabStop = false;
+ this.PB_Mark5.Click += new System.EventHandler(this.clickMarking);
+ //
// PB_MarkCured
//
this.PB_MarkCured.Image = ((System.Drawing.Image)(resources.GetObject("PB_MarkCured.Image")));
@@ -2460,6 +2424,19 @@
this.PB_MarkCured.TabIndex = 7;
this.PB_MarkCured.TabStop = false;
//
+ // PB_Mark2
+ //
+ this.PB_Mark2.Image = ((System.Drawing.Image)(resources.GetObject("PB_Mark2.Image")));
+ this.PB_Mark2.InitialImage = ((System.Drawing.Image)(resources.GetObject("PB_Mark2.InitialImage")));
+ this.PB_Mark2.Location = new System.Drawing.Point(26, 36);
+ this.PB_Mark2.Margin = new System.Windows.Forms.Padding(1);
+ this.PB_Mark2.Name = "PB_Mark2";
+ this.PB_Mark2.Size = new System.Drawing.Size(20, 20);
+ this.PB_Mark2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
+ this.PB_Mark2.TabIndex = 1;
+ this.PB_Mark2.TabStop = false;
+ this.PB_Mark2.Click += new System.EventHandler(this.clickMarking);
+ //
// PB_MarkShiny
//
this.PB_MarkShiny.Image = ((System.Drawing.Image)(resources.GetObject("PB_MarkShiny.Image")));
@@ -2471,71 +2448,12 @@
this.PB_MarkShiny.TabIndex = 6;
this.PB_MarkShiny.TabStop = false;
//
- // PB_Mark6
- //
- this.PB_Mark6.Image = ((System.Drawing.Image)(resources.GetObject("PB_Mark6.Image")));
- this.PB_Mark6.InitialImage = ((System.Drawing.Image)(resources.GetObject("PB_Mark6.InitialImage")));
- this.PB_Mark6.Location = new System.Drawing.Point(107, 35);
- this.PB_Mark6.Name = "PB_Mark6";
- this.PB_Mark6.Size = new System.Drawing.Size(20, 20);
- this.PB_Mark6.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
- this.PB_Mark6.TabIndex = 5;
- this.PB_Mark6.TabStop = false;
- this.PB_Mark6.Click += new System.EventHandler(this.clickMarking);
- //
- // PB_Mark5
- //
- this.PB_Mark5.Image = ((System.Drawing.Image)(resources.GetObject("PB_Mark5.Image")));
- this.PB_Mark5.InitialImage = ((System.Drawing.Image)(resources.GetObject("PB_Mark5.InitialImage")));
- this.PB_Mark5.Location = new System.Drawing.Point(87, 35);
- this.PB_Mark5.Name = "PB_Mark5";
- this.PB_Mark5.Size = new System.Drawing.Size(20, 20);
- this.PB_Mark5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
- this.PB_Mark5.TabIndex = 4;
- this.PB_Mark5.TabStop = false;
- this.PB_Mark5.Click += new System.EventHandler(this.clickMarking);
- //
- // PB_Mark4
- //
- this.PB_Mark4.Image = ((System.Drawing.Image)(resources.GetObject("PB_Mark4.Image")));
- this.PB_Mark4.InitialImage = ((System.Drawing.Image)(resources.GetObject("PB_Mark4.InitialImage")));
- this.PB_Mark4.Location = new System.Drawing.Point(67, 35);
- this.PB_Mark4.Name = "PB_Mark4";
- this.PB_Mark4.Size = new System.Drawing.Size(20, 20);
- this.PB_Mark4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
- this.PB_Mark4.TabIndex = 3;
- this.PB_Mark4.TabStop = false;
- this.PB_Mark4.Click += new System.EventHandler(this.clickMarking);
- //
- // PB_Mark3
- //
- this.PB_Mark3.Image = ((System.Drawing.Image)(resources.GetObject("PB_Mark3.Image")));
- this.PB_Mark3.InitialImage = ((System.Drawing.Image)(resources.GetObject("PB_Mark3.InitialImage")));
- this.PB_Mark3.Location = new System.Drawing.Point(47, 35);
- this.PB_Mark3.Name = "PB_Mark3";
- this.PB_Mark3.Size = new System.Drawing.Size(20, 20);
- this.PB_Mark3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
- this.PB_Mark3.TabIndex = 2;
- this.PB_Mark3.TabStop = false;
- this.PB_Mark3.Click += new System.EventHandler(this.clickMarking);
- //
- // PB_Mark2
- //
- this.PB_Mark2.Image = ((System.Drawing.Image)(resources.GetObject("PB_Mark2.Image")));
- this.PB_Mark2.InitialImage = ((System.Drawing.Image)(resources.GetObject("PB_Mark2.InitialImage")));
- this.PB_Mark2.Location = new System.Drawing.Point(27, 35);
- this.PB_Mark2.Name = "PB_Mark2";
- this.PB_Mark2.Size = new System.Drawing.Size(20, 20);
- this.PB_Mark2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
- this.PB_Mark2.TabIndex = 1;
- this.PB_Mark2.TabStop = false;
- this.PB_Mark2.Click += new System.EventHandler(this.clickMarking);
- //
// PB_Mark1
//
this.PB_Mark1.Image = ((System.Drawing.Image)(resources.GetObject("PB_Mark1.Image")));
this.PB_Mark1.InitialImage = ((System.Drawing.Image)(resources.GetObject("PB_Mark1.InitialImage")));
- this.PB_Mark1.Location = new System.Drawing.Point(7, 35);
+ this.PB_Mark1.Location = new System.Drawing.Point(5, 36);
+ this.PB_Mark1.Margin = new System.Windows.Forms.Padding(1);
this.PB_Mark1.Name = "PB_Mark1";
this.PB_Mark1.Size = new System.Drawing.Size(20, 20);
this.PB_Mark1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
@@ -2543,6 +2461,19 @@
this.PB_Mark1.TabStop = false;
this.PB_Mark1.Click += new System.EventHandler(this.clickMarking);
//
+ // PB_Mark4
+ //
+ this.PB_Mark4.Image = ((System.Drawing.Image)(resources.GetObject("PB_Mark4.Image")));
+ this.PB_Mark4.InitialImage = ((System.Drawing.Image)(resources.GetObject("PB_Mark4.InitialImage")));
+ this.PB_Mark4.Location = new System.Drawing.Point(68, 36);
+ this.PB_Mark4.Margin = new System.Windows.Forms.Padding(1);
+ this.PB_Mark4.Name = "PB_Mark4";
+ this.PB_Mark4.Size = new System.Drawing.Size(20, 20);
+ this.PB_Mark4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
+ this.PB_Mark4.TabIndex = 3;
+ this.PB_Mark4.TabStop = false;
+ this.PB_Mark4.Click += new System.EventHandler(this.clickMarking);
+ //
// GB_ExtraBytes
//
this.GB_ExtraBytes.Controls.Add(this.TB_ExtraByte);
@@ -2569,34 +2500,7 @@
this.CB_ExtraBytes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_ExtraBytes.FormattingEnabled = true;
this.CB_ExtraBytes.Items.AddRange(new object[] {
- "0x36",
- "0x37",
- "0x3B",
- "0x3C",
- "0x3D",
- "0x3E",
- "0x3F",
- "0x58",
- "0x59",
- "0x73",
- "0x90",
- "0x91",
- "0x9E",
- "0x9F",
- "0xA0",
- "0xA1",
- "0xA7",
- "0xAA",
- "0xAB",
- "0xAC",
- "0xAD",
- "0xC8",
- "0xC9",
- "0xD7",
- "0xE4",
- "0xE5",
- "0xE6",
- "0xE7"});
+ "0x00"});
this.CB_ExtraBytes.Location = new System.Drawing.Point(20, 18);
this.CB_ExtraBytes.Name = "CB_ExtraBytes";
this.CB_ExtraBytes.Size = new System.Drawing.Size(57, 21);
@@ -2701,15 +2605,6 @@
this.Label_EncryptionConstant.Text = "Encryption Constant:";
this.Label_EncryptionConstant.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
- // Label_Diamond
- //
- this.Label_Diamond.Location = new System.Drawing.Point(215, 224);
- this.Label_Diamond.Name = "Label_Diamond";
- this.Label_Diamond.Size = new System.Drawing.Size(26, 20);
- this.Label_Diamond.TabIndex = 11;
- this.Label_Diamond.Text = " ♦";
- this.Label_Diamond.Visible = false;
- //
// menuStrip1
//
this.menuStrip1.BackColor = System.Drawing.Color.Transparent;
@@ -2736,19 +2631,21 @@
//
// Menu_Open
//
+ this.Menu_Open.Image = global::PKHeX.Properties.Resources.open;
this.Menu_Open.Name = "Menu_Open";
this.Menu_Open.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
this.Menu_Open.ShowShortcutKeys = false;
- this.Menu_Open.Size = new System.Drawing.Size(139, 22);
+ this.Menu_Open.Size = new System.Drawing.Size(152, 22);
this.Menu_Open.Text = "&Open...";
this.Menu_Open.Click += new System.EventHandler(this.mainMenuOpen);
//
// Menu_Save
//
+ this.Menu_Save.Image = global::PKHeX.Properties.Resources.savePKM;
this.Menu_Save.Name = "Menu_Save";
this.Menu_Save.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.Menu_Save.ShowShortcutKeys = false;
- this.Menu_Save.Size = new System.Drawing.Size(139, 22);
+ this.Menu_Save.Size = new System.Drawing.Size(152, 22);
this.Menu_Save.Text = "&Save PK6...";
this.Menu_Save.Click += new System.EventHandler(this.mainMenuSave);
//
@@ -2758,34 +2655,38 @@
this.Menu_ExportMAIN,
this.Menu_ExportBAK});
this.Menu_ExportSAV.Enabled = false;
+ this.Menu_ExportSAV.Image = global::PKHeX.Properties.Resources.saveSAV;
this.Menu_ExportSAV.Name = "Menu_ExportSAV";
- this.Menu_ExportSAV.Size = new System.Drawing.Size(139, 22);
+ this.Menu_ExportSAV.Size = new System.Drawing.Size(152, 22);
this.Menu_ExportSAV.Text = "&Export SAV...";
//
// Menu_ExportMAIN
//
+ this.Menu_ExportMAIN.Image = global::PKHeX.Properties.Resources.main;
this.Menu_ExportMAIN.Name = "Menu_ExportMAIN";
this.Menu_ExportMAIN.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E)));
this.Menu_ExportMAIN.ShowShortcutKeys = false;
- this.Menu_ExportMAIN.Size = new System.Drawing.Size(130, 22);
+ this.Menu_ExportMAIN.Size = new System.Drawing.Size(152, 22);
this.Menu_ExportMAIN.Text = "&Export main";
this.Menu_ExportMAIN.Click += new System.EventHandler(this.clickExportSAV);
//
// Menu_ExportBAK
//
+ this.Menu_ExportBAK.Image = global::PKHeX.Properties.Resources.bak;
this.Menu_ExportBAK.Name = "Menu_ExportBAK";
this.Menu_ExportBAK.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.B)));
this.Menu_ExportBAK.ShowShortcutKeys = false;
- this.Menu_ExportBAK.Size = new System.Drawing.Size(130, 22);
+ this.Menu_ExportBAK.Size = new System.Drawing.Size(152, 22);
this.Menu_ExportBAK.Text = "Export &BAK";
this.Menu_ExportBAK.Click += new System.EventHandler(this.clickExportSAVBAK);
//
// Menu_Exit
//
+ this.Menu_Exit.Image = global::PKHeX.Properties.Resources.exit;
this.Menu_Exit.Name = "Menu_Exit";
this.Menu_Exit.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Q)));
this.Menu_Exit.ShowShortcutKeys = false;
- this.Menu_Exit.Size = new System.Drawing.Size(139, 22);
+ this.Menu_Exit.Size = new System.Drawing.Size(152, 22);
this.Menu_Exit.Text = "&Quit";
this.Menu_Exit.Click += new System.EventHandler(this.mainMenuExit);
//
@@ -2807,31 +2708,35 @@
this.Menu_ShowdownExportPK6,
this.Menu_ShowdownExportParty,
this.Menu_ShowdownExportBattleBox});
+ this.Menu_Showdown.Image = global::PKHeX.Properties.Resources.showdown;
this.Menu_Showdown.Name = "Menu_Showdown";
this.Menu_Showdown.Size = new System.Drawing.Size(143, 22);
this.Menu_Showdown.Text = "Showdown";
//
// Menu_ShowdownImportPK6
//
+ this.Menu_ShowdownImportPK6.Image = global::PKHeX.Properties.Resources.import;
this.Menu_ShowdownImportPK6.Name = "Menu_ShowdownImportPK6";
+ this.Menu_ShowdownImportPK6.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T)));
+ this.Menu_ShowdownImportPK6.ShowShortcutKeys = false;
this.Menu_ShowdownImportPK6.Size = new System.Drawing.Size(231, 22);
this.Menu_ShowdownImportPK6.Text = "Import Set from Clipboard";
this.Menu_ShowdownImportPK6.Click += new System.EventHandler(this.clickShowdownImportPK6);
- this.Menu_ShowdownImportPK6.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T)));
- this.Menu_ShowdownImportPK6.ShowShortcutKeys = false;
//
// Menu_ShowdownExportPK6
//
+ this.Menu_ShowdownExportPK6.Image = global::PKHeX.Properties.Resources.export;
this.Menu_ShowdownExportPK6.Name = "Menu_ShowdownExportPK6";
+ this.Menu_ShowdownExportPK6.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
+ | System.Windows.Forms.Keys.T)));
+ this.Menu_ShowdownExportPK6.ShowShortcutKeys = false;
this.Menu_ShowdownExportPK6.Size = new System.Drawing.Size(231, 22);
this.Menu_ShowdownExportPK6.Text = "Export Set to Clipboard";
this.Menu_ShowdownExportPK6.Click += new System.EventHandler(this.clickShowdownExportPK6);
- this.Menu_ShowdownExportPK6.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
- | System.Windows.Forms.Keys.T)));
- this.Menu_ShowdownExportPK6.ShowShortcutKeys = false;
//
// Menu_ShowdownExportParty
//
+ this.Menu_ShowdownExportParty.Image = global::PKHeX.Properties.Resources.export;
this.Menu_ShowdownExportParty.Name = "Menu_ShowdownExportParty";
this.Menu_ShowdownExportParty.Size = new System.Drawing.Size(231, 22);
this.Menu_ShowdownExportParty.Text = "Export Party to Clipboard";
@@ -2839,6 +2744,7 @@
//
// Menu_ShowdownExportBattleBox
//
+ this.Menu_ShowdownExportBattleBox.Image = global::PKHeX.Properties.Resources.export;
this.Menu_ShowdownExportBattleBox.Name = "Menu_ShowdownExportBattleBox";
this.Menu_ShowdownExportBattleBox.Size = new System.Drawing.Size(231, 22);
this.Menu_ShowdownExportBattleBox.Text = "Export Battle Box to Clipboard";
@@ -2849,12 +2755,14 @@
this.Menu_CyberGadget.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.Menu_OpenTemp,
this.Menu_OpenCache});
+ this.Menu_CyberGadget.Image = global::PKHeX.Properties.Resources.other;
this.Menu_CyberGadget.Name = "Menu_CyberGadget";
this.Menu_CyberGadget.Size = new System.Drawing.Size(143, 22);
this.Menu_CyberGadget.Text = "CyberGadget";
//
// Menu_OpenTemp
//
+ this.Menu_OpenTemp.Image = global::PKHeX.Properties.Resources.folder;
this.Menu_OpenTemp.Name = "Menu_OpenTemp";
this.Menu_OpenTemp.Size = new System.Drawing.Size(175, 22);
this.Menu_OpenTemp.Text = "Open Temp Folder";
@@ -2862,6 +2770,7 @@
//
// Menu_OpenCache
//
+ this.Menu_OpenCache.Image = global::PKHeX.Properties.Resources.folder;
this.Menu_OpenCache.Name = "Menu_OpenCache";
this.Menu_OpenCache.Size = new System.Drawing.Size(175, 22);
this.Menu_OpenCache.Text = "Open Cache Folder";
@@ -2874,12 +2783,14 @@
this.Menu_DumpBoxes,
this.Menu_Report,
this.Menu_Database});
+ this.Menu_Data.Image = global::PKHeX.Properties.Resources.data;
this.Menu_Data.Name = "Menu_Data";
this.Menu_Data.Size = new System.Drawing.Size(143, 22);
this.Menu_Data.Text = "Data";
//
// Menu_LoadBoxes
//
+ this.Menu_LoadBoxes.Image = global::PKHeX.Properties.Resources.load;
this.Menu_LoadBoxes.Name = "Menu_LoadBoxes";
this.Menu_LoadBoxes.Size = new System.Drawing.Size(151, 22);
this.Menu_LoadBoxes.Text = "Load Boxes";
@@ -2887,6 +2798,7 @@
//
// Menu_DumpBoxes
//
+ this.Menu_DumpBoxes.Image = global::PKHeX.Properties.Resources.dump;
this.Menu_DumpBoxes.Name = "Menu_DumpBoxes";
this.Menu_DumpBoxes.Size = new System.Drawing.Size(151, 22);
this.Menu_DumpBoxes.Text = "Dump Boxes";
@@ -2894,6 +2806,7 @@
//
// Menu_Report
//
+ this.Menu_Report.Image = global::PKHeX.Properties.Resources.report;
this.Menu_Report.Name = "Menu_Report";
this.Menu_Report.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.R)));
this.Menu_Report.ShowShortcutKeys = false;
@@ -2903,6 +2816,7 @@
//
// Menu_Database
//
+ this.Menu_Database.Image = global::PKHeX.Properties.Resources.database;
this.Menu_Database.Name = "Menu_Database";
this.Menu_Database.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D)));
this.Menu_Database.ShowShortcutKeys = false;
@@ -2915,12 +2829,14 @@
this.Menu_Other.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.Menu_OpenSDF,
this.Menu_OpenSDB});
+ this.Menu_Other.Image = global::PKHeX.Properties.Resources.other;
this.Menu_Other.Name = "Menu_Other";
this.Menu_Other.Size = new System.Drawing.Size(143, 22);
this.Menu_Other.Text = "Other";
//
// Menu_OpenSDF
//
+ this.Menu_OpenSDF.Image = global::PKHeX.Properties.Resources.folder;
this.Menu_OpenSDF.Name = "Menu_OpenSDF";
this.Menu_OpenSDF.Size = new System.Drawing.Size(229, 22);
this.Menu_OpenSDF.Text = "Open SaveDataFiler Folder";
@@ -2928,6 +2844,7 @@
//
// Menu_OpenSDB
//
+ this.Menu_OpenSDB.Image = global::PKHeX.Properties.Resources.folder;
this.Menu_OpenSDB.Name = "Menu_OpenSDB";
this.Menu_OpenSDB.Size = new System.Drawing.Size(229, 22);
this.Menu_OpenSDB.Text = "Open SaveDataBackup Folder";
@@ -2948,6 +2865,7 @@
//
this.Menu_Language.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.CB_MainLanguage});
+ this.Menu_Language.Image = global::PKHeX.Properties.Resources.language;
this.Menu_Language.Name = "Menu_Language";
this.Menu_Language.Size = new System.Drawing.Size(139, 22);
this.Menu_Language.Text = "Language";
@@ -2964,6 +2882,7 @@
this.Menu_Modify.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.Menu_ModifyDex,
this.Menu_ModifyPK6});
+ this.Menu_Modify.Image = global::PKHeX.Properties.Resources.settings;
this.Menu_Modify.Name = "Menu_Modify";
this.Menu_Modify.Size = new System.Drawing.Size(139, 22);
this.Menu_Modify.Text = "Set to SAV";
@@ -2986,7 +2905,7 @@
this.Menu_ModifyPK6.Name = "Menu_ModifyPK6";
this.Menu_ModifyPK6.Size = new System.Drawing.Size(159, 22);
this.Menu_ModifyPK6.Text = "Modify PK6 Info";
- this.Menu_ModifyPK6.Click += new System.EventHandler(this.mainMenuModifyPK6);
+ this.Menu_ModifyPK6.Click += new System.EventHandler(this.mainMenuModifyPKM);
//
// Menu_Unicode
//
@@ -3000,6 +2919,7 @@
//
// Menu_About
//
+ this.Menu_About.Image = global::PKHeX.Properties.Resources.about;
this.Menu_About.Name = "Menu_About";
this.Menu_About.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P)));
this.Menu_About.ShowShortcutKeys = false;
@@ -3830,7 +3750,6 @@
//
// Tab_Other
//
- this.Tab_Other.Controls.Add(this.B_OpenSecretBase);
this.Tab_Other.Controls.Add(this.GB_Daycare);
this.Tab_Other.Controls.Add(this.GB_GTS);
this.Tab_Other.Controls.Add(this.GB_Fused);
@@ -3843,17 +3762,6 @@
this.Tab_Other.Text = "Other";
this.Tab_Other.UseVisualStyleBackColor = true;
//
- // B_OpenSecretBase
- //
- this.B_OpenSecretBase.Location = new System.Drawing.Point(227, 151);
- this.B_OpenSecretBase.Name = "B_OpenSecretBase";
- this.B_OpenSecretBase.Size = new System.Drawing.Size(60, 37);
- this.B_OpenSecretBase.TabIndex = 21;
- this.B_OpenSecretBase.Text = "Secret Base";
- this.B_OpenSecretBase.UseVisualStyleBackColor = true;
- this.B_OpenSecretBase.Visible = false;
- this.B_OpenSecretBase.Click += new System.EventHandler(this.B_OpenSecretBase_Click);
- //
// GB_Daycare
//
this.GB_Daycare.Controls.Add(this.L_XP2);
@@ -4118,7 +4026,7 @@
this.TB_Secure2.Size = new System.Drawing.Size(120, 20);
this.TB_Secure2.TabIndex = 17;
this.TB_Secure2.Text = "0000000000000000";
- this.TB_Secure2.TextChanged += new System.EventHandler(this.updateSecure2);
+ this.TB_Secure2.TextChanged += new System.EventHandler(this.updateU64);
//
// L_Secure1
//
@@ -4139,11 +4047,10 @@
this.TB_Secure1.Size = new System.Drawing.Size(120, 20);
this.TB_Secure1.TabIndex = 15;
this.TB_Secure1.Text = "0000000000000000";
- this.TB_Secure1.TextChanged += new System.EventHandler(this.updateSecure1);
+ this.TB_Secure1.TextChanged += new System.EventHandler(this.updateU64);
//
// B_JPEG
//
- this.B_JPEG.Enabled = false;
this.B_JPEG.Location = new System.Drawing.Point(198, 20);
this.B_JPEG.Name = "B_JPEG";
this.B_JPEG.Size = new System.Drawing.Size(75, 45);
@@ -4171,7 +4078,7 @@
this.TB_GameSync.Size = new System.Drawing.Size(120, 20);
this.TB_GameSync.TabIndex = 10;
this.TB_GameSync.Text = "0000000000000000";
- this.TB_GameSync.TextChanged += new System.EventHandler(this.updateGameSync);
+ this.TB_GameSync.TextChanged += new System.EventHandler(this.updateU64);
//
// B_SaveBoxBin
//
@@ -4194,147 +4101,182 @@
this.B_VerifyCHK.UseVisualStyleBackColor = true;
this.B_VerifyCHK.Click += new System.EventHandler(this.clickVerifyCHK);
//
- // B_OpenHallofFame
+ // GB_SAVtools
//
- this.B_OpenHallofFame.Location = new System.Drawing.Point(230, 41);
- this.B_OpenHallofFame.Name = "B_OpenHallofFame";
- this.B_OpenHallofFame.Size = new System.Drawing.Size(75, 23);
- this.B_OpenHallofFame.TabIndex = 8;
- this.B_OpenHallofFame.Text = "Hall of Fame";
- this.B_OpenHallofFame.UseVisualStyleBackColor = true;
- this.B_OpenHallofFame.Click += new System.EventHandler(this.B_OUTHallofFame_Click);
+ this.GB_SAVtools.Controls.Add(this.FLP_SAVtools);
+ this.GB_SAVtools.Location = new System.Drawing.Point(300, 252);
+ this.GB_SAVtools.Name = "GB_SAVtools";
+ this.GB_SAVtools.Size = new System.Drawing.Size(308, 100);
+ this.GB_SAVtools.TabIndex = 100;
+ this.GB_SAVtools.TabStop = false;
//
- // B_OUTPasserby
+ // FLP_SAVtools
//
- this.B_OUTPasserby.Location = new System.Drawing.Point(230, 12);
- this.B_OUTPasserby.Name = "B_OUTPasserby";
- this.B_OUTPasserby.Size = new System.Drawing.Size(75, 23);
- this.B_OUTPasserby.TabIndex = 4;
- this.B_OUTPasserby.Text = "Passerby";
- this.B_OUTPasserby.UseVisualStyleBackColor = true;
- this.B_OUTPasserby.Click += new System.EventHandler(this.B_OUTPasserby_Click);
+ this.FLP_SAVtools.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.FLP_SAVtools.AutoScroll = true;
+ this.FLP_SAVtools.Controls.Add(this.B_OpenPokepuffs);
+ this.FLP_SAVtools.Controls.Add(this.B_OpenItemPouch);
+ this.FLP_SAVtools.Controls.Add(this.B_OpenTrainerInfo);
+ this.FLP_SAVtools.Controls.Add(this.B_OUTPasserby);
+ this.FLP_SAVtools.Controls.Add(this.B_OpenBoxLayout);
+ this.FLP_SAVtools.Controls.Add(this.B_OpenWondercards);
+ this.FLP_SAVtools.Controls.Add(this.B_OpenSuperTraining);
+ this.FLP_SAVtools.Controls.Add(this.B_OpenHallofFame);
+ this.FLP_SAVtools.Controls.Add(this.B_OpenOPowers);
+ this.FLP_SAVtools.Controls.Add(this.B_OpenEventFlags);
+ this.FLP_SAVtools.Controls.Add(this.B_OpenPokedex);
+ this.FLP_SAVtools.Controls.Add(this.B_OpenBerryField);
+ this.FLP_SAVtools.Controls.Add(this.B_OpenSecretBase);
+ this.FLP_SAVtools.Controls.Add(this.B_Pokeblocks);
+ this.FLP_SAVtools.Location = new System.Drawing.Point(6, 10);
+ this.FLP_SAVtools.Name = "FLP_SAVtools";
+ this.FLP_SAVtools.Size = new System.Drawing.Size(297, 87);
+ this.FLP_SAVtools.TabIndex = 101;
//
// B_OpenPokepuffs
//
- this.B_OpenPokepuffs.Location = new System.Drawing.Point(5, 12);
+ this.B_OpenPokepuffs.Location = new System.Drawing.Point(3, 3);
this.B_OpenPokepuffs.Name = "B_OpenPokepuffs";
- this.B_OpenPokepuffs.Size = new System.Drawing.Size(75, 23);
+ this.B_OpenPokepuffs.Size = new System.Drawing.Size(87, 23);
this.B_OpenPokepuffs.TabIndex = 1;
this.B_OpenPokepuffs.Text = "Poké Puffs";
this.B_OpenPokepuffs.UseVisualStyleBackColor = true;
this.B_OpenPokepuffs.Click += new System.EventHandler(this.B_OpenPokepuffs_Click);
//
- // B_OpenBoxLayout
- //
- this.B_OpenBoxLayout.Location = new System.Drawing.Point(5, 41);
- this.B_OpenBoxLayout.Name = "B_OpenBoxLayout";
- this.B_OpenBoxLayout.Size = new System.Drawing.Size(75, 23);
- this.B_OpenBoxLayout.TabIndex = 5;
- this.B_OpenBoxLayout.Text = "Box Layout";
- this.B_OpenBoxLayout.UseVisualStyleBackColor = true;
- this.B_OpenBoxLayout.Click += new System.EventHandler(this.B_OpenBoxLayout_Click);
- //
- // B_OpenOPowers
- //
- this.B_OpenOPowers.Location = new System.Drawing.Point(5, 70);
- this.B_OpenOPowers.Name = "B_OpenOPowers";
- this.B_OpenOPowers.Size = new System.Drawing.Size(75, 23);
- this.B_OpenOPowers.TabIndex = 9;
- this.B_OpenOPowers.Text = "O-Powers";
- this.B_OpenOPowers.UseVisualStyleBackColor = true;
- this.B_OpenOPowers.Click += new System.EventHandler(this.B_OpenOPowers_Click);
- //
// B_OpenItemPouch
//
- this.B_OpenItemPouch.Location = new System.Drawing.Point(80, 12);
+ this.B_OpenItemPouch.Location = new System.Drawing.Point(96, 3);
this.B_OpenItemPouch.Name = "B_OpenItemPouch";
- this.B_OpenItemPouch.Size = new System.Drawing.Size(75, 23);
+ this.B_OpenItemPouch.Size = new System.Drawing.Size(87, 23);
this.B_OpenItemPouch.TabIndex = 2;
this.B_OpenItemPouch.Text = "Items";
this.B_OpenItemPouch.UseVisualStyleBackColor = true;
this.B_OpenItemPouch.Click += new System.EventHandler(this.B_OpenItemPouch_Click);
//
- // B_OpenEventFlags
- //
- this.B_OpenEventFlags.Location = new System.Drawing.Point(80, 70);
- this.B_OpenEventFlags.Name = "B_OpenEventFlags";
- this.B_OpenEventFlags.Size = new System.Drawing.Size(75, 23);
- this.B_OpenEventFlags.TabIndex = 10;
- this.B_OpenEventFlags.Text = "Event Flags";
- this.B_OpenEventFlags.UseVisualStyleBackColor = true;
- this.B_OpenEventFlags.Click += new System.EventHandler(this.B_OpenEventFlags_Click);
- //
- // B_OpenWondercards
- //
- this.B_OpenWondercards.Location = new System.Drawing.Point(80, 41);
- this.B_OpenWondercards.Name = "B_OpenWondercards";
- this.B_OpenWondercards.Size = new System.Drawing.Size(75, 23);
- this.B_OpenWondercards.TabIndex = 6;
- this.B_OpenWondercards.Text = "Wondercard";
- this.B_OpenWondercards.UseVisualStyleBackColor = true;
- this.B_OpenWondercards.Click += new System.EventHandler(this.B_OpenWondercards_Click);
- //
// B_OpenTrainerInfo
//
- this.B_OpenTrainerInfo.Location = new System.Drawing.Point(155, 12);
+ this.B_OpenTrainerInfo.Location = new System.Drawing.Point(189, 3);
this.B_OpenTrainerInfo.Name = "B_OpenTrainerInfo";
- this.B_OpenTrainerInfo.Size = new System.Drawing.Size(75, 23);
+ this.B_OpenTrainerInfo.Size = new System.Drawing.Size(87, 23);
this.B_OpenTrainerInfo.TabIndex = 3;
this.B_OpenTrainerInfo.Text = "Trainer Info";
this.B_OpenTrainerInfo.UseVisualStyleBackColor = true;
this.B_OpenTrainerInfo.Click += new System.EventHandler(this.B_OpenTrainerInfo_Click);
//
- // B_OpenBerryField
+ // B_OUTPasserby
//
- this.B_OpenBerryField.Location = new System.Drawing.Point(230, 70);
- this.B_OpenBerryField.Name = "B_OpenBerryField";
- this.B_OpenBerryField.Size = new System.Drawing.Size(75, 23);
- this.B_OpenBerryField.TabIndex = 12;
- this.B_OpenBerryField.Text = "Berry Field";
- this.B_OpenBerryField.UseVisualStyleBackColor = true;
- this.B_OpenBerryField.Click += new System.EventHandler(this.B_OpenBerryField_Click);
+ this.B_OUTPasserby.Location = new System.Drawing.Point(3, 32);
+ this.B_OUTPasserby.Name = "B_OUTPasserby";
+ this.B_OUTPasserby.Size = new System.Drawing.Size(87, 23);
+ this.B_OUTPasserby.TabIndex = 4;
+ this.B_OUTPasserby.Text = "Passerby";
+ this.B_OUTPasserby.UseVisualStyleBackColor = true;
+ this.B_OUTPasserby.Click += new System.EventHandler(this.B_OUTPasserby_Click);
+ //
+ // B_OpenBoxLayout
+ //
+ this.B_OpenBoxLayout.Location = new System.Drawing.Point(96, 32);
+ this.B_OpenBoxLayout.Name = "B_OpenBoxLayout";
+ this.B_OpenBoxLayout.Size = new System.Drawing.Size(87, 23);
+ this.B_OpenBoxLayout.TabIndex = 5;
+ this.B_OpenBoxLayout.Text = "Box Layout";
+ this.B_OpenBoxLayout.UseVisualStyleBackColor = true;
+ this.B_OpenBoxLayout.Click += new System.EventHandler(this.B_OpenBoxLayout_Click);
+ //
+ // B_OpenWondercards
+ //
+ this.B_OpenWondercards.Location = new System.Drawing.Point(189, 32);
+ this.B_OpenWondercards.Name = "B_OpenWondercards";
+ this.B_OpenWondercards.Size = new System.Drawing.Size(87, 23);
+ this.B_OpenWondercards.TabIndex = 6;
+ this.B_OpenWondercards.Text = "Wondercard";
+ this.B_OpenWondercards.UseVisualStyleBackColor = true;
+ this.B_OpenWondercards.Click += new System.EventHandler(this.B_OpenWondercards_Click);
+ //
+ // B_OpenSuperTraining
+ //
+ this.B_OpenSuperTraining.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.B_OpenSuperTraining.Location = new System.Drawing.Point(3, 61);
+ this.B_OpenSuperTraining.Name = "B_OpenSuperTraining";
+ this.B_OpenSuperTraining.Size = new System.Drawing.Size(87, 23);
+ this.B_OpenSuperTraining.TabIndex = 7;
+ this.B_OpenSuperTraining.Text = "Super Train";
+ this.B_OpenSuperTraining.UseVisualStyleBackColor = true;
+ this.B_OpenSuperTraining.Click += new System.EventHandler(this.B_OpenSuperTraining_Click);
+ //
+ // B_OpenHallofFame
+ //
+ this.B_OpenHallofFame.Location = new System.Drawing.Point(96, 61);
+ this.B_OpenHallofFame.Name = "B_OpenHallofFame";
+ this.B_OpenHallofFame.Size = new System.Drawing.Size(87, 23);
+ this.B_OpenHallofFame.TabIndex = 8;
+ this.B_OpenHallofFame.Text = "Hall of Fame";
+ this.B_OpenHallofFame.UseVisualStyleBackColor = true;
+ this.B_OpenHallofFame.Click += new System.EventHandler(this.B_OUTHallofFame_Click);
+ //
+ // B_OpenOPowers
+ //
+ this.B_OpenOPowers.Location = new System.Drawing.Point(189, 61);
+ this.B_OpenOPowers.Name = "B_OpenOPowers";
+ this.B_OpenOPowers.Size = new System.Drawing.Size(87, 23);
+ this.B_OpenOPowers.TabIndex = 9;
+ this.B_OpenOPowers.Text = "O-Powers";
+ this.B_OpenOPowers.UseVisualStyleBackColor = true;
+ this.B_OpenOPowers.Click += new System.EventHandler(this.B_OpenOPowers_Click);
+ //
+ // B_OpenEventFlags
+ //
+ this.B_OpenEventFlags.Location = new System.Drawing.Point(3, 90);
+ this.B_OpenEventFlags.Name = "B_OpenEventFlags";
+ this.B_OpenEventFlags.Size = new System.Drawing.Size(87, 23);
+ this.B_OpenEventFlags.TabIndex = 10;
+ this.B_OpenEventFlags.Text = "Event Flags";
+ this.B_OpenEventFlags.UseVisualStyleBackColor = true;
+ this.B_OpenEventFlags.Click += new System.EventHandler(this.B_OpenEventFlags_Click);
//
// B_OpenPokedex
//
- this.B_OpenPokedex.Location = new System.Drawing.Point(155, 70);
+ this.B_OpenPokedex.Location = new System.Drawing.Point(96, 90);
this.B_OpenPokedex.Name = "B_OpenPokedex";
- this.B_OpenPokedex.Size = new System.Drawing.Size(75, 23);
+ this.B_OpenPokedex.Size = new System.Drawing.Size(87, 23);
this.B_OpenPokedex.TabIndex = 11;
this.B_OpenPokedex.Text = "Pokédex";
this.B_OpenPokedex.UseVisualStyleBackColor = true;
this.B_OpenPokedex.Click += new System.EventHandler(this.B_OpenPokedex_Click);
//
- // GB_SAVtools
+ // B_OpenBerryField
//
- this.GB_SAVtools.Controls.Add(this.B_OpenSuperTraining);
- this.GB_SAVtools.Controls.Add(this.B_OpenPokedex);
- this.GB_SAVtools.Controls.Add(this.B_OpenHallofFame);
- this.GB_SAVtools.Controls.Add(this.B_OpenBerryField);
- this.GB_SAVtools.Controls.Add(this.B_OpenBoxLayout);
- this.GB_SAVtools.Controls.Add(this.B_OpenTrainerInfo);
- this.GB_SAVtools.Controls.Add(this.B_OUTPasserby);
- this.GB_SAVtools.Controls.Add(this.B_OpenWondercards);
- this.GB_SAVtools.Controls.Add(this.B_OpenEventFlags);
- this.GB_SAVtools.Controls.Add(this.B_OpenItemPouch);
- this.GB_SAVtools.Controls.Add(this.B_OpenOPowers);
- this.GB_SAVtools.Controls.Add(this.B_OpenPokepuffs);
- this.GB_SAVtools.Enabled = false;
- this.GB_SAVtools.Location = new System.Drawing.Point(300, 254);
- this.GB_SAVtools.Name = "GB_SAVtools";
- this.GB_SAVtools.Size = new System.Drawing.Size(310, 100);
- this.GB_SAVtools.TabIndex = 100;
- this.GB_SAVtools.TabStop = false;
+ this.B_OpenBerryField.Location = new System.Drawing.Point(189, 90);
+ this.B_OpenBerryField.Name = "B_OpenBerryField";
+ this.B_OpenBerryField.Size = new System.Drawing.Size(87, 23);
+ this.B_OpenBerryField.TabIndex = 12;
+ this.B_OpenBerryField.Text = "Berry Field";
+ this.B_OpenBerryField.UseVisualStyleBackColor = true;
+ this.B_OpenBerryField.Click += new System.EventHandler(this.B_OpenBerryField_Click);
//
- // B_OpenSuperTraining
+ // B_OpenSecretBase
//
- this.B_OpenSuperTraining.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.B_OpenSuperTraining.Location = new System.Drawing.Point(155, 41);
- this.B_OpenSuperTraining.Name = "B_OpenSuperTraining";
- this.B_OpenSuperTraining.Size = new System.Drawing.Size(75, 23);
- this.B_OpenSuperTraining.TabIndex = 7;
- this.B_OpenSuperTraining.Text = "Super Train";
- this.B_OpenSuperTraining.UseVisualStyleBackColor = true;
- this.B_OpenSuperTraining.Click += new System.EventHandler(this.B_OpenSuperTraining_Click);
+ this.B_OpenSecretBase.Location = new System.Drawing.Point(3, 119);
+ this.B_OpenSecretBase.Name = "B_OpenSecretBase";
+ this.B_OpenSecretBase.Size = new System.Drawing.Size(87, 23);
+ this.B_OpenSecretBase.TabIndex = 21;
+ this.B_OpenSecretBase.Text = "Secret Base";
+ this.B_OpenSecretBase.UseVisualStyleBackColor = true;
+ this.B_OpenSecretBase.Visible = false;
+ this.B_OpenSecretBase.Click += new System.EventHandler(this.B_OpenSecretBase_Click);
+ //
+ // B_Pokeblocks
+ //
+ this.B_Pokeblocks.Location = new System.Drawing.Point(96, 119);
+ this.B_Pokeblocks.Name = "B_Pokeblocks";
+ this.B_Pokeblocks.Size = new System.Drawing.Size(87, 23);
+ this.B_Pokeblocks.TabIndex = 22;
+ this.B_Pokeblocks.Text = "Pokéblocks";
+ this.B_Pokeblocks.UseVisualStyleBackColor = true;
+ this.B_Pokeblocks.Visible = false;
+ this.B_Pokeblocks.Click += new System.EventHandler(this.B_OpenPokeblocks_Click);
//
// dragout
//
@@ -4400,11 +4342,11 @@
this.ClientSize = new System.Drawing.Size(614, 361);
this.Controls.Add(this.PB_Legal);
this.Controls.Add(this.dragout);
- this.Controls.Add(this.GB_SAVtools);
this.Controls.Add(this.tabBoxMulti);
this.Controls.Add(this.L_Save);
this.Controls.Add(this.tabMain);
this.Controls.Add(this.menuStrip1);
+ this.Controls.Add(this.GB_SAVtools);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.KeyPreview = true;
@@ -4440,15 +4382,15 @@
this.GB_nOT.ResumeLayout(false);
this.GB_nOT.PerformLayout();
this.GB_Markings.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.PB_MarkPentagon)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.PB_MarkCured)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.PB_MarkShiny)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Mark6)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.PB_Mark5)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.PB_Mark4)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.PB_MarkPentagon)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Mark3)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.PB_Mark5)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.PB_MarkCured)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Mark2)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.PB_MarkShiny)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Mark1)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.PB_Mark4)).EndInit();
this.GB_ExtraBytes.ResumeLayout(false);
this.GB_ExtraBytes.PerformLayout();
this.GB_OT.ResumeLayout(false);
@@ -4528,6 +4470,7 @@
this.Tab_SAV.ResumeLayout(false);
this.Tab_SAV.PerformLayout();
this.GB_SAVtools.ResumeLayout(false);
+ this.FLP_SAVtools.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dragout)).EndInit();
this.mnuL.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.PB_Legal)).EndInit();
@@ -4570,12 +4513,6 @@
private System.Windows.Forms.Button BTN_History;
private System.Windows.Forms.Button BTN_Ribbons;
private System.Windows.Forms.GroupBox GB_Markings;
- private System.Windows.Forms.CheckBox CHK_Diamond;
- private System.Windows.Forms.CheckBox CHK_Square;
- private System.Windows.Forms.CheckBox CHK_Star;
- private System.Windows.Forms.CheckBox CHK_Triangle;
- private System.Windows.Forms.CheckBox CHK_Heart;
- private System.Windows.Forms.CheckBox CHK_Circle;
private System.Windows.Forms.GroupBox GB_ExtraBytes;
private System.Windows.Forms.ComboBox CB_ExtraBytes;
public System.Windows.Forms.GroupBox GB_OT;
@@ -4665,7 +4602,6 @@
private System.Windows.Forms.CheckBox CHK_Nicknamed;
private System.Windows.Forms.Button BTN_Shinytize;
private System.Windows.Forms.MaskedTextBox TB_AbilityNumber;
- private System.Windows.Forms.Label Label_Diamond;
private System.Windows.Forms.MaskedTextBox TB_MetLevel;
public System.Windows.Forms.GroupBox GB_nOT;
private System.Windows.Forms.MenuStrip menuStrip1;
@@ -4689,7 +4625,6 @@
private System.Windows.Forms.Button B_OpenTrainerInfo;
private System.Windows.Forms.Button B_OpenBerryField;
private System.Windows.Forms.Button B_OpenPokedex;
- private System.Windows.Forms.GroupBox GB_SAVtools;
private System.Windows.Forms.TabPage Tab_Other;
private System.Windows.Forms.Label L_BattleBox;
private System.Windows.Forms.Label L_Party;
@@ -4783,7 +4718,6 @@
private System.Windows.Forms.PictureBox PB_Mark4;
private System.Windows.Forms.PictureBox PB_Mark3;
private System.Windows.Forms.PictureBox PB_Mark2;
- private System.Windows.Forms.PictureBox PB_Mark1;
private System.Windows.Forms.PictureBox Label_IsShiny;
private System.Windows.Forms.Panel PAN_Party;
private System.Windows.Forms.Panel PAN_BattleBox;
@@ -4870,6 +4804,10 @@
private System.Windows.Forms.ToolStripMenuItem mnuLLegality;
private System.Windows.Forms.ToolStripMenuItem mnuLQR;
private System.Windows.Forms.PictureBox PB_Legal;
+ private System.Windows.Forms.FlowLayoutPanel FLP_SAVtools;
+ private System.Windows.Forms.GroupBox GB_SAVtools;
+ private System.Windows.Forms.PictureBox PB_Mark1;
+ private System.Windows.Forms.Button B_Pokeblocks;
}
}
diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs
index 7cd6a5fef..153d0f277 100644
--- a/PKX/f1-Main.cs
+++ b/PKX/f1-Main.cs
@@ -17,10 +17,13 @@ namespace PKHeX
{
#region Initialize Form
new Thread(() => new SplashScreen().ShowDialog()).Start();
+ pkm_from = SAV.BlankPKM.EncryptedPartyData;
InitializeComponent();
- // Initialize SAV-Set Parameters in case compilation settings were changed.
- SAV6.SetUpdateDex = Menu_ModifyDex.Checked;
- SAV6.SetUpdatePK6 = Menu_ModifyPK6.Checked;
+ CB_ExtraBytes.SelectedIndex = 0;
+ SaveFile.SetUpdateDex = Menu_ModifyDex.Checked;
+ SaveFile.SetUpdatePKM = Menu_ModifyPK6.Checked;
+
+ // Set up form properties and arrays.
SlotPictureBoxes = new[] {
bpkx1, bpkx2, bpkx3, bpkx4, bpkx5, bpkx6,
bpkx7, bpkx8, bpkx9, bpkx10,bpkx11,bpkx12,
@@ -37,24 +40,18 @@ namespace PKHeX
movePB = new[] { PB_WarnMove1, PB_WarnMove2, PB_WarnMove3, PB_WarnMove4 };
defaultControlWhite = CB_Species.BackColor;
defaultControlText = Label_Species.ForeColor;
- CB_ExtraBytes.SelectedIndex = 0;
-
- // Initialize Boxes
- for (int i = 0; i < 30*31; i++)
- SAV.setData(blankEK6, SAV.Box + i*PK6.SIZE_STORED);
// Set up Language Selection
foreach (var cbItem in main_langlist)
CB_MainLanguage.Items.Add(cbItem);
// ToolTips for Drag&Drop
- new ToolTip().SetToolTip(dragout, "PK6 QuickSave");
+ new ToolTip().SetToolTip(dragout, "PKM QuickSave");
// Box Drag & Drop
foreach (PictureBox pb in PAN_Box.Controls)
{
- pb.AllowDrop = true;
- // The PictureBoxes have their own drag&drop event handlers.
+ pb.AllowDrop = true; // The PictureBoxes have their own drag&drop event handlers (pbBoxSlot)
}
foreach (TabPage tab in tabMain.TabPages)
{
@@ -68,67 +65,6 @@ namespace PKHeX
tab.DragDrop += tabMain_DragDrop;
tab.DragEnter += tabMain_DragEnter;
}
- // Box to Tabs D&D
- dragout.AllowDrop = true;
-
- string[] args = Environment.GetCommandLineArgs();
- string filename = args.Length > 0 ? Path.GetFileNameWithoutExtension(args[0]).ToLower() : "";
- HaX = filename.IndexOf("hax", StringComparison.Ordinal) >= 0;
- // Show Hacked Stuff if HaX
- CHK_HackedStats.Enabled = CHK_HackedStats.Visible = DEV_Ability.Enabled = DEV_Ability.Visible =
- MT_Level.Enabled = MT_Level.Visible = TB_AbilityNumber.Visible = MT_Form.Enabled = MT_Form.Visible = HaX;
- // Hide Regular Stuff if !HaX
- TB_Level.Visible = CB_Ability.Visible = !HaX;
- // Load WC6 folder to legality
- refreshWC6DB();
-
- Menu_Modify.DropDown.Closing += (sender, e) =>
- {
- if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked)
- e.Cancel = true;
- };
- #endregion
- #region Localize & Populate Fields
- // Try and detect the language
- string lastTwoChars = filename.Length > 2 ? filename.Substring(filename.Length - 2) : "";
- if (lastTwoChars == "jp") lastTwoChars = "ja";
- int lang = Array.IndexOf(lang_val, lastTwoChars);
- CB_MainLanguage.SelectedIndex = lang < 0 ? 1 : lang;
-
- InitializeFields();
- #endregion
- #region Load Initial File(s)
- // Load the arguments
- pathSDF = Util.GetSDFLocation();
- path3DS = Util.get3DSLocation();
- string pathCache = Util.GetCacheFolder();
- if (args.Length > 1)
- {
- foreach (string arg in args.Skip(1).Where(a => a.Length > 4))
- openQuick(arg);
- }
- else if (path3DS != null && File.Exists(Path.Combine(Path.GetPathRoot(path3DS), "SaveDataBackup", "main")))
- openQuick(Path.Combine(Path.GetPathRoot(path3DS), "SaveDataBackup", "main"));
- else if (pathSDF != null)
- openQuick(Path.Combine(pathSDF, "main"));
- else if (path3DS != null && Directory.Exists(Path.Combine(Path.GetPathRoot(path3DS), "JKSV", "Saves")))
- {
- string[] files = Directory.GetFiles(Path.Combine(Path.GetPathRoot(path3DS), "JKSV", "Saves"), "main", SearchOption.AllDirectories);
- string file = files.Where(f => SAV6.SizeValid((int)new FileInfo(f).Length)) // filter
- .OrderByDescending(f => new FileInfo(f).LastWriteTime).FirstOrDefault();
-
- if (file != null)
- openQuick(file);
- }
- else if (Directory.Exists(pathCache))
- {
- string file = Directory.GetFiles(pathCache).Where(f => SAV6.SizeValid((int)new FileInfo(f).Length)) // filter
- .OrderByDescending(f => new FileInfo(f).LastWriteTime).FirstOrDefault();
- if (file != null)
- openQuick(file);
- }
- else if (File.Exists(Util.NormalizePath(Path.Combine(Util.GetTempFolder(), "root", "main"))))
- openQuick(Util.NormalizePath(Path.Combine(Util.GetTempFolder(), "root", "main")));
GB_OT.Click += clickGT;
GB_nOT.Click += clickGT;
@@ -138,7 +74,46 @@ namespace PKHeX
TB_Nickname.Font = PKX.getPKXFont(11);
TB_OT.Font = (Font)TB_Nickname.Font.Clone();
TB_OTt2.Font = (Font)TB_Nickname.Font.Clone();
+
+ Menu_Modify.DropDown.Closing += (sender, e) =>
+ {
+ if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked)
+ e.Cancel = true;
+ };
+
+ // Box to Tabs D&D
+ dragout.AllowDrop = true;
+
+ // Load WC6 folder to legality
+ refreshWC6DB();
+
+ #endregion
+ #region Localize & Populate Fields
+ string[] args = Environment.GetCommandLineArgs();
+ string filename = args.Length > 0 ? Path.GetFileNameWithoutExtension(args[0]).ToLower() : "";
+ HaX = filename.IndexOf("hax", StringComparison.Ordinal) >= 0;
+
+ // Try and detect the language
+ string lastTwoChars = filename.Length > 2 ? filename.Substring(filename.Length - 2) : "";
+ if (lastTwoChars == "jp") lastTwoChars = "ja";
+ int lang = Array.IndexOf(lang_val, lastTwoChars);
+ CB_MainLanguage.SelectedIndex = lang < 0 ? 1 : lang;
+
+ InitializeFields();
formInitialized = true;
+ #endregion
+ #region Load Initial File(s)
+ if (args.Length > 1) // Load the arguments
+ {
+ foreach (string arg in args.Skip(1).Where(a => a.Length > 4))
+ openQuick(arg, force: true);
+ }
+ else // Detect save
+ {
+ string path = detectSaveFile();
+ if (path != null)
+ openQuick(path, force: true);
+ }
// Splash Screen closes on its own.
BringToFront();
@@ -150,15 +125,14 @@ namespace PKHeX
}
#region Important Variables
- public static readonly byte[] blankEK6 = PKX.encryptArray(new byte[PK6.SIZE_PARTY]);
- public static PK6 pk6 = new PK6(); // Tab Pokemon Data Storage
- public static SAV6 SAV = new SAV6 { Game = (int)GameVersion.AS, OT = "PKHeX", TID = 12345, SID = 54321, Language = 2, Country = 49, SubRegion = 7}; // Save File
- public static Color defaultControlWhite;
- public static Color defaultControlText;
+ public static PKM pkm = new PK6(); // Tab Pokemon Data Storage
+ public static SaveFile SAV = new SAV6 { Game = (int)GameVersion.AS, OT = "PKHeX", TID = 12345, SID = 54321, Language = 2, Country = 49, SubRegion = 7 }; // Save File
+ public static Color defaultControlWhite, defaultControlText;
public static string eggname = "";
public const string DatabasePath = "db";
private const string WC6DatabasePath = "wc6";
private const string BackupPath = "bak";
+ public static string curlanguage = "en";
public static string[] gendersymbols = { "♂", "♀", "-" };
public static string[] specieslist, movelist, itemlist, abilitylist, types, natures, forms,
memories, genloc, trainingbags, trainingstage, characteristics,
@@ -167,18 +141,15 @@ namespace PKHeX
public static string[] metBW2_00000, metBW2_30000, metBW2_40000, metBW2_60000 = { };
public static string[] metXY_00000, metXY_30000, metXY_40000, metXY_60000 = { };
public static string[] wallpapernames, puffs, itempouch = { };
- public static string curlanguage = "en";
public static bool unicode;
public static List MoveDataSource, ItemDataSource, SpeciesDataSource, BallDataSource, NatureDataSource, AbilityDataSource, VersionDataSource;
public static volatile bool formInitialized, fieldsInitialized, fieldsLoaded;
- private static int colorizedbox = 32;
+ private static int colorizedbox = -1;
private static Image colorizedcolor;
private static int colorizedslot;
- private static string pathSDF;
- private static string path3DS;
private static bool HaX;
- private LegalityAnalysis Legality = new LegalityAnalysis(new PK6());
+ private LegalityAnalysis Legality = new LegalityAnalysis(new PK3());
private static readonly Image mixedHighlight = Util.ChangeOpacity(Properties.Resources.slotSet, 0.5);
private static readonly string[] lang_val = { "ja", "en", "fr", "it", "de", "es", "ko", "zh", "pt" };
private static readonly string[] main_langlist =
@@ -218,26 +189,13 @@ namespace PKHeX
ofd.InitialDirectory = Environment.CurrentDirectory;
// Detect main
- string cyberpath = Util.GetTempFolder();
- pathSDF = Util.GetSDFLocation();
- path3DS = Util.get3DSLocation();
- string pathCache = Util.GetCacheFolder();
- if (path3DS != null && File.Exists(Path.Combine(Path.GetPathRoot(path3DS), "SaveDataBackup", "main")))
- ofd.InitialDirectory = Path.Combine(Path.GetPathRoot(path3DS), "SaveDataBackup");
- else if (pathSDF != null)
- ofd.InitialDirectory = pathSDF;
- else if (path3DS != null && Directory.Exists(Path.Combine(Path.GetPathRoot(path3DS), "JKSV", "Saves")))
- ofd.InitialDirectory = Path.Combine(Path.GetPathRoot(path3DS), "JKSV", "Saves");
- else if (path3DS != null)
- ofd.InitialDirectory = Path.GetPathRoot(path3DS);
- else if (Directory.Exists(Path.Combine(cyberpath, "root")))
- ofd.InitialDirectory = Path.Combine(cyberpath, "root");
- else if (Directory.Exists(pathCache))
- ofd.InitialDirectory = pathCache;
- else if (Directory.Exists(cyberpath))
- ofd.InitialDirectory = cyberpath;
- else if (File.Exists(Path.Combine(ofd.InitialDirectory, "main"))) { }
- else { ofd.RestoreDirectory = false; ofd.FilterIndex = 1; ofd.FileName = ""; }
+ string path = detectSaveFile();
+ if (path != null)
+ { ofd.InitialDirectory = Path.GetDirectoryName(path); }
+ else if (File.Exists(Path.Combine(ofd.InitialDirectory, "main")))
+ { }
+ else if (!Directory.Exists(ofd.InitialDirectory))
+ { ofd.RestoreDirectory = false; ofd.FilterIndex = 1; ofd.FileName = ""; }
if (ofd.ShowDialog() == DialogResult.OK)
openQuick(ofd.FileName);
@@ -245,7 +203,7 @@ namespace PKHeX
private void mainMenuSave(object sender, EventArgs e)
{
if (!verifiedPKX()) return;
- PK6 pk = preparepkx();
+ PKM pk = preparePKM();
SaveFileDialog sfd = new SaveFileDialog
{
Filter = "PKX File|*.pk6;*.pkx" +
@@ -275,7 +233,7 @@ namespace PKHeX
else
{
Util.Error($"Foreign File Extension: {ext}", "Exporting as encrypted.");
- File.WriteAllBytes(path, pk6.EncryptedPartyData);
+ File.WriteAllBytes(path, pkm.EncryptedPartyData);
}
}
private void mainMenuExit(object sender, EventArgs e)
@@ -295,10 +253,10 @@ namespace PKHeX
var z = Application.OpenForms.Cast