PKHeX/PKHeX.Core/Saves/Substructures/Gen7/BattleTree7.cs
Kurt 8d8adde2b1 sealed
sealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealed
2019-10-03 19:09:02 -07:00

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;
}
}
}