Enforce met location matching for crystal data

Only while format == 2
improve detection for gen1/2 ingame trades
This commit is contained in:
Kurt
2017-06-12 18:15:26 -07:00
parent 3d641ada38
commit 8a4c40908b
4 changed files with 24 additions and 19 deletions

View File

@@ -285,7 +285,7 @@ private void verifyNicknameTrade()
}
else if (pkm.Format <= 2 || pkm.VC)
{
var et = EncounterOriginalGB as EncounterTrade;
var et = (EncounterOriginalGB ?? EncounterMatch) as EncounterTrade;
if (et?.TID == 0) // Gen1 Trade
{
if (!EncounterGenerator.getEncounterTrade1Valid(pkm))

View File

@@ -143,14 +143,16 @@ private static IEnumerable<GBEncounterData> GenerateRawEncounters12(PKM pkm, Gam
private static IEnumerable<GBEncounterData> GenerateFilteredEncounters(PKM pkm)
{
IEnumerable<GBEncounterData> filter(IEnumerable<GBEncounterData> data) => data
.OrderBy(z => z.Type == GBEncounterType.EggEncounter).ThenBy(z => z.Species).ThenBy(z => z.Level);
.OrderBy(z => !(z.Encounter is EncounterTrade && z.Generation == 2) || z.Type == GBEncounterType.EggEncounter)
.ThenBy(z => z.Species).ThenBy(z => z.Level);
if (!pkm.Gen2_NotTradeback)
bool crystal = pkm.Format == 2 && pkm.Met_Location != 0;
if (!pkm.Gen2_NotTradeback && !crystal)
foreach (var z in filter(GenerateRawEncounters12(pkm, GameVersion.RBY)))
yield return z;
if (!pkm.Gen1_NotTradeback && AllowGen2VCTransfer)
foreach (var z in filter(GenerateRawEncounters12(pkm, GameVersion.GSC)))
foreach (var z in filter(GenerateRawEncounters12(pkm, crystal ? GameVersion.C : GameVersion.GSC)))
yield return z;
}
private static IEnumerable<IEncounterable> GenerateRawEncounters(PKM pkm)
@@ -582,8 +584,8 @@ private static IEnumerable<EncounterArea> getEncounterAreas(PKM pkm, GameVersion
gameSource = (GameVersion)pkm.Version;
var slots = getEncounterSlots(pkm, gameSource: gameSource);
bool noMet = !pkm.HasOriginalMetLocation;
return noMet || pkm.Format <= 2 ? slots : slots.Where(area => area.Location == pkm.Met_Location);
bool noMet = !pkm.HasOriginalMetLocation || pkm.Format == 2 && gameSource != GameVersion.C;
return noMet ? slots : slots.Where(area => area.Location == pkm.Met_Location);
}
private static IEnumerable<EncounterArea> getSlots(PKM pkm, IEnumerable<EncounterArea> tables, int lvl = -1)
{
@@ -638,6 +640,7 @@ private static IEnumerable<EncounterTrade> getValidEncounterTradeVC(PKM pkm, Gam
var table = !AllowGen1Tradeback ? TradeGift_RBY_NoTradeback : TradeGift_RBY_Tradeback;
return getValidEncounterTradeVC1(pkm, p, table);
case GameVersion.GSC:
case GameVersion.C:
return getValidEncounterTradeVC2(pkm, p);
default:
return null;
@@ -651,11 +654,11 @@ private static IEnumerable<EncounterTrade> getValidEncounterTradeVC2(PKM pkm, De
foreach (var z in possible)
{
// Filter Criteria
if (z?.Gender != pkm.Gender)
continue;
if (z.TID != pkm.TID)
continue;
if (!z.IVs.SequenceEqual(pkm.IVs))
if (z.Gender != pkm.Gender && pkm.Format <= 2)
continue;
if (!z.IVs.SequenceEqual(pkm.IVs) && pkm.Format <= 2)
continue;
if (pkm.Met_Location != 0 && pkm.Format == 2 && pkm.Met_Location != z.Location)
continue;

View File

@@ -122,16 +122,16 @@ public static partial class Legal
internal static readonly EncounterTrade[] TradeGift_GSC =
{
new EncounterTrade { Species = 095, Generation =2, Level = 03, Gender = 0, Location = 06, TID = 48926, IVs = new[] {08, 09, 06, 06, 06} }, // Onix @ Violet City for Bellsprout [wild]
new EncounterTrade { Species = 066, Generation =2, Level = 05, Gender = 1, Location = 16, TID = 37460, IVs = new[] {12, 03, 07, 06, 06} }, // Machop @ Goldenrod City for Drowzee [wild 9, hatched egg 5]
new EncounterTrade { Species = 100, Generation =2, Level = 05, Gender = 2, Location = 27, TID = 29189, IVs = new[] {08, 09, 08, 08, 08} }, // Voltorb @ Olivine City for Krabby [egg]
new EncounterTrade { Species = 112, Generation =2, Level = 30, Gender = 1, Location = 41, TID = 00283, IVs = new[] {12, 07, 07, 06, 06} }, // Rhydon @ Blackthorn City for Dragonair [blue jp game corner]
new EncounterTrade { Species = 142, Generation =2, Level = 05, Gender = 0, Location = 76, TID = 26491, IVs = new[] {08, 09, 06, 06, 06} }, // Aerodactyl @ Route 14 for Chansey [egg]
new EncounterTrade { Species = 078, Generation =2, Level = 14, Gender = 0, Location = 51, TID = 15616, IVs = new[] {08, 09, 06, 06, 06} }, // Rapidash @ Pewter City for Gloom [wild]
new EncounterTrade { Species = 085, Generation =2, Level = 30, Gender = 1, Location = 41, TID = 00283, IVs = new[] {12, 07, 07, 06, 06} }, // Dodrio @ Blackthorn City for Dragonair [blue jp game corner]
new EncounterTrade { Species = 178, Generation =2, Level = 15, Gender = 0, Location = 51, TID = 15616, IVs = new[] {08, 09, 06, 08, 06} }, // Xatu @ Pewter City for Haunter [wild]
new EncounterTrade { Species = 082, Generation =2, Level = 16, Gender = 2, Location = 68, TID = 50082, IVs = new[] {08, 09, 06, 06, 06} }, // Magneton @ Power Plant for Dugtrio [wild]
new EncounterTrade { Species = 095, Generation = 2, Level = 03, Gender = 0, Location = 06, TID = 48926, IVs = new[] {08, 09, 06, 06, 06, 06} }, // Onix @ Violet City for Bellsprout [wild]
new EncounterTrade { Species = 066, Generation = 2, Level = 05, Gender = 1, Location = 16, TID = 37460, IVs = new[] {12, 03, 07, 06, 06, 06} }, // Machop @ Goldenrod City for Drowzee [wild 9, hatched egg 5]
new EncounterTrade { Species = 100, Generation = 2, Level = 05, Gender = 2, Location = 27, TID = 29189, IVs = new[] {08, 09, 08, 08, 08, 08} }, // Voltorb @ Olivine City for Krabby [egg]
new EncounterTrade { Species = 112, Generation = 2, Level = 30, Gender = 1, Location = 41, TID = 00283, IVs = new[] {12, 07, 07, 06, 06, 06} }, // Rhydon @ Blackthorn City for Dragonair [blue jp game corner]
new EncounterTrade { Species = 142, Generation = 2, Level = 05, Gender = 0, Location = 76, TID = 26491, IVs = new[] {08, 09, 06, 06, 06, 06} }, // Aerodactyl @ Route 14 for Chansey [egg]
new EncounterTrade { Species = 078, Generation = 2, Level = 14, Gender = 0, Location = 51, TID = 15616, IVs = new[] {08, 09, 06, 06, 06, 06} }, // Rapidash @ Pewter City for Gloom [wild]
new EncounterTrade { Species = 085, Generation = 2, Level = 30, Gender = 1, Location = 41, TID = 00283, IVs = new[] {12, 07, 07, 06, 06, 06} }, // Dodrio @ Blackthorn City for Dragonair [blue jp game corner]
new EncounterTrade { Species = 178, Generation = 2, Level = 15, Gender = 0, Location = 51, TID = 15616, IVs = new[] {08, 09, 06, 08, 08, 06} }, // Xatu @ Pewter City for Haunter [wild]
new EncounterTrade { Species = 082, Generation = 2, Level = 16, Gender = 2, Location = 68, TID = 50082, IVs = new[] {08, 09, 06, 06, 06, 06} }, // Magneton @ Power Plant for Dugtrio [wild]
};
internal static readonly string[][] TradeGift_GSC_OTs =
{

View File

@@ -1092,6 +1092,8 @@ private void tabMain_DragEnter(object sender, DragEventArgs e)
private void tabMain_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files == null || files.Length == 0)
return;
OpenQuick(files[0]);
e.Effect = DragDropEffects.Copy;