Remove usage of LegalityAnalysis from PK*

CK3<->XK3 transfers to PK3 first now (no direct transfer legally)
This commit is contained in:
Kurt
2017-12-06 21:28:34 -08:00
parent bd9f7fc7e2
commit f9946368a0
3 changed files with 131 additions and 6 deletions

View File

@@ -262,5 +262,78 @@ public static partial class Legal
{
196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212,
}));
/// <summary>
/// Species ID that can be originated from Colosseum (using only Generation 3 max Species ID values).
/// </summary>
internal static readonly HashSet<int> ValidSpecies_Colo = new HashSet<int>
{
025, // Pikachu
153, // Bayleef
154, // Meganium
156, // Quilava
157, // Typhlosion
159, // Croconaw
160, // Feraligatr
162, // Furret
164, // Noctowl
166, // Ledian
168, // Ariados
175, // Togepi
176, // Togetic
179, // Mareep
180, // Flaaffy
185, // Sudowoodo
188, // Skiploom
189, // Jumpluff
190, // Aipom
192, // Sunflora
193, // Yanma
195, // Quagsire
196, // Espeon
197, // Umbreon
198, // Murkrow
200, // Misdreavus
205, // Forretress
206, // Dunsparce
207, // Gligar
210, // Granbull
211, // Qwilfish
212, // Scizor
213, // Shuckle
214, // Heracross
215, // Sneasel
217, // Ursaring
218, // Slugma
219, // Magcargo
221, // Piloswine
223, // Remoraid
225, // Delibird
226, // Mantine
227, // Skarmory
229, // Houndoom
234, // Stantler
235, // Smeargle
237, // Hitmontop
241, // Miltank
243, // Raikou
244, // Entei
245, // Suicune
248, // Tyranitar
250, // Ho-Oh
251, // Celebi
296, // Makuhita
297, // Hariyama
307, // Meditite
308, // Medicham
311, // Plusle
329, // Vibrava
330, // Flygon
333, // Swablu
334, // Altaria
357, // Tropius
359, // Absol
376, // Metagross
};
}
}

View File

@@ -911,7 +911,7 @@ public PKM ConvertToCK3()
if (GetType() == typeof(CK3))
return this;
var pk = new CK3();
TransferPropertiesWithReflection(this, pk);
TransferPropertiesWithReflection(this is XK3 ? ConvertToPK3() : this, pk);
pk.SetStats(GetStats(PersonalTable.RS[pk.Species]));
pk.Stat_Level = pk.CurrentLevel;
return pk;
@@ -927,7 +927,7 @@ public PKM ConvertToXK3()
if (GetType() == typeof(XK3))
return this;
var pk = new XK3();
TransferPropertiesWithReflection(this, pk);
TransferPropertiesWithReflection(this is CK3 ? ConvertToPK3() : this, pk);
pk.SetStats(GetStats(PersonalTable.RS[pk.Species]));
pk.Stat_Level = pk.CurrentLevel;
return pk;
@@ -944,6 +944,11 @@ public PKM ConvertToPK3()
return this;
var pk = new PK3();
TransferPropertiesWithReflection(this, pk);
// Transferring XK3 to PK3 when it originates from XD sets the fateful encounter (obedience) flag.
if (this is XK3 xk3 && xk3.Version == 15 && xk3.IsOriginXD())
pk.FatefulEncounter = true;
pk.RefreshChecksum();
return pk;
}
@@ -964,10 +969,6 @@ public void TransferPropertiesWithReflection(PKM Source, PKM Destination)
if (prop != null)
ReflectUtil.SetValue(Destination, property, prop);
}
// Transferring XK3 to PK3 when it originates from XD sets the fateful encounter (obedience) flag.
if (Source is XK3 xk3 && xk3.Version == 15 && new LegalityAnalysis(xk3).Info.WasXD)
Destination.FatefulEncounter = true;
}
/// <summary>

View File

@@ -213,5 +213,56 @@ protected override byte[] Encrypt()
public override int MaxEV => 252;
public override int OTLength => 7;
public override int NickLength => 10;
public bool IsOriginXD()
{
if (ShadowID != 0)
return true;
return IsOriginXD(Species, Met_Level);
}
public static bool IsOriginXD(int species, int metLevel)
{
switch (species)
{
case 296: // Makuhita 30 Colo 18 XD
case 297:
return metLevel != 30;
case 175: // Togepi 20 Colo 25 XD, also 20 as Togetic in Colo
case 176:
return metLevel != 20;
case 179: // Mareep 37 Colo 17 XD
case 180: // Flaafy 30 Colo
case 181:
return metLevel != 37 && metLevel != 30;
case 219: // Magcargo 30 Colo 38 XD (Slugma in Colo)
return metLevel != 30;
case 195: // Quagsire 30 Colo // ** Wooper XD
return metLevel != 30;
case 334: // Altaria 33 Colo // 36 XD (Swablu in Colo)
return metLevel != 33;
case 167: // Ledian 40 Colo // 10 Ledyba XD
return metLevel != 40;
case 207: // Gligar 43 Colo // ** Gligar XD
return metLevel != 43;
case 221: // Piloswine 43 Colo // 22 Swinub XD
return metLevel != 43;
case 205: // Forretress 43 Colo // 20 Pineco XD
return metLevel != 43;
case 168: // Ariados 43 Colo // 14 Spinarak XD
return metLevel != 43;
case 229: // Houndoom 48 Colo // 17 Houndour XD
return metLevel != 48;
case 217: // Ursaring 45 Colo // 11 Teddiursa XD
return metLevel != 45;
case 212: // Scizor 50 Colo // 40 Scyther XD
return metLevel != 50;
case 196: // Espeon
return metLevel != 25;
case 197: // Umbreon
return metLevel != 26;
}
// all other cases handled, if not in Colo's table it's from XD.
return !Legal.ValidSpecies_Colo.Contains(species);
}
}
}