Relocate transfer block cases to separate method

#1559
This commit is contained in:
Kurt
2017-11-06 18:34:35 -08:00
parent 9cac3738dc
commit 062684f4a6

View File

@@ -213,6 +213,9 @@ public static PKM ConvertToType(PKM pk, Type PKMType, out string comment)
return pk;
}
if (IsNotTransferrable(pk, out comment))
return null;
Debug.WriteLine($"Trying to convert {fromType.Name} to {PKMType.Name}.");
int fromFormat = int.Parse(fromType.Name.Last().ToString());
@@ -279,11 +282,6 @@ public static PKM ConvertToType(PKM pk, Type PKMType, out string comment)
pkm = ((PK4) pkm).ConvertToBK4();
break;
}
if (pkm.Species == 172 && pkm.AltForm != 0)
{
comment = "Cannot transfer Spiky-Eared Pichu forward.";
return null;
}
pkm = ((PK4) pkm).ConvertToPK5();
if (toFormat == 5)
break;
@@ -314,6 +312,28 @@ public static PKM ConvertToType(PKM pk, Type PKMType, out string comment)
return pkm;
}
/// <summary>
/// Checks to see if a PKM is transferrable relative to in-game restrictions and <see cref="PKM.AltForm"/>.
/// </summary>
/// <param name="pk">PKM to convert</param>
/// <param name="comment">Comment indicating why the <see cref="PKM"/> is not transferrable.</param>
/// <returns>Indication if Not Transferrable</returns>
private static bool IsNotTransferrable(PKM pk, out string comment)
{
switch (pk.Species)
{
default:
comment = null;
return false;
case 025 when pk.AltForm != 0 && pk.GenNumber == 6: // Cosplay Pikachu
comment = "Cannot transfer Cosplay Pikachu forward.";
return true;
case 172 when pk.AltForm != 0 && pk.GenNumber == 4: // Spiky Eared Pichu
comment = "Cannot transfer Spiky-Eared Pichu forward.";
return true;
}
}
/// <summary>
/// Converts a PKM from one Generation 3 format to another. If it matches the destination format, the conversion will automatically return.
/// </summary>