2016-03-12 03:43:40 +00:00
|
|
|
|
using System;
|
2016-03-25 07:10:11 +00:00
|
|
|
|
using System.Collections.Generic;
|
2016-03-05 04:43:00 +00:00
|
|
|
|
using System.Linq;
|
2017-05-12 04:34:18 +00:00
|
|
|
|
using System.Reflection;
|
2017-03-24 17:59:45 +00:00
|
|
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
2016-02-23 06:52:48 +00:00
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.Core
|
2016-02-23 06:52:48 +00:00
|
|
|
|
{
|
2016-03-14 03:19:04 +00:00
|
|
|
|
public partial class LegalityAnalysis
|
2016-02-23 06:52:48 +00:00
|
|
|
|
{
|
2016-10-23 19:48:49 +00:00
|
|
|
|
private PKM pkm;
|
|
|
|
|
private readonly List<CheckResult> Parse = new List<CheckResult>();
|
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
private IEncounterable EncounterOriginalGB;
|
|
|
|
|
private IEncounterable EncounterMatch => info.EncounterMatch;
|
2017-04-24 00:53:22 +00:00
|
|
|
|
private Type Type; // Parent class when applicable (EncounterStatic / MysteryGift)
|
|
|
|
|
private Type MatchedType; // Child class if applicable (WC6, PGF, etc)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
private string EncounterName => Legal.getEncounterTypeName(EncounterOriginalGB ?? EncounterMatch);
|
2016-10-23 19:48:49 +00:00
|
|
|
|
private CheckResult Encounter, History;
|
|
|
|
|
// private bool SecondaryChecked;
|
|
|
|
|
|
|
|
|
|
public readonly bool Parsed;
|
|
|
|
|
public readonly bool Valid;
|
2017-04-23 04:00:06 +00:00
|
|
|
|
public readonly bool Error;
|
2017-05-28 04:17:53 +00:00
|
|
|
|
public LegalInfo info;
|
2017-03-18 23:50:34 +00:00
|
|
|
|
public bool ParsedValid => Parsed && Valid;
|
|
|
|
|
public bool ParsedInvalid => Parsed && !Valid;
|
2017-04-23 04:00:06 +00:00
|
|
|
|
public string Report(bool verbose = false) => verbose ? getVerboseLegalityReport() : getLegalityReport();
|
|
|
|
|
private IEnumerable<int> AllSuggestedMoves
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (Error)
|
|
|
|
|
return new int[4];
|
|
|
|
|
if (_allSuggestedMoves == null)
|
2017-05-18 04:50:52 +00:00
|
|
|
|
return _allSuggestedMoves = pkm == null || !pkm.IsOriginValid ? new int[4] : getSuggestedMoves(true, true, true);
|
2017-04-23 04:00:06 +00:00
|
|
|
|
return _allSuggestedMoves;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private IEnumerable<int> AllSuggestedRelearnMoves
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (Error)
|
|
|
|
|
return new int[4];
|
|
|
|
|
if (_allSuggestedRelearnMoves == null)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
return _allSuggestedRelearnMoves = pkm == null || !pkm.IsOriginValid ? new int[4] : Legal.getValidRelearn(pkm, info.EncounterMatch.Species).ToArray();
|
2017-04-23 04:00:06 +00:00
|
|
|
|
return _allSuggestedRelearnMoves;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private int[] _allSuggestedMoves, _allSuggestedRelearnMoves;
|
|
|
|
|
public int[] AllSuggestedMovesAndRelearn => AllSuggestedMoves.Concat(AllSuggestedRelearnMoves).ToArray();
|
2016-03-14 03:19:04 +00:00
|
|
|
|
|
2016-06-20 04:22:43 +00:00
|
|
|
|
public LegalityAnalysis(PKM pk)
|
2016-02-23 06:52:48 +00:00
|
|
|
|
{
|
2016-06-30 05:59:20 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2017-02-13 01:00:03 +00:00
|
|
|
|
switch (pk.Format) // prior to storing GameVersion
|
|
|
|
|
{
|
|
|
|
|
case 1: parsePK1(pk); break;
|
2017-02-27 05:46:00 +00:00
|
|
|
|
case 2: parsePK1(pk); break;
|
2017-02-13 01:00:03 +00:00
|
|
|
|
}
|
2017-02-14 06:49:32 +00:00
|
|
|
|
|
|
|
|
|
if (!Parse.Any())
|
2016-11-14 15:38:44 +00:00
|
|
|
|
switch (pk.GenNumber)
|
2016-10-23 19:48:49 +00:00
|
|
|
|
{
|
2017-04-30 19:17:27 +00:00
|
|
|
|
case 3: parsePK3(pk); break;
|
2017-03-18 23:50:34 +00:00
|
|
|
|
case 4: parsePK4(pk); break;
|
|
|
|
|
case 5: parsePK5(pk); break;
|
2016-10-23 19:48:49 +00:00
|
|
|
|
case 6: parsePK6(pk); break;
|
2017-02-14 02:06:01 +00:00
|
|
|
|
|
|
|
|
|
case 1: parsePK7(pk); break;
|
2016-10-23 19:48:49 +00:00
|
|
|
|
case 7: parsePK7(pk); break;
|
|
|
|
|
}
|
2016-11-15 00:27:15 +00:00
|
|
|
|
|
2017-05-18 04:50:52 +00:00
|
|
|
|
if (Parse.Count > 0)
|
2016-11-15 00:27:15 +00:00
|
|
|
|
{
|
|
|
|
|
if (Parse.Any(chk => !chk.Valid))
|
|
|
|
|
Valid = false;
|
2017-05-28 04:17:53 +00:00
|
|
|
|
else if (info.vMoves.Any(m => m.Valid != true))
|
2016-11-15 00:27:15 +00:00
|
|
|
|
Valid = false;
|
2017-05-28 04:17:53 +00:00
|
|
|
|
else if (info.vRelearn.Any(m => m.Valid != true))
|
2016-11-15 00:27:15 +00:00
|
|
|
|
Valid = false;
|
2017-05-18 04:50:52 +00:00
|
|
|
|
else
|
|
|
|
|
Valid = true;
|
2016-11-15 00:27:15 +00:00
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
if (pkm.FatefulEncounter && info.vRelearn.Any(chk => !chk.Valid) && EncounterMatch == null)
|
2017-03-21 07:18:38 +00:00
|
|
|
|
AddLine(Severity.Indeterminate, V188, CheckIdentifier.Fateful);
|
2016-11-15 00:27:15 +00:00
|
|
|
|
}
|
2016-06-30 05:59:20 +00:00
|
|
|
|
}
|
2017-03-24 06:15:49 +00:00
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(e.Message);
|
|
|
|
|
Valid = false;
|
|
|
|
|
AddLine(Severity.Invalid, V190, CheckIdentifier.Misc);
|
2017-04-23 04:00:06 +00:00
|
|
|
|
Error = true;
|
2017-03-24 06:15:49 +00:00
|
|
|
|
}
|
2017-05-18 04:50:52 +00:00
|
|
|
|
Parsed = true;
|
2016-10-23 19:48:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddLine(Severity s, string c, CheckIdentifier i)
|
|
|
|
|
{
|
|
|
|
|
AddLine(new CheckResult(s, c, i));
|
|
|
|
|
}
|
|
|
|
|
private void AddLine(CheckResult chk)
|
|
|
|
|
{
|
|
|
|
|
Parse.Add(chk);
|
|
|
|
|
}
|
2017-02-13 01:00:03 +00:00
|
|
|
|
|
|
|
|
|
private void parsePK1(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
pkm = pk;
|
2017-02-15 08:11:12 +00:00
|
|
|
|
if (!pkm.IsOriginValid)
|
2017-03-21 07:18:38 +00:00
|
|
|
|
{ AddLine(Severity.Invalid, V187, CheckIdentifier.None); return; }
|
2017-04-27 05:05:32 +00:00
|
|
|
|
updateTradebackG12();
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
|
|
|
|
updateInfo();
|
2017-04-22 20:04:12 +00:00
|
|
|
|
updateTypeInfo();
|
2017-05-28 04:17:53 +00:00
|
|
|
|
if (pk.Format > 2) // transferred
|
|
|
|
|
{
|
|
|
|
|
EncounterOriginalGB = EncounterMatch;
|
|
|
|
|
foreach (var z in verifyVCEncounter(pkm, EncounterMatch.Species, EncounterMatch as GBEncounterData))
|
|
|
|
|
AddLine(z);
|
|
|
|
|
}
|
2017-02-13 01:00:03 +00:00
|
|
|
|
verifyNickname();
|
|
|
|
|
verifyDVs();
|
|
|
|
|
verifyG1OT();
|
Generation 1 and 2 legal Improvements (#1099)
* Refactor parseMovesForEncounter to gather valid moves for species encounter, some Pokemon can have valid encounters with different source species from the encounter, the valid moves change if the encounter species change because some preevolutions moves are illegal if pokemon caught already evolved.
Example, generation 1 Pikachu that can have a RBY Pikachu encounter and GSC Pichu encounter, the valid moves for the first encounters should not have any Pichu exclusive evolution moves
Also assign the encounter match from gb when parsing moves like the variable Encounter Match, to store the encounter that is valid for the pokemon moves instead the first encounter.
Store the species encounter, this will be needed to check if the evolution is valid for species that evolve leveling with a given learned move
* Add Tradeback Status to the pokemon, this variable for generations 1 and 2 use data like the catch rate to determine if trade between generations 1 and 2 was possible.
If analysis is for VC games tradeback have value NotTradeback for every gen 1 pokemon, but for cart saves some pokemon can be determine that have not been tradeback, if catch rate match species catch rate but do not match a valid generation 2 held item that means the pokemon habe been never traded to generation 2 games, that allow to discart encounters and moves from generation 2.
Also if is not tradeback catch rate is used to filter encounters, catch rate determine in what species was captured the pokemon discarting some preevolutions moves
Also add option for generation 1 cart save analysis to check legal status not allowing generation 2 games, like VC games but with Stadium allowed, like the generation 1 non tradeback rules from Smogon
Also change evolution chains to included generation 2 preevolutions for gen 1 pokemon if tradeback was possible, it is needed to avoid parsemoves to check illegal pokemon like Hitmonchan with Tyrogue level up moves
* Check legal values of generation 1 type and catch rate
Replace pokemon catch rate after changind pokemon species always if pokemon was not tradeback from generation 2, the catch rate will keep unchanged only if it can be a held item and do not match species catch rate (default item)
Also if catch rate is changed use base species catch rate to avoid legal errors if the catch rate of the evolution species if is not possible with the current moves
* Filter ingame trades and static encounters with catch rate for generation 1 non tradeback
* Fix min moves for generation 1 metapod encounter
* Clean up
* Fix encounter level for generation 1, valid moves are those with one level after the encounter level, pokemon can not learn a new move until level up
Clean up type validation
Fix generation 3 fatefull encounter eggs, the pokemon lost the fatefull mark when it hatch
* Clean-up
* Use new variable EncounterSpecies when it is needed to detect the species of the encounter, the old code wont work if the encounter is a wild slots array
* Fix generation 1 evolution chains and catch rate as default held item
* Fix Generation 1 Yellow Pikachu and Kadabra catch rates
2017-04-27 04:27:59 +00:00
|
|
|
|
verifyMiscG1();
|
2017-02-13 01:00:03 +00:00
|
|
|
|
}
|
2017-03-18 23:50:34 +00:00
|
|
|
|
private void parsePK3(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
pkm = pk;
|
|
|
|
|
if (!pkm.IsOriginValid)
|
2017-03-21 07:18:38 +00:00
|
|
|
|
{ AddLine(Severity.Invalid, V187, CheckIdentifier.None); return; }
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
|
|
|
|
updateInfo();
|
2017-04-22 20:04:12 +00:00
|
|
|
|
updateTypeInfo();
|
2017-03-18 23:50:34 +00:00
|
|
|
|
updateChecks();
|
2017-05-28 04:17:53 +00:00
|
|
|
|
if (pkm.Format > 3)
|
|
|
|
|
verifyTransferLegalityG3();
|
2017-04-30 19:17:27 +00:00
|
|
|
|
|
2017-04-30 23:53:54 +00:00
|
|
|
|
if (pkm.Version == 15)
|
|
|
|
|
verifyCXD();
|
2017-03-18 23:50:34 +00:00
|
|
|
|
}
|
|
|
|
|
private void parsePK4(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
pkm = pk;
|
|
|
|
|
if (!pkm.IsOriginValid)
|
2017-03-21 07:18:38 +00:00
|
|
|
|
{ AddLine(Severity.Invalid, V187, CheckIdentifier.None); return; }
|
2017-03-24 04:42:33 +00:00
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
updateInfo();
|
2017-04-22 20:04:12 +00:00
|
|
|
|
updateTypeInfo();
|
2017-03-18 23:50:34 +00:00
|
|
|
|
updateChecks();
|
2017-05-28 04:17:53 +00:00
|
|
|
|
if (pkm.Format > 4)
|
|
|
|
|
verifyTransferLegalityG4();
|
2017-03-18 23:50:34 +00:00
|
|
|
|
}
|
|
|
|
|
private void parsePK5(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
pkm = pk;
|
|
|
|
|
if (!pkm.IsOriginValid)
|
2017-03-21 07:18:38 +00:00
|
|
|
|
{ AddLine(Severity.Invalid, V187, CheckIdentifier.None); return; }
|
2017-03-24 04:42:33 +00:00
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
updateInfo();
|
2017-04-22 20:04:12 +00:00
|
|
|
|
updateTypeInfo();
|
2017-03-18 23:50:34 +00:00
|
|
|
|
updateChecks();
|
|
|
|
|
}
|
2016-10-23 19:48:49 +00:00
|
|
|
|
private void parsePK6(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
pkm = pk;
|
2017-02-15 08:11:12 +00:00
|
|
|
|
if (!pkm.IsOriginValid)
|
2017-03-21 07:18:38 +00:00
|
|
|
|
{ AddLine(Severity.Invalid, V187, CheckIdentifier.None); return; }
|
2016-10-23 19:48:49 +00:00
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
updateInfo();
|
2017-04-22 20:04:12 +00:00
|
|
|
|
updateTypeInfo();
|
2016-10-23 19:48:49 +00:00
|
|
|
|
updateChecks();
|
|
|
|
|
}
|
|
|
|
|
private void parsePK7(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
pkm = pk;
|
2017-02-15 08:11:12 +00:00
|
|
|
|
if (!pkm.IsOriginValid)
|
2017-03-21 07:18:38 +00:00
|
|
|
|
{ AddLine(Severity.Invalid, V187, CheckIdentifier.None); return; }
|
2016-10-23 19:48:49 +00:00
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
updateInfo();
|
2017-04-22 20:04:12 +00:00
|
|
|
|
updateTypeInfo();
|
2016-10-23 19:48:49 +00:00
|
|
|
|
updateChecks();
|
2016-03-12 04:56:40 +00:00
|
|
|
|
}
|
2016-03-14 03:19:04 +00:00
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
private void updateInfo()
|
2016-03-12 04:56:40 +00:00
|
|
|
|
{
|
2017-05-28 04:17:53 +00:00
|
|
|
|
info = EncounterFinder.verifyEncounter(pkm);
|
|
|
|
|
Encounter = info.Parse[0];
|
|
|
|
|
Parse.AddRange(info.Parse);
|
2017-01-04 04:51:33 +00:00
|
|
|
|
}
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
2017-04-27 05:05:32 +00:00
|
|
|
|
private void updateTradebackG12()
|
Generation 1 and 2 legal Improvements (#1099)
* Refactor parseMovesForEncounter to gather valid moves for species encounter, some Pokemon can have valid encounters with different source species from the encounter, the valid moves change if the encounter species change because some preevolutions moves are illegal if pokemon caught already evolved.
Example, generation 1 Pikachu that can have a RBY Pikachu encounter and GSC Pichu encounter, the valid moves for the first encounters should not have any Pichu exclusive evolution moves
Also assign the encounter match from gb when parsing moves like the variable Encounter Match, to store the encounter that is valid for the pokemon moves instead the first encounter.
Store the species encounter, this will be needed to check if the evolution is valid for species that evolve leveling with a given learned move
* Add Tradeback Status to the pokemon, this variable for generations 1 and 2 use data like the catch rate to determine if trade between generations 1 and 2 was possible.
If analysis is for VC games tradeback have value NotTradeback for every gen 1 pokemon, but for cart saves some pokemon can be determine that have not been tradeback, if catch rate match species catch rate but do not match a valid generation 2 held item that means the pokemon habe been never traded to generation 2 games, that allow to discart encounters and moves from generation 2.
Also if is not tradeback catch rate is used to filter encounters, catch rate determine in what species was captured the pokemon discarting some preevolutions moves
Also add option for generation 1 cart save analysis to check legal status not allowing generation 2 games, like VC games but with Stadium allowed, like the generation 1 non tradeback rules from Smogon
Also change evolution chains to included generation 2 preevolutions for gen 1 pokemon if tradeback was possible, it is needed to avoid parsemoves to check illegal pokemon like Hitmonchan with Tyrogue level up moves
* Check legal values of generation 1 type and catch rate
Replace pokemon catch rate after changind pokemon species always if pokemon was not tradeback from generation 2, the catch rate will keep unchanged only if it can be a held item and do not match species catch rate (default item)
Also if catch rate is changed use base species catch rate to avoid legal errors if the catch rate of the evolution species if is not possible with the current moves
* Filter ingame trades and static encounters with catch rate for generation 1 non tradeback
* Fix min moves for generation 1 metapod encounter
* Clean up
* Fix encounter level for generation 1, valid moves are those with one level after the encounter level, pokemon can not learn a new move until level up
Clean up type validation
Fix generation 3 fatefull encounter eggs, the pokemon lost the fatefull mark when it hatch
* Clean-up
* Use new variable EncounterSpecies when it is needed to detect the species of the encounter, the old code wont work if the encounter is a wild slots array
* Fix generation 1 evolution chains and catch rate as default held item
* Fix Generation 1 Yellow Pikachu and Kadabra catch rates
2017-04-27 04:27:59 +00:00
|
|
|
|
{
|
|
|
|
|
if (pkm.Format == 1)
|
|
|
|
|
{
|
|
|
|
|
if (!Legal.AllowGen1Tradeback)
|
|
|
|
|
{
|
|
|
|
|
pkm.TradebackStatus = TradebackType.Gen1_NotTradeback;
|
2017-04-27 05:05:32 +00:00
|
|
|
|
((PK1)pkm).CatchRateIsItem = false;
|
|
|
|
|
return;
|
Generation 1 and 2 legal Improvements (#1099)
* Refactor parseMovesForEncounter to gather valid moves for species encounter, some Pokemon can have valid encounters with different source species from the encounter, the valid moves change if the encounter species change because some preevolutions moves are illegal if pokemon caught already evolved.
Example, generation 1 Pikachu that can have a RBY Pikachu encounter and GSC Pichu encounter, the valid moves for the first encounters should not have any Pichu exclusive evolution moves
Also assign the encounter match from gb when parsing moves like the variable Encounter Match, to store the encounter that is valid for the pokemon moves instead the first encounter.
Store the species encounter, this will be needed to check if the evolution is valid for species that evolve leveling with a given learned move
* Add Tradeback Status to the pokemon, this variable for generations 1 and 2 use data like the catch rate to determine if trade between generations 1 and 2 was possible.
If analysis is for VC games tradeback have value NotTradeback for every gen 1 pokemon, but for cart saves some pokemon can be determine that have not been tradeback, if catch rate match species catch rate but do not match a valid generation 2 held item that means the pokemon habe been never traded to generation 2 games, that allow to discart encounters and moves from generation 2.
Also if is not tradeback catch rate is used to filter encounters, catch rate determine in what species was captured the pokemon discarting some preevolutions moves
Also add option for generation 1 cart save analysis to check legal status not allowing generation 2 games, like VC games but with Stadium allowed, like the generation 1 non tradeback rules from Smogon
Also change evolution chains to included generation 2 preevolutions for gen 1 pokemon if tradeback was possible, it is needed to avoid parsemoves to check illegal pokemon like Hitmonchan with Tyrogue level up moves
* Check legal values of generation 1 type and catch rate
Replace pokemon catch rate after changind pokemon species always if pokemon was not tradeback from generation 2, the catch rate will keep unchanged only if it can be a held item and do not match species catch rate (default item)
Also if catch rate is changed use base species catch rate to avoid legal errors if the catch rate of the evolution species if is not possible with the current moves
* Filter ingame trades and static encounters with catch rate for generation 1 non tradeback
* Fix min moves for generation 1 metapod encounter
* Clean up
* Fix encounter level for generation 1, valid moves are those with one level after the encounter level, pokemon can not learn a new move until level up
Clean up type validation
Fix generation 3 fatefull encounter eggs, the pokemon lost the fatefull mark when it hatch
* Clean-up
* Use new variable EncounterSpecies when it is needed to detect the species of the encounter, the old code wont work if the encounter is a wild slots array
* Fix generation 1 evolution chains and catch rate as default held item
* Fix Generation 1 Yellow Pikachu and Kadabra catch rates
2017-04-27 04:27:59 +00:00
|
|
|
|
}
|
2017-04-27 05:05:32 +00:00
|
|
|
|
|
|
|
|
|
// 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);
|
Encounter Type fix and detection of pokemon that should have evolve on trade (#1105)
* Detect encounter trades that evolve on trade and have not been evolved
Detect generation 1 pokemon with special catch rates : krabby trade and Pokemon Stadium
Detect generation 1 pokemon that evolve on trade and have been traded but not evolved
Detect pokemon with tradeback status any but with only encounters from the other GB generation, that means they are WasTradeback
Detect pokemon with moves from the other GB generation, change tradebackstatus to WasTradeback
* Fix dppt surfing and fishing encounter type, is is surfing because the battle background is the same as other surfingfishing encounters
Fix headbutt encounter type, the encounter type depends on the battle background used when battle a pokemon, for headbutt it changes with the player tile, is the player is in a city it will be building encounter, in a grass tile tall grass, in water it is surfingfishing and cave inside a cave. Some locations have more than one possible encounter type, for example routes with trees near the grass, near the water and near non-combat tiles.
Also added slot type headbutt special for the special trees, those trees are all in routes and are only adjacent to non-combat tiles
* Fix encounter type for missing areas with multiple grass encounters types: Mt Coronet, Mt Silver Cave and Stark Mountain (Issue # 1095)
* Fixes and typos
* Check for non-japanese e-reader pokemon, is unreleased
2017-05-01 15:07:20 +00:00
|
|
|
|
// 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;
|
2017-04-27 05:05:32 +00:00
|
|
|
|
|
|
|
|
|
// 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;
|
Generation 1 and 2 legal Improvements (#1099)
* Refactor parseMovesForEncounter to gather valid moves for species encounter, some Pokemon can have valid encounters with different source species from the encounter, the valid moves change if the encounter species change because some preevolutions moves are illegal if pokemon caught already evolved.
Example, generation 1 Pikachu that can have a RBY Pikachu encounter and GSC Pichu encounter, the valid moves for the first encounters should not have any Pichu exclusive evolution moves
Also assign the encounter match from gb when parsing moves like the variable Encounter Match, to store the encounter that is valid for the pokemon moves instead the first encounter.
Store the species encounter, this will be needed to check if the evolution is valid for species that evolve leveling with a given learned move
* Add Tradeback Status to the pokemon, this variable for generations 1 and 2 use data like the catch rate to determine if trade between generations 1 and 2 was possible.
If analysis is for VC games tradeback have value NotTradeback for every gen 1 pokemon, but for cart saves some pokemon can be determine that have not been tradeback, if catch rate match species catch rate but do not match a valid generation 2 held item that means the pokemon habe been never traded to generation 2 games, that allow to discart encounters and moves from generation 2.
Also if is not tradeback catch rate is used to filter encounters, catch rate determine in what species was captured the pokemon discarting some preevolutions moves
Also add option for generation 1 cart save analysis to check legal status not allowing generation 2 games, like VC games but with Stadium allowed, like the generation 1 non tradeback rules from Smogon
Also change evolution chains to included generation 2 preevolutions for gen 1 pokemon if tradeback was possible, it is needed to avoid parsemoves to check illegal pokemon like Hitmonchan with Tyrogue level up moves
* Check legal values of generation 1 type and catch rate
Replace pokemon catch rate after changind pokemon species always if pokemon was not tradeback from generation 2, the catch rate will keep unchanged only if it can be a held item and do not match species catch rate (default item)
Also if catch rate is changed use base species catch rate to avoid legal errors if the catch rate of the evolution species if is not possible with the current moves
* Filter ingame trades and static encounters with catch rate for generation 1 non tradeback
* Fix min moves for generation 1 metapod encounter
* Clean up
* Fix encounter level for generation 1, valid moves are those with one level after the encounter level, pokemon can not learn a new move until level up
Clean up type validation
Fix generation 3 fatefull encounter eggs, the pokemon lost the fatefull mark when it hatch
* Clean-up
* Use new variable EncounterSpecies when it is needed to detect the species of the encounter, the old code wont work if the encounter is a wild slots array
* Fix generation 1 evolution chains and catch rate as default held item
* Fix Generation 1 Yellow Pikachu and Kadabra catch rates
2017-04-27 04:27:59 +00:00
|
|
|
|
else
|
2017-04-27 05:05:32 +00:00
|
|
|
|
pkm.TradebackStatus = TradebackType.Any;
|
Generation 1 and 2 legal Improvements (#1099)
* Refactor parseMovesForEncounter to gather valid moves for species encounter, some Pokemon can have valid encounters with different source species from the encounter, the valid moves change if the encounter species change because some preevolutions moves are illegal if pokemon caught already evolved.
Example, generation 1 Pikachu that can have a RBY Pikachu encounter and GSC Pichu encounter, the valid moves for the first encounters should not have any Pichu exclusive evolution moves
Also assign the encounter match from gb when parsing moves like the variable Encounter Match, to store the encounter that is valid for the pokemon moves instead the first encounter.
Store the species encounter, this will be needed to check if the evolution is valid for species that evolve leveling with a given learned move
* Add Tradeback Status to the pokemon, this variable for generations 1 and 2 use data like the catch rate to determine if trade between generations 1 and 2 was possible.
If analysis is for VC games tradeback have value NotTradeback for every gen 1 pokemon, but for cart saves some pokemon can be determine that have not been tradeback, if catch rate match species catch rate but do not match a valid generation 2 held item that means the pokemon habe been never traded to generation 2 games, that allow to discart encounters and moves from generation 2.
Also if is not tradeback catch rate is used to filter encounters, catch rate determine in what species was captured the pokemon discarting some preevolutions moves
Also add option for generation 1 cart save analysis to check legal status not allowing generation 2 games, like VC games but with Stadium allowed, like the generation 1 non tradeback rules from Smogon
Also change evolution chains to included generation 2 preevolutions for gen 1 pokemon if tradeback was possible, it is needed to avoid parsemoves to check illegal pokemon like Hitmonchan with Tyrogue level up moves
* Check legal values of generation 1 type and catch rate
Replace pokemon catch rate after changind pokemon species always if pokemon was not tradeback from generation 2, the catch rate will keep unchanged only if it can be a held item and do not match species catch rate (default item)
Also if catch rate is changed use base species catch rate to avoid legal errors if the catch rate of the evolution species if is not possible with the current moves
* Filter ingame trades and static encounters with catch rate for generation 1 non tradeback
* Fix min moves for generation 1 metapod encounter
* Clean up
* Fix encounter level for generation 1, valid moves are those with one level after the encounter level, pokemon can not learn a new move until level up
Clean up type validation
Fix generation 3 fatefull encounter eggs, the pokemon lost the fatefull mark when it hatch
* Clean-up
* Use new variable EncounterSpecies when it is needed to detect the species of the encounter, the old code wont work if the encounter is a wild slots array
* Fix generation 1 evolution chains and catch rate as default held item
* Fix Generation 1 Yellow Pikachu and Kadabra catch rates
2017-04-27 04:27:59 +00:00
|
|
|
|
|
2017-04-27 05:05:32 +00:00
|
|
|
|
|
|
|
|
|
// Update the editing settings for the PKM to acknowledge the tradeback status if the species is changed.
|
Encounter Type fix and detection of pokemon that should have evolve on trade (#1105)
* Detect encounter trades that evolve on trade and have not been evolved
Detect generation 1 pokemon with special catch rates : krabby trade and Pokemon Stadium
Detect generation 1 pokemon that evolve on trade and have been traded but not evolved
Detect pokemon with tradeback status any but with only encounters from the other GB generation, that means they are WasTradeback
Detect pokemon with moves from the other GB generation, change tradebackstatus to WasTradeback
* Fix dppt surfing and fishing encounter type, is is surfing because the battle background is the same as other surfingfishing encounters
Fix headbutt encounter type, the encounter type depends on the battle background used when battle a pokemon, for headbutt it changes with the player tile, is the player is in a city it will be building encounter, in a grass tile tall grass, in water it is surfingfishing and cave inside a cave. Some locations have more than one possible encounter type, for example routes with trees near the grass, near the water and near non-combat tiles.
Also added slot type headbutt special for the special trees, those trees are all in routes and are only adjacent to non-combat tiles
* Fix encounter type for missing areas with multiple grass encounters types: Mt Coronet, Mt Silver Cave and Stark Mountain (Issue # 1095)
* Fixes and typos
* Check for non-japanese e-reader pokemon, is unreleased
2017-05-01 15:07:20 +00:00
|
|
|
|
((PK1)pkm).CatchRateIsItem = !pkm.Gen1_NotTradeback && HeldItemCatchRate && !matchAny;
|
Generation 1 and 2 legal Improvements (#1099)
* Refactor parseMovesForEncounter to gather valid moves for species encounter, some Pokemon can have valid encounters with different source species from the encounter, the valid moves change if the encounter species change because some preevolutions moves are illegal if pokemon caught already evolved.
Example, generation 1 Pikachu that can have a RBY Pikachu encounter and GSC Pichu encounter, the valid moves for the first encounters should not have any Pichu exclusive evolution moves
Also assign the encounter match from gb when parsing moves like the variable Encounter Match, to store the encounter that is valid for the pokemon moves instead the first encounter.
Store the species encounter, this will be needed to check if the evolution is valid for species that evolve leveling with a given learned move
* Add Tradeback Status to the pokemon, this variable for generations 1 and 2 use data like the catch rate to determine if trade between generations 1 and 2 was possible.
If analysis is for VC games tradeback have value NotTradeback for every gen 1 pokemon, but for cart saves some pokemon can be determine that have not been tradeback, if catch rate match species catch rate but do not match a valid generation 2 held item that means the pokemon habe been never traded to generation 2 games, that allow to discart encounters and moves from generation 2.
Also if is not tradeback catch rate is used to filter encounters, catch rate determine in what species was captured the pokemon discarting some preevolutions moves
Also add option for generation 1 cart save analysis to check legal status not allowing generation 2 games, like VC games but with Stadium allowed, like the generation 1 non tradeback rules from Smogon
Also change evolution chains to included generation 2 preevolutions for gen 1 pokemon if tradeback was possible, it is needed to avoid parsemoves to check illegal pokemon like Hitmonchan with Tyrogue level up moves
* Check legal values of generation 1 type and catch rate
Replace pokemon catch rate after changind pokemon species always if pokemon was not tradeback from generation 2, the catch rate will keep unchanged only if it can be a held item and do not match species catch rate (default item)
Also if catch rate is changed use base species catch rate to avoid legal errors if the catch rate of the evolution species if is not possible with the current moves
* Filter ingame trades and static encounters with catch rate for generation 1 non tradeback
* Fix min moves for generation 1 metapod encounter
* Clean up
* Fix encounter level for generation 1, valid moves are those with one level after the encounter level, pokemon can not learn a new move until level up
Clean up type validation
Fix generation 3 fatefull encounter eggs, the pokemon lost the fatefull mark when it hatch
* Clean-up
* Use new variable EncounterSpecies when it is needed to detect the species of the encounter, the old code wont work if the encounter is a wild slots array
* Fix generation 1 evolution chains and catch rate as default held item
* Fix Generation 1 Yellow Pikachu and Kadabra catch rates
2017-04-27 04:27:59 +00:00
|
|
|
|
}
|
|
|
|
|
else if (pkm.Format == 2 || pkm.VC2)
|
|
|
|
|
{
|
2017-04-27 05:05:32 +00:00
|
|
|
|
// Eggs, pokemon with non-empty crystal met location, and generation 2 species without generation 1 preevolutions can't be traded to generation 1.
|
Generation 1 and 2 legal Improvements (#1099)
* Refactor parseMovesForEncounter to gather valid moves for species encounter, some Pokemon can have valid encounters with different source species from the encounter, the valid moves change if the encounter species change because some preevolutions moves are illegal if pokemon caught already evolved.
Example, generation 1 Pikachu that can have a RBY Pikachu encounter and GSC Pichu encounter, the valid moves for the first encounters should not have any Pichu exclusive evolution moves
Also assign the encounter match from gb when parsing moves like the variable Encounter Match, to store the encounter that is valid for the pokemon moves instead the first encounter.
Store the species encounter, this will be needed to check if the evolution is valid for species that evolve leveling with a given learned move
* Add Tradeback Status to the pokemon, this variable for generations 1 and 2 use data like the catch rate to determine if trade between generations 1 and 2 was possible.
If analysis is for VC games tradeback have value NotTradeback for every gen 1 pokemon, but for cart saves some pokemon can be determine that have not been tradeback, if catch rate match species catch rate but do not match a valid generation 2 held item that means the pokemon habe been never traded to generation 2 games, that allow to discart encounters and moves from generation 2.
Also if is not tradeback catch rate is used to filter encounters, catch rate determine in what species was captured the pokemon discarting some preevolutions moves
Also add option for generation 1 cart save analysis to check legal status not allowing generation 2 games, like VC games but with Stadium allowed, like the generation 1 non tradeback rules from Smogon
Also change evolution chains to included generation 2 preevolutions for gen 1 pokemon if tradeback was possible, it is needed to avoid parsemoves to check illegal pokemon like Hitmonchan with Tyrogue level up moves
* Check legal values of generation 1 type and catch rate
Replace pokemon catch rate after changind pokemon species always if pokemon was not tradeback from generation 2, the catch rate will keep unchanged only if it can be a held item and do not match species catch rate (default item)
Also if catch rate is changed use base species catch rate to avoid legal errors if the catch rate of the evolution species if is not possible with the current moves
* Filter ingame trades and static encounters with catch rate for generation 1 non tradeback
* Fix min moves for generation 1 metapod encounter
* Clean up
* Fix encounter level for generation 1, valid moves are those with one level after the encounter level, pokemon can not learn a new move until level up
Clean up type validation
Fix generation 3 fatefull encounter eggs, the pokemon lost the fatefull mark when it hatch
* Clean-up
* Use new variable EncounterSpecies when it is needed to detect the species of the encounter, the old code wont work if the encounter is a wild slots array
* Fix generation 1 evolution chains and catch rate as default held item
* Fix Generation 1 Yellow Pikachu and Kadabra catch rates
2017-04-27 04:27:59 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2017-04-27 05:05:32 +00:00
|
|
|
|
// 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.
|
Generation 1 and 2 legal Improvements (#1099)
* Refactor parseMovesForEncounter to gather valid moves for species encounter, some Pokemon can have valid encounters with different source species from the encounter, the valid moves change if the encounter species change because some preevolutions moves are illegal if pokemon caught already evolved.
Example, generation 1 Pikachu that can have a RBY Pikachu encounter and GSC Pichu encounter, the valid moves for the first encounters should not have any Pichu exclusive evolution moves
Also assign the encounter match from gb when parsing moves like the variable Encounter Match, to store the encounter that is valid for the pokemon moves instead the first encounter.
Store the species encounter, this will be needed to check if the evolution is valid for species that evolve leveling with a given learned move
* Add Tradeback Status to the pokemon, this variable for generations 1 and 2 use data like the catch rate to determine if trade between generations 1 and 2 was possible.
If analysis is for VC games tradeback have value NotTradeback for every gen 1 pokemon, but for cart saves some pokemon can be determine that have not been tradeback, if catch rate match species catch rate but do not match a valid generation 2 held item that means the pokemon habe been never traded to generation 2 games, that allow to discart encounters and moves from generation 2.
Also if is not tradeback catch rate is used to filter encounters, catch rate determine in what species was captured the pokemon discarting some preevolutions moves
Also add option for generation 1 cart save analysis to check legal status not allowing generation 2 games, like VC games but with Stadium allowed, like the generation 1 non tradeback rules from Smogon
Also change evolution chains to included generation 2 preevolutions for gen 1 pokemon if tradeback was possible, it is needed to avoid parsemoves to check illegal pokemon like Hitmonchan with Tyrogue level up moves
* Check legal values of generation 1 type and catch rate
Replace pokemon catch rate after changind pokemon species always if pokemon was not tradeback from generation 2, the catch rate will keep unchanged only if it can be a held item and do not match species catch rate (default item)
Also if catch rate is changed use base species catch rate to avoid legal errors if the catch rate of the evolution species if is not possible with the current moves
* Filter ingame trades and static encounters with catch rate for generation 1 non tradeback
* Fix min moves for generation 1 metapod encounter
* Clean up
* Fix encounter level for generation 1, valid moves are those with one level after the encounter level, pokemon can not learn a new move until level up
Clean up type validation
Fix generation 3 fatefull encounter eggs, the pokemon lost the fatefull mark when it hatch
* Clean-up
* Use new variable EncounterSpecies when it is needed to detect the species of the encounter, the old code wont work if the encounter is a wild slots array
* Fix generation 1 evolution chains and catch rate as default held item
* Fix Generation 1 Yellow Pikachu and Kadabra catch rates
2017-04-27 04:27:59 +00:00
|
|
|
|
pkm.TradebackStatus = TradebackType.Gen1_NotTradeback;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pkm.TradebackStatus = TradebackType.Any;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-22 20:04:12 +00:00
|
|
|
|
private void updateTypeInfo()
|
2017-01-04 04:51:33 +00:00
|
|
|
|
{
|
2017-04-10 04:59:44 +00:00
|
|
|
|
if (pkm.VC && pkm.Format == 7)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
info.EncounterMatch = EncounterGenerator.getRBYStaticTransfer(pkm.Species);
|
2016-11-10 01:52:38 +00:00
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
if (pkm.GenNumber <= 2 && pkm.TradebackStatus == TradebackType.Any && (EncounterMatch as GBEncounterData)?.Generation != pkm.GenNumber)
|
Encounter Type fix and detection of pokemon that should have evolve on trade (#1105)
* Detect encounter trades that evolve on trade and have not been evolved
Detect generation 1 pokemon with special catch rates : krabby trade and Pokemon Stadium
Detect generation 1 pokemon that evolve on trade and have been traded but not evolved
Detect pokemon with tradeback status any but with only encounters from the other GB generation, that means they are WasTradeback
Detect pokemon with moves from the other GB generation, change tradebackstatus to WasTradeback
* Fix dppt surfing and fishing encounter type, is is surfing because the battle background is the same as other surfingfishing encounters
Fix headbutt encounter type, the encounter type depends on the battle background used when battle a pokemon, for headbutt it changes with the player tile, is the player is in a city it will be building encounter, in a grass tile tall grass, in water it is surfingfishing and cave inside a cave. Some locations have more than one possible encounter type, for example routes with trees near the grass, near the water and near non-combat tiles.
Also added slot type headbutt special for the special trees, those trees are all in routes and are only adjacent to non-combat tiles
* Fix encounter type for missing areas with multiple grass encounters types: Mt Coronet, Mt Silver Cave and Stark Mountain (Issue # 1095)
* Fixes and typos
* Check for non-japanese e-reader pokemon, is unreleased
2017-05-01 15:07:20 +00:00
|
|
|
|
// Example: GSC Pokemon with only possible encounters in RBY, like the legendary birds
|
|
|
|
|
pkm.TradebackStatus = TradebackType.WasTradeback;
|
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
MatchedType = Type = (EncounterOriginalGB ?? EncounterMatch)?.GetType();
|
2017-05-12 04:34:18 +00:00
|
|
|
|
var bt = Type.GetTypeInfo().BaseType;
|
|
|
|
|
if (bt != null && !(bt == typeof(Array) || bt == typeof(object) || bt.GetTypeInfo().IsPrimitive)) // a parent exists
|
2017-04-24 00:53:22 +00:00
|
|
|
|
Type = bt; // use base type
|
2017-02-15 01:33:57 +00:00
|
|
|
|
}
|
|
|
|
|
private void updateChecks()
|
|
|
|
|
{
|
2016-10-23 19:48:49 +00:00
|
|
|
|
verifyECPID();
|
|
|
|
|
verifyNickname();
|
2017-01-27 05:35:26 +00:00
|
|
|
|
verifyOT();
|
2016-10-23 19:48:49 +00:00
|
|
|
|
verifyIVs();
|
|
|
|
|
verifyEVs();
|
|
|
|
|
verifyLevel();
|
|
|
|
|
verifyRibbons();
|
|
|
|
|
verifyAbility();
|
|
|
|
|
verifyBall();
|
|
|
|
|
verifyForm();
|
|
|
|
|
verifyMisc();
|
|
|
|
|
verifyGender();
|
2017-02-26 17:44:59 +00:00
|
|
|
|
verifyItem();
|
Special Eggs improvement and Generation 4 Encounter Type legal analysis (#1083)
* Ignore relearn level 2-100 moves from Phione
* Cave encounter types DPPt
* Generation 4 EncounterType filter and validation
Not every generation 4 static encounter have yet their encounter type defined, i temporally included Any to those encounters
Generation 4 roaaming static encounters have been splitted in two, grass and surf
* Added new legality texts
* Added unreleased event DP Darkai, added check for surf in jhoto route 45, is impossible
Moved unreleased DP locations to valid Platinum locations only
* Improved generation 3 special egg check.
Only check special egg if pokemon knows any of the special egg moves, also in that case do check for normal egg before special egg
because special eggs will explicitly check for normal egg moves but normal eggs will not check special egg moves, it will improve the error output
* Clean up
* Fix gen 5 pokemon from issue #1011
Those pokemon have generation 4 static gift encounters and also wild encounters, the analysis was selecting the static encounter, but if there is a valid wild encounter and the static encounter does not match the pokemon ball the willd encounter should be selected instead
Also move the transfer legality to check it before the static encounters and make that check to work like generation 3 transfer legality
* Another fix for Issue 1011, suppress temporally OT and pokemon name analysis for generations 3 to 5 instead of format 3 to 5, there is no data stored yet to make those analysis
* Do not make wild encounters prevail static encounter if the pokemon was an egg
* Changed type of WildEncounter variable to EncounterSlot[]
* Fix Jhoto Route 45 to avoid return error with fishing encounters
2017-04-22 18:49:49 +00:00
|
|
|
|
if (pkm.Format >= 4)
|
|
|
|
|
verifyEncounterType();
|
2017-03-18 23:50:34 +00:00
|
|
|
|
if (pkm.Format >= 6)
|
|
|
|
|
{
|
|
|
|
|
History = verifyHistory();
|
|
|
|
|
AddLine(History);
|
|
|
|
|
verifyOTMemory();
|
|
|
|
|
verifyHTMemory();
|
|
|
|
|
verifyHyperTraining();
|
|
|
|
|
verifyMedals();
|
2017-03-19 17:44:46 +00:00
|
|
|
|
verifyRegion();
|
2017-03-24 02:47:53 +00:00
|
|
|
|
verifyVersionEvolution();
|
2017-03-18 23:50:34 +00:00
|
|
|
|
}
|
2017-02-28 04:57:24 +00:00
|
|
|
|
|
2016-10-23 19:48:49 +00:00
|
|
|
|
// SecondaryChecked = true;
|
2016-02-23 06:52:48 +00:00
|
|
|
|
}
|
2016-03-09 03:20:26 +00:00
|
|
|
|
private string getLegalityReport()
|
|
|
|
|
{
|
2017-05-18 04:50:52 +00:00
|
|
|
|
if (!Parsed || pkm == null)
|
2017-03-21 07:18:38 +00:00
|
|
|
|
return V189;
|
2016-03-14 03:19:04 +00:00
|
|
|
|
|
2017-04-29 22:45:21 +00:00
|
|
|
|
var lines = new List<string>();
|
2017-05-28 04:17:53 +00:00
|
|
|
|
var vMoves = info.vMoves;
|
|
|
|
|
var vRelearn = info.vRelearn;
|
2016-03-12 04:56:40 +00:00
|
|
|
|
for (int i = 0; i < 4; i++)
|
2016-03-12 17:16:41 +00:00
|
|
|
|
if (!vMoves[i].Valid)
|
2017-04-29 22:45:21 +00:00
|
|
|
|
lines.Add(string.Format(V191, getString(vMoves[i].Judgement), i + 1, vMoves[i].Comment));
|
2017-02-13 01:00:03 +00:00
|
|
|
|
|
|
|
|
|
if (pkm.Format >= 6)
|
2016-03-12 04:56:40 +00:00
|
|
|
|
for (int i = 0; i < 4; i++)
|
2016-03-12 17:16:41 +00:00
|
|
|
|
if (!vRelearn[i].Valid)
|
2017-04-29 22:45:21 +00:00
|
|
|
|
lines.Add(string.Format(V192, getString(vRelearn[i].Judgement), i + 1, vRelearn[i].Comment));
|
2016-03-12 04:56:40 +00:00
|
|
|
|
|
2017-04-29 22:45:21 +00:00
|
|
|
|
if (lines.Count == 0 && Parse.All(chk => chk.Valid) && Valid)
|
2017-03-21 07:18:38 +00:00
|
|
|
|
return V193;
|
2016-10-23 19:48:49 +00:00
|
|
|
|
|
2016-03-12 03:43:40 +00:00
|
|
|
|
// Build result string...
|
2017-03-21 07:18:38 +00:00
|
|
|
|
var outputLines = Parse.Where(chk => !chk.Valid); // Only invalid
|
2017-04-29 22:45:21 +00:00
|
|
|
|
lines.AddRange(outputLines.Select(chk => string.Format(V196, getString(chk.Judgement), chk.Comment)));
|
2016-03-12 04:56:40 +00:00
|
|
|
|
|
2017-04-29 22:45:21 +00:00
|
|
|
|
if (lines.Count == 0)
|
|
|
|
|
return V190;
|
2016-11-08 16:43:57 +00:00
|
|
|
|
|
2017-04-29 22:45:21 +00:00
|
|
|
|
return string.Join(Environment.NewLine, lines);
|
2016-04-04 00:11:58 +00:00
|
|
|
|
}
|
|
|
|
|
private string getVerboseLegalityReport()
|
|
|
|
|
{
|
2017-04-29 22:45:21 +00:00
|
|
|
|
if (!Parsed)
|
|
|
|
|
return V189;
|
|
|
|
|
|
|
|
|
|
const string separator = "===";
|
|
|
|
|
string[] br = {separator, ""};
|
|
|
|
|
var lines = new List<string> {br[1]};
|
|
|
|
|
lines.AddRange(br);
|
|
|
|
|
int rl = lines.Count;
|
2016-04-16 18:36:01 +00:00
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
var vMoves = info.vMoves;
|
|
|
|
|
var vRelearn = info.vRelearn;
|
2016-04-16 18:36:01 +00:00
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
if (vMoves[i].Valid)
|
2017-04-29 22:45:21 +00:00
|
|
|
|
lines.Add(string.Format(V191, getString(vMoves[i].Judgement), i + 1, vMoves[i].Comment));
|
2017-02-13 01:00:03 +00:00
|
|
|
|
|
|
|
|
|
if (pkm.Format >= 6)
|
2017-03-21 07:18:38 +00:00
|
|
|
|
for (int i = 0; i < 4; i++)
|
2016-04-16 18:36:01 +00:00
|
|
|
|
if (vRelearn[i].Valid)
|
2017-04-29 22:45:21 +00:00
|
|
|
|
lines.Add(string.Format(V192, getString(vRelearn[i].Judgement), i + 1, vRelearn[i].Comment));
|
2016-04-16 18:36:01 +00:00
|
|
|
|
|
2017-04-29 22:45:21 +00:00
|
|
|
|
if (rl != lines.Count) // move info added, break for next section
|
|
|
|
|
lines.Add(br[1]);
|
2016-10-23 19:48:49 +00:00
|
|
|
|
|
2017-03-21 07:18:38 +00:00
|
|
|
|
var outputLines = Parse.Where(chk => chk != null && chk.Valid && chk.Comment != V).OrderBy(chk => chk.Judgement); // Fishy sorted to top
|
2017-04-29 22:45:21 +00:00
|
|
|
|
lines.AddRange(outputLines.Select(chk => string.Format(V196, getString(chk.Judgement), chk.Comment)));
|
2016-12-31 01:13:22 +00:00
|
|
|
|
|
2017-04-29 22:45:21 +00:00
|
|
|
|
lines.AddRange(br);
|
|
|
|
|
lines.Add(string.Format(V195, EncounterName));
|
2017-04-30 03:04:54 +00:00
|
|
|
|
var pidiv = MethodFinder.Analyze(pkm);
|
|
|
|
|
if (pidiv != null)
|
|
|
|
|
{
|
|
|
|
|
if (!pidiv.NoSeed)
|
|
|
|
|
lines.Add(string.Format(V248, pidiv.OriginSeed.ToString("X8")));
|
|
|
|
|
lines.Add(string.Format(V249, pidiv.Type));
|
|
|
|
|
}
|
2017-04-29 22:45:21 +00:00
|
|
|
|
|
|
|
|
|
return getLegalityReport() + string.Join(Environment.NewLine, lines);
|
2016-03-09 03:20:26 +00:00
|
|
|
|
}
|
2016-03-25 07:10:11 +00:00
|
|
|
|
|
|
|
|
|
public int[] getSuggestedRelearn()
|
|
|
|
|
{
|
2017-05-28 04:17:53 +00:00
|
|
|
|
if (info.RelearnBase == null || pkm.GenNumber < 6 || !pkm.IsOriginValid)
|
2016-10-23 19:48:49 +00:00
|
|
|
|
return new int[4];
|
2016-03-25 07:10:11 +00:00
|
|
|
|
|
2016-10-23 19:48:49 +00:00
|
|
|
|
if (!pkm.WasEgg)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
return info.RelearnBase;
|
2016-03-25 07:10:11 +00:00
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
List<int> window = new List<int>(info.RelearnBase);
|
|
|
|
|
var vMoves = info.vMoves;
|
2017-03-24 03:05:13 +00:00
|
|
|
|
window.AddRange(pkm.Moves.Where((v, i) => !vMoves[i].Valid || vMoves[i].Flag));
|
2017-04-05 06:11:47 +00:00
|
|
|
|
window = window.Distinct().ToList();
|
2016-03-25 07:10:11 +00:00
|
|
|
|
if (window.Count < 4)
|
|
|
|
|
window.AddRange(new int[4 - window.Count]);
|
2017-03-24 03:05:13 +00:00
|
|
|
|
return window.Skip(window.Count - 4).ToArray();
|
2016-03-25 07:10:11 +00:00
|
|
|
|
}
|
2016-11-27 04:02:44 +00:00
|
|
|
|
public int[] getSuggestedMoves(bool tm, bool tutor, bool reminder)
|
2016-11-15 06:13:15 +00:00
|
|
|
|
{
|
2017-02-15 08:11:12 +00:00
|
|
|
|
if (pkm == null || !pkm.IsOriginValid)
|
2016-11-15 06:13:15 +00:00
|
|
|
|
return null;
|
2017-02-14 06:49:32 +00:00
|
|
|
|
if (!Parsed)
|
2017-02-13 01:00:03 +00:00
|
|
|
|
return new int[4];
|
2017-05-28 04:17:53 +00:00
|
|
|
|
return Legal.getValidMoves(pkm, info.EvoChainsAllGens, Tutor: tutor, Machine: tm, MoveReminder: reminder).Skip(1).ToArray(); // skip move 0
|
2016-12-31 01:13:22 +00:00
|
|
|
|
}
|
2016-11-27 07:23:45 +00:00
|
|
|
|
|
|
|
|
|
public EncounterStatic getSuggestedMetInfo()
|
|
|
|
|
{
|
2016-11-27 21:33:00 +00:00
|
|
|
|
if (pkm == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2017-02-15 08:11:12 +00:00
|
|
|
|
int loc = getSuggestedTransferLocation(pkm);
|
2016-11-27 07:23:45 +00:00
|
|
|
|
if (pkm.WasEgg)
|
2017-03-25 05:41:45 +00:00
|
|
|
|
{
|
|
|
|
|
int lvl = 1; // gen5+
|
|
|
|
|
if (!pkm.IsNative)
|
|
|
|
|
lvl = pkm.CurrentLevel; // be generous with transfer conditions
|
|
|
|
|
else if (pkm.Format < 5) // and native
|
|
|
|
|
lvl = 0;
|
2016-11-27 07:23:45 +00:00
|
|
|
|
return new EncounterStatic
|
|
|
|
|
{
|
2016-12-03 04:26:35 +00:00
|
|
|
|
Species = Legal.getBaseSpecies(pkm),
|
2017-02-15 08:11:12 +00:00
|
|
|
|
Location = loc != -1 ? loc : getSuggestedEggMetLocation(pkm),
|
2017-03-25 05:41:45 +00:00
|
|
|
|
Level = lvl,
|
2016-11-27 07:23:45 +00:00
|
|
|
|
};
|
2017-03-25 05:41:45 +00:00
|
|
|
|
}
|
2016-11-27 07:23:45 +00:00
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
var area = EncounterGenerator.getCaptureLocation(pkm);
|
2017-02-15 01:33:57 +00:00
|
|
|
|
if (area != null)
|
|
|
|
|
{
|
|
|
|
|
var slots = area.Slots.OrderBy(s => s.LevelMin);
|
2016-11-27 07:23:45 +00:00
|
|
|
|
return new EncounterStatic
|
|
|
|
|
{
|
2017-02-15 01:33:57 +00:00
|
|
|
|
Species = slots.First().Species,
|
2017-02-15 08:11:12 +00:00
|
|
|
|
Location = loc != -1 ? loc : area.Location,
|
2017-02-15 01:33:57 +00:00
|
|
|
|
Level = slots.First().LevelMin,
|
2016-11-27 07:23:45 +00:00
|
|
|
|
};
|
2017-02-15 01:33:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
var encounter = EncounterGenerator.getStaticLocation(pkm);
|
2017-03-10 04:27:03 +00:00
|
|
|
|
if (loc != -1 && encounter != null)
|
2017-02-15 08:11:12 +00:00
|
|
|
|
encounter.Location = loc;
|
2016-11-27 07:23:45 +00:00
|
|
|
|
return encounter;
|
|
|
|
|
}
|
|
|
|
|
private static int getSuggestedEggMetLocation(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
// Return one of legal hatch locations for game
|
|
|
|
|
switch ((GameVersion)pkm.Version)
|
|
|
|
|
{
|
2017-03-25 05:41:45 +00:00
|
|
|
|
case GameVersion.R:
|
|
|
|
|
case GameVersion.S:
|
|
|
|
|
case GameVersion.E:
|
|
|
|
|
case GameVersion.FR:
|
|
|
|
|
case GameVersion.LG:
|
|
|
|
|
switch (pkm.Format)
|
|
|
|
|
{
|
|
|
|
|
case 3:
|
|
|
|
|
return pkm.FRLG ? 146 /* Four Island */ : 32; // Route 117
|
|
|
|
|
case 4:
|
|
|
|
|
return 0x37; // Pal Park
|
|
|
|
|
default:
|
|
|
|
|
return 30001; // Transporter
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-27 07:23:45 +00:00
|
|
|
|
case GameVersion.D:
|
|
|
|
|
case GameVersion.P:
|
|
|
|
|
case GameVersion.Pt:
|
|
|
|
|
return pkm.Format > 4 ? 30001 /* Transporter */ : 4; // Solaceon Town
|
|
|
|
|
case GameVersion.HG:
|
|
|
|
|
case GameVersion.SS:
|
|
|
|
|
return pkm.Format > 4 ? 30001 /* Transporter */ : 182; // Route 34
|
|
|
|
|
|
|
|
|
|
case GameVersion.B:
|
|
|
|
|
case GameVersion.W:
|
|
|
|
|
return 16; // Route 3
|
|
|
|
|
|
|
|
|
|
case GameVersion.X:
|
|
|
|
|
case GameVersion.Y:
|
|
|
|
|
return 38; // Route 7
|
|
|
|
|
case GameVersion.AS:
|
|
|
|
|
case GameVersion.OR:
|
|
|
|
|
return 318; // Battle Resort
|
|
|
|
|
|
|
|
|
|
case GameVersion.SN:
|
|
|
|
|
case GameVersion.MN:
|
2016-12-01 05:36:02 +00:00
|
|
|
|
return 50; // Route 4
|
2016-11-27 07:23:45 +00:00
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2017-02-15 08:11:12 +00:00
|
|
|
|
private static int getSuggestedTransferLocation(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
// Return one of legal hatch locations for game
|
|
|
|
|
if (pkm.HasOriginalMetLocation)
|
|
|
|
|
return -1;
|
|
|
|
|
if (pkm.VC1)
|
|
|
|
|
return 30013;
|
|
|
|
|
if (pkm.Format == 4) // Pal Park
|
|
|
|
|
return 0x37;
|
|
|
|
|
if (pkm.Format == 5) // Transporter
|
|
|
|
|
return 30001;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2016-02-23 06:52:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|