From bd5cc538c401c12a113fdc027dceeed9b3ac0b48 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 5 Jun 2022 10:56:17 -0700 Subject: [PATCH] Check met date of WA8/WB8 less than current moment --- .../Encounters/Data/EncounterServerDate.cs | 20 +++++++------------ PKHeX.Core/MysteryGifts/WB8.cs | 2 +- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/Data/EncounterServerDate.cs b/PKHeX.Core/Legality/Encounters/Data/EncounterServerDate.cs index 17332b601..8f4cea31f 100644 --- a/PKHeX.Core/Legality/Encounters/Data/EncounterServerDate.cs +++ b/PKHeX.Core/Legality/Encounters/Data/EncounterServerDate.cs @@ -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 @@ private static bool IsValidDate(DateTime obtained, (DateTime Start, DateTime End {9014, new DateTime(2021, 06, 17)}, // Gigantamax Squirtle }; - private static readonly DateTime Never = DateTime.MaxValue; + private static readonly DateTime? Never = null; /// /// Minimum date the gift can be received. /// - public static readonly Dictionary WA8Gifts = new() + public static readonly Dictionary 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 @@ private static bool IsValidDate(DateTime obtained, (DateTime Start, DateTime End /// /// Minimum date the gift can be received. /// - public static readonly Dictionary WB8Gifts = new() + public static readonly Dictionary WB8Gifts = new() { {9015, (new(2022, 05, 18), Never)}, // Hidden Ability Turtwig {9016, (new(2022, 05, 18), Never)}, // Hidden Ability Chimchar diff --git a/PKHeX.Core/MysteryGifts/WB8.cs b/PKHeX.Core/MysteryGifts/WB8.cs index d943bb6bd..122fb7743 100644 --- a/PKHeX.Core/MysteryGifts/WB8.cs +++ b/PKHeX.Core/MysteryGifts/WB8.cs @@ -468,7 +468,7 @@ public override PKM ConvertToPKM(ITrainerInfo sav, EncounterCriteria criteria) 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;