Check met date of WA8/WB8 less than current moment

This commit is contained in:
Kurt 2022-06-05 10:56:17 -07:00
parent 893b5d5293
commit bd5cc538c4
2 changed files with 8 additions and 14 deletions

View file

@ -21,18 +21,12 @@ public static class EncounterServerDate
private static bool IsValidDate(DateTime obtained, DateTime start) => obtained >= start && obtained <= DateTime.UtcNow;
private static bool IsValidDate(DateTime obtained, DateTime start, DateTime end) => obtained >= start && obtained <= end;
//private static bool IsValidDate(DateTime obtained, (DateTime Start, DateTime? End) value)
//{
// var (start, end) = value;
// if (end is not { } x)
// return IsValidDate(obtained, start);
// return IsValidDate(obtained, start, x);
//}
private static bool IsValidDate(DateTime obtained, (DateTime Start, DateTime End) value)
private static bool IsValidDate(DateTime obtained, (DateTime Start, DateTime? End) value)
{
var (start, end) = value;
return IsValidDate(obtained, start, end);
if (end is not { } x)
return IsValidDate(obtained, start);
return IsValidDate(obtained, start, x);
}
private static EncounterServerDateCheck Result(bool result) => result ? Valid : Invalid;
@ -71,12 +65,12 @@ public static class EncounterServerDate
{9014, new DateTime(2021, 06, 17)}, // Gigantamax Squirtle
};
private static readonly DateTime Never = DateTime.MaxValue;
private static readonly DateTime? Never = null;
/// <summary>
/// Minimum date the gift can be received.
/// </summary>
public static readonly Dictionary<int, (DateTime Start, DateTime End)> WA8Gifts = new()
public static readonly Dictionary<int, (DateTime Start, DateTime? End)> WA8Gifts = new()
{
{0138, (new(2022, 01, 27), new(2023, 02, 01))}, // Poké Center Happiny
{0301, (new(2022, 02, 04), new(2023, 03, 01))}, // プロポチャ Piplup
@ -92,7 +86,7 @@ public static class EncounterServerDate
/// <summary>
/// Minimum date the gift can be received.
/// </summary>
public static readonly Dictionary<int, (DateTime Start, DateTime End)> WB8Gifts = new()
public static readonly Dictionary<int, (DateTime Start, DateTime? End)> WB8Gifts = new()
{
{9015, (new(2022, 05, 18), Never)}, // Hidden Ability Turtwig
{9016, (new(2022, 05, 18), Never)}, // Hidden Ability Chimchar

View file

@ -468,7 +468,7 @@ namespace PKHeX.Core
pk.SID = sav.SID;
}
pk.MetDate = IsDateRestricted && EncounterServerDate.WA8Gifts.TryGetValue(CardID, out var dt) ? dt.Start : DateTime.Now;
pk.MetDate = IsDateRestricted && EncounterServerDate.WB8Gifts.TryGetValue(CardID, out var dt) ? dt.Start : DateTime.Now;
// HOME Gifts for Sinnoh/Hisui starters were forced JPN until May 20, 2022 (UTC).
if (CardID is 9015 or 9016 or 9017)
pk.Met_Day = 20;