private void UpdateTradebackG12() { if (pkm.Format == 1) { if (!Legal.AllowGen1Tradeback) { pkm.TradebackStatus = TradebackType.Gen1_NotTradeback; ((PK1)pkm).CatchRateIsItem = false; return; } // Detect tradeback status by comparing the catch rate(Gen1)/held item(Gen2) to the species in the pkm's evolution chain. var catch_rate = ((PK1)pkm).Catch_Rate; // For species catch rate, discard any species that has no valid encounters and a different catch rate than their pre-evolutions var Lineage = Legal.GetLineage(pkm).Where(s => !Legal.Species_NotAvailable_CatchRate.Contains(s)).ToList(); // Dragonite's Catch Rate is different than Dragonair's in Yellow, but there is no Dragonite encounter. var RGBCatchRate = Lineage.Any(s => catch_rate == PersonalTable.RB[s].CatchRate); var YCatchRate = Lineage.Any(s => s != 149 && catch_rate == PersonalTable.Y[s].CatchRate); // Krabby encounter trade special catch rate var TradeCatchRate = ((pkm.Species == 098 || pkm.Species == 099) && catch_rate == 204); var StadiumCatchRate = Legal.Stadium_GiftSpecies.Contains(pkm.Species) && Legal.Stadium_CatchRate.Contains(catch_rate); bool matchAny = RGBCatchRate || YCatchRate || TradeCatchRate || StadiumCatchRate; // If the catch rate value has been modified, the item has either been removed or swapped in Generation 2. var HeldItemCatchRate = catch_rate == 0 || Legal.HeldItems_GSC.Any(h => h == catch_rate); if (HeldItemCatchRate && !matchAny) { pkm.TradebackStatus = TradebackType.WasTradeback; } else if (!HeldItemCatchRate && matchAny) { pkm.TradebackStatus = TradebackType.Gen1_NotTradeback; } else { pkm.TradebackStatus = TradebackType.Any; } // Update the editing settings for the PKM to acknowledge the tradeback status if the species is changed. ((PK1)pkm).CatchRateIsItem = !pkm.Gen1_NotTradeback && HeldItemCatchRate && !matchAny; } else if (pkm.Format == 2 || pkm.VC2) { // Eggs, pokemon with non-empty Crystal met location, and generation 2 species without generation 1 preevolutions can't be traded to generation 1. if (pkm.IsEgg || pkm.HasOriginalMetLocation || (pkm.Species > Legal.MaxSpeciesID_1 && !Legal.FutureEvolutionsGen1.Contains(pkm.Species))) { pkm.TradebackStatus = TradebackType.Gen2_NotTradeback; } else { pkm.TradebackStatus = TradebackType.Any; } } else if (pkm.VC1) { // If VC2 is ever released, we can assume it will be TradebackType.Any. // Met date cannot be used definitively as the player can change their system clock. pkm.TradebackStatus = TradebackType.Gen1_NotTradeback; } else { pkm.TradebackStatus = TradebackType.Any; } }