mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-06-03 08:04:11 -05:00
add more pkhex.core xml documentation
adds a bunch of documentation useful for those unfamiliar with the core library
This commit is contained in:
parent
2ad5b19f6c
commit
69cf1eaa9c
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Key Value pair for a displayed <see cref="string"/> and underlying <see cref="int"/> value.
|
||||
/// </summary>
|
||||
public struct ComboItem
|
||||
{
|
||||
public string Text { get; set; }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility class for <see cref="GameVersion"/> logic.
|
||||
/// </summary>
|
||||
public static class GameUtil
|
||||
{
|
||||
/// <summary>Determines the Version Grouping of an input Version ID</summary>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Game Version ID enum shared between actual Version IDs and lumped version groupings.
|
||||
/// </summary>
|
||||
public enum GameVersion
|
||||
{
|
||||
// Indicators
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Legality Check object containing the <see cref="CheckResult"/> data and overview values from the parse.
|
||||
/// </summary>
|
||||
public partial class LegalityAnalysis
|
||||
{
|
||||
private PKM pkm;
|
||||
|
|
@ -53,6 +56,10 @@ private IEnumerable<int> AllSuggestedRelearnMoves
|
|||
private int[] _allSuggestedMoves, _allSuggestedRelearnMoves;
|
||||
public int[] AllSuggestedMovesAndRelearn => AllSuggestedMoves.Concat(AllSuggestedRelearnMoves).ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Checks the input <see cref="PKM"/> data for legality.
|
||||
/// </summary>
|
||||
/// <param name="pk">Input data to check</param>
|
||||
public LegalityAnalysis(PKM pk)
|
||||
{
|
||||
#if SUPPRESS
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 1 Encounters
|
||||
/// </summary>
|
||||
internal static class Encounters1
|
||||
{
|
||||
internal static readonly EncounterArea[] SlotsRBY;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 2 Encounters
|
||||
/// </summary>
|
||||
internal static class Encounters2
|
||||
{
|
||||
internal static readonly EncounterArea[] SlotsGSC, SlotsGS, SlotsC;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 3 Encounters
|
||||
/// </summary>
|
||||
internal static class Encounters3
|
||||
{
|
||||
internal static readonly EncounterArea[] SlotsR, SlotsS, SlotsE;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 4 Encounters
|
||||
/// </summary>
|
||||
internal static class Encounters4
|
||||
{
|
||||
internal static readonly EncounterArea[] SlotsD, SlotsP, SlotsPt, SlotsHG, SlotsSS;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 5 Encounters
|
||||
/// </summary>
|
||||
internal static class Encounters5
|
||||
{
|
||||
internal static readonly EncounterArea[] SlotsB, SlotsW, SlotsB2, SlotsW2;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 6 Encounters
|
||||
/// </summary>
|
||||
internal static class Encounters6
|
||||
{
|
||||
internal static readonly EncounterArea[] SlotsX, SlotsY, SlotsA, SlotsO;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 7 Encounters
|
||||
/// </summary>
|
||||
internal static class Encounters7
|
||||
{
|
||||
internal static readonly EncounterArea[] SlotsSN, SlotsMN, SlotsUS, SlotsUM;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,13 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 3 <see cref="WC3"/> Gifts
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Generation 3 has a wide range of PIDIV types and other restrictions, and was never consistently stored in raw bytes.
|
||||
/// Normally we'd just load the data from a binary, but without raw data... hard-code everything by hand.
|
||||
/// </remarks>
|
||||
internal static class EncountersWC3
|
||||
{
|
||||
internal static readonly MysteryGift[] Encounter_Event3 =
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Egg Encounter Data
|
||||
/// </summary>
|
||||
public class EncounterEgg : IEncounterable
|
||||
{
|
||||
public int Species { get; set; }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Invalid Encounter Data
|
||||
/// </summary>
|
||||
public class EncounterInvalid : IEncounterable
|
||||
{
|
||||
public int Species { get; }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Rejected Encounter Data containing a reason why the encounter was rejected (not compatible).
|
||||
/// </summary>
|
||||
public class EncounterRejected : IEncounterable
|
||||
{
|
||||
public readonly IEncounterable Encounter;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic for providing suggested property values with respect to the input data.
|
||||
/// </summary>
|
||||
internal static class EncounterSuggestion
|
||||
{
|
||||
public static EncounterStatic GetSuggestedMetInfo(PKM pkm)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Calculated Information storage with properties useful for parsing the legality of the input <see cref="PKM"/>.
|
||||
/// </summary>
|
||||
public class LegalInfo
|
||||
{
|
||||
/// <summary>The <see cref="PKM"/> object used for comparisons.</summary>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Iterates a generic collection with the ability to peek into the collection to see if the next element exists.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Generic Collection Element Type</typeparam>
|
||||
public class PeekEnumerator<T> : IEnumerator<T>
|
||||
{
|
||||
private readonly IEnumerator<T> Enumerator;
|
||||
|
|
@ -12,6 +16,10 @@ public class PeekEnumerator<T> : IEnumerator<T>
|
|||
|
||||
#region IEnumerator Implementation
|
||||
|
||||
/// <summary>
|
||||
/// Advances the enumerator to the next element in the collection.
|
||||
/// </summary>
|
||||
/// <returns>Indication if there are more elements in the collection.</returns>
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (!didPeek)
|
||||
|
|
@ -19,6 +27,9 @@ public bool MoveNext()
|
|||
didPeek = false;
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets the enumerator to its initial position, which is before the first element in the collection.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
Enumerator.Reset();
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic to verify the current <see cref="PKM.Moves"/>.
|
||||
/// </summary>
|
||||
public static class VerifyCurrentMoves
|
||||
{
|
||||
public static CheckMoveResult[] VerifyMoves(PKM pkm, LegalInfo info, GameVersion game = GameVersion.Any)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic to verify the current <see cref="PKM.RelearnMoves"/>.
|
||||
/// </summary>
|
||||
public static class VerifyRelearnMoves
|
||||
{
|
||||
public static CheckResult[] VerifyRelearn(PKM pkm, LegalInfo info)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Legality Check Message Strings to indicate why certain <see cref="PKM"/> <see cref="LegalInfo"/> values are flagged.
|
||||
/// </summary>
|
||||
public static class LegalityCheckStrings
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Source the Move was learned from
|
||||
/// </summary>
|
||||
public enum MoveSource
|
||||
{
|
||||
Unknown,
|
||||
|
|
@ -17,6 +20,9 @@ public enum MoveSource
|
|||
Sketch,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move specific <see cref="CheckResult"/> to contain in which Generation it was learned & source.
|
||||
/// </summary>
|
||||
public class CheckMoveResult : CheckResult
|
||||
{
|
||||
public readonly MoveSource Source;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Result of a Legality Check
|
||||
/// </summary>
|
||||
public class CheckResult
|
||||
{
|
||||
internal readonly Severity Judgement = Severity.Valid;
|
||||
|
|
|
|||
|
|
@ -4,12 +4,26 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an Area where <see cref="PKM"/> can be encountered, which contains a Location ID and <see cref="EncounterSlot"/> data.
|
||||
/// </summary>
|
||||
public class EncounterArea
|
||||
{
|
||||
public int Location;
|
||||
public EncounterSlot[] Slots;
|
||||
|
||||
/// <summary>
|
||||
/// Creates an empty encounter area ready for initialization.
|
||||
/// </summary>
|
||||
public EncounterArea() { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates an array of encounter data with a specified location ID.
|
||||
/// </summary>
|
||||
/// <param name="data">Encounter data</param>
|
||||
/// <remarks>
|
||||
/// Encounter Data is stored in the following format: (u16 Location, n*[u16 Species/Form, u8 Min, u8 Max])
|
||||
/// </remarks>
|
||||
private EncounterArea(byte[] data)
|
||||
{
|
||||
Location = BitConverter.ToUInt16(data, 0);
|
||||
|
|
@ -49,10 +63,10 @@ public EncounterArea[] Clone(int[] locations)
|
|||
return Areas;
|
||||
}
|
||||
|
||||
private static EncounterSlot1[] GetSlots1_GW(byte[] data, ref int ofs, SlotType t)
|
||||
private static IEnumerable<EncounterSlot1> GetSlots1_GW(byte[] data, ref int ofs, SlotType t)
|
||||
{
|
||||
int rate = data[ofs++];
|
||||
return rate == 0 ? new EncounterSlot1[0] : ReadSlots(data, ref ofs, 10, t, rate);
|
||||
return rate == 0 ? Enumerable.Empty<EncounterSlot1>() : ReadSlots(data, ref ofs, 10, t, rate);
|
||||
}
|
||||
private static EncounterSlot1[] GetSlots1_F(byte[] data, ref int ofs)
|
||||
{
|
||||
|
|
@ -85,7 +99,7 @@ private static EncounterSlot1[] GetSlots2_GW(byte[] data, ref int ofs, SlotType
|
|||
return slots;
|
||||
}
|
||||
|
||||
private static EncounterSlot1[] GetSlots2_F(byte[] data, ref int ofs, SlotType t)
|
||||
private static List<EncounterSlot1> GetSlots2_F(byte[] data, ref int ofs, SlotType t)
|
||||
{
|
||||
// slot set ends in 0xFF 0x** 0x**
|
||||
var slots = new List<EncounterSlot1>();
|
||||
|
|
@ -109,7 +123,7 @@ private static EncounterSlot1[] GetSlots2_F(byte[] data, ref int ofs, SlotType t
|
|||
if (rate == 0xFF)
|
||||
break;
|
||||
}
|
||||
return slots.ToArray();
|
||||
return slots;
|
||||
}
|
||||
private static EncounterSlot1[] GetSlots2_H(byte[] data, ref int ofs, SlotType t)
|
||||
{
|
||||
|
|
@ -916,6 +930,11 @@ public static EncounterArea[] GetSimpleEncounterArea(IEnumerable<int> species, i
|
|||
return new[] { new EncounterArea { Location = location, Slots = l.ToArray() } };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an array of areas from an array of raw area data
|
||||
/// </summary>
|
||||
/// <param name="entries">Simplified raw format of an Area</param>
|
||||
/// <returns>Array of areas</returns>
|
||||
public static EncounterArea[] GetArray(byte[][] entries)
|
||||
{
|
||||
if (entries == null)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Pokémon Link Encounter Data
|
||||
/// </summary>
|
||||
public class EncounterLink : IEncounterable, IRibbonSetEvent4, IMoveset
|
||||
{
|
||||
public int Species { get; set; }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
// Gender Locking
|
||||
/// <summary>
|
||||
/// Encounter lock values restricting certain properties to a fixed value.
|
||||
/// </summary>
|
||||
/// <remarks>Used in Colosseum/XD to ensure that non-shadow <see cref="PKM"/> are of a certain Nature/etc.</remarks>
|
||||
public class EncounterLock
|
||||
{
|
||||
public int Species { get; set; }
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ public class EncounterSlotPermissions
|
|||
public bool IsNormalLead => !(WhiteFlute || BlackFlute || DexNav);
|
||||
public bool IsDexNav => AllowDexNav && DexNav;
|
||||
}
|
||||
/// <summary>
|
||||
/// Wild Encounter Slot data
|
||||
/// </summary>
|
||||
public class EncounterSlot : IEncounterable, IGeneration
|
||||
{
|
||||
public int Location { get; set; } = -1;
|
||||
|
|
@ -53,10 +56,18 @@ public string Name
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generation 1 Wild Encounter Slot data
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Contains Time data which is present in <see cref="GameVersion.C"/> origin data.
|
||||
/// Contains <see cref="GameVersion"/> identification, as this Version value is not stored in <see cref="PK1"/> or <see cref="PK2"/> formats.
|
||||
/// </remarks>
|
||||
public class EncounterSlot1 : EncounterSlot
|
||||
{
|
||||
public int Rate;
|
||||
public EncounterTime Time = EncounterTime.Any;
|
||||
internal EncounterTime Time = EncounterTime.Any;
|
||||
public GameVersion Version = GameVersion.Any;
|
||||
public override EncounterSlot Clone()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Static Encounter Data
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Static Encounters are fixed position encounters with properties that are not subject to Wild Encounter conditions.
|
||||
/// </remarks>
|
||||
public class EncounterStatic : IEncounterable, IMoveset, IGeneration
|
||||
{
|
||||
public int Species { get; set; }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
public enum EncounterTime
|
||||
/// <summary>
|
||||
/// Generation 2 Time of Encounter enum
|
||||
/// </summary>
|
||||
internal enum EncounterTime
|
||||
{
|
||||
Any = -1,
|
||||
MorningDay = -2,
|
||||
|
|
@ -9,9 +12,9 @@ public enum EncounterTime
|
|||
Night = 3
|
||||
}
|
||||
|
||||
public static class EncounterTimeExtension
|
||||
internal static class EncounterTimeExtension
|
||||
{
|
||||
public static bool Contains(this EncounterTime t1, int t2) => t1.Contains((EncounterTime)t2);
|
||||
internal static bool Contains(this EncounterTime t1, int t2) => t1.Contains((EncounterTime)t2);
|
||||
private static bool Contains(this EncounterTime t1, EncounterTime t2)
|
||||
{
|
||||
if (t1 == t2 || t1 == EncounterTime.Any || t2 == EncounterTime.Any)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Trade Encounter data
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Trade data is fixed level in all cases except for the first few generations of games.
|
||||
/// </remarks>
|
||||
public class EncounterTrade : IEncounterable, IMoveset, IGeneration
|
||||
{
|
||||
public int Species { get; set; }
|
||||
|
|
@ -36,11 +42,20 @@ public class EncounterTrade : IEncounterable, IMoveset, IGeneration
|
|||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trade Encounter data with a fixed PID.
|
||||
/// </summary>
|
||||
public class EncounterTradePID : EncounterTrade
|
||||
{
|
||||
public uint PID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trade Encounter data with a fixed Catch Rate
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Generation 1 specific value used in detecting unmodified/untraded Generation 1 Trade Encounter data.
|
||||
/// </remarks>
|
||||
public class EncounterTradeCatchRate : EncounterTrade
|
||||
{
|
||||
public uint Catch_Rate;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Tile type the <see cref="PKM"/> was encountered from.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Used in Generation 4 games, this value is set depending on what type of overworld tile the player is standing on when the <see cref="PKM"/> is obtained.
|
||||
/// Some locations have multiple tile types, requiring multiple values possible.
|
||||
/// May be worthwhile to convert this and associated to bitflags for supporting 3+ tile types (or the ability to not be specific for combinations permitted).
|
||||
/// </remarks>
|
||||
public enum EncounterType
|
||||
{
|
||||
Headbutt_Grass = -1, // None or TallGrass
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation specific Evolution Tree data.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Used to determine if a <see cref="PKM.Species"/> can evolve from prior steps in its evolution branch.
|
||||
/// </remarks>
|
||||
public class EvolutionTree
|
||||
{
|
||||
private static readonly EvolutionTree Evolves1;
|
||||
|
|
@ -207,10 +213,16 @@ public IEnumerable<DexLevel> GetValidPreEvolutions(PKM pkm, int maxLevel, int ma
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Table of Evolution Branch Entries
|
||||
/// </summary>
|
||||
public abstract class EvolutionSet
|
||||
{
|
||||
public EvolutionMethod[] PossibleEvolutions;
|
||||
}
|
||||
/// <summary>
|
||||
/// Generation 1 Evolution Branch Entries
|
||||
/// </summary>
|
||||
public class EvolutionSet1 : EvolutionSet
|
||||
{
|
||||
private static EvolutionMethod GetMethod(byte[] data, ref int offset)
|
||||
|
|
@ -263,6 +275,9 @@ public static List<EvolutionSet> GetArray(byte[] data, int maxSpecies)
|
|||
return evos;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Generation 2 Evolution Branch Entries
|
||||
/// </summary>
|
||||
public class EvolutionSet2 : EvolutionSet
|
||||
{
|
||||
private static EvolutionMethod GetMethod(byte[] data, ref int offset)
|
||||
|
|
@ -299,6 +314,9 @@ public static List<EvolutionSet> GetArray(byte[] data, int maxSpecies)
|
|||
return evos;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Generation 3 Evolution Branch Entries
|
||||
/// </summary>
|
||||
public class EvolutionSet3 : EvolutionSet
|
||||
{
|
||||
private static EvolutionMethod GetMethod(byte[] data, int offset)
|
||||
|
|
@ -358,6 +376,9 @@ public static List<EvolutionSet> GetArray(byte[] data)
|
|||
return evos.ToList();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Generation 4 Evolution Branch Entries
|
||||
/// </summary>
|
||||
public class EvolutionSet4 : EvolutionSet
|
||||
{
|
||||
private static EvolutionMethod GetMethod(byte[] data, int offset)
|
||||
|
|
@ -410,6 +431,9 @@ public static List<EvolutionSet> GetArray(byte[] data)
|
|||
return evos;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Generation 5 Evolution Branch Entries
|
||||
/// </summary>
|
||||
public class EvolutionSet5 : EvolutionSet
|
||||
{
|
||||
private static EvolutionMethod GetMethod(byte[] data, int offset)
|
||||
|
|
@ -457,6 +481,9 @@ public static List<EvolutionSet> GetArray(byte[] data)
|
|||
return evos;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Generation 6 Evolution Branch Entries
|
||||
/// </summary>
|
||||
public class EvolutionSet6 : EvolutionSet
|
||||
{
|
||||
private static readonly HashSet<int> argEvos = new HashSet<int> {6, 8, 16, 17, 18, 19, 20, 21, 22, 29, 30, 32, 33, 34};
|
||||
|
|
@ -484,6 +511,9 @@ public EvolutionSet6(byte[] data)
|
|||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Generation 7 Evolution Branch Entries
|
||||
/// </summary>
|
||||
public class EvolutionSet7 : EvolutionSet
|
||||
{
|
||||
private const int SIZE = 8;
|
||||
|
|
@ -503,6 +533,10 @@ public EvolutionSet7(byte[] data)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Criteria for evolving to this branch in the <see cref="EvolutionTree"/>
|
||||
/// </summary>
|
||||
public class EvolutionMethod
|
||||
{
|
||||
public int Method;
|
||||
|
|
@ -624,7 +658,9 @@ public EvolutionMethod Copy(int species = -1)
|
|||
}
|
||||
}
|
||||
|
||||
// Informatics
|
||||
/// <summary>
|
||||
/// Informatics pertaining to a <see cref="PKM"/>'s evolution lineage.
|
||||
/// </summary>
|
||||
public class EvolutionLineage
|
||||
{
|
||||
public readonly List<EvolutionStage> Chain = new List<EvolutionStage>();
|
||||
|
|
@ -720,6 +756,9 @@ private static void UpdateMinValues(IReadOnlyCollection<DexLevel> dl, EvolutionM
|
|||
last.RequiresLvlUp = evo.RequiresLevelUp;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Evolution Stage Entries
|
||||
/// </summary>
|
||||
public struct EvolutionStage
|
||||
{
|
||||
public List<EvolutionMethod> StageEntryMethods;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public enum GBEncounterType
|
||||
/// <summary>
|
||||
/// Generation 1/2 Encounter Data type, which serves as a 'best match' priority rating when returning from a list.
|
||||
/// </summary>
|
||||
internal enum GBEncounterType
|
||||
{
|
||||
EggEncounter,
|
||||
WildEncounter,
|
||||
|
|
@ -12,12 +15,15 @@ public enum GBEncounterType
|
|||
TradeEncounterG2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generation 1/2 Encounter Data wrapper for storing supplemental information about the encounter.
|
||||
/// </summary>
|
||||
public class GBEncounterData : IEncounterable
|
||||
{
|
||||
public readonly int Level;
|
||||
private readonly int Level;
|
||||
public readonly GameVersion Game;
|
||||
public readonly int Generation;
|
||||
public readonly GBEncounterType Type;
|
||||
internal readonly GBEncounterType Type;
|
||||
public readonly IEncounterable Encounter;
|
||||
|
||||
public int Species => Encounter.Species;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Common Encounter Properties base interface.
|
||||
/// </summary>
|
||||
public interface IEncounterable
|
||||
{
|
||||
int Species { get; }
|
||||
|
|
@ -17,15 +20,13 @@ private static bool IsWithinRange(this IEncounterable encounter, int lvl)
|
|||
}
|
||||
public static bool IsWithinRange(this IEncounterable encounter, PKM pkm)
|
||||
{
|
||||
if (pkm.HasOriginalMetLocation)
|
||||
{
|
||||
if (encounter.EggEncounter)
|
||||
return pkm.CurrentLevel == Legal.GetEggHatchLevel(pkm);
|
||||
if (encounter is MysteryGift g)
|
||||
return pkm.CurrentLevel == g.Level;
|
||||
return pkm.CurrentLevel == pkm.Met_Level;
|
||||
}
|
||||
return encounter.IsWithinRange(pkm.CurrentLevel);
|
||||
if (!pkm.HasOriginalMetLocation)
|
||||
return encounter.IsWithinRange(pkm.CurrentLevel);
|
||||
if (encounter.EggEncounter)
|
||||
return pkm.CurrentLevel == Legal.GetEggHatchLevel(pkm);
|
||||
if (encounter is MysteryGift g)
|
||||
return pkm.CurrentLevel == g.Level;
|
||||
return pkm.CurrentLevel == pkm.Met_Level;
|
||||
}
|
||||
internal static string GetEncounterTypeName(this IEncounterable Encounter) => Encounter?.Name ?? "Unknown";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface that exposes a Generation value for the object.
|
||||
/// </summary>
|
||||
internal interface IGeneration
|
||||
{
|
||||
int Generation { get; }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface that exposes a Moveset for the object.
|
||||
/// </summary>
|
||||
internal interface IMoveset
|
||||
{
|
||||
int[] Moves { get; set; }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Nature ID values for the corresponding English nature name.
|
||||
/// </summary>
|
||||
public enum Nature
|
||||
{
|
||||
Random = -1,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Wild Encounter data <see cref="EncounterSlot"/> Type
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Different from <see cref="EncounterType"/>, this corresponds to the method that the <see cref="IEncounterable"/> may be encountered.</remarks>
|
||||
public enum SlotType
|
||||
{
|
||||
Any,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates if the <see cref="PKM"/> is required to be traded between Generation 1/2 saves.
|
||||
/// </summary>
|
||||
/// <remarks>Used for only Generation 1/2 data.</remarks>
|
||||
public enum TradebackType
|
||||
{
|
||||
Any,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Object which stores information useful for analyzing a moveset relative to the encounter data.
|
||||
/// </summary>
|
||||
public class ValidEncounterMoves
|
||||
{
|
||||
public int EncounterSpecies { get; }
|
||||
|
|
|
|||
|
|
@ -242,18 +242,26 @@ private struct FormSubregionTable
|
|||
},
|
||||
};
|
||||
|
||||
public static bool CheckVivillonPattern(int form, int pkmcountry, int pkmregion)
|
||||
/// <summary>
|
||||
/// Compares the Vivillon pattern against its country and region to determine if the pattern is able to be obtained legally.
|
||||
/// </summary>
|
||||
/// <param name="form">Alternate Forme Pattern</param>
|
||||
/// <param name="country">Country ID</param>
|
||||
/// <param name="region">Console Region ID</param>
|
||||
/// <returns></returns>
|
||||
public static bool CheckVivillonPattern(int form, int country, int region)
|
||||
{
|
||||
if (!VivillonCountryTable[form].Contains(pkmcountry))
|
||||
if (!VivillonCountryTable[form].Contains(country))
|
||||
return false; // Country mismatch
|
||||
if (RegionFormTable.All(c => c.countryID != pkmcountry))
|
||||
|
||||
CountryTable ct = RegionFormTable.Where(t => t.countryID == country).FirstOrDefault();
|
||||
if (ct.otherforms == null) // empty struct = no forms referenced
|
||||
return true; // No subregion table
|
||||
|
||||
CountryTable ct = RegionFormTable.Where(t => t.countryID == pkmcountry).ToArray()[0];
|
||||
if (ct.mainform == form)
|
||||
return !ct.otherforms.SelectMany(e => e.region).Contains(pkmregion); //true if Mainform not in other specific region
|
||||
return !ct.otherforms.Any(e => e.region.Contains(region)); //true if Mainform not in other specific region
|
||||
|
||||
return ct.otherforms.Any(e => e.form == form && e.region.Contains(pkmregion));
|
||||
return ct.otherforms.Any(e => e.form == form && e.region.Contains(region));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Bad-word Filter class containing logic to check against unsavory regular expressions.
|
||||
/// </summary>
|
||||
public static class WordFilter
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,14 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public class PL6 //: PokemonLink
|
||||
/// <summary>
|
||||
/// Pokemon Link Data Storage
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This Template object is very similar to the <see cref="PCD"/> structure in that it stores more data than just the gift.
|
||||
/// This template object is only present in Generation 6 save files.
|
||||
/// </remarks>
|
||||
public class PL6
|
||||
{
|
||||
public const int Size = 0xA47;
|
||||
public const string Filter = "Pokémon Link Data|*.pl6|All Files (*.*)|*.*";
|
||||
|
|
@ -14,13 +21,17 @@ public PL6(byte[] data = null)
|
|||
{
|
||||
Data = (byte[])(data?.Clone() ?? new byte[Size]);
|
||||
}
|
||||
// Pokémon Link Flag
|
||||
/// <summary>
|
||||
/// Pokémon Link Flag
|
||||
/// </summary>
|
||||
public byte PL_Flag {
|
||||
get => Data[0x00]; set => Data[0x00] = value;
|
||||
}
|
||||
public bool PL_enabled { get => PL_Flag != 0; set => PL_Flag = (byte)(value ? 1 << 7 : 0); }
|
||||
|
||||
//Name of data source
|
||||
|
||||
/// <summary>
|
||||
/// Name of data source
|
||||
/// </summary>
|
||||
public string Origin_app {
|
||||
get => Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x01, 0x6E));
|
||||
set => Encoding.Unicode.GetBytes(value.PadRight(54 + 1, '\0')).CopyTo(Data, 0x01);
|
||||
|
|
@ -171,9 +182,15 @@ public int[] Quantities
|
|||
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x4A3); }
|
||||
}
|
||||
|
||||
public class PL6_PKM : IEncounterable
|
||||
/// <summary>
|
||||
/// Pokemon Link Gift Template
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This Template object is very similar to the <see cref="WC6"/> structure and similar objects, in that the structure offsets are ordered the same.
|
||||
/// This template object is only present in Generation 6 save files.
|
||||
/// </remarks>
|
||||
public class PL6_PKM : IEncounterable, IRibbonSetEvent3, IRibbonSetEvent4
|
||||
{
|
||||
|
||||
internal const int Size = 0xA0;
|
||||
|
||||
public readonly byte[] Data;
|
||||
|
|
@ -289,22 +306,22 @@ public PL6_PKM(byte[] data = null)
|
|||
public int OT_Feeling { get => Data[0x7C]; set => Data[0x7C] = (byte)value; }
|
||||
|
||||
private byte RIB0 { get => Data[0x0C]; set => Data[0x0C] = value; }
|
||||
public bool RIB0_0 { get => (RIB0 & (1 << 0)) == 1 << 0; set => RIB0 = (byte)(RIB0 & ~(1 << 0) | (value ? 1 << 0 : 0)); } // Battle Champ Ribbon
|
||||
public bool RIB0_1 { get => (RIB0 & (1 << 1)) == 1 << 1; set => RIB0 = (byte)(RIB0 & ~(1 << 1) | (value ? 1 << 1 : 0)); } // Regional Champ Ribbon
|
||||
public bool RIB0_2 { get => (RIB0 & (1 << 2)) == 1 << 2; set => RIB0 = (byte)(RIB0 & ~(1 << 2) | (value ? 1 << 2 : 0)); } // National Champ Ribbon
|
||||
public bool RIB0_3 { get => (RIB0 & (1 << 3)) == 1 << 3; set => RIB0 = (byte)(RIB0 & ~(1 << 3) | (value ? 1 << 3 : 0)); } // Country Ribbon
|
||||
public bool RIB0_4 { get => (RIB0 & (1 << 4)) == 1 << 4; set => RIB0 = (byte)(RIB0 & ~(1 << 4) | (value ? 1 << 4 : 0)); } // National Ribbon
|
||||
public bool RIB0_5 { get => (RIB0 & (1 << 5)) == 1 << 5; set => RIB0 = (byte)(RIB0 & ~(1 << 5) | (value ? 1 << 5 : 0)); } // Earth Ribbon
|
||||
public bool RIB0_6 { get => (RIB0 & (1 << 6)) == 1 << 6; set => RIB0 = (byte)(RIB0 & ~(1 << 6) | (value ? 1 << 6 : 0)); } // World Ribbon
|
||||
public bool RIB0_7 { get => (RIB0 & (1 << 7)) == 1 << 7; set => RIB0 = (byte)(RIB0 & ~(1 << 7) | (value ? 1 << 7 : 0)); } // Event Ribbon
|
||||
public bool RibbonChampionBattle { get => (RIB0 & (1 << 0)) == 1 << 0; set => RIB0 = (byte)(RIB0 & ~(1 << 0) | (value ? 1 << 0 : 0)); } // Battle Champ Ribbon
|
||||
public bool RibbonChampionRegional { get => (RIB0 & (1 << 1)) == 1 << 1; set => RIB0 = (byte)(RIB0 & ~(1 << 1) | (value ? 1 << 1 : 0)); } // Regional Champ Ribbon
|
||||
public bool RibbonChampionNational { get => (RIB0 & (1 << 2)) == 1 << 2; set => RIB0 = (byte)(RIB0 & ~(1 << 2) | (value ? 1 << 2 : 0)); } // National Champ Ribbon
|
||||
public bool RibbonCountry { get => (RIB0 & (1 << 3)) == 1 << 3; set => RIB0 = (byte)(RIB0 & ~(1 << 3) | (value ? 1 << 3 : 0)); } // Country Ribbon
|
||||
public bool RibbonNational { get => (RIB0 & (1 << 4)) == 1 << 4; set => RIB0 = (byte)(RIB0 & ~(1 << 4) | (value ? 1 << 4 : 0)); } // National Ribbon
|
||||
public bool RibbonEarth { get => (RIB0 & (1 << 5)) == 1 << 5; set => RIB0 = (byte)(RIB0 & ~(1 << 5) | (value ? 1 << 5 : 0)); } // Earth Ribbon
|
||||
public bool RibbonWorld { get => (RIB0 & (1 << 6)) == 1 << 6; set => RIB0 = (byte)(RIB0 & ~(1 << 6) | (value ? 1 << 6 : 0)); } // World Ribbon
|
||||
public bool RibbonEvent { get => (RIB0 & (1 << 7)) == 1 << 7; set => RIB0 = (byte)(RIB0 & ~(1 << 7) | (value ? 1 << 7 : 0)); } // Event Ribbon
|
||||
private byte RIB1 { get => Data[0x0D]; set => Data[0x0D] = value; }
|
||||
public bool RIB1_0 { get => (RIB1 & (1 << 0)) == 1 << 0; set => RIB1 = (byte)(RIB1 & ~(1 << 0) | (value ? 1 << 0 : 0)); } // World Champ Ribbon
|
||||
public bool RIB1_1 { get => (RIB1 & (1 << 1)) == 1 << 1; set => RIB1 = (byte)(RIB1 & ~(1 << 1) | (value ? 1 << 1 : 0)); } // Birthday Ribbon
|
||||
public bool RIB1_2 { get => (RIB1 & (1 << 2)) == 1 << 2; set => RIB1 = (byte)(RIB1 & ~(1 << 2) | (value ? 1 << 2 : 0)); } // Special Ribbon
|
||||
public bool RIB1_3 { get => (RIB1 & (1 << 3)) == 1 << 3; set => RIB1 = (byte)(RIB1 & ~(1 << 3) | (value ? 1 << 3 : 0)); } // Souvenir Ribbon
|
||||
public bool RIB1_4 { get => (RIB1 & (1 << 4)) == 1 << 4; set => RIB1 = (byte)(RIB1 & ~(1 << 4) | (value ? 1 << 4 : 0)); } // Wishing Ribbon
|
||||
public bool RIB1_5 { get => (RIB1 & (1 << 5)) == 1 << 5; set => RIB1 = (byte)(RIB1 & ~(1 << 5) | (value ? 1 << 5 : 0)); } // Classic Ribbon
|
||||
public bool RIB1_6 { get => (RIB1 & (1 << 6)) == 1 << 6; set => RIB1 = (byte)(RIB1 & ~(1 << 6) | (value ? 1 << 6 : 0)); } // Premier Ribbon
|
||||
public bool RibbonChampionWorld { get => (RIB1 & (1 << 0)) == 1 << 0; set => RIB1 = (byte)(RIB1 & ~(1 << 0) | (value ? 1 << 0 : 0)); } // World Champ Ribbon
|
||||
public bool RibbonBirthday { get => (RIB1 & (1 << 1)) == 1 << 1; set => RIB1 = (byte)(RIB1 & ~(1 << 1) | (value ? 1 << 1 : 0)); } // Birthday Ribbon
|
||||
public bool RibbonSpecial { get => (RIB1 & (1 << 2)) == 1 << 2; set => RIB1 = (byte)(RIB1 & ~(1 << 2) | (value ? 1 << 2 : 0)); } // Special Ribbon
|
||||
public bool RibbonSouvenir { get => (RIB1 & (1 << 3)) == 1 << 3; set => RIB1 = (byte)(RIB1 & ~(1 << 3) | (value ? 1 << 3 : 0)); } // Souvenir Ribbon
|
||||
public bool RibbonWishing { get => (RIB1 & (1 << 4)) == 1 << 4; set => RIB1 = (byte)(RIB1 & ~(1 << 4) | (value ? 1 << 4 : 0)); } // Wishing Ribbon
|
||||
public bool RibbonClassic { get => (RIB1 & (1 << 5)) == 1 << 5; set => RIB1 = (byte)(RIB1 & ~(1 << 5) | (value ? 1 << 5 : 0)); } // Classic Ribbon
|
||||
public bool RibbonPremier { get => (RIB1 & (1 << 6)) == 1 << 6; set => RIB1 = (byte)(RIB1 & ~(1 << 6) | (value ? 1 << 6 : 0)); } // Premier Ribbon
|
||||
public bool RIB1_7 { get => (RIB1 & (1 << 7)) == 1 << 7; set => RIB1 = (byte)(RIB1 & ~(1 << 7) | (value ? 1 << 7 : 0)); } // Empty
|
||||
|
||||
public int[] Moves
|
||||
|
|
|
|||
|
|
@ -2,6 +2,13 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <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>
|
||||
public class WC3 : MysteryGift, IRibbonSetEvent3
|
||||
{
|
||||
// Template Properties
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public class BK4 : PKM // Big Endian 4th Generation PKM File
|
||||
/// <summary> Generation 4 <see cref="PKM"/> format, exclusively for Pokémon Battle Revolution. </summary>
|
||||
/// <remarks> Values are stored in Big Endian format rather than Little Endian. Beware. </remarks>
|
||||
public class BK4 : PKM
|
||||
{
|
||||
public static readonly byte[] ExtraBytes =
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary> Generation 3 <see cref="PKM"/> format, exclusively for Pokémon Colosseum. </summary>
|
||||
public class CK3 : PKM, IRibbonSetEvent3, IRibbonSetCommon3, IRibbonSetUnique3, IRibbonSetOnly3, IShadowPKM
|
||||
{
|
||||
public static readonly byte[] ExtraBytes =
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface that exposes Shadow details for the object.
|
||||
/// </summary>
|
||||
/// <remarks>Used only for Colosseum/XD <see cref="PKM"/> that were shadow encounters.</remarks>
|
||||
public interface IShadowPKM
|
||||
{
|
||||
int ShadowID { get; set; }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic for converting Item IDs between the generation specific value sets.
|
||||
/// </summary>
|
||||
internal static class ItemConverter
|
||||
{
|
||||
/// <summary>Unused item ID, placeholder for item/sprite finding</summary>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary> Generation 1 <see cref="PKM"/> format. </summary>
|
||||
public class PK1 : PKM
|
||||
{
|
||||
// Internal use only
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary> Generation 2 <see cref="PKM"/> format. </summary>
|
||||
public class PK2 : PKM
|
||||
{
|
||||
// Internal use only
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary> Generation 3 <see cref="PKM"/> format. </summary>
|
||||
public class PK3 : PKM, IRibbonSetEvent3, IRibbonSetCommon3, IRibbonSetUnique3, IRibbonSetOnly3
|
||||
{
|
||||
public static readonly byte[] ExtraBytes =
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary> Generation 4 <see cref="PKM"/> format. </summary>
|
||||
public class PK4 : PKM, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetUnique3, IRibbonSetUnique4, IRibbonSetCommon3, IRibbonSetCommon4
|
||||
{
|
||||
public static readonly byte[] ExtraBytes =
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary> Generation 5 <see cref="PKM"/> format. </summary>
|
||||
public class PK5 : PKM, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetUnique3, IRibbonSetUnique4, IRibbonSetCommon3, IRibbonSetCommon4
|
||||
{
|
||||
public static readonly byte[] ExtraBytes =
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary> Generation 6 <see cref="PKM"/> format. </summary>
|
||||
public class PK6 : PKM, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6
|
||||
{
|
||||
public static readonly byte[] ExtraBytes =
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary> Generation 7 <see cref="PKM"/> format. </summary>
|
||||
public class PK7 : PKM, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IRibbonSetCommon7
|
||||
{
|
||||
public static readonly byte[] ExtraBytes =
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Object representing a <see cref="PKM"/>'s data and derived properties.
|
||||
/// </summary>
|
||||
public abstract class PKM
|
||||
{
|
||||
public static readonly string[] Extensions = PKX.GetPKMExtensions();
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic for converting a <see cref="PKM"/> from one generation specific format to another.
|
||||
/// </summary>
|
||||
public static class PKMConverter
|
||||
{
|
||||
public static int Country { get; private set; } = 49;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic for exporting and importing <see cref="PKM"/> data in Pokémon Showdown's text format.
|
||||
/// </summary>
|
||||
public class ShowdownSet
|
||||
{
|
||||
// String to Values
|
||||
|
|
@ -285,7 +288,7 @@ private void ParseSpeciesNickname(ref string line)
|
|||
{
|
||||
n1 = line.Substring(0, index - 1);
|
||||
n2 = line.Substring(index).Trim();
|
||||
ReplaceAll(ref n2, "", "[", "]", "(", ")"); // Trim out excess data
|
||||
n2 = ReplaceAll(n2, string.Empty, "[", "]", "(", ")"); // Trim out excess data
|
||||
}
|
||||
else // nickname first (manually created set, incorrect)
|
||||
{
|
||||
|
|
@ -308,7 +311,7 @@ private string ParseLineMove(string line)
|
|||
if (moveString.Length > 13)
|
||||
{
|
||||
string type = moveString.Remove(0, 13);
|
||||
ReplaceAll(ref type, "", "[", "]", "(", ")"); // Trim out excess data
|
||||
type = ReplaceAll(type, string.Empty, "[", "]", "(", ")"); // Trim out excess data
|
||||
int hpVal = Array.IndexOf(hptypes, type); // Get HP Type
|
||||
if (hpVal >= 0)
|
||||
IVs = PKX.SetHPIVs(hpVal, IVs); // Get IVs
|
||||
|
|
@ -418,9 +421,9 @@ private static string[] SplitLineStats(string line)
|
|||
.Replace("SDef", "SpD").Replace("Sp Def", "SpD")
|
||||
.Replace("Spd", "Spe").Replace("Speed", "Spe").Split(new[] { " / ", " " }, StringSplitOptions.None);
|
||||
}
|
||||
private static void ReplaceAll(ref string rv, string o, params string[] i)
|
||||
private static string ReplaceAll(string original, string to, params string[] toBeReplaced)
|
||||
{
|
||||
rv = i.Aggregate(rv, (current, v) => current.Replace(v, o));
|
||||
return toBeReplaced.Aggregate(original, (current, v) => current.Replace(v, to));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic for converting a National Pokédex Species ID to/from generation specific values.
|
||||
/// </summary>
|
||||
/// <remarks>Generation 4+ always use the national dex ID. Prior generations do not.</remarks>
|
||||
internal static class SpeciesConverter
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic for converting a <see cref="string"/> between the various generation specific encoding formats.
|
||||
/// </summary>
|
||||
public static class StringConverter
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary> Generation 3 <see cref="PKM"/> format, exclusively for Pokémon XD. </summary>
|
||||
public class XK3 : PKM, IRibbonSetEvent3, IRibbonSetCommon3, IRibbonSetUnique3, IRibbonSetOnly3, IShadowPKM
|
||||
{
|
||||
public static readonly byte[] ExtraBytes =
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Stat/misc data for individual species or their associated alternate forme data.
|
||||
/// </summary>
|
||||
public abstract class PersonalInfo
|
||||
{
|
||||
protected byte[] Data;
|
||||
|
|
@ -59,8 +62,15 @@ protected static byte[] SetBits(bool[] bits)
|
|||
return data;
|
||||
}
|
||||
|
||||
public void AddTMHM(byte[] data) => TMHM = GetBits(data);
|
||||
public void AddTypeTutors(byte[] data) => TypeTutors = GetBits(data);
|
||||
/// <summary>
|
||||
/// Injects supplementary TM/HM compatibility which is not present in the generation specific PersonalInfo format.
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
internal void AddTMHM(byte[] data) => TMHM = GetBits(data);
|
||||
/// <summary>
|
||||
/// Injects supplementary Type Tutor compatibility which is not present in the generation specific PersonalInfo format.
|
||||
/// </summary>
|
||||
internal void AddTypeTutors(byte[] data) => TypeTutors = GetBits(data);
|
||||
|
||||
// Data Manipulation
|
||||
public int FormeIndex(int species, int forme)
|
||||
|
|
@ -87,7 +97,7 @@ public int RandomGender
|
|||
case 0: // Male
|
||||
return 0;
|
||||
default:
|
||||
return (int)(Util.Rand32() % 2);
|
||||
return (int)(Util.Rand32() & 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from the Black 2 & White 2 games.
|
||||
/// </summary>
|
||||
public class PersonalInfoB2W2 : PersonalInfoBW
|
||||
{
|
||||
public new const int SIZE = 0x4C;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from the Black & White games.
|
||||
/// </summary>
|
||||
public class PersonalInfoBW : PersonalInfo
|
||||
{
|
||||
protected PersonalInfoBW() { }
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from Generation 1 games.
|
||||
/// </summary>
|
||||
public class PersonalInfoG1 : PersonalInfo
|
||||
{
|
||||
protected PersonalInfoG1() { }
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from Generation 2 games.
|
||||
/// </summary>
|
||||
public class PersonalInfoG2 : PersonalInfo
|
||||
{
|
||||
protected PersonalInfoG2() { }
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from Generation 3 games.
|
||||
/// </summary>
|
||||
public class PersonalInfoG3 : PersonalInfo
|
||||
{
|
||||
protected PersonalInfoG3() { }
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from Generation 4 games.
|
||||
/// </summary>
|
||||
public class PersonalInfoG4 : PersonalInfoG3
|
||||
{
|
||||
public new const int SIZE = 0x2C;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from the OR & AS games.
|
||||
/// </summary>
|
||||
public class PersonalInfoORAS : PersonalInfoXY
|
||||
{
|
||||
public new const int SIZE = 0x50;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from the Sun/Moon games.
|
||||
/// </summary>
|
||||
public class PersonalInfoSM : PersonalInfoXY
|
||||
{
|
||||
public new const int SIZE = 0x54;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from the X & Y games.
|
||||
/// </summary>
|
||||
public class PersonalInfoXY : PersonalInfoBW
|
||||
{
|
||||
protected PersonalInfoXY() { } // For ORAS
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> table (array).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Serves as the main object that is accessed for stat data in a particular generation/game format.
|
||||
/// </remarks>
|
||||
public class PersonalTable
|
||||
{
|
||||
public static readonly PersonalTable USUM = GetTable("sm", GameVersion.USUM);
|
||||
|
|
@ -151,14 +157,12 @@ private PersonalTable(byte[] data, GameVersion format)
|
|||
|
||||
public int[] GetAbilities(int species, int forme)
|
||||
{
|
||||
if (species >= Table.Length)
|
||||
{ species = 0; Debug.WriteLine("Requested out of bounds SpeciesID"); }
|
||||
return this[GetFormeIndex(species, forme)].Abilities;
|
||||
return GetFormeEntry(species, forme).Abilities;
|
||||
}
|
||||
public int GetFormeIndex(int species, int forme)
|
||||
{
|
||||
if (species >= Table.Length)
|
||||
{ species = 0; Debug.WriteLine("Requested out of bounds SpeciesID"); }
|
||||
{ species = 0; Debug.WriteLine($"Requested out of bounds {nameof(species)}: {species} (max={Table.Length-1}"); }
|
||||
return this[species].FormeIndex(species, forme);
|
||||
}
|
||||
public PersonalInfo GetFormeEntry(int species, int forme)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 1 <see cref="SaveFile"/> object.
|
||||
/// </summary>
|
||||
public sealed class SAV1 : SaveFile
|
||||
{
|
||||
public override string BAKName => $"{FileName} [{OT} ({Version}) - {PlayTimeString}].bak";
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 2 <see cref="SaveFile"/> object.
|
||||
/// </summary>
|
||||
public sealed class SAV2 : SaveFile
|
||||
{
|
||||
public override string BAKName => $"{FileName} [{OT} ({Version}) - {PlayTimeString}].bak";
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 3 <see cref="SaveFile"/> object.
|
||||
/// </summary>
|
||||
public sealed class SAV3 : SaveFile
|
||||
{
|
||||
public override string BAKName => $"{FileName} [{OT} ({Version}) - {PlayTimeString}].bak";
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 3 <see cref="SaveFile"/> object for Pokémon Colosseum saves.
|
||||
/// </summary>
|
||||
public sealed class SAV3Colosseum : SaveFile, IDisposable
|
||||
{
|
||||
public override string BAKName => $"{FileName} [{OT} ({Version}) - {PlayTimeString}].bak";
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ namespace PKHeX.Core
|
|||
* https://github.com/dolphin-emu/dolphin/
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Flags for indicating what data is present in the Memory Card
|
||||
/// </summary>
|
||||
public enum GCMemoryCardState
|
||||
{
|
||||
Invalid,
|
||||
|
|
@ -21,6 +24,9 @@ public enum GCMemoryCardState
|
|||
DuplicateRSBOX,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GameCube save container which may or may not contain Generation 3 <see cref="SaveFile"/> objects.
|
||||
/// </summary>
|
||||
public sealed class SAV3GCMemoryCard
|
||||
{
|
||||
private const int BLOCK_SIZE = 0x2000;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 3 <see cref="SaveFile"/> object for Pokémon Ruby Sapphire Box saves.
|
||||
/// </summary>
|
||||
public sealed class SAV3RSBox : SaveFile
|
||||
{
|
||||
public override string BAKName => $"{FileName} [{Version} #{SaveCount:0000}].bak";
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 3 <see cref="SaveFile"/> object for Pokémon XD saves.
|
||||
/// </summary>
|
||||
public sealed class SAV3XD : SaveFile
|
||||
{
|
||||
public override string BAKName => $"{FileName} [{OT} ({Version}) #{SaveCount:0000}].bak";
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 4 <see cref="SaveFile"/> object.
|
||||
/// </summary>
|
||||
public sealed class SAV4 : SaveFile
|
||||
{
|
||||
public override string BAKName => $"{FileName} [{OT} ({Version}) - {PlayTimeString}].bak";
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 4 <see cref="SaveFile"/> object for Pokémon Battle Revolution saves.
|
||||
/// </summary>
|
||||
public sealed class SAV4BR : SaveFile
|
||||
{
|
||||
public override string BAKName => $"{FileName} [{Version} #{SaveCount:0000}].bak";
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 5 <see cref="SaveFile"/> object.
|
||||
/// </summary>
|
||||
public sealed class SAV5 : SaveFile
|
||||
{
|
||||
// Save Data Attributes
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 6 <see cref="SaveFile"/> object.
|
||||
/// </summary>
|
||||
public sealed class SAV6 : SaveFile
|
||||
{
|
||||
// Save Data Attributes
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generation 7 <see cref="SaveFile"/> object.
|
||||
/// </summary>
|
||||
public sealed class SAV7 : SaveFile
|
||||
{
|
||||
// Save Data Attributes
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
// Base Class for Save Files
|
||||
/// <summary>
|
||||
/// Base Class for Save Files
|
||||
/// </summary>
|
||||
public abstract class SaveFile
|
||||
{
|
||||
public static bool SetUpdateDex { protected get; set; } = true;
|
||||
|
|
@ -198,9 +200,8 @@ public IList<PKM> PartyData
|
|||
if (value[0].Species == 0)
|
||||
Debug.WriteLine($"Empty first slot, received {value.Count}.");
|
||||
|
||||
PKM[] newParty = value.Where(pk => pk.Species != 0).ToArray();
|
||||
|
||||
Array.Resize(ref newParty, 6);
|
||||
PKM[] newParty = new PKM[6];
|
||||
value.Where(pk => pk.Species != 0).CopyTo(newParty);
|
||||
|
||||
for (int i = PartyCount; i < newParty.Length; i++)
|
||||
newParty[i] = BlankPKM;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic for <see cref="SaveFile"/> data loading and manipulation.
|
||||
/// </summary>
|
||||
public static class SaveUtil
|
||||
{
|
||||
public const int BEEF = 0x42454546;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ public struct Daycare
|
|||
public ulong Seed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Structure containing Mystery Gift Block Data
|
||||
/// </summary>
|
||||
public struct MysteryGiftAlbum
|
||||
{
|
||||
public MysteryGift[] Gifts;
|
||||
|
|
|
|||
|
|
@ -586,14 +586,14 @@ private bool TryLoadPKM(byte[] input, string path, string ext, SaveFile SAV)
|
|||
if (pk == null)
|
||||
{
|
||||
WinFormsUtil.Alert("Conversion failed.", c);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (SAV.Generation < 3 && ((pk as PK1)?.Japanese ?? ((PK2)pk).Japanese) != SAV.Japanese)
|
||||
if (SAV.Generation < 3 && pk.Japanese != SAV.Japanese)
|
||||
{
|
||||
var strs = new[] { "International", "Japanese" };
|
||||
var val = SAV.Japanese ? 0 : 1;
|
||||
WinFormsUtil.Alert($"Cannot load {strs[val]} {pk.GetType().Name}s to {strs[val ^ 1]} saves.");
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
PKME_Tabs.PopulateFields(pk);
|
||||
|
|
@ -607,7 +607,7 @@ private bool TryLoadPCBoxBin(byte[] input)
|
|||
if (!C_SAV.OpenPCBoxBin(input, out string c))
|
||||
{
|
||||
WinFormsUtil.Alert("Binary is not compatible with save file.", c);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
WinFormsUtil.Alert(c);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user