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