mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 22:54:14 +00:00
Add properties for cleaner interaction
This commit is contained in:
parent
d8c5c027ac
commit
1d00e17217
5 changed files with 20 additions and 14 deletions
|
@ -10,6 +10,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
public sealed override int Generation => 5;
|
||||
public bool Roaming { get; init; }
|
||||
public bool IsWildCorrelationPID => !Roaming && Shiny == Shiny.Random && Species != (int)Core.Species.Crustle;
|
||||
|
||||
public EncounterStatic5(GameVersion game) : base(game) { }
|
||||
|
||||
|
|
|
@ -37,12 +37,11 @@ namespace PKHeX.Core
|
|||
if (!s.Shiny.IsValid(pkm))
|
||||
data.AddLine(GetInvalid(LEncStaticPIDShiny, CheckIdentifier.Shiny));
|
||||
|
||||
// Underground Raids are originally anti-shiny on encounter.
|
||||
// When selecting a prize at the end, the game rolls and force-shiny is applied to be XOR=1.
|
||||
if (s is EncounterStatic8U {Shiny: Shiny.Random})
|
||||
{
|
||||
// Underground Raids are originally anti-shiny on encounter.
|
||||
// When selecting a prize at the end, the game rolls and force-shiny is applied to be XOR=1.
|
||||
var xor = pkm.ShinyXor;
|
||||
if (xor is <= 15 and not 1)
|
||||
if (pkm.ShinyXor is <= 15 and not 1)
|
||||
data.AddLine(GetInvalid(LEncStaticPIDShiny, CheckIdentifier.Shiny));
|
||||
break;
|
||||
}
|
||||
|
@ -61,9 +60,8 @@ namespace PKHeX.Core
|
|||
|
||||
// Forced PID or generated without an encounter
|
||||
// Crustle has 0x80 for its StartWildBattle flag; dunno what it does, but sometimes it doesn't align with the expected PID xor.
|
||||
if (s is EncounterStatic5 s5 && (s5.Roaming || s5.Shiny != Shiny.Random || s5.Species == (int)Species.Crustle))
|
||||
break;
|
||||
VerifyG5PID_IDCorrelation(data);
|
||||
if (s is EncounterStatic5 { IsWildCorrelationPID: true })
|
||||
VerifyG5PID_IDCorrelation(data);
|
||||
break;
|
||||
|
||||
case EncounterSlot5 {IsHiddenGrotto: true}:
|
||||
|
@ -75,7 +73,7 @@ namespace PKHeX.Core
|
|||
break;
|
||||
|
||||
case PCD d: // fixed PID
|
||||
if (d.Gift.PK.PID != 1 && pkm.EncryptionConstant != d.Gift.PK.PID)
|
||||
if (d.IsFixedPID() && pkm.EncryptionConstant != d.Gift.PK.PID)
|
||||
data.AddLine(GetInvalid(LEncGiftPIDMismatch, CheckIdentifier.Shiny));
|
||||
break;
|
||||
|
||||
|
@ -120,7 +118,7 @@ namespace PKHeX.Core
|
|||
|
||||
if (pkm.EncryptionConstant == 0)
|
||||
{
|
||||
if (Info.EncounterMatch is WC8 {PID: 0, EncryptionConstant: 0})
|
||||
if (Info.EncounterMatch is WC8 {IsHOMEGift: true})
|
||||
return; // HOME Gifts
|
||||
data.AddLine(Get(LPIDEncryptZero, Severity.Fishy, CheckIdentifier.EC));
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ namespace PKHeX.Core
|
|||
if (wc.Species == (int)Core.Species.Milotic && pkm is IContestStats s && s.IsContestBelow(wc))
|
||||
return false;
|
||||
|
||||
if (wc.PID == 1)
|
||||
if (IsRandomPID())
|
||||
{
|
||||
// Random PID, never shiny
|
||||
// PID=0 was never used (pure random).
|
||||
|
@ -205,5 +205,8 @@ namespace PKHeX.Core
|
|||
public bool RibbonWorld { get => Gift.RibbonWorld; set => Gift.RibbonWorld = value; }
|
||||
public bool RibbonChampionWorld { get => Gift.RibbonChampionWorld; set => Gift.RibbonChampionWorld = value; }
|
||||
public bool RibbonSouvenir { get => Gift.RibbonSouvenir; set => Gift.RibbonSouvenir = value; }
|
||||
|
||||
public bool IsFixedPID() => Gift.PK.PID != 1;
|
||||
public bool IsRandomPID() => Gift.PK.PID == 1; // nothing used 0 (full random), always anti-shiny
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,7 +162,9 @@ namespace PKHeX.Core
|
|||
public int Nature { get => (sbyte)Data[CardStart + 0x246]; set => Data[CardStart + 0x246] = (byte)value; }
|
||||
public override int AbilityType { get => Data[CardStart + 0x247]; set => Data[CardStart + 0x247] = (byte)value; }
|
||||
|
||||
public Shiny PIDType => Data[CardStart + 0x248] switch
|
||||
private byte PIDTypeValue => Data[CardStart + 0x248];
|
||||
|
||||
public Shiny PIDType => PIDTypeValue switch
|
||||
{
|
||||
0 => Shiny.Never,
|
||||
1 => Shiny.Random,
|
||||
|
@ -525,8 +527,7 @@ namespace PKHeX.Core
|
|||
|
||||
private void SetPID(PKM pk)
|
||||
{
|
||||
var val = Data[CardStart + 0x248];
|
||||
pk.PID = GetPID(pk, val);
|
||||
pk.PID = GetPID(pk, PIDTypeValue);
|
||||
}
|
||||
|
||||
private void SetIVs(PKM pk)
|
||||
|
@ -648,7 +649,7 @@ namespace PKHeX.Core
|
|||
// PID Types 0 and 1 do not use the fixed PID value.
|
||||
// Values 2,3 are specific shiny states, and 4 is fixed value.
|
||||
// 2,3,4 can change if it is a traded egg to ensure the same shiny state.
|
||||
var type = Data[CardStart + 0x248];
|
||||
var type = PIDTypeValue;
|
||||
if (type <= 1)
|
||||
return true;
|
||||
return pkm.PID == GetPID(pkm, type);
|
||||
|
|
|
@ -67,11 +67,14 @@ namespace PKHeX.Core
|
|||
int size_pkm = GetEntrySize() * capacity;
|
||||
int size_str = 2 * GetStringLength(jp) * capacity;
|
||||
|
||||
// first byte: count (0)
|
||||
var result = new byte[1 + size_intro + size_pkm + size_str];
|
||||
|
||||
// species present in slot: none
|
||||
for (int i = 1; i <= size_intro; i++)
|
||||
result[i] = SLOT_NONE;
|
||||
|
||||
// fill string buffers with terminators
|
||||
for (int i = 1 + size_intro + size_pkm; i < result.Length; i++)
|
||||
result[i] = StringConverter12.G1TerminatorCode; // terminator
|
||||
|
||||
|
|
Loading…
Reference in a new issue