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
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
|
|
public sealed class Misc7 : SaveBlock<SAV7>
|
2019-06-09 02:56:11 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public Misc7(SAV7 sav, int offset) : base(sav) => Offset = offset;
|
2019-06-09 02:56:11 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public uint Money
|
|
|
|
|
{
|
|
|
|
|
get => ReadUInt32LittleEndian(Data.AsSpan(Offset + 0x4));
|
|
|
|
|
set
|
2019-06-09 02:56:11 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
if (value > 9_999_999)
|
|
|
|
|
value = 9_999_999;
|
|
|
|
|
WriteUInt32LittleEndian(Data.AsSpan(Offset + 0x4), value);
|
2019-06-09 02:56:11 +00:00
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
|
}
|
2019-06-09 02:56:11 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public uint Stamps
|
|
|
|
|
{
|
|
|
|
|
get => (ReadUInt32LittleEndian(Data.AsSpan(Offset + 0x08)) << 13) >> 17; // 15 stamps; discard top13, lowest4
|
|
|
|
|
set
|
2019-06-09 02:56:11 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
uint flags = ReadUInt32LittleEndian(Data.AsSpan(Offset + 0x08)) & 0xFFF8000F;
|
|
|
|
|
flags |= (value & 0x7FFF) << 4;
|
|
|
|
|
WriteUInt32LittleEndian(SAV.Data.AsSpan(Offset + 0x08), flags);
|
2019-06-09 02:56:11 +00:00
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
|
}
|
2019-06-09 02:56:11 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public uint BP
|
|
|
|
|
{
|
|
|
|
|
get => ReadUInt32LittleEndian(Data.AsSpan(Offset + 0x11C));
|
|
|
|
|
set
|
2019-06-09 02:56:11 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
if (value > 9999)
|
|
|
|
|
value = 9999;
|
|
|
|
|
WriteUInt32LittleEndian(Data.AsSpan(Offset + 0x11C), value);
|
2019-06-09 02:56:11 +00:00
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
|
}
|
2019-10-08 01:40:09 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public int Vivillon
|
|
|
|
|
{
|
|
|
|
|
get => Data[Offset + 0x130] & 0x1F;
|
|
|
|
|
set => Data[Offset + 0x130] = (byte)((Data[Offset + 0x130] & ~0x1F) | (value & 0x1F));
|
|
|
|
|
}
|
2019-06-09 02:56:11 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public uint StarterEncryptionConstant
|
|
|
|
|
{
|
|
|
|
|
get => ReadUInt32LittleEndian(Data.AsSpan(Offset + 0x148));
|
|
|
|
|
set => WriteUInt32LittleEndian(Data.AsSpan(Offset + 0x148), value);
|
|
|
|
|
}
|
2019-06-09 02:56:11 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public int DaysFromRefreshed
|
|
|
|
|
{
|
|
|
|
|
get => Data[Offset + 0x123];
|
|
|
|
|
set => Data[Offset + 0x123] = (byte)value;
|
|
|
|
|
}
|
2019-06-09 02:56:11 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public int GetSurfScore(int recordID)
|
|
|
|
|
{
|
|
|
|
|
if ((uint)recordID >= 4)
|
|
|
|
|
recordID = 0;
|
|
|
|
|
return ReadInt32LittleEndian(Data.AsSpan(Offset + 0x138 + (4 * recordID)));
|
|
|
|
|
}
|
2019-06-09 02:56:11 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public void SetSurfScore(int recordID, int score)
|
|
|
|
|
{
|
|
|
|
|
if ((uint)recordID >= 4)
|
|
|
|
|
recordID = 0;
|
|
|
|
|
WriteInt32LittleEndian(Data.AsSpan(Offset + 0x138 + (4 * recordID)), score);
|
2019-06-09 02:56:11 +00:00
|
|
|
|
}
|
2022-01-03 05:35:59 +00:00
|
|
|
|
}
|