2019-06-09 02:56:11 +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
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2019-10-04 02:09:02 +00:00
|
|
|
|
public sealed class Puff6 : SaveBlock
|
2019-06-09 02:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
private const int MaxPuffID = 26; // Supreme Winter Poké Puff
|
|
|
|
|
private const int PuffSlots = 100;
|
|
|
|
|
|
|
|
|
|
public Puff6(SaveFile SAV, int offset) : base(SAV) => Offset = offset;
|
|
|
|
|
|
2020-11-12 05:01:41 +00:00
|
|
|
|
public byte[] GetPuffs() => SAV.GetData(Offset, PuffSlots);
|
|
|
|
|
public void SetPuffs(byte[] value) => SAV.SetData(value, Offset);
|
2019-06-09 02:56:11 +00:00
|
|
|
|
|
|
|
|
|
public int PuffCount
|
|
|
|
|
{
|
2022-01-03 05:35:59 +00:00
|
|
|
|
get => ReadInt32LittleEndian(Data.AsSpan(Offset + PuffSlots));
|
|
|
|
|
set => WriteInt32LittleEndian(Data.AsSpan(Offset + PuffSlots), value);
|
2019-06-09 02:56:11 +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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MaxCheat(bool special = false)
|
|
|
|
|
{
|
2020-01-26 05:49:52 +00:00
|
|
|
|
var rnd = Util.Rand;
|
2019-06-09 02:56:11 +00:00
|
|
|
|
if (special)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < PuffSlots; i++)
|
2020-01-26 05:49:52 +00:00
|
|
|
|
Data[Offset + i] = (byte)(21 + rnd.Next(2)); // Supreme Wish or Honor
|
2019-06-09 02:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < PuffSlots; i++)
|
|
|
|
|
Data[Offset + i] = (byte)((i % MaxPuffID) + 1);
|
2022-01-03 05:35:59 +00:00
|
|
|
|
Util.Shuffle(Data.AsSpan(), Offset, Offset + PuffSlots, rnd);
|
2019-06-09 02:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
PuffCount = PuffSlots;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Sort(bool reverse = false)
|
|
|
|
|
{
|
|
|
|
|
Array.Sort(Data, Offset, PuffCount);
|
|
|
|
|
if (reverse)
|
|
|
|
|
Array.Reverse(Data, Offset, PuffCount);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-25 00:11:39 +00:00
|
|
|
|
}
|