RaidSpawnList8 fix DenType and Flags (#2686)

* RaidSpawnList8 use enum RaidType for DenType

fix IsWishingPiece and add WattsHarvested

* Add check between RaidType.Event and IsEvent flag
This commit is contained in:
Frank 2020-02-06 17:12:26 -08:00 committed by GitHub
parent 29258ca501
commit e5286f3325
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -86,10 +86,21 @@ namespace PKHeX.Core
}
[Category(General), Description("First set of Den Flags.")]
public byte DenType
public RaidType DenType
{
get => Data[Offset + 0x12];
set => Data[Offset + 0x12] = value;
get => (RaidType)Data[Offset + 0x12];
set
{
Data[Offset + 0x12] = (byte)value;
if (value == RaidType.Event)
{
IsEvent = true;
}
else if (value != RaidType.CommonWish)
{
IsEvent = false;
}
}
}
[Category(General), Description("Second set of Den Flags.")]
@ -105,12 +116,39 @@ namespace PKHeX.Core
[Category(Derived), Description("Rare encounter details used instead of Common details.")]
public bool IsRare
{
get => IsActive && (DenType & 1) == 0;
set => DenType = 2; // set the 1th bit; the 2th bit has a similar-unknown function (?)
get => DenType == RaidType.Rare || DenType == RaidType.RareWish;
set
{
if (value)
{
DenType = IsWishingPiece ? RaidType.RareWish : RaidType.Rare;
}
else
{
DenType = IsWishingPiece ? RaidType.CommonWish : RaidType.Common;
}
}
}
[Category(Derived), Description("Wishing Piece was used for Raid encounter.")]
public bool IsWishingPiece
{
get => DenType == RaidType.CommonWish || DenType == RaidType.RareWish;
set
{
if (value)
{
DenType = IsRare ? RaidType.RareWish : RaidType.CommonWish;
}
else
{
DenType = IsRare ? RaidType.Rare : RaidType.Common;
}
}
}
[Category(Derived), Description("Has watts already been harvested.")]
public bool WattsHarvested
{
get => IsActive && ((Flags >> 0) & 1) == 1;
set => Flags = (byte)((Flags & ~1) | (value ? 1 : 0));
@ -120,7 +158,24 @@ namespace PKHeX.Core
public bool IsEvent
{
get => IsActive && ((Flags >> 1) & 1) == 1;
set => Flags = (byte)((Flags & ~2) | (value ? 2 : 0));
set
{
Flags = (byte)((Flags & ~(byte)2) | (value ? 2 : 0));
if (value)
{
if (DenType != RaidType.CommonWish && DenType != RaidType.Event)
{
DenType = RaidType.Event;
}
}
else
{
if (DenType == RaidType.Event)
{
DenType = RaidType.Common;
}
}
}
}
public void Activate(byte star, byte rand, bool rare = false, bool isEvent = false)