Fix conversion issues

pk5->pk6 conversion was missing Gender/AltForm definition.
This commit is contained in:
Kurt 2015-12-29 10:28:24 -08:00
parent aa7974e158
commit b9af9deac8
4 changed files with 140 additions and 3 deletions

View file

@ -135,6 +135,43 @@ namespace PKHeX
// Simple Generated Attributes
public bool Japanese { get { return Language == 1; } }
public bool Gen3 { get { return ((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()
{
@ -243,6 +280,15 @@ namespace PKHeX
pk4.Gender = PKM.getGender(pk4.Species, pk4.PID);
pk4.IsNicknamed |= (pk4.Nickname != PKM.getSpeciesName(pk4.Species, pk4.Language));
// 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;
}

View file

@ -276,7 +276,6 @@ namespace PKHeX
}
}
public int[] EVs { get { return new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD }; } }
public int[] Moves { get { return new[] { Move1, Move2, Move3, Move4 }; } }
public int PSV { get { return (int)(((PID >> 16) ^ (PID & 0xFFFF)) >> 3); } }
public int TSV { get { return (TID ^ SID) >> 3; } }
public bool IsShiny { get { return TSV == PSV; } }
@ -285,6 +284,17 @@ namespace PKHeX
public bool Gen4 { get { return (Version >= 10 && Version < 12) || (Version >= 7 && Version <= 8); } }
public bool Gen3 { get { return ((Version >= 1 && Version <= 5) || Version == 15); } }
public bool GenU { get { return !(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];
}
}
// Complex Generated Attributes
public int Characteristic
@ -353,6 +363,30 @@ namespace PKHeX
return false;
}
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 PK5 convertToPK5()
{
@ -401,6 +435,18 @@ namespace PKHeX
// Fix Level
pk5.Met_Level = PKX.getLevel(pk5.Species, pk5.EXP);
// Remove HM moves; Defog should be kept if both are learned.
int[] banned = Moves.Contains(250) /*Whirlpool*/ && !Moves.Contains(432) /*Defog*/
? new[] {15, 19, 57, 70, 432, 249, 127, 431} // No Defog
: new[] {15, 19, 57, 70, 250, 249, 127, 431};// No Whirlpool
int[] newMoves = pk5.Moves;
for (int i = 0; i < 4; i++)
if (banned.Contains(newMoves[i]))
newMoves[i] = 0;
pk5.Moves = newMoves;
pk5.FixMoves();
pk5.RefreshChecksum();
return pk5;
}

View file

@ -278,7 +278,6 @@ namespace PKHeX
}
}
public int[] EVs { get { return new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD }; } }
public int[] Moves { get { return new[] { Move1, Move2, Move3, Move4 }; } }
public int PSV { get { return (int)(((PID >> 16) ^ (PID & 0xFFFF)) >> 3); } }
public int TSV { get { return (TID ^ SID) >> 3; } }
public bool IsShiny { get { return TSV == PSV; } }
@ -288,6 +287,13 @@ namespace PKHeX
public bool Gen4 { get { return (Version >= 10 && Version < 12) || (Version >= 7 && Version <= 8); } }
public bool Gen3 { get { return ((Version >= 1 && Version <= 5) || Version == 15); } }
public bool GenU { get { return !(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]; } }
// Complex Generated Attributes
public int Characteristic
@ -354,6 +360,30 @@ namespace PKHeX
return true;
return false;
}
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 PK6 convertToPK6()
{
@ -422,6 +452,8 @@ namespace PKHeX
pk6.IsNicknamed = IsNicknamed;
pk6.FatefulEncounter = FatefulEncounter;
pk6.Gender = Gender;
pk6.AltForm = AltForm;
pk6.Nature = Nature;
pk6.Nickname = Nickname.Length > 1 && !IsNicknamed
@ -560,6 +592,9 @@ namespace PKHeX
if (XOR >= 8 && XOR < 16) // If we get an illegal collision...
pk6.PID ^= 0x80000000;
// HMs are not deleted 5->6, transfer away (but fix if blank spots?)
pk6.FixMoves();
// Fix Checksum
pk6.RefreshChecksum();

View file

@ -417,7 +417,6 @@ namespace PKHeX
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 }; } }
public int[] Moves { get { return new[] { Move1, Move2, Move3, Move4 }; } }
public int PSV { get { return (int)(((PID >> 16) ^ (PID & 0xFFFF)) >> 4); } }
public int TSV { get { return (TID ^ SID) >> 4; } }
public bool IsShiny { get { return TSV == PSV; } }
@ -430,6 +429,17 @@ namespace PKHeX
public bool Gen4 { get { return (Version >= 10 && Version < 12) || (Version >= 7 && Version <= 8); } }
public bool Gen3 { get { return ((Version >= 1 && Version <= 5) || Version == 15); } }
public bool GenU { get { return !(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];
}
}
// Complex Generated Attributes
public Image Sprite { get { return getSprite(this); } }