mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 14:30:56 +00:00
8d8adde2b1
sealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealed
40 lines
No EOL
1.2 KiB
C#
40 lines
No EOL
1.2 KiB
C#
using System;
|
|
|
|
namespace PKHeX.Core
|
|
{
|
|
public sealed class BattleTree7 : SaveBlock
|
|
{
|
|
public BattleTree7(SAV7 sav, int offset) : base(sav) => Offset = offset;
|
|
|
|
public int GetTreeStreak(int battletype, bool super, bool max)
|
|
{
|
|
if (battletype > 3)
|
|
throw new ArgumentException(nameof(battletype));
|
|
|
|
var offset = GetStreakOffset(battletype, super, max);
|
|
return BitConverter.ToUInt16(Data, Offset + offset);
|
|
}
|
|
|
|
public void SetTreeStreak(int value, int battletype, bool super, bool max)
|
|
{
|
|
if (battletype > 3)
|
|
throw new ArgumentException(nameof(battletype));
|
|
|
|
if (value > ushort.MaxValue)
|
|
value = ushort.MaxValue;
|
|
|
|
var offset = GetStreakOffset(battletype, super, max);
|
|
BitConverter.GetBytes((ushort)value).CopyTo(Data, Offset + offset);
|
|
}
|
|
|
|
private static int GetStreakOffset(int battletype, bool super, bool max)
|
|
{
|
|
int offset = 8 * battletype;
|
|
if (super)
|
|
offset += 2;
|
|
if (max)
|
|
offset += 4;
|
|
return offset;
|
|
}
|
|
}
|
|
} |