mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 20:43:07 +00:00
Update mystery gift logic
Automatically enable mystery gift if any card is active Flag gift availability on set, hide flag on get.
This commit is contained in:
parent
2adbeed48a
commit
2981f39704
1 changed files with 24 additions and 11 deletions
|
@ -579,18 +579,37 @@ namespace PKHeX.Core
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mystery Gift
|
// Mystery Gift
|
||||||
|
public bool MysteryGiftActive { get { return (Data[GBO + 72] & 1) == 1; } set { Data[GBO + 72] = (byte)((Data[GBO + 72] & 0xFE) | (value ? 1 : 0)); } }
|
||||||
|
private static bool getIsMysteryGiftAvailable(MysteryGift[] value)
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
return false;
|
||||||
|
for (int i = 0; i < 8; i++) // 8 PGT
|
||||||
|
if ((value[i] as PGT)?.CardType != 0)
|
||||||
|
return true;
|
||||||
|
for (int i = 8; i < 11; i++) // 3 PCD
|
||||||
|
if ((value[i] as PCD)?.Gift.CardType != 0)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
public override MysteryGiftAlbum GiftAlbum
|
public override MysteryGiftAlbum GiftAlbum
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return new MysteryGiftAlbum
|
var album = new MysteryGiftAlbum
|
||||||
{
|
{
|
||||||
Flags = MysteryGiftReceivedFlags,
|
Flags = MysteryGiftReceivedFlags,
|
||||||
Gifts = MysteryGiftCards,
|
Gifts = MysteryGiftCards,
|
||||||
};
|
};
|
||||||
|
album.Flags[2047] = false;
|
||||||
|
return album;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
bool available = getIsMysteryGiftAvailable(value.Gifts);
|
||||||
|
MysteryGiftActive |= available;
|
||||||
|
value.Flags[2047] = available;
|
||||||
|
|
||||||
MysteryGiftReceivedFlags = value.Flags;
|
MysteryGiftReceivedFlags = value.Flags;
|
||||||
MysteryGiftCards = value.Gifts;
|
MysteryGiftCards = value.Gifts;
|
||||||
}
|
}
|
||||||
|
@ -639,17 +658,11 @@ namespace PKHeX.Core
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return;
|
return;
|
||||||
for (int i = 0; i < 8; i++) // 8 PGT
|
for (int i = 0; i < 8; i++) // 8 PGT
|
||||||
{
|
if (value[i] is PGT)
|
||||||
if (value[i].GetType() != typeof(PGT))
|
setData(value[i].Data, WondercardData + i*PGT.Size);
|
||||||
continue;
|
|
||||||
setData(value[i].Data, WondercardData + i * PGT.Size);
|
|
||||||
}
|
|
||||||
for (int i = 8; i < 11; i++) // 3 PCD
|
for (int i = 8; i < 11; i++) // 3 PCD
|
||||||
{
|
if (value[i] is PCD)
|
||||||
if (value[i].GetType() != typeof(PCD))
|
setData(value[i].Data, WondercardData + 8*PGT.Size + (i - 8)*PCD.Size);
|
||||||
continue;
|
|
||||||
setData(value[i].Data, WondercardData + 8 * PGT.Size + (i-8) * PCD.Size);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue