Add initial date checks for HOME gifts

This commit is contained in:
Kurt 2021-02-03 22:57:59 -08:00
parent 5745f8b44e
commit f6f81ec782
3 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using static PKHeX.Core.Species;
namespace PKHeX.Core
{
public static class EncountersHOME
{
public static bool IsValidDateWC8(int species, DateTime obtained) => WC8Gifts.TryGetValue(species, out var time) && obtained >= time && obtained <= DateTime.Today.AddDays(1);
/// <summary>
/// Minimum date the gift can be received.
/// </summary>
public static readonly Dictionary<int, DateTime> WC8Gifts = new()
{
{(int) Bulbasaur, new DateTime(2020, 12, 02)},
{(int) Charmander, new DateTime(2020, 12, 02)},
{(int) Squirtle, new DateTime(2020, 12, 02)},
{(int) Pikachu, new DateTime(2020, 12, 02)},
{(int) Eevee, new DateTime(2020, 12, 02)},
{(int) Pichu, new DateTime(2020, 12, 02)},
{(int) Rotom, new DateTime(2020, 12, 02)},
{(int) Magearna, new DateTime(2020, 15, 02)},
{(int) Zeraora, new DateTime(2020, 30, 06)},
{(int) Melmetal, new DateTime(2020, 10, 11)},
{(int) Grookey, new DateTime(2020, 02, 06)},
{(int) Scorbunny, new DateTime(2020, 02, 06)},
{(int) Sobble, new DateTime(2020, 02, 06)},
};
}
}

View file

@ -95,6 +95,8 @@ namespace PKHeX.Core
public static string LContestZero { get; set; } = "Contest Stats should be 0.";
public static string LDateOutsideDistributionWindow { get; set; } = "Met Date is outside of distribution window.";
public static string LEggContest { get; set; } = "Cannot increase Contest Stats of an Egg.";
public static string LEggEXP { get; set; } = "Eggs cannot receive experience.";
public static string LEggFMetLevel_0 { get; set; } = "Invalid Met Level, expected {0}.";

View file

@ -63,6 +63,13 @@ namespace PKHeX.Core
if (pkm.Format >= 6)
VerifyFullness(data, pkm);
if (data.EncounterMatch is WC8 { IsHOMEGift: true } w)
{
var date = new DateTime(pkm.Met_Year, pkm.Met_Month, pkm.Met_Day);
if (!EncountersHOME.IsValidDateWC8(w.Species, date))
data.AddLine(GetInvalid(LDateOutsideDistributionWindow));
}
VerifyMiscFatefulEncounter(data);
}