mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-18 00:13:10 +00:00
b536388d0d
Add xmldoc Simplify some casts Demote priority of Gen2 event yielding Remove old EncounterMatchUtil code Repoint DateTime.Now to console specific date provider stubs
61 lines
1.5 KiB
C#
61 lines
1.5 KiB
C#
using System;
|
|
using static System.Buffers.Binary.BinaryPrimitives;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
public sealed class Puff6 : SaveBlock<SAV6>
|
|
{
|
|
private const byte MaxPuffID = 26; // Supreme Winter Poké Puff
|
|
private const int PuffSlots = 100;
|
|
|
|
public Puff6(SAV6 SAV, int offset) : base(SAV) => Offset = offset;
|
|
|
|
public Span<byte> GetPuffs() => SAV.Data.AsSpan(Offset, PuffSlots);
|
|
public void SetPuffs(ReadOnlySpan<byte> value) => SAV.SetData(value, Offset);
|
|
|
|
public int PuffCount
|
|
{
|
|
get => ReadInt32LittleEndian(Data.AsSpan(Offset + PuffSlots));
|
|
set => WriteInt32LittleEndian(Data.AsSpan(Offset + PuffSlots), value);
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
var puffs = GetPuffs();
|
|
puffs.Clear();
|
|
// Set the first few default Puffs
|
|
puffs[0] = 1;
|
|
puffs[1] = 2;
|
|
puffs[2] = 3;
|
|
puffs[3] = 4;
|
|
puffs[4] = 5;
|
|
PuffCount = 5;
|
|
}
|
|
|
|
public void MaxCheat(bool special = false)
|
|
{
|
|
var rnd = Util.Rand;
|
|
var puffs = GetPuffs();
|
|
if (special)
|
|
{
|
|
foreach (ref var puff in puffs)
|
|
puff = (byte)(21 + rnd.Next(2)); // Supreme Wish or Honor
|
|
}
|
|
else
|
|
{
|
|
int i = 0;
|
|
foreach (ref var puff in puffs)
|
|
puff = (byte)((i++ % MaxPuffID) + 1);
|
|
rnd.Shuffle(puffs);
|
|
}
|
|
PuffCount = PuffSlots;
|
|
}
|
|
|
|
public void Sort(bool reverse = false)
|
|
{
|
|
var puffs = GetPuffs();
|
|
puffs.Sort();
|
|
if (reverse)
|
|
puffs.Reverse();
|
|
}
|
|
}
|