mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-14 00:07:15 +00:00
Update FormVerifier.cs
This commit is contained in:
parent
a7f65554ad
commit
5bb4c9e7fe
1 changed files with 23 additions and 31 deletions
|
@ -252,39 +252,10 @@ namespace PKHeX.Core
|
|||
var pkm = data.pkm;
|
||||
var enc = data.EncounterMatch;
|
||||
|
||||
static bool VerifyDayCounters(uint value, uint maxSeed, bool canRefresh = false)
|
||||
{
|
||||
// lowest byte is days remaining
|
||||
// second lowest is days elapsed (lol)
|
||||
var remain = value & 0xFF;
|
||||
var elapsed = (value >> 8) & 0xFF;
|
||||
if (canRefresh)
|
||||
{
|
||||
if (remain + elapsed < maxSeed)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (remain + elapsed != maxSeed)
|
||||
return false;
|
||||
}
|
||||
if (remain > maxSeed)
|
||||
return false;
|
||||
return remain != 0;
|
||||
}
|
||||
|
||||
return (Species)pkm.Species switch
|
||||
{
|
||||
Furfrou => arg switch
|
||||
{
|
||||
not 0 when pkm.Form != 0 || pkm.IsEgg => GetInvalid(LFormArgumentNotAllowed),
|
||||
_ => VerifyDayCounters(arg, 5, true) ? GetValid(LFormArgumentValid) : GetInvalid(LFormArgumentInvalid),
|
||||
},
|
||||
Hoopa => arg switch
|
||||
{
|
||||
not 0 when pkm.Form != 1 => GetInvalid(LFormArgumentNotAllowed),
|
||||
_ => VerifyDayCounters(arg, 3) ? GetValid(LFormArgumentValid) : GetInvalid(LFormArgumentInvalid),
|
||||
},
|
||||
Furfrou when pkm.Form != 0 => !IsFormArgumentDayCounterValid(arg, 5) ? GetInvalid(LFormArgumentInvalid) :GetValid(LFormArgumentValid),
|
||||
Hoopa when pkm.Form == 1 => !IsFormArgumentDayCounterValid(arg, 3) ? GetInvalid(LFormArgumentInvalid) : GetValid(LFormArgumentValid),
|
||||
Yamask when pkm.Form == 1 => arg switch
|
||||
{
|
||||
not 0 when pkm.IsEgg => GetInvalid(LFormArgumentNotAllowed),
|
||||
|
@ -319,5 +290,26 @@ namespace PKHeX.Core
|
|||
},
|
||||
};
|
||||
}
|
||||
|
||||
private static bool IsFormArgumentDayCounterValid(uint value, uint maxSeed, bool canRefresh = false)
|
||||
{
|
||||
// lowest byte is days remaining
|
||||
// second lowest is days elapsed (lol)
|
||||
var remain = value & 0xFF;
|
||||
var elapsed = (value >> 8) & 0xFF;
|
||||
if (canRefresh)
|
||||
{
|
||||
if (remain + elapsed < maxSeed)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (remain + elapsed != maxSeed)
|
||||
return false;
|
||||
}
|
||||
if (remain > maxSeed)
|
||||
return false;
|
||||
return remain != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue