mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-15 00:37:11 +00:00
Add xmldoc for new obj/func related to GO legality
This commit is contained in:
parent
e6a60ec210
commit
037db7b8a3
9 changed files with 95 additions and 37 deletions
|
@ -10,7 +10,10 @@ namespace PKHeX.Core
|
|||
/// </summary>
|
||||
public sealed class EncounterArea7g : EncounterArea
|
||||
{
|
||||
/// <summary> Species for the area </summary>
|
||||
/// <remarks> Due to how the encounter data is packaged by PKHeX, each species-form is grouped together. </remarks>
|
||||
public int Species { get; }
|
||||
/// <summary> Form of the Species </summary>
|
||||
public int Form { get; }
|
||||
|
||||
private EncounterArea7g(int species, int form) : base(GameVersion.GO)
|
||||
|
@ -53,7 +56,7 @@ namespace PKHeX.Core
|
|||
int end = BitConverter.ToInt32(data, offset + 4);
|
||||
var shiny = (Shiny)data[offset + 8];
|
||||
var type = (PogoType)data[offset + 9];
|
||||
return new EncounterSlot7GO(area, species, form, type, shiny, start, end);
|
||||
return new EncounterSlot7GO(area, species, form, start, end, shiny, type);
|
||||
}
|
||||
|
||||
public override IEnumerable<EncounterSlot> GetMatchingSlots(PKM pkm, IReadOnlyList<EvoCriteria> chain)
|
||||
|
@ -75,6 +78,7 @@ namespace PKHeX.Core
|
|||
continue;
|
||||
if (!slot.IsWithinStartEnd(stamp))
|
||||
continue;
|
||||
|
||||
yield return slot;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,10 @@ namespace PKHeX.Core
|
|||
/// </summary>
|
||||
public sealed class EncounterArea8g : EncounterArea
|
||||
{
|
||||
/// <summary> Species for the area </summary>
|
||||
/// <remarks> Due to how the encounter data is packaged by PKHeX, each species-form is grouped together. </remarks>
|
||||
public int Species { get; }
|
||||
/// <summary> Form of the Species </summary>
|
||||
public int Form { get; }
|
||||
|
||||
private EncounterArea8g(int species, int form) : base(GameVersion.GO)
|
||||
|
@ -55,11 +58,16 @@ namespace PKHeX.Core
|
|||
int end = BitConverter.ToInt32(data, offset + 4);
|
||||
var shiny = (Shiny)data[offset + 8];
|
||||
var type = (PogoType)data[offset + 9];
|
||||
return new EncounterSlot8GO(area, species, form, group, type, shiny, start, end);
|
||||
return new EncounterSlot8GO(area, species, form, start, end, shiny, type, group);
|
||||
}
|
||||
|
||||
private static GameVersion GetGroup(int species, int form)
|
||||
{
|
||||
// Transfer Rules:
|
||||
// If it can exist in LGP/E, it uses LGP/E's move data for the initial moves.
|
||||
// Else, if it can exist in SW/SH, it uses SW/SH's move data for the initial moves.
|
||||
// Else, it must exist in US/UM, thus it uses US/UM's moves.
|
||||
|
||||
var pt8 = PersonalTable.SWSH;
|
||||
var ptGG = PersonalTable.GG;
|
||||
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 7 Wild Encounter Slot data (GO Park)
|
||||
/// </summary>
|
||||
public sealed class EncounterSlot7GO : EncounterSlotGO
|
||||
{
|
||||
public override int Generation => 7;
|
||||
|
||||
public EncounterSlot7GO(EncounterArea7g area, int species, int form, PogoType type, Shiny shiny, int start, int end)
|
||||
: base(area, start, end, type, shiny)
|
||||
public EncounterSlot7GO(EncounterArea7g area, int species, int form, int start, int end, Shiny shiny, PogoType type)
|
||||
: base(area, start, end, shiny, type)
|
||||
{
|
||||
Species = species;
|
||||
Form = form;
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 8 Wild Encounter Slot data (GO -> HOME)
|
||||
/// </summary>
|
||||
public sealed class EncounterSlot8GO : EncounterSlotGO
|
||||
{
|
||||
public override int Generation => 8;
|
||||
public GameVersion OriginGroup { get; }
|
||||
|
||||
public EncounterSlot8GO(EncounterArea8g area, int species, int form, GameVersion gameVersion, PogoType type, Shiny shiny, int start, int end)
|
||||
: base(area, start, end, type, shiny)
|
||||
public EncounterSlot8GO(EncounterArea8g area, int species, int form, int start, int end, Shiny shiny, PogoType type, GameVersion originGroup)
|
||||
: base(area, start, end, shiny, type)
|
||||
{
|
||||
Species = species;
|
||||
Form = form;
|
||||
|
||||
OriginGroup = gameVersion;
|
||||
OriginGroup = originGroup;
|
||||
}
|
||||
|
||||
public int GetMinIV() => Type.GetMinIV();
|
||||
|
@ -25,7 +28,9 @@ namespace PKHeX.Core
|
|||
pk8.CurrentHandler = 1;
|
||||
|
||||
base.ApplyDetails(sav, criteria, pk);
|
||||
pk.Ball = (int)Type.GetValidBall();
|
||||
var ball = Type.GetValidBall();
|
||||
if (ball != Ball.None)
|
||||
pk.Ball = (int)ball;
|
||||
|
||||
pk8.HeightScalar = PokeSizeUtil.GetRandomScalar();
|
||||
pk8.WeightScalar = PokeSizeUtil.GetRandomScalar();
|
||||
|
|
|
@ -2,14 +2,25 @@ using System;
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public abstract class EncounterSlotGO : EncounterSlot, IPogoSlotTime
|
||||
/// <summary>
|
||||
/// Contains details about an encounter that can be found in <see cref="GameVersion.GO"/>
|
||||
/// </summary>
|
||||
public abstract class EncounterSlotGO : EncounterSlot, IPogoSlot
|
||||
{
|
||||
public PogoType Type { get; }
|
||||
public Shiny Shiny { get; }
|
||||
/// <summary> Start Date timestamp of when the encounter became available. </summary>
|
||||
public int Start { get; }
|
||||
|
||||
/// <summary> End Date timestamp of when the encounter became unavailable. </summary>
|
||||
/// <remarks> If there is no end date (yet), we'll try to clamp to a date in the near-future to prevent it from being open-ended. </remarks>
|
||||
public int End { get; }
|
||||
|
||||
protected EncounterSlotGO(EncounterArea area, int start, int end, PogoType type, Shiny shiny) : base(area)
|
||||
/// <summary> Possibility of being shiny. </summary>
|
||||
public Shiny Shiny { get; }
|
||||
|
||||
/// <summary> How the encounter was captured. </summary>
|
||||
public PogoType Type { get; }
|
||||
|
||||
protected EncounterSlotGO(EncounterArea area, int start, int end, Shiny shiny, PogoType type) : base(area)
|
||||
{
|
||||
LevelMin = type.GetMinLevel();
|
||||
LevelMax = EncountersGO.MAX_LEVEL;
|
||||
|
@ -49,14 +60,20 @@ namespace PKHeX.Core
|
|||
const int tolerance = 1;
|
||||
|
||||
if (End == 0)
|
||||
return Start <= stamp;
|
||||
return Start <= stamp && GetDate(stamp) <= DateTime.Now.AddDays(tolerance);
|
||||
if (Start == 0)
|
||||
return stamp <= End + tolerance;
|
||||
return Start <= stamp && stamp <= End + tolerance;
|
||||
}
|
||||
|
||||
public static int GetTimeStamp(int y, int m, int d) => (y << 16) | (m << 8) | d;
|
||||
/// <summary>
|
||||
/// Converts a split timestamp into a single integer.
|
||||
/// </summary>
|
||||
public static int GetTimeStamp(int year, int month, int day) => (year << 16) | (month << 8) | day;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a random date within the availability range.
|
||||
/// </summary>
|
||||
public DateTime GetRandomValidDate()
|
||||
{
|
||||
if (Start == 0)
|
||||
|
|
|
@ -1,8 +1,20 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores details about <see cref="GameVersion.GO"/> encounters relevant for legality.
|
||||
/// </summary>
|
||||
public interface IPogoSlot
|
||||
{
|
||||
/// <summary> Start date the encounter became available. If zero, no date specified (unbounded start). </summary>
|
||||
int Start { get; }
|
||||
|
||||
/// <summary> Last day the encounter was available. If zero, no date specified (unbounded finish). </summary>
|
||||
int End { get; }
|
||||
|
||||
/// <summary> Possibility of shiny for the encounter. </summary>
|
||||
Shiny Shiny { get; }
|
||||
|
||||
/// <summary> Method the Pokémon may be encountered with. </summary>
|
||||
PogoType Type { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
public interface IPogoSlotTime : IPogoSlot
|
||||
{
|
||||
int Start { get; }
|
||||
int End { get; }
|
||||
}
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Encounter Type for various <see cref="GameVersion.GO"/> encounters.
|
||||
/// </summary>
|
||||
public enum PogoType : byte
|
||||
{
|
||||
None, // Don't use this.
|
||||
|
@ -29,7 +32,11 @@ namespace PKHeX.Core
|
|||
|
||||
public static class PogoTypeExtensions
|
||||
{
|
||||
public static int GetMinLevel(this PogoType t) => t switch
|
||||
/// <summary>
|
||||
/// Gets the minimum level (relative to GO's 1-<see cref="EncountersGO.MAX_LEVEL"/>) the <see cref="encounterType"/> must have.
|
||||
/// </summary>
|
||||
/// <param name="encounterType">Descriptor indicating how the Pokémon was encountered in GO.</param>
|
||||
public static int GetMinLevel(this PogoType encounterType) => encounterType switch
|
||||
{
|
||||
PogoType.Raid15 => 15,
|
||||
PogoType.Raid20 => 20,
|
||||
|
@ -41,7 +48,12 @@ namespace PKHeX.Core
|
|||
_ => 1,
|
||||
};
|
||||
|
||||
public static int GetMinIV(this PogoType t) => t switch
|
||||
/// <summary>
|
||||
/// Gets the minimum IVs (relative to GO's 0-15) the <see cref="encounterType"/> must have.
|
||||
/// </summary>
|
||||
/// <param name="encounterType">Descriptor indicating how the Pokémon was encountered in GO.</param>
|
||||
/// <returns>Required minimum IV (0-15)</returns>
|
||||
public static int GetMinIV(this PogoType encounterType) => encounterType switch
|
||||
{
|
||||
PogoType.Wild => 0,
|
||||
PogoType.Raid20 => 10,
|
||||
|
@ -51,15 +63,26 @@ namespace PKHeX.Core
|
|||
_ => 1,
|
||||
};
|
||||
|
||||
public static bool IsBallValid(this PogoType t, Ball b)
|
||||
/// <summary>
|
||||
/// Checks if the <see cref="ball"/> is valid for the <see cref="encounterType"/>.
|
||||
/// </summary>
|
||||
/// <param name="encounterType">Descriptor indicating how the Pokémon was encountered in GO.</param>
|
||||
/// <param name="ball">Current <see cref="Ball"/> the Pokémon is in.</param>
|
||||
/// <returns>True if valid, false if invalid.</returns>
|
||||
public static bool IsBallValid(this PogoType encounterType, Ball ball)
|
||||
{
|
||||
var req = t.GetValidBall();
|
||||
var req = encounterType.GetValidBall();
|
||||
if (req == Ball.None)
|
||||
return (uint)(b - 2) <= 2; // Poke, Great, Ultra
|
||||
return b == req;
|
||||
return (uint)(ball - 2) <= 2; // Poke, Great, Ultra
|
||||
return ball == req;
|
||||
}
|
||||
|
||||
public static Ball GetValidBall(this PogoType t) => t switch
|
||||
/// <summary>
|
||||
/// Gets a valid ball that the <see cref="encounterType"/> can have based on the type of capture in Pokémon GO.
|
||||
/// </summary>
|
||||
/// <param name="encounterType">Descriptor indicating how the Pokémon was encountered in GO.</param>
|
||||
/// <returns><see cref="Ball.None"/> if no specific ball is required, otherwise returns the required ball.</returns>
|
||||
public static Ball GetValidBall(this PogoType encounterType) => encounterType switch
|
||||
{
|
||||
PogoType.Egg => Ball.Poke,
|
||||
PogoType.FieldP => Ball.Poke,
|
||||
|
|
|
@ -34,8 +34,8 @@ namespace PKHeX.Core
|
|||
return VerifyBallEquals(data, t.Ball);
|
||||
case EncounterStatic s when s.Gift:
|
||||
return VerifyBallEquals(data, s.Ball);
|
||||
case EncounterSlot8GO g:
|
||||
return VerifyBallGOHOME(data, g);
|
||||
case EncounterSlot8GO _: // Already a strict match
|
||||
return GetResult(true);
|
||||
}
|
||||
|
||||
// Capture / Inherit cases -- can be one of many balls
|
||||
|
@ -85,12 +85,6 @@ namespace PKHeX.Core
|
|||
return VerifyBallEquals(data, Legal.GetWildBalls(data.Info.Generation, data.Info.Game));
|
||||
}
|
||||
|
||||
private CheckResult VerifyBallGOHOME(LegalityAnalysis data, EncounterSlot8GO enc)
|
||||
{
|
||||
var valid = enc.IsBallValid((Ball)data.pkm.Ball);
|
||||
return GetResult(valid);
|
||||
}
|
||||
|
||||
private CheckResult VerifyBallEgg(LegalityAnalysis data)
|
||||
{
|
||||
var pkm = data.pkm;
|
||||
|
|
Loading…
Reference in a new issue