mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 04:23:12 +00:00
Ranch level indexing fixes and general API usability improvements (#4041)
This commit is contained in:
parent
8d409be8ba
commit
1816aefc25
3 changed files with 31 additions and 31 deletions
|
@ -26,12 +26,12 @@ public sealed class SAV4Ranch : BulkStorage, ISaveFileRevision
|
||||||
private readonly int TrainerMiiCountOffset;
|
private readonly int TrainerMiiCountOffset;
|
||||||
private readonly int PokemonCountOffset;
|
private readonly int PokemonCountOffset;
|
||||||
|
|
||||||
public override int SlotCount => RanchLevel.GetSlotCount(CurrentRanchLevelIndex);
|
public override int SlotCount => RanchLevel.GetSlotCount(CurrentRanchLevel);
|
||||||
public override int BoxCount => (int)Math.Ceiling((decimal)SlotCount / SlotsPerBox);
|
public override int BoxCount => (int)Math.Ceiling((decimal)SlotCount / SlotsPerBox);
|
||||||
public int MiiCount { get; }
|
public int MiiCount { get; }
|
||||||
public int TrainerMiiCount { get; }
|
public int TrainerMiiCount { get; }
|
||||||
public int MaxToyCount => RanchLevel.GetMaxToyCount(CurrentRanchLevelIndex);
|
public int MaxToyCount => RanchLevel.GetMaxToyCount(CurrentRanchLevel);
|
||||||
public int MaxMiiCount => RanchLevel.GetMaxMiiCount(CurrentRanchLevelIndex);
|
public int MaxMiiCount => RanchLevel.GetMaxMiiCount(CurrentRanchLevel);
|
||||||
|
|
||||||
private readonly RanchToy BlankToy = new(new byte[RanchToy.SIZE]);
|
private readonly RanchToy BlankToy = new(new byte[RanchToy.SIZE]);
|
||||||
|
|
||||||
|
@ -83,8 +83,8 @@ public sealed class SAV4Ranch : BulkStorage, ISaveFileRevision
|
||||||
|
|
||||||
private const int ToyBaseOffset = 0x227B;
|
private const int ToyBaseOffset = 0x227B;
|
||||||
|
|
||||||
public byte CurrentRanchLevelIndex { get => Data[0x5A]; set => Data[0x5A] = value; }
|
public int CurrentRanchLevel { get => Data[0x5A] + 1; set => Data[0x5A] = (byte)(value - 1); }
|
||||||
public byte PlannedRanchLevelIndex { get => Data[0x5B]; set => Data[0x5B] = value; } // tomorrow's level
|
public int PlannedRanchLevel { get => Data[0x5B] + 1; set => Data[0x5B] = (byte)(value - 1); } // tomorrow's level
|
||||||
|
|
||||||
public uint SecondsSince2000 { get => ReadUInt32BigEndian(Data.AsSpan(0x5C)); set => WriteUInt32BigEndian(Data.AsSpan(0x5C), value); }
|
public uint SecondsSince2000 { get => ReadUInt32BigEndian(Data.AsSpan(0x5C)); set => WriteUInt32BigEndian(Data.AsSpan(0x5C), value); }
|
||||||
public uint TotalSeconds { get => ReadUInt32BigEndian(Data.AsSpan(0x60)); set => WriteUInt32BigEndian(Data.AsSpan(0x60), value); }
|
public uint TotalSeconds { get => ReadUInt32BigEndian(Data.AsSpan(0x60)); set => WriteUInt32BigEndian(Data.AsSpan(0x60), value); }
|
||||||
|
|
|
@ -5,9 +5,7 @@ namespace PKHeX.Core;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class RanchLevel
|
public static class RanchLevel
|
||||||
{
|
{
|
||||||
public static int GetLevel(byte levelIndex) => levelIndex + 1;
|
public static int GetMaxMiiCount(int ranchLevel) => ranchLevel switch
|
||||||
|
|
||||||
public static int GetMaxMiiCount(byte levelIndex) => levelIndex switch
|
|
||||||
{
|
{
|
||||||
>= 11 => 20,
|
>= 11 => 20,
|
||||||
>= 08 => 15,
|
>= 08 => 15,
|
||||||
|
@ -15,7 +13,7 @@ public static class RanchLevel
|
||||||
_ => 5,
|
_ => 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static int GetMaxToyCount(byte levelIndex) => levelIndex switch
|
public static int GetMaxToyCount(int ranchLevel) => ranchLevel switch
|
||||||
{
|
{
|
||||||
>= 25 => 6,
|
>= 25 => 6,
|
||||||
>= 20 => 5,
|
>= 20 => 5,
|
||||||
|
@ -25,36 +23,38 @@ public static class RanchLevel
|
||||||
_ => 1,
|
_ => 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static int GetSlotCount(byte levelIndex) => levelIndex switch
|
public static int GetSlotCount(int ranchLevel) => ranchLevel switch
|
||||||
{
|
{
|
||||||
00 => 020,
|
01 => 020,
|
||||||
01 => 025,
|
02 => 025,
|
||||||
02 => 030,
|
03 => 030,
|
||||||
03 => 040,
|
|
||||||
04 => 050,
|
|
||||||
05 => 060,
|
|
||||||
06 => 080,
|
|
||||||
|
|
||||||
07 => 100,
|
04 => 040,
|
||||||
08 => 150,
|
05 => 050,
|
||||||
09 => 200,
|
06 => 060,
|
||||||
10 => 250,
|
|
||||||
11 => 300,
|
|
||||||
12 => 350,
|
|
||||||
|
|
||||||
13 => 400,
|
07 => 080,
|
||||||
14 => 500,
|
08 => 100,
|
||||||
15 => 600,
|
|
||||||
16 => 700,
|
|
||||||
17 => 800,
|
|
||||||
18 => 900,
|
|
||||||
19 => 1000,
|
|
||||||
|
|
||||||
|
09 => 150,
|
||||||
|
10 => 200,
|
||||||
|
11 => 250,
|
||||||
|
12 => 300,
|
||||||
|
13 => 350,
|
||||||
|
|
||||||
|
14 => 400,
|
||||||
|
15 => 500,
|
||||||
|
16 => 600,
|
||||||
|
17 => 700,
|
||||||
|
18 => 800,
|
||||||
|
19 => 900,
|
||||||
20 => 1000,
|
20 => 1000,
|
||||||
|
|
||||||
21 => 1000,
|
21 => 1000,
|
||||||
22 => 1000,
|
22 => 1000,
|
||||||
23 => 1000,
|
23 => 1000,
|
||||||
24 => 1000,
|
24 => 1000,
|
||||||
|
25 => 1000,
|
||||||
|
|
||||||
_ => 1500,
|
_ => 1500,
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,5 +46,5 @@ public enum RanchToyType : byte
|
||||||
Twirler = 36,
|
Twirler = 36,
|
||||||
Bound_Mat = 37,
|
Bound_Mat = 37,
|
||||||
Tree = 38,
|
Tree = 38,
|
||||||
Water = 39, // Normally unused; creates a massive plane of water in the sky
|
Water = 39, // Normally unobtainable; creates a massive plane of water in the sky featured in the "Surfing Jump" event
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue