mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 04:23:12 +00:00
Add Toys from the My Pokémon Ranch Platinum Update (#3766)
* Add Ranch Toys from Platinum Update * Add ToyType validation to SAV4Ranch
This commit is contained in:
parent
a16b2cbd3a
commit
c6e133cff8
3 changed files with 28 additions and 7 deletions
|
@ -13,6 +13,7 @@ public sealed class SAV4Ranch : BulkStorage, ISaveFileRevision
|
|||
{
|
||||
protected override int SIZE_STORED => PokeCrypto.SIZE_4RSTORED;
|
||||
protected override int SIZE_PARTY => PokeCrypto.SIZE_4RSTORED;
|
||||
public int MaxToyID => (int) ((SaveRevision == 0) ? RanchToyType.Poke_Ball : RanchToyType.Water);
|
||||
|
||||
public int SaveRevision => Version == GameVersion.DP ? 0 : 1;
|
||||
public string SaveRevisionString => Version == GameVersion.DP ? "-DP" : "-Pt";
|
||||
|
@ -30,8 +31,10 @@ public sealed class SAV4Ranch : BulkStorage, ISaveFileRevision
|
|||
public override int BoxCount => (int)Math.Ceiling((decimal)SlotCount / SlotsPerBox);
|
||||
public int MiiCount { get; }
|
||||
public int TrainerMiiCount { get; }
|
||||
public int MaxToys => RanchLevel.GetMaxToys(CurrentRanchLevelIndex);
|
||||
public int MaxMiiCount => RanchLevel.GetMaxMiis(CurrentRanchLevelIndex);
|
||||
public int MaxToyCount => RanchLevel.GetMaxToyCount(CurrentRanchLevelIndex);
|
||||
public int MaxMiiCount => RanchLevel.GetMaxMiiCount(CurrentRanchLevelIndex);
|
||||
|
||||
private readonly RanchToy BlankToy = new(new byte[] { (byte)RanchToyType.None, 0 });
|
||||
|
||||
public override PersonalTable4 Personal => PersonalTable.Pt;
|
||||
public override IReadOnlyList<ushort> HeldItems => Legal.HeldItems_Pt;
|
||||
|
@ -90,7 +93,7 @@ public sealed class SAV4Ranch : BulkStorage, ISaveFileRevision
|
|||
|
||||
public RanchToy GetRanchToy(int index)
|
||||
{
|
||||
if ((uint)index >= MaxToys)
|
||||
if ((uint)index >= MaxToyCount)
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
|
||||
int toyOffset = ToyBaseOffset + (RanchToy.SIZE * index);
|
||||
|
@ -100,8 +103,10 @@ public sealed class SAV4Ranch : BulkStorage, ISaveFileRevision
|
|||
|
||||
public void SetRanchToy(RanchToy toy, int index)
|
||||
{
|
||||
if ((uint)index >= MaxToys)
|
||||
if ((uint)index >= MaxToyCount)
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
if (((int)toy.ToyType) > MaxToyID) // Ranch will throw "Corrupt Save" error if ToyId is > expected.
|
||||
toy = BlankToy;
|
||||
|
||||
int toyOffset = ToyBaseOffset + (RanchToy.SIZE * index);
|
||||
SetData(Data, toy.Data, toyOffset);
|
||||
|
|
|
@ -7,7 +7,7 @@ public static class RanchLevel
|
|||
{
|
||||
public static int GetLevel(byte levelIndex) => levelIndex + 1;
|
||||
|
||||
public static int GetMaxMiis(byte levelIndex) => levelIndex switch
|
||||
public static int GetMaxMiiCount(byte levelIndex) => levelIndex switch
|
||||
{
|
||||
>= 11 => 20,
|
||||
>= 08 => 15,
|
||||
|
@ -15,7 +15,7 @@ public static class RanchLevel
|
|||
_ => 5,
|
||||
};
|
||||
|
||||
public static int GetMaxToys(byte levelIndex) => levelIndex switch
|
||||
public static int GetMaxToyCount(byte levelIndex) => levelIndex switch
|
||||
{
|
||||
>= 25 => 6,
|
||||
>= 20 => 5,
|
||||
|
|
|
@ -30,5 +30,21 @@ public enum RanchToyType : byte
|
|||
Sprint_Stand = 22,
|
||||
Attractor = 23,
|
||||
Challenger = 24,
|
||||
Toy_Box = 25,
|
||||
Toy_Box = 25, // Supports metadata - Metadata value is the index of the contained toy.
|
||||
Poke_Ball = 26, // Normally unused
|
||||
|
||||
// Pt Update:
|
||||
Birthday_Cake = 27,
|
||||
Apple_Box_S = 28, // Small Apple Box
|
||||
Apple_Box_L = 29, // Large Apple Box
|
||||
Dice = 30,
|
||||
Picture_Frame_S = 31, // Small Picture Frame
|
||||
Picture_Frame_L = 32, // Large Picture Frame
|
||||
Flower = 33,
|
||||
Lamp = 34,
|
||||
Magnet = 35,
|
||||
Twirler = 36,
|
||||
Bound_Mat = 37,
|
||||
Tree = 38,
|
||||
Water = 39 // Normally unused; creates a massive plane of water in the sky
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue