2017-05-29 07:48:25 +00:00
|
|
|
|
using System;
|
2020-01-19 00:46:38 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2017-05-29 07:48:25 +00:00
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2017-10-24 06:12:58 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generation 3 Mystery Gift Template File
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// This is fabricated data built to emulate the future generation Mystery Gift objects.
|
|
|
|
|
/// Data here is not stored in any save file and cannot be naturally exported.
|
|
|
|
|
/// </remarks>
|
2020-05-20 04:07:30 +00:00
|
|
|
|
public sealed class WC3 : MysteryGift, IRibbonSetEvent3
|
2017-05-29 07:48:25 +00:00
|
|
|
|
{
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
public override MysteryGift Clone() => (WC3)MemberwiseClone();
|
|
|
|
|
|
2017-05-29 07:48:25 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Matched <see cref="PIDIV"/> Type
|
|
|
|
|
/// </summary>
|
|
|
|
|
public PIDType Method;
|
|
|
|
|
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
public override string OT_Name { get; set; } = string.Empty;
|
2020-12-24 04:40:59 +00:00
|
|
|
|
public int OT_Gender { get; init; } = 3;
|
2017-11-18 19:34:23 +00:00
|
|
|
|
public override int TID { get; set; }
|
|
|
|
|
public override int SID { get; set; }
|
2018-01-02 20:00:41 +00:00
|
|
|
|
public override int Location { get; set; } = 255;
|
|
|
|
|
public override int EggLocation { get => 0; set {} }
|
2020-05-20 04:07:30 +00:00
|
|
|
|
public override GameVersion Version { get; set; }
|
2020-12-24 04:40:59 +00:00
|
|
|
|
public int Language { get; init; } = -1;
|
2017-05-29 07:48:25 +00:00
|
|
|
|
public override int Species { get; set; }
|
|
|
|
|
public override bool IsEgg { get; set; }
|
2020-01-19 00:46:38 +00:00
|
|
|
|
public override IReadOnlyList<int> Moves { get; set; } = Array.Empty<int>();
|
2020-12-24 04:40:59 +00:00
|
|
|
|
public bool NotDistributed { get; init; }
|
|
|
|
|
public Shiny Shiny { get; init; } = Shiny.Random;
|
|
|
|
|
public bool Fateful { get; init; } // Obedience Flag
|
2017-05-29 07:48:25 +00:00
|
|
|
|
|
|
|
|
|
// Mystery Gift Properties
|
2020-12-11 04:42:30 +00:00
|
|
|
|
public override int Generation => 3;
|
2017-05-29 07:48:25 +00:00
|
|
|
|
public override int Level { get; set; }
|
|
|
|
|
public override int Ball { get; set; } = 4;
|
2018-04-04 16:53:48 +00:00
|
|
|
|
public override bool IsShiny => Shiny == Shiny.Always;
|
2018-12-27 09:00:08 +00:00
|
|
|
|
public bool RibbonEarth { get; set; }
|
|
|
|
|
public bool RibbonNational { get; set; }
|
|
|
|
|
public bool RibbonCountry { get; set; }
|
|
|
|
|
public bool RibbonChampionBattle { get; set; }
|
|
|
|
|
public bool RibbonChampionRegional { get; set; }
|
|
|
|
|
public bool RibbonChampionNational { get; set; }
|
|
|
|
|
|
2017-05-29 07:48:25 +00:00
|
|
|
|
// Description
|
|
|
|
|
public override string CardTitle { get; set; } = "Generation 3 Event";
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override string CardHeader => CardTitle;
|
2017-05-29 07:48:25 +00:00
|
|
|
|
|
|
|
|
|
// Unused
|
|
|
|
|
public override bool GiftUsed { get; set; }
|
|
|
|
|
public override int CardID { get; set; }
|
|
|
|
|
public override bool IsItem { get; set; }
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override int ItemID { get; set; }
|
2017-07-16 01:36:55 +00:00
|
|
|
|
public override bool IsPokémon { get; set; } = true;
|
|
|
|
|
public override bool Empty => false;
|
2017-11-18 19:34:23 +00:00
|
|
|
|
public override int Gender { get; set; }
|
|
|
|
|
public override int Form { get; set; }
|
2017-05-29 07:48:25 +00:00
|
|
|
|
|
2017-06-30 02:32:29 +00:00
|
|
|
|
// Synthetic
|
2020-12-24 04:40:59 +00:00
|
|
|
|
private readonly int? _metLevel;
|
2018-08-10 04:53:39 +00:00
|
|
|
|
|
2017-06-30 02:32:29 +00:00
|
|
|
|
public int Met_Level
|
|
|
|
|
{
|
2017-07-06 06:22:06 +00:00
|
|
|
|
get => _metLevel ?? (IsEgg ? 0 : Level);
|
2020-12-24 04:40:59 +00:00
|
|
|
|
init => _metLevel = value;
|
2017-06-30 02:32:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-17 02:46:22 +00:00
|
|
|
|
public override PKM ConvertToPKM(ITrainerInfo sav, EncounterCriteria criteria)
|
2017-05-29 07:48:25 +00:00
|
|
|
|
{
|
2020-12-22 01:17:56 +00:00
|
|
|
|
PK3 pk = new()
|
2017-07-16 01:36:55 +00:00
|
|
|
|
{
|
|
|
|
|
Species = Species,
|
|
|
|
|
Met_Level = Met_Level,
|
2018-01-02 20:00:41 +00:00
|
|
|
|
Met_Location = Location,
|
2017-07-16 01:36:55 +00:00
|
|
|
|
Ball = 4,
|
2019-11-19 06:48:03 +00:00
|
|
|
|
|
2017-07-16 01:36:55 +00:00
|
|
|
|
// Ribbons
|
|
|
|
|
RibbonCountry = RibbonCountry,
|
|
|
|
|
RibbonNational = RibbonNational,
|
|
|
|
|
RibbonEarth = RibbonEarth,
|
|
|
|
|
RibbonChampionBattle = RibbonChampionBattle,
|
|
|
|
|
RibbonChampionRegional = RibbonChampionRegional,
|
|
|
|
|
RibbonChampionNational = RibbonChampionNational,
|
|
|
|
|
|
|
|
|
|
FatefulEncounter = Fateful,
|
2020-06-17 02:46:22 +00:00
|
|
|
|
Version = GetVersion(sav),
|
2017-07-16 01:36:55 +00:00
|
|
|
|
};
|
2019-11-16 01:34:18 +00:00
|
|
|
|
pk.EXP = Experience.GetEXP(Level, pk.PersonalInfo.EXPGrowth);
|
2019-02-09 19:37:20 +00:00
|
|
|
|
SetMoves(pk);
|
|
|
|
|
|
2020-06-17 02:46:22 +00:00
|
|
|
|
bool hatchedEgg = IsEgg && sav.Generation != 3;
|
2019-02-09 19:37:20 +00:00
|
|
|
|
if (hatchedEgg)
|
2017-07-16 01:36:55 +00:00
|
|
|
|
{
|
2020-06-17 02:46:22 +00:00
|
|
|
|
SetForceHatchDetails(pk, sav);
|
2017-07-16 01:36:55 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-06-17 02:46:22 +00:00
|
|
|
|
pk.OT_Gender = OT_Gender != 3 ? OT_Gender & 1 : sav.Gender;
|
2017-07-16 01:36:55 +00:00
|
|
|
|
pk.TID = TID;
|
|
|
|
|
pk.SID = SID;
|
2019-02-09 19:37:20 +00:00
|
|
|
|
|
2020-06-17 02:46:22 +00:00
|
|
|
|
pk.Language = (int)GetSafeLanguage((LanguageID)sav.Language);
|
|
|
|
|
pk.OT_Name = !string.IsNullOrWhiteSpace(OT_Name) ? OT_Name : sav.OT;
|
2019-02-09 19:37:20 +00:00
|
|
|
|
if (IsEgg)
|
2020-03-14 01:37:51 +00:00
|
|
|
|
pk.IsEgg = true; // lang should be set to japanese already
|
2017-07-16 01:36:55 +00:00
|
|
|
|
}
|
2019-09-19 02:58:23 +00:00
|
|
|
|
pk.Nickname = SpeciesName.GetSpeciesNameGeneration(Species, pk.Language, 3); // will be set to Egg nickname if appropriate by PK3 setter
|
2017-07-16 01:36:55 +00:00
|
|
|
|
|
2019-02-09 19:37:20 +00:00
|
|
|
|
var pi = pk.PersonalInfo;
|
|
|
|
|
pk.OT_Friendship = pk.IsEgg ? pi.HatchCycles : pi.BaseFriendship;
|
|
|
|
|
|
2017-07-16 01:36:55 +00:00
|
|
|
|
// Generate PIDIV
|
2019-02-09 19:37:20 +00:00
|
|
|
|
SetPINGA(pk, criteria);
|
2020-06-17 02:46:22 +00:00
|
|
|
|
pk.HeldItem = 0; // clear, only random for Jirachi (?), no loss
|
2017-07-16 01:36:55 +00:00
|
|
|
|
|
2018-05-27 17:11:01 +00:00
|
|
|
|
if (Version == GameVersion.XD)
|
2018-05-27 22:04:21 +00:00
|
|
|
|
pk.FatefulEncounter = true; // pk3 is already converted from xk3
|
2019-02-09 19:37:20 +00:00
|
|
|
|
|
2018-12-30 06:24:34 +00:00
|
|
|
|
pk.RefreshChecksum();
|
|
|
|
|
return pk;
|
|
|
|
|
}
|
2018-05-27 17:11:01 +00:00
|
|
|
|
|
2020-10-04 15:59:33 +00:00
|
|
|
|
private void SetForceHatchDetails(PK3 pk, ITrainerInfo sav)
|
2019-02-09 19:37:20 +00:00
|
|
|
|
{
|
2020-10-04 15:59:33 +00:00
|
|
|
|
pk.Language = (int)GetSafeLanguageNotEgg((LanguageID)sav.Language);
|
|
|
|
|
pk.OT_Name = sav.OT;
|
2019-02-09 19:37:20 +00:00
|
|
|
|
// ugly workaround for character table interactions
|
2020-10-04 15:59:33 +00:00
|
|
|
|
if (string.IsNullOrWhiteSpace(pk.OT_Name))
|
|
|
|
|
{
|
|
|
|
|
pk.Language = (int)LanguageID.English;
|
|
|
|
|
pk.OT_Name = "PKHeX";
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-17 02:46:22 +00:00
|
|
|
|
pk.OT_Gender = sav.Gender;
|
|
|
|
|
pk.TID = sav.TID;
|
|
|
|
|
pk.SID = sav.SID;
|
2019-02-09 19:37:20 +00:00
|
|
|
|
pk.Met_Location = pk.FRLG ? 146 /* Four Island */ : 32; // Route 117
|
|
|
|
|
pk.FatefulEncounter &= pk.FRLG; // clear flag for RSE
|
|
|
|
|
pk.Met_Level = 0; // hatched
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-17 02:46:22 +00:00
|
|
|
|
private int GetVersion(ITrainerInfo sav)
|
2019-02-09 19:37:20 +00:00
|
|
|
|
{
|
2019-10-04 05:21:33 +00:00
|
|
|
|
if (Version != 0)
|
|
|
|
|
return (int) GetRandomVersion(Version);
|
2020-06-17 02:46:22 +00:00
|
|
|
|
bool gen3 = sav.Game <= 15 && GameVersion.Gen3.Contains((GameVersion)sav.Game);
|
|
|
|
|
return gen3 ? sav.Game : (int)GameVersion.R;
|
2019-02-09 19:37:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-30 06:24:34 +00:00
|
|
|
|
private void SetMoves(PK3 pk)
|
|
|
|
|
{
|
2020-01-19 00:46:38 +00:00
|
|
|
|
if (Moves.Count == 0) // not completely defined
|
2020-06-21 00:44:05 +00:00
|
|
|
|
Moves = MoveList.GetBaseEggMoves(pk, Species, Form, (GameVersion)pk.Version, Level);
|
2020-01-19 00:46:38 +00:00
|
|
|
|
if (Moves.Count != 4)
|
2017-07-16 06:35:32 +00:00
|
|
|
|
{
|
2020-01-19 00:46:38 +00:00
|
|
|
|
var moves = Moves.ToArray();
|
2017-07-16 01:36:55 +00:00
|
|
|
|
Array.Resize(ref moves, 4);
|
2017-07-16 06:35:32 +00:00
|
|
|
|
Moves = moves;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-19 00:46:38 +00:00
|
|
|
|
pk.SetMoves(Moves);
|
2018-04-07 18:40:01 +00:00
|
|
|
|
pk.SetMaximumPPCurrent(Moves);
|
2018-12-30 06:24:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-09 21:52:49 +00:00
|
|
|
|
private void SetPINGA(PK3 pk, EncounterCriteria _)
|
2018-12-30 06:24:34 +00:00
|
|
|
|
{
|
|
|
|
|
var seed = Util.Rand32();
|
2021-02-01 18:53:40 +00:00
|
|
|
|
seed = TID == 06930 ? MystryMew.GetSeed(seed, Method) : GetSaneSeed(seed);
|
2019-02-09 19:37:20 +00:00
|
|
|
|
PIDGenerator.SetValuesFromSeed(pk, Method, seed);
|
2018-12-30 06:24:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-01-02 01:08:49 +00:00
|
|
|
|
private uint GetSaneSeed(uint seed) => Method switch
|
2018-12-30 06:24:34 +00:00
|
|
|
|
{
|
2021-01-02 01:08:49 +00:00
|
|
|
|
PIDType.BACD_R => seed & 0x0000FFFF, // u16
|
|
|
|
|
PIDType.BACD_R_S => seed & 0x000000FF, // u8
|
2021-08-20 20:49:20 +00:00
|
|
|
|
_ => seed,
|
2021-01-02 01:08:49 +00:00
|
|
|
|
};
|
2017-07-01 23:50:45 +00:00
|
|
|
|
|
2020-03-14 01:37:51 +00:00
|
|
|
|
private LanguageID GetSafeLanguage(LanguageID hatchLang)
|
2017-07-16 06:35:32 +00:00
|
|
|
|
{
|
2020-03-14 01:37:51 +00:00
|
|
|
|
if (IsEgg)
|
|
|
|
|
return LanguageID.Japanese;
|
2020-10-04 15:59:33 +00:00
|
|
|
|
return GetSafeLanguageNotEgg(hatchLang);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private LanguageID GetSafeLanguageNotEgg(LanguageID hatchLang)
|
|
|
|
|
{
|
2020-03-14 01:37:51 +00:00
|
|
|
|
if (Language != -1)
|
2020-10-04 15:59:33 +00:00
|
|
|
|
return (LanguageID) Language;
|
2020-03-14 01:37:51 +00:00
|
|
|
|
if (hatchLang < LanguageID.Korean && hatchLang != LanguageID.Hacked)
|
|
|
|
|
return hatchLang;
|
|
|
|
|
return LanguageID.English; // fallback
|
2017-07-16 06:35:32 +00:00
|
|
|
|
}
|
2018-08-10 04:53:39 +00:00
|
|
|
|
|
2018-05-27 21:16:56 +00:00
|
|
|
|
private static GameVersion GetRandomVersion(GameVersion version)
|
2017-07-16 06:35:32 +00:00
|
|
|
|
{
|
2021-05-29 22:31:47 +00:00
|
|
|
|
if (version is <= GameVersion.CXD and > 0) // single game
|
2017-07-16 06:35:32 +00:00
|
|
|
|
return version;
|
|
|
|
|
|
2020-12-24 01:14:38 +00:00
|
|
|
|
return version switch
|
2017-07-16 06:35:32 +00:00
|
|
|
|
{
|
2021-01-02 01:08:49 +00:00
|
|
|
|
GameVersion.FRLG => GameVersion.FR + Util.Rand.Next(2), // or LG
|
|
|
|
|
GameVersion.RS or GameVersion.RSE => GameVersion.S + Util.Rand.Next(2), // or R
|
|
|
|
|
GameVersion.COLO or GameVersion.XD => GameVersion.CXD,
|
2021-08-20 20:49:20 +00:00
|
|
|
|
_ => throw new Exception($"Unknown GameVersion: {version}"),
|
2020-12-24 01:14:38 +00:00
|
|
|
|
};
|
2017-07-16 06:35:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
Fracture the encounter matching checks to allow progressive validation (#3137)
## Issue
We want to discard-but-remember any slots that aren't a perfect fit, on the off chance that a better one exists later in the search space. If there's no better match, then we gotta go with what we got.
## Example:
Wurmple exists in area `X`, and also has a more rare slot for Silcoon, with the same level for both slots.
* We have a Silcoon that we've leveled up a few times.
Was our Silcoon originally a Wurmple, or was it caught as a Silcoon?
* To be sure, we have to check the EC/PID if the Wurmple wouldn't evolve into Cascoon instead.
* We don't want to wholly reject that Wurmple slot, as maybe the Met Level isn't within Silcoon's slot range.
---
Existing implementation would store "deferred" matches in a list; we only need to keep 1 of these matches around (less allocation!). We also want to differentiate between a "good" deferral and a "bad" deferral; I don't think this is necessary but it's currently used by Mystery Gift matching (implemented for the Eeveelution mystery gifts which matter for evolution moves).
The existing logic didn't use inheritance, and instead had static methods being reused across generations. Quite kludgy. Also, the existing logic was a pain to modify the master encounter yield methods, as one generation's quirks had to not impact all other generations that used the method.
---
The new implementation splits out the encounter yielding methods to be separate for each generation / subset. Now, things don't have to check `WasLink` for Gen7 origin, because Pokémon Link wasn't a thing in Gen7.
---
## Future
Maybe refactoring yielders into "GameCores" that expose yielding behaviors / properties, rather than the static logic. As more generations and side-gamegroups get added (thanks LGPE/GO/GameCube), all this switch stuff gets annoying to maintain instead of just overriding/inheritance.
## Conclusion
This shouldn't impact any legality results negatively; if you notice any regressions, report them! This should reduce false flags where we didn't defer-discard an encounter when we should have (wild area mons being confused with raids).
2021-01-30 01:55:27 +00:00
|
|
|
|
public override bool IsMatchExact(PKM pkm, DexLevel evo)
|
2018-12-27 09:00:08 +00:00
|
|
|
|
{
|
|
|
|
|
// Gen3 Version MUST match.
|
2020-07-17 17:56:35 +00:00
|
|
|
|
if (Version != 0 && !Version.Contains((GameVersion)pkm.Version))
|
2018-12-27 09:00:08 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
bool hatchedEgg = IsEgg && !pkm.IsEgg;
|
|
|
|
|
if (!hatchedEgg)
|
|
|
|
|
{
|
|
|
|
|
if (SID != -1 && SID != pkm.SID) return false;
|
|
|
|
|
if (TID != -1 && TID != pkm.TID) return false;
|
|
|
|
|
if (OT_Gender < 3 && OT_Gender != pkm.OT_Gender) return false;
|
|
|
|
|
var wcOT = OT_Name;
|
2020-02-04 03:22:16 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(wcOT))
|
2018-12-27 09:00:08 +00:00
|
|
|
|
{
|
2020-06-17 02:46:22 +00:00
|
|
|
|
if (wcOT.Length > 7) // Colosseum MATTLE Ho-Oh
|
2018-12-27 09:00:08 +00:00
|
|
|
|
{
|
|
|
|
|
if (!GetIsValidOTMattleHoOh(wcOT, pkm.OT_Name, pkm is CK3))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else if (wcOT != pkm.OT_Name)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-11 04:42:30 +00:00
|
|
|
|
if (Form != evo.Form && !FormInfo.IsFormChangeable(Species, Form, pkm.Form, pkm.Format))
|
2020-07-18 18:29:16 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
2018-12-27 09:00:08 +00:00
|
|
|
|
if (Language != -1 && Language != pkm.Language) return false;
|
|
|
|
|
if (Ball != pkm.Ball) return false;
|
|
|
|
|
if (Fateful != pkm.FatefulEncounter)
|
|
|
|
|
{
|
|
|
|
|
// XD Gifts only at level 20 get flagged after transfer
|
|
|
|
|
if (Version == GameVersion.XD != pkm is XK3)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pkm.IsNative)
|
|
|
|
|
{
|
|
|
|
|
if (hatchedEgg)
|
|
|
|
|
return true; // defer egg specific checks to later.
|
|
|
|
|
if (Met_Level != pkm.Met_Level)
|
|
|
|
|
return false;
|
|
|
|
|
if (Location != pkm.Met_Location)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (pkm.IsEgg)
|
|
|
|
|
return false;
|
|
|
|
|
if (Level > pkm.Met_Level)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static bool GetIsValidOTMattleHoOh(string wc, string ot, bool ck3)
|
|
|
|
|
{
|
|
|
|
|
if (ck3 && ot.Length == 10)
|
|
|
|
|
return wc == ot;
|
|
|
|
|
return ot.Length == 7 && wc.StartsWith(ot);
|
|
|
|
|
}
|
|
|
|
|
|
Fracture the encounter matching checks to allow progressive validation (#3137)
## Issue
We want to discard-but-remember any slots that aren't a perfect fit, on the off chance that a better one exists later in the search space. If there's no better match, then we gotta go with what we got.
## Example:
Wurmple exists in area `X`, and also has a more rare slot for Silcoon, with the same level for both slots.
* We have a Silcoon that we've leveled up a few times.
Was our Silcoon originally a Wurmple, or was it caught as a Silcoon?
* To be sure, we have to check the EC/PID if the Wurmple wouldn't evolve into Cascoon instead.
* We don't want to wholly reject that Wurmple slot, as maybe the Met Level isn't within Silcoon's slot range.
---
Existing implementation would store "deferred" matches in a list; we only need to keep 1 of these matches around (less allocation!). We also want to differentiate between a "good" deferral and a "bad" deferral; I don't think this is necessary but it's currently used by Mystery Gift matching (implemented for the Eeveelution mystery gifts which matter for evolution moves).
The existing logic didn't use inheritance, and instead had static methods being reused across generations. Quite kludgy. Also, the existing logic was a pain to modify the master encounter yield methods, as one generation's quirks had to not impact all other generations that used the method.
---
The new implementation splits out the encounter yielding methods to be separate for each generation / subset. Now, things don't have to check `WasLink` for Gen7 origin, because Pokémon Link wasn't a thing in Gen7.
---
## Future
Maybe refactoring yielders into "GameCores" that expose yielding behaviors / properties, rather than the static logic. As more generations and side-gamegroups get added (thanks LGPE/GO/GameCube), all this switch stuff gets annoying to maintain instead of just overriding/inheritance.
## Conclusion
This shouldn't impact any legality results negatively; if you notice any regressions, report them! This should reduce false flags where we didn't defer-discard an encounter when we should have (wild area mons being confused with raids).
2021-01-30 01:55:27 +00:00
|
|
|
|
protected override bool IsMatchDeferred(PKM pkm) => Species != pkm.Species;
|
|
|
|
|
protected override bool IsMatchPartial(PKM pkm) => false;
|
2017-05-29 07:48:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|