mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 06:20:25 +00:00
Consolidate encounterlink into mysterygift
use synthetic wondercards to match link gifts
This commit is contained in:
parent
ce11bda416
commit
41a3989b53
14 changed files with 16 additions and 216 deletions
|
@ -254,10 +254,11 @@ namespace PKHeX.Core
|
|||
public static int[] GetSuggestedRelearnMoves(this PKM pk, LegalityAnalysis legal)
|
||||
{
|
||||
int[] m = legal.GetSuggestedRelearn();
|
||||
if (!m.All(z => z == 0))
|
||||
if (m.Any(z => z != 0))
|
||||
return m;
|
||||
|
||||
if (pk.WasEgg || pk.WasEvent || pk.WasEventEgg || pk.WasLink)
|
||||
var enc = legal.EncounterMatch;
|
||||
if (enc is MysteryGift || enc is EncounterEgg)
|
||||
return m;
|
||||
|
||||
var encounter = legal.GetSuggestedMetInfo();
|
||||
|
|
|
@ -401,23 +401,5 @@ namespace PKHeX.Core
|
|||
new EncounterTrade { Species = 222, Level = 50, Ability = 4, Gender = 1, TID = 00325, Nature = Nature.Calm, IVs = new[] {31, -1, -1, -1, -1, 31}, }, // Corsola
|
||||
};
|
||||
#endregion
|
||||
#region Pokémon Link Gifts
|
||||
|
||||
internal static readonly EncounterLink[] LinkGifts6 =
|
||||
{
|
||||
new EncounterLink { Species = 154, Level = 50, Ability = 4, Moves = new[] {076, 241, 235, 034} }, // Meganium
|
||||
new EncounterLink { Species = 157, Level = 50, Ability = 4, Moves = new[] {315, 172, 488, 129} }, // Typhlosion
|
||||
new EncounterLink { Species = 160, Level = 50, Ability = 4, Moves = new[] {008, 242, 127, 103} }, // Feraligatr with Ice Punch (not relearn)
|
||||
|
||||
new EncounterLink { Species = 251, Level = 10, Ability = 1, Moves = new[] {105, 215, 610, 219}, RelearnMoves = new[] {610, 0, 0, 0}, Ball = 11, Version = GameVersion.XY }, // Celebi
|
||||
|
||||
new EncounterLink { Species = 377, Level = 50, Ability = 4, Moves = new[] {153, 008, 444, 359}, RelearnMoves = new[] {153, 008, 444, 359}, }, // Regirock
|
||||
new EncounterLink { Species = 378, Level = 50, Ability = 4, Moves = new[] {085, 133, 058, 258}, RelearnMoves = new[] {085, 133, 058, 258}, }, // Regice
|
||||
new EncounterLink { Species = 379, Level = 50, Ability = 4, Moves = new[] {442, 157, 356, 334}, RelearnMoves = new[] {442, 157, 356, 334}, }, // Registeel
|
||||
|
||||
new EncounterLink { Species = 208, Level = 40, Ability = 1, Moves = new[] {231, 242, 157, 103}, RibbonClassic = false, Version = GameVersion.ORAS, OT = false }, // Steelix
|
||||
new EncounterLink { Species = 362, Level = 40, Ability = 1, Moves = new[] {423, 029, 182, 524}, RibbonClassic = false, Version = GameVersion.ORAS, OT = false }, // Glalie
|
||||
};
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Pokémon Link Encounter Data
|
||||
/// </summary>
|
||||
public sealed class EncounterLink : IEncounterable, IRibbonSetEvent4, IMoveset, ILocation, IVersion
|
||||
{
|
||||
public int Species { get; set; }
|
||||
public int Level { get; set; }
|
||||
public int LevelMin => Level;
|
||||
public int LevelMax => Level;
|
||||
public int Location { get; set; } = 30011;
|
||||
public int Ability { get; set; } = 1;
|
||||
public int Ball { get; set; } = 4; // Pokéball
|
||||
public int[] RelearnMoves { get; set; } = Array.Empty<int>();
|
||||
public bool OT { get; set; } = true; // Receiver is OT?
|
||||
|
||||
public bool EggEncounter => false;
|
||||
public int EggLocation { get => 0; set { } }
|
||||
public GameVersion Version { get; set; } = GameVersion.Gen6;
|
||||
|
||||
public int[] Moves { get; set; } = Array.Empty<int>();
|
||||
|
||||
public string Name => "Pokémon Link Gift";
|
||||
|
||||
public bool RibbonClassic { get; set; } = true;
|
||||
|
||||
// Unused
|
||||
public bool RibbonWishing { get; set; }
|
||||
public bool RibbonPremier { get; set; }
|
||||
public bool RibbonEvent { get; set; }
|
||||
public bool RibbonBirthday { get; set; }
|
||||
public bool RibbonSpecial { get; set; }
|
||||
public bool RibbonWorld { get; set; }
|
||||
public bool RibbonChampionWorld { get; set; }
|
||||
public bool RibbonSouvenir { get; set; }
|
||||
|
||||
public PKM ConvertToPKM(ITrainerInfo SAV) => ConvertToPKM(SAV, EncounterCriteria.Unrestricted);
|
||||
|
||||
public PKM ConvertToPKM(ITrainerInfo SAV, EncounterCriteria criteria)
|
||||
{
|
||||
const int gen = 6;
|
||||
var version = this.GetCompatibleVersion((GameVersion)SAV.Game);
|
||||
int lang = (int)Legal.GetSafeLanguage(6, (LanguageID)SAV.Language);
|
||||
var pk = new PK6
|
||||
{
|
||||
EncryptionConstant = Util.Rand32(),
|
||||
Species = Species,
|
||||
Language = lang,
|
||||
CurrentLevel = Level,
|
||||
Version = (int)version,
|
||||
PID = Util.Rand32(),
|
||||
Nickname = PKX.GetSpeciesNameGeneration(Species, lang, gen),
|
||||
Ball = Ball,
|
||||
};
|
||||
|
||||
SAV.ApplyToPKM(pk);
|
||||
SetMetData(pk);
|
||||
SetNatureGender(pk, criteria);
|
||||
pk.RefreshAbility(Ability >> 1);
|
||||
pk.SetRandomIVs(flawless: 3);
|
||||
|
||||
pk.Version = (int)version;
|
||||
pk.Language = lang;
|
||||
|
||||
pk.Moves = Moves;
|
||||
pk.SetMaximumPPCurrent(Moves);
|
||||
pk.OT_Friendship = pk.PersonalInfo.BaseFriendship;
|
||||
|
||||
if (RelearnMoves.Length > 0)
|
||||
pk.RelearnMoves = RelearnMoves;
|
||||
if (RibbonClassic)
|
||||
pk.RibbonClassic = true;
|
||||
|
||||
pk.SetRandomMemory6();
|
||||
if (!OT)
|
||||
SAV.ApplyHandlingTrainerInfo(pk);
|
||||
|
||||
return pk;
|
||||
}
|
||||
|
||||
private static void SetNatureGender(PKM pk, EncounterCriteria criteria)
|
||||
{
|
||||
pk.Nature = (int)criteria.GetNature(Nature.Random);
|
||||
pk.Gender = criteria.GetGender(-1, pk.PersonalInfo);
|
||||
}
|
||||
|
||||
private void SetMetData(PKM pk)
|
||||
{
|
||||
pk.MetDate = DateTime.Today;
|
||||
pk.Met_Level = Level;
|
||||
pk.Met_Location = Location;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,7 +7,6 @@ using static PKHeX.Core.MysteryGiftGenerator;
|
|||
using static PKHeX.Core.EncounterTradeGenerator;
|
||||
using static PKHeX.Core.EncounterSlotGenerator;
|
||||
using static PKHeX.Core.EncounterStaticGenerator;
|
||||
using static PKHeX.Core.EncounterLinkGenerator;
|
||||
using static PKHeX.Core.EncounterEggGenerator;
|
||||
|
||||
namespace PKHeX.Core
|
||||
|
@ -305,14 +304,8 @@ namespace PKHeX.Core
|
|||
private static IEnumerable<IEncounterable> GenerateRawEncounters(PKM pkm)
|
||||
{
|
||||
int ctr = 0;
|
||||
if (pkm.WasLink)
|
||||
{
|
||||
foreach (var z in GetValidLinkGifts(pkm))
|
||||
{ yield return z; ++ctr; }
|
||||
if (ctr != 0) yield break;
|
||||
}
|
||||
|
||||
if (pkm.WasEvent || pkm.WasEventEgg)
|
||||
if (pkm.WasEvent || pkm.WasEventEgg || pkm.WasLink)
|
||||
{
|
||||
foreach (var z in GetValidGifts(pkm))
|
||||
{ yield return z; ++ctr; }
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public static class EncounterLinkGenerator
|
||||
{
|
||||
public static IEnumerable<EncounterLink> GetPossible(PKM pkm)
|
||||
{
|
||||
if (!pkm.Gen6)
|
||||
return Enumerable.Empty<EncounterLink>();
|
||||
return Encounters6.LinkGifts6.Where(g => g.Species == pkm.Species);
|
||||
}
|
||||
|
||||
public static IEnumerable<EncounterLink> GetPossible(PKM pkm, IReadOnlyList<DexLevel> vs)
|
||||
{
|
||||
if (!pkm.Gen6)
|
||||
return Enumerable.Empty<EncounterLink>();
|
||||
return Encounters6.LinkGifts6.Where(g => vs.Any(z => z.Species == g.Species));
|
||||
}
|
||||
|
||||
public static IEnumerable<EncounterLink> GetValidLinkGifts(PKM pkm)
|
||||
{
|
||||
return GetPossible(pkm).Where(g => g.Level == pkm.Met_Level);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -133,7 +133,6 @@ namespace PKHeX.Core
|
|||
{
|
||||
case EncounterOrder.Egg: return GetEggs(pk, needs, version);
|
||||
case EncounterOrder.Mystery: return GetGifts(pk, needs);
|
||||
case EncounterOrder.Link: return GetLink(pk, needs);
|
||||
case EncounterOrder.Static: return GetStatic(pk, needs);
|
||||
case EncounterOrder.Trade: return GetTrades(pk, needs);
|
||||
case EncounterOrder.Slot: return GetSlots(pk, needs);
|
||||
|
@ -195,28 +194,6 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets possible encounters that allow all moves requested to be learned.
|
||||
/// </summary>
|
||||
/// <param name="pk">Rough Pokémon data which contains the requested species, gender, and form.</param>
|
||||
/// <param name="needs">Moves which cannot be taught by the player.</param>
|
||||
/// <returns>A consumable <see cref="IEncounterable"/> list of possible encounters.</returns>
|
||||
private static IEnumerable<EncounterLink> GetLink(PKM pk, IReadOnlyCollection<int> needs)
|
||||
{
|
||||
var gifts = EncounterLinkGenerator.GetPossible(pk);
|
||||
foreach (var gift in gifts)
|
||||
{
|
||||
if (needs.Count == 0)
|
||||
{
|
||||
yield return gift;
|
||||
continue;
|
||||
}
|
||||
var em = gift.Moves;
|
||||
if (!needs.Except(em).Any())
|
||||
yield return gift;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets possible encounters that allow all moves requested to be learned.
|
||||
/// </summary>
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace PKHeX.Core
|
|||
{
|
||||
Egg,
|
||||
Mystery,
|
||||
Link,
|
||||
Static,
|
||||
Trade,
|
||||
Slot,
|
||||
|
|
|
@ -29,7 +29,6 @@ namespace PKHeX.Core
|
|||
switch (info.EncounterMatch)
|
||||
{
|
||||
case EncounterEgg _: return VerifyEncounterEgg(pkm);
|
||||
case EncounterLink l: return VerifyEncounterLink(pkm, l);
|
||||
case EncounterTrade t: return VerifyEncounterTrade(pkm, t);
|
||||
case EncounterSlot w: return VerifyEncounterWild(pkm, w);
|
||||
case EncounterStatic s: return VerifyEncounterStatic(pkm, s);
|
||||
|
@ -342,25 +341,6 @@ namespace PKHeX.Core
|
|||
return new CheckResult(Severity.Valid, LEncTradeMatch, CheckIdentifier.Encounter);
|
||||
}
|
||||
|
||||
private static CheckResult VerifyEncounterLink(PKM pkm, EncounterLink enc)
|
||||
{
|
||||
// Should NOT be Fateful, and should be in Database
|
||||
if (enc == null)
|
||||
return new CheckResult(Severity.Invalid, LLinkNone, CheckIdentifier.Encounter);
|
||||
|
||||
if (pkm.XY && !enc.CanBeReceivedBy(GameVersion.XY))
|
||||
return new CheckResult(Severity.Invalid, LLinkXY, CheckIdentifier.Encounter);
|
||||
if (pkm.AO && !enc.CanBeReceivedBy(GameVersion.ORAS))
|
||||
return new CheckResult(Severity.Invalid, LLinkAO, CheckIdentifier.Encounter);
|
||||
|
||||
if (pkm.IsShiny)
|
||||
return new CheckResult(Severity.Invalid, LLinkShiny, CheckIdentifier.Encounter);
|
||||
|
||||
return pkm.FatefulEncounter
|
||||
? new CheckResult(Severity.Invalid, LLinkFateful, CheckIdentifier.Encounter)
|
||||
: new CheckResult(Severity.Valid, LLinkValid, CheckIdentifier.Encounter);
|
||||
}
|
||||
|
||||
private static CheckResult VerifyEncounterEvent(PKM pkm, MysteryGift MatchedGift)
|
||||
{
|
||||
switch (MatchedGift)
|
||||
|
|
|
@ -20,8 +20,6 @@ namespace PKHeX.Core
|
|||
|
||||
switch (info.EncounterMatch)
|
||||
{
|
||||
case EncounterLink l when l.RelearnMoves.Length > 0:
|
||||
return VerifyRelearnSpecifiedMoveset(pkm, info, l.RelearnMoves);
|
||||
case MysteryGift g:
|
||||
return VerifyRelearnSpecifiedMoveset(pkm, info, g.RelearnMoves);
|
||||
case EncounterStatic s when s.Relearn.Length > 0:
|
||||
|
|
|
@ -335,7 +335,6 @@ namespace PKHeX.Core
|
|||
{
|
||||
case EncounterStatic s: return s.Ability;
|
||||
case EncounterTrade t: return t.Ability;
|
||||
case EncounterLink l: return l.Ability;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,8 +30,6 @@ namespace PKHeX.Core
|
|||
{
|
||||
case MysteryGift g:
|
||||
return VerifyBallMysteryGift(data, g);
|
||||
case EncounterLink l:
|
||||
return VerifyBallEquals(data, l.Ball);
|
||||
case EncounterTrade t:
|
||||
return VerifyBallEquals(data, t.Ball);
|
||||
case EncounterStatic s when s.Gift:
|
||||
|
|
|
@ -270,10 +270,10 @@ namespace PKHeX.Core
|
|||
break;
|
||||
}
|
||||
return;
|
||||
case WC6 g when !g.IsEgg:
|
||||
case WC6 g when !g.IsEgg && g.OTGender != 3:
|
||||
VerifyOTMemoryIs(data, g.OT_Memory, g.OT_Intensity, g.OT_TextVar, g.OT_Feeling);
|
||||
return;
|
||||
case WC7 g when !g.IsEgg:
|
||||
case WC7 g when !g.IsEgg && g.OTGender != 3:
|
||||
VerifyOTMemoryIs(data, g.OT_Memory, g.OT_Intensity, g.OT_TextVar, g.OT_Feeling);
|
||||
return;
|
||||
}
|
||||
|
@ -387,15 +387,10 @@ namespace PKHeX.Core
|
|||
{
|
||||
if (generation < 6)
|
||||
return false;
|
||||
if (EncounterMatch is EncounterLink link && !link.OT)
|
||||
return false;
|
||||
|
||||
bool untraded = pkm.HT_Name.Length == 0 || (pkm is IGeoTrack g && g.Geo1_Country == 0);
|
||||
if (!(EncounterMatch is MysteryGift gift))
|
||||
return untraded;
|
||||
|
||||
untraded |= !pkm.WasEventEgg;
|
||||
untraded &= gift.IsEgg;
|
||||
if (EncounterMatch is WC6 gift)
|
||||
return gift.OTGender == 3 && untraded;
|
||||
return untraded;
|
||||
}
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ namespace PKHeX.Core
|
|||
data.AddLine(GetInvalid(LPIDTypeMismatch, CheckIdentifier.PID));
|
||||
}
|
||||
|
||||
var result = pkm.FatefulEncounter
|
||||
var result = pkm.FatefulEncounter != pkm.WasLink
|
||||
? GetValid(LFatefulMystery, CheckIdentifier.Fateful)
|
||||
: GetInvalid(LFatefulMysteryMissing, CheckIdentifier.Fateful);
|
||||
data.AddLine(result);
|
||||
|
|
|
@ -352,7 +352,7 @@ namespace PKHeX.Core
|
|||
OT_Memory = OT_Memory,
|
||||
OT_TextVar = OT_TextVar,
|
||||
OT_Feeling = OT_Feeling,
|
||||
FatefulEncounter = true,
|
||||
FatefulEncounter = MetLocation != 30011, // Link gifts do not set fateful encounter
|
||||
|
||||
EVs = EVs,
|
||||
};
|
||||
|
@ -457,10 +457,12 @@ namespace PKHeX.Core
|
|||
{
|
||||
if (pkm.Egg_Location == 0) // Not Egg
|
||||
{
|
||||
if (CardID != pkm.SID) return false;
|
||||
if (TID != pkm.TID) return false;
|
||||
if (OT_Name != pkm.OT_Name) return false;
|
||||
if (OTGender != pkm.OT_Gender) return false;
|
||||
if (OTGender != 3)
|
||||
{
|
||||
if (SID != pkm.SID) return false;
|
||||
if (TID != pkm.TID) return false;
|
||||
if (OTGender != pkm.OT_Gender) return false;
|
||||
}
|
||||
if (PIDType == Shiny.FixedValue && pkm.PID != PID) return false;
|
||||
if (!PIDType.IsValid(pkm)) return false;
|
||||
if (OriginGame != 0 && OriginGame != pkm.Version) return false;
|
||||
|
|
Loading…
Reference in a new issue