2023-03-26 06:14:50 +00:00
|
|
|
using System;
|
2022-01-03 05:35:59 +00:00
|
|
|
using static System.Buffers.Binary.BinaryPrimitives;
|
2019-06-09 02:56:11 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
public sealed class Puff6 : SaveBlock<SAV6>
|
2019-06-09 02:56:11 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
private const int MaxPuffID = 26; // Supreme Winter Poké Puff
|
|
|
|
private const int PuffSlots = 100;
|
2019-06-09 02:56:11 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public Puff6(SAV6 SAV, int offset) : base(SAV) => Offset = offset;
|
2019-06-09 02:56:11 +00:00
|
|
|
|
2023-03-26 06:14:50 +00:00
|
|
|
public Span<byte> GetPuffs() => SAV.Data.AsSpan(Offset, PuffSlots);
|
|
|
|
public void SetPuffs(ReadOnlySpan<byte> value) => SAV.SetData(value, Offset);
|
2019-06-09 02:56:11 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public int PuffCount
|
|
|
|
{
|
|
|
|
get => ReadInt32LittleEndian(Data.AsSpan(Offset + PuffSlots));
|
|
|
|
set => WriteInt32LittleEndian(Data.AsSpan(Offset + PuffSlots), value);
|
|
|
|
}
|
2019-06-09 02:56:11 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public void Reset()
|
|
|
|
{
|
|
|
|
Array.Clear(Data, Offset, PuffSlots);
|
|
|
|
// Set the first few default Puffs
|
|
|
|
Data[Offset + 0] = 1;
|
|
|
|
Data[Offset + 1] = 2;
|
|
|
|
Data[Offset + 2] = 3;
|
|
|
|
Data[Offset + 3] = 4;
|
|
|
|
Data[Offset + 4] = 5;
|
|
|
|
PuffCount = 5;
|
|
|
|
}
|
2019-06-09 02:56:11 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public void MaxCheat(bool special = false)
|
|
|
|
{
|
|
|
|
var rnd = Util.Rand;
|
|
|
|
if (special)
|
2019-06-09 02:56:11 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
for (int i = 0; i < PuffSlots; i++)
|
|
|
|
Data[Offset + i] = (byte)(21 + rnd.Next(2)); // Supreme Wish or Honor
|
2019-06-09 02:56:11 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
else
|
2019-06-09 02:56:11 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
for (int i = 0; i < PuffSlots; i++)
|
|
|
|
Data[Offset + i] = (byte)((i % MaxPuffID) + 1);
|
|
|
|
Util.Shuffle(Data.AsSpan(), Offset, Offset + PuffSlots, rnd);
|
2019-06-09 02:56:11 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
PuffCount = PuffSlots;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Sort(bool reverse = false)
|
|
|
|
{
|
|
|
|
Array.Sort(Data, Offset, PuffCount);
|
|
|
|
if (reverse)
|
|
|
|
Array.Reverse(Data, Offset, PuffCount);
|
2019-06-09 02:56:11 +00:00
|
|
|
}
|
2020-05-25 00:11:39 +00:00
|
|
|
}
|