2022-11-25 01:42:17 +00:00
|
|
|
using System;
|
|
|
|
using static System.Buffers.Binary.BinaryPrimitives;
|
|
|
|
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
2023-12-04 04:13:20 +00:00
|
|
|
public sealed class MyStatus9(SAV9SV sav, SCBlock block) : SaveBlock<SAV9SV>(sav, block.Data)
|
2022-11-25 01:42:17 +00:00
|
|
|
{
|
2023-01-22 04:02:33 +00:00
|
|
|
public uint ID32
|
|
|
|
{
|
|
|
|
get => ReadUInt32LittleEndian(Data);
|
|
|
|
set => WriteUInt32LittleEndian(Data, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public ushort TID16
|
2022-11-25 01:42:17 +00:00
|
|
|
{
|
2024-03-04 05:13:16 +00:00
|
|
|
get => ReadUInt16LittleEndian(Data);
|
|
|
|
set => WriteUInt16LittleEndian(Data, value);
|
2022-11-25 01:42:17 +00:00
|
|
|
}
|
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
public ushort SID16
|
2022-11-25 01:42:17 +00:00
|
|
|
{
|
2024-03-04 05:13:16 +00:00
|
|
|
get => ReadUInt16LittleEndian(Data[0x02..]);
|
|
|
|
set => WriteUInt16LittleEndian(Data[0x02..], value);
|
2022-11-25 01:42:17 +00:00
|
|
|
}
|
|
|
|
|
2024-02-23 03:20:54 +00:00
|
|
|
public byte Game
|
2022-11-25 01:42:17 +00:00
|
|
|
{
|
|
|
|
get => Data[0x04];
|
2024-02-23 03:20:54 +00:00
|
|
|
set => Data[0x04] = value;
|
2022-11-25 01:42:17 +00:00
|
|
|
}
|
|
|
|
|
2024-02-23 03:20:54 +00:00
|
|
|
public byte Gender
|
2022-11-25 01:42:17 +00:00
|
|
|
{
|
|
|
|
get => Data[0x05];
|
2024-02-23 03:20:54 +00:00
|
|
|
set => Data[0x05] = value;
|
2022-11-25 01:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// A6
|
|
|
|
public int Language
|
|
|
|
{
|
2024-03-04 05:13:16 +00:00
|
|
|
get => Data[0x07];
|
2022-11-25 01:42:17 +00:00
|
|
|
set
|
|
|
|
{
|
|
|
|
if (value == Language)
|
|
|
|
return;
|
2024-03-04 05:13:16 +00:00
|
|
|
Data[0x07] = (byte)value;
|
2022-11-25 01:42:17 +00:00
|
|
|
|
2023-12-29 18:17:50 +00:00
|
|
|
// For runtime language, the game has different indexes (not even shifted like previous games, just different)
|
|
|
|
var runtimeLanguage = GetRuntimeLanguage((LanguageID)value);
|
|
|
|
SAV.SetValue(SaveBlockAccessor9SV.KGameLanguage, (int)runtimeLanguage); // Int32
|
2022-11-25 01:42:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-29 18:17:50 +00:00
|
|
|
private static RuntimeLanguage GetRuntimeLanguage(LanguageID value) => value switch
|
|
|
|
{
|
|
|
|
LanguageID.Japanese => RuntimeLanguage.Japanese,
|
|
|
|
LanguageID.English => RuntimeLanguage.English,
|
|
|
|
LanguageID.Spanish => RuntimeLanguage.Spanish,
|
|
|
|
LanguageID.German => RuntimeLanguage.German,
|
|
|
|
LanguageID.French => RuntimeLanguage.French,
|
|
|
|
LanguageID.Italian => RuntimeLanguage.Italian,
|
|
|
|
LanguageID.Korean => RuntimeLanguage.Korean,
|
|
|
|
LanguageID.ChineseS => RuntimeLanguage.ChineseS,
|
|
|
|
LanguageID.ChineseT => RuntimeLanguage.ChineseT,
|
|
|
|
_ => RuntimeLanguage.English, // Default to English
|
|
|
|
};
|
|
|
|
|
|
|
|
private enum RuntimeLanguage
|
|
|
|
{
|
|
|
|
Japanese = 0,
|
|
|
|
English = 1,
|
|
|
|
Spanish = 2,
|
|
|
|
German = 3,
|
|
|
|
French = 4,
|
|
|
|
Italian = 5,
|
|
|
|
Korean = 6,
|
|
|
|
ChineseS = 7,
|
|
|
|
ChineseT = 8,
|
|
|
|
}
|
|
|
|
|
2024-03-04 05:13:16 +00:00
|
|
|
private Span<byte> OriginalTrainerTrash => Data.Slice(0x10, 0x1A);
|
2022-11-25 01:42:17 +00:00
|
|
|
|
|
|
|
public string OT
|
|
|
|
{
|
2024-02-23 03:20:54 +00:00
|
|
|
get => SAV.GetString(OriginalTrainerTrash);
|
|
|
|
set => SAV.SetString(OriginalTrainerTrash, value, SAV.MaxStringLengthOT, StringConverterOption.ClearZero);
|
2022-11-25 01:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public byte BirthMonth { get => Data[0x5A]; set => Data[0x5A] = value; }
|
|
|
|
public byte BirthDay { get => Data[0x5B]; set => Data[0x5B] = value; }
|
|
|
|
}
|