Add date restrictions for WC9, pika diff

This commit is contained in:
Kurt 2023-02-03 20:30:41 -08:00
parent 60a53b6afa
commit fe2cbeac31
3 changed files with 27 additions and 13 deletions

View file

@ -28,14 +28,16 @@ public static class EncounterServerDate
WC8 wc8 => Result(IsValidDateWC8(wc8.CardID, obtained)), WC8 wc8 => Result(IsValidDateWC8(wc8.CardID, obtained)),
WA8 wa8 => Result(IsValidDateWA8(wa8.CardID, obtained)), WA8 wa8 => Result(IsValidDateWA8(wa8.CardID, obtained)),
WB8 wb8 => Result(IsValidDateWB8(wb8.CardID, obtained)), WB8 wb8 => Result(IsValidDateWB8(wb8.CardID, obtained)),
//WC9 wc9 => Result(IsValidDateWC9(wc9.CardID, obtained)), WC9 wc9 => Result(IsValidDateWC9(wc9, obtained)),
_ => throw new ArgumentOutOfRangeException(nameof(enc)), _ => throw new ArgumentOutOfRangeException(nameof(enc)),
}; };
public static bool IsValidDateWC8(int cardID, DateOnly obtained) => WC8Gifts.TryGetValue(cardID, out var time) && IsValidDate(obtained, time); public static bool IsValidDateWC8(int cardID, DateOnly obtained) => WC8Gifts.TryGetValue(cardID, out var time) && IsValidDate(obtained, time);
public static bool IsValidDateWA8(int cardID, DateOnly obtained) => WA8Gifts.TryGetValue(cardID, out var time) && IsValidDate(obtained, time); public static bool IsValidDateWA8(int cardID, DateOnly obtained) => WA8Gifts.TryGetValue(cardID, out var time) && IsValidDate(obtained, time);
public static bool IsValidDateWB8(int cardID, DateOnly obtained) => WB8Gifts.TryGetValue(cardID, out var time) && IsValidDate(obtained, time); public static bool IsValidDateWB8(int cardID, DateOnly obtained) => WB8Gifts.TryGetValue(cardID, out var time) && IsValidDate(obtained, time);
public static bool IsValidDateWC9(int cardID, DateOnly obtained) => WC9Gifts.TryGetValue(cardID, out var time) && IsValidDate(obtained, time);
public static bool IsValidDateWC9(WC9 card , DateOnly obtained) => (WC9Gifts.TryGetValue(card.CardID, out var time)
|| WC9GiftsChk.TryGetValue(card.Checksum, out time)) && IsValidDate(obtained, time);
/// <summary> /// <summary>
/// Minimum date the gift can be received. /// Minimum date the gift can be received.
@ -89,9 +91,20 @@ public static class EncounterServerDate
{9017, (new(2022, 05, 18), Never)}, // Hidden Ability Piplup {9017, (new(2022, 05, 18), Never)}, // Hidden Ability Piplup
}; };
// ReSharper disable once CollectionNeverUpdated.Global
/// <summary> /// <summary>
/// Minimum date the gift can be received. /// Minimum date the gift can be received.
/// </summary> /// </summary>
public static readonly Dictionary<int, (DateOnly Start, DateOnly? End)> WC9Gifts = new(0); public static readonly Dictionary<int, (DateOnly Start, DateOnly? End)> WC9GiftsChk = new()
{
{0xE5EB, (new(2022, 11, 17), new(2023, 02, 03))}, // Fly Pikachu - rev 1 (male 128)
{0x908B, (new(2023, 02, 02), Never)}, // Fly Pikachu - rev 2 (both 0)
};
/// <summary>
/// Minimum date the gift can be received.
/// </summary>
public static readonly Dictionary<int, (DateOnly Start, DateOnly? End)> WC9Gifts = new()
{
{1501, (new(2022, 11, 17), Never)}, // Flabébé Pokécenter
};
} }

View file

@ -268,6 +268,8 @@ public sealed class WC9 : DataMysteryGift, ILangNick, INature, ITeraType, IRibbo
public byte OT_Feeling { get => Data[CardStart + 0x277]; set => Data[CardStart + 0x277] = value; } public byte OT_Feeling { get => Data[CardStart + 0x277]; set => Data[CardStart + 0x277] = value; }
public ushort OT_TextVar { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x278)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x278), value); } public ushort OT_TextVar { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x278)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x278), value); }
public ushort Checksum => ReadUInt16LittleEndian(Data.AsSpan(0x2C4));
// Meta Accessible Properties // Meta Accessible Properties
public override int[] IVs public override int[] IVs
{ {
@ -505,7 +507,7 @@ public sealed class WC9 : DataMysteryGift, ILangNick, INature, ITeraType, IRibbo
} }
} }
pk.MetDate = IsDateRestricted && EncounterServerDate.WC9Gifts.TryGetValue(CardID, out var dt) ? dt.Start : DateOnly.FromDateTime(DateTime.Now); pk.MetDate = IsDateRestricted && EncounterServerDate.WC9GiftsChk.TryGetValue(CardID, out var dt) ? dt.Start : DateOnly.FromDateTime(DateTime.Now);
var nickname_language = GetLanguage(language); var nickname_language = GetLanguage(language);
pk.Language = nickname_language != 0 ? nickname_language : tr.Language; pk.Language = nickname_language != 0 ? nickname_language : tr.Language;
@ -525,12 +527,10 @@ public sealed class WC9 : DataMysteryGift, ILangNick, INature, ITeraType, IRibbo
SetEggMetData(pk); SetEggMetData(pk);
pk.CurrentFriendship = pk.IsEgg ? pi.HatchCycles : pi.BaseFriendship; pk.CurrentFriendship = pk.IsEgg ? pi.HatchCycles : pi.BaseFriendship;
pk.HeightScalar = (byte)HeightValue;
pk.WeightScalar = (byte)WeightValue;
if (!IsHOMEGift) if (!IsHOMEGift)
{
pk.HeightScalar = PokeSizeUtil.GetRandomScalar();
pk.WeightScalar = PokeSizeUtil.GetRandomScalar();
pk.Scale = PokeSizeUtil.GetRandomScalar(); pk.Scale = PokeSizeUtil.GetRandomScalar();
}
pk.Obedience_Level = Level; pk.Obedience_Level = Level;
pk.ResetPartyStats(); pk.ResetPartyStats();
@ -723,12 +723,13 @@ public sealed class WC9 : DataMysteryGift, ILangNick, INature, ITeraType, IRibbo
if (Nature != -1 && pk.Nature != Nature) return false; if (Nature != -1 && pk.Nature != Nature) return false;
if (Gender != 3 && Gender != pk.Gender) return false; if (Gender != 3 && Gender != pk.Gender) return false;
if (IsHOMEGift && pk is IScaledSize s) if (pk is IScaledSize s)
{ {
if (s.HeightScalar != 0) if (s.HeightScalar != HeightValue)
return false; return false;
if (s.WeightScalar != 0) if (s.WeightScalar != WeightValue)
return false; return false;
// Random scalar
} }
// PID Types 0 and 1 do not use the fixed PID value. // PID Types 0 and 1 do not use the fixed PID value.
@ -740,7 +741,7 @@ public sealed class WC9 : DataMysteryGift, ILangNick, INature, ITeraType, IRibbo
return pk.PID == GetPID(pk, type); return pk.PID == GetPID(pk, type);
} }
public bool IsDateRestricted => IsHOMEGift; public bool IsDateRestricted => true;
protected override bool IsMatchDeferred(PKM pk) => Species != pk.Species; protected override bool IsMatchDeferred(PKM pk) => Species != pk.Species;
protected override bool IsMatchPartial(PKM pk) protected override bool IsMatchPartial(PKM pk)