mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 12:33:06 +00:00
Split gen6/7 affection stats to interface
not in future formats, doesn't belong
This commit is contained in:
parent
02b4343827
commit
85d1b0e7ad
10 changed files with 47 additions and 33 deletions
|
@ -8,7 +8,8 @@
|
|||
/// <param name="pk">Pokémon to modify.</param>
|
||||
public static void ClearMemories(this PKM pk)
|
||||
{
|
||||
pk.OT_Affection = pk.HT_Affection = 0;
|
||||
if (pk is IAffection a)
|
||||
a.OT_Affection = a.HT_Affection = 0;
|
||||
if (pk is IMemoryOT o)
|
||||
o.ClearMemoriesOT();
|
||||
if (pk is IMemoryHT h)
|
||||
|
@ -28,7 +29,8 @@
|
|||
o.OT_Intensity = 1;
|
||||
o.OT_TextVar = pk.XY ? 43 : 27; // riverside road : battling spot
|
||||
}
|
||||
pk.OT_Affection = 0;
|
||||
if (pk is IAffection a)
|
||||
a.OT_Affection = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -97,7 +97,6 @@ namespace PKHeX.Core
|
|||
public string Relearn4 => Get(Strings.movelist, pkm.RelearnMove4);
|
||||
public ushort Checksum => pkm.Checksum;
|
||||
public int Friendship => pkm.OT_Friendship;
|
||||
public int OT_Affection => pkm.OT_Affection;
|
||||
public int Egg_Year => pkm.EggMetDate.GetValueOrDefault().Year;
|
||||
public int Egg_Month => pkm.EggMetDate.GetValueOrDefault().Month;
|
||||
public int Egg_Day => pkm.EggMetDate.GetValueOrDefault().Day;
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace PKHeX.Core
|
|||
data.AddLine(GetInvalid(LegalityCheckStrings.LMemoryHTFlagInvalid));
|
||||
else if (pkm.HT_Friendship != 0)
|
||||
data.AddLine(GetInvalid(LegalityCheckStrings.LMemoryStatFriendshipHT0));
|
||||
else if (pkm.HT_Affection != 0)
|
||||
else if (pkm is IAffection a && a.HT_Affection != 0)
|
||||
data.AddLine(GetInvalid(LegalityCheckStrings.LMemoryStatAffectionHT0));
|
||||
|
||||
// Don't check trade evolutions if Untraded. The Evolution Chain already checks for trade evolutions.
|
||||
|
@ -96,16 +96,14 @@ namespace PKHeX.Core
|
|||
|
||||
private void VerifyOTAffection(LegalityAnalysis data, bool neverOT, int origin, PKM pkm)
|
||||
{
|
||||
if (!(pkm is IAffection a))
|
||||
return;
|
||||
|
||||
if (origin < 6)
|
||||
{
|
||||
// Can gain affection in Gen6 via the Contest glitch applying affection to OT rather than HT.
|
||||
// VC encounters cannot obtain OT affection since they can't visit Gen6.
|
||||
if ((origin <= 2 && pkm.OT_Affection != 0) || IsInvalidContestAffection(pkm))
|
||||
data.AddLine(GetInvalid(LegalityCheckStrings.LMemoryStatAffectionOT0));
|
||||
}
|
||||
else if (origin == 8)
|
||||
{
|
||||
if (pkm.OT_Affection != 0)
|
||||
if ((origin <= 2 && a.OT_Affection != 0) || IsInvalidContestAffection(a))
|
||||
data.AddLine(GetInvalid(LegalityCheckStrings.LMemoryStatAffectionOT0));
|
||||
}
|
||||
else if (neverOT)
|
||||
|
@ -114,17 +112,17 @@ namespace PKHeX.Core
|
|||
{
|
||||
if (pkm.IsUntraded && pkm.XY)
|
||||
{
|
||||
if (pkm.OT_Affection != 0)
|
||||
if (a.OT_Affection != 0)
|
||||
data.AddLine(GetInvalid(LegalityCheckStrings.LMemoryStatAffectionOT0));
|
||||
}
|
||||
else if (IsInvalidContestAffection(pkm))
|
||||
else if (IsInvalidContestAffection(a))
|
||||
{
|
||||
data.AddLine(GetInvalid(LegalityCheckStrings.LMemoryStatAffectionOT0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pkm.OT_Affection != 0)
|
||||
if (a.OT_Affection != 0)
|
||||
data.AddLine(GetInvalid(LegalityCheckStrings.LMemoryStatAffectionOT0));
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +169,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
// ORAS contests mistakenly apply 20 affection to the OT instead of the current handler's value
|
||||
private static bool IsInvalidContestAffection(PKM pkm) => pkm.OT_Affection != 255 && pkm.OT_Affection % 20 != 0;
|
||||
private static bool IsInvalidContestAffection(IAffection pkm) => pkm.OT_Affection != 255 && pkm.OT_Affection % 20 != 0;
|
||||
|
||||
public static bool GetCanOTHandle(IEncounterable enc, PKM pkm, int gen)
|
||||
{
|
||||
|
|
|
@ -153,9 +153,9 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
// Gen8+ replaced with Max Friendship. Gen6/7 uses affection.
|
||||
if (pkm.Format <= 7 && s6.RibbonBestFriends) // can't lower affection
|
||||
if (pkm is IAffection a && s6.RibbonBestFriends) // can't lower affection
|
||||
{
|
||||
if (pkm.OT_Affection < 255 && pkm.IsUntraded)
|
||||
if (a.OT_Affection < 255 && pkm.IsUntraded)
|
||||
yield return new RibbonResult(nameof(s6.RibbonBestFriends));
|
||||
}
|
||||
}
|
||||
|
@ -253,9 +253,9 @@ namespace PKHeX.Core
|
|||
|
||||
// Each contest victory requires a contest participation; each participation gives 20 OT affection (not current trainer).
|
||||
// Affection is discarded on PK7->PK8 in favor of friendship, which can be lowered.
|
||||
if (pkm.Format <= 7)
|
||||
if (pkm is IAffection a)
|
||||
{
|
||||
var affect = pkm.OT_Affection;
|
||||
var affect = a.OT_Affection;
|
||||
var contMemory = s6.RibbonNamesContest();
|
||||
int contCount = 0;
|
||||
var present = contMemory.Where((_, i) => contest[i] && affect < 20 * ++contCount);
|
||||
|
|
|
@ -226,7 +226,7 @@ namespace PKHeX.Core
|
|||
// 0xA0 Unused
|
||||
// 0xA1 Unused
|
||||
public override int HT_Friendship { get => Data[0xA2]; set => Data[0xA2] = (byte)value; }
|
||||
public override int HT_Affection { get => Data[0xA3]; set => Data[0xA3] = (byte)value; }
|
||||
// 0xA1 HT_Affection Unused
|
||||
public int HT_Intensity { get => Data[0xA4]; set => Data[0xA4] = (byte)value; }
|
||||
public int HT_Memory { get => Data[0xA5]; set => Data[0xA5] = (byte)value; }
|
||||
public int HT_Feeling { get => Data[0xA6]; set => Data[0xA6] = (byte)value; }
|
||||
|
@ -329,7 +329,6 @@ namespace PKHeX.Core
|
|||
if (HT_Name != tr.OT)
|
||||
{
|
||||
HT_Friendship = CurrentFriendship; // copy friendship instead of resetting (don't alter CP)
|
||||
HT_Affection = 0;
|
||||
HT_Name = tr.OT;
|
||||
}
|
||||
CurrentHandler = 1;
|
||||
|
@ -339,7 +338,7 @@ namespace PKHeX.Core
|
|||
public void FixMemories()
|
||||
{
|
||||
if (IsUntraded)
|
||||
HT_Friendship = HT_Affection = HT_TextVar = HT_Memory = HT_Intensity = HT_Feeling = 0;
|
||||
HT_Friendship = HT_TextVar = HT_Memory = HT_Intensity = HT_Feeling = 0;
|
||||
}
|
||||
|
||||
// Maximums
|
||||
|
|
|
@ -4,7 +4,8 @@ using System.Collections.Generic;
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary> Generation 6 <see cref="PKM"/> format. </summary>
|
||||
public sealed class PK6 : G6PKM, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IContestStats, IGeoTrack, ISuperTrain, IFormArgument, ITrainerMemories
|
||||
public sealed class PK6 : G6PKM, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6,
|
||||
IContestStats, IGeoTrack, ISuperTrain, IFormArgument, ITrainerMemories, IAffection
|
||||
{
|
||||
private static readonly ushort[] Unused =
|
||||
{
|
||||
|
@ -310,7 +311,7 @@ namespace PKHeX.Core
|
|||
// 0xA0 Unused
|
||||
// 0xA1 Unused
|
||||
public override int HT_Friendship { get => Data[0xA2]; set => Data[0xA2] = (byte)value; }
|
||||
public override int HT_Affection { get => Data[0xA3]; set => Data[0xA3] = (byte)value; }
|
||||
public int HT_Affection { get => Data[0xA3]; set => Data[0xA3] = (byte)value; }
|
||||
public int HT_Intensity { get => Data[0xA4]; set => Data[0xA4] = (byte)value; }
|
||||
public int HT_Memory { get => Data[0xA5]; set => Data[0xA5] = (byte)value; }
|
||||
public int HT_Feeling { get => Data[0xA6]; set => Data[0xA6] = (byte)value; }
|
||||
|
@ -326,7 +327,7 @@ namespace PKHeX.Core
|
|||
#region Block D
|
||||
public override string OT_Name { get => GetString(0xB0, 24); set => SetString(value, 12).CopyTo(Data, 0xB0); }
|
||||
public override int OT_Friendship { get => Data[0xCA]; set => Data[0xCA] = (byte)value; }
|
||||
public override int OT_Affection { get => Data[0xCB]; set => Data[0xCB] = (byte)value; }
|
||||
public int OT_Affection { get => Data[0xCB]; set => Data[0xCB] = (byte)value; }
|
||||
public int OT_Intensity { get => Data[0xCC]; set => Data[0xCC] = (byte)value; }
|
||||
public int OT_Memory { get => Data[0xCD]; set => Data[0xCD] = (byte)value; }
|
||||
public int OT_TextVar { get => BitConverter.ToUInt16(Data, 0xCE); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xCE); }
|
||||
|
|
|
@ -4,7 +4,8 @@ using System.Collections.Generic;
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary> Generation 7 <see cref="PKM"/> format. </summary>
|
||||
public sealed class PK7 : G6PKM, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IRibbonSetCommon7, IContestStats, IHyperTrain, IGeoTrack, ISuperTrain, IFormArgument, ITrainerMemories
|
||||
public sealed class PK7 : G6PKM, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IRibbonSetCommon7,
|
||||
IContestStats, IHyperTrain, IGeoTrack, ISuperTrain, IFormArgument, ITrainerMemories, IAffection
|
||||
{
|
||||
private static readonly ushort[] Unused =
|
||||
{
|
||||
|
@ -336,7 +337,7 @@ namespace PKHeX.Core
|
|||
// 0xA0 Unused
|
||||
// 0xA1 Unused
|
||||
public override int HT_Friendship { get => Data[0xA2]; set => Data[0xA2] = (byte)value; }
|
||||
public override int HT_Affection { get => Data[0xA3]; set => Data[0xA3] = (byte)value; }
|
||||
public int HT_Affection { get => Data[0xA3]; set => Data[0xA3] = (byte)value; }
|
||||
public int HT_Intensity { get => Data[0xA4]; set => Data[0xA4] = (byte)value; }
|
||||
public int HT_Memory { get => Data[0xA5]; set => Data[0xA5] = (byte)value; }
|
||||
public int HT_Feeling { get => Data[0xA6]; set => Data[0xA6] = (byte)value; }
|
||||
|
@ -352,7 +353,7 @@ namespace PKHeX.Core
|
|||
#region Block D
|
||||
public override string OT_Name { get => GetString(0xB0, 24); set => SetString(value, 12).CopyTo(Data, 0xB0); }
|
||||
public override int OT_Friendship { get => Data[0xCA]; set => Data[0xCA] = (byte)value; }
|
||||
public override int OT_Affection { get => Data[0xCB]; set => Data[0xCB] = (byte)value; }
|
||||
public int OT_Affection { get => Data[0xCB]; set => Data[0xCB] = (byte)value; }
|
||||
public int OT_Intensity { get => Data[0xCC]; set => Data[0xCC] = (byte)value; }
|
||||
public int OT_Memory { get => Data[0xCD]; set => Data[0xCD] = (byte)value; }
|
||||
public int OT_TextVar { get => BitConverter.ToUInt16(Data, 0xCE); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xCE); }
|
||||
|
|
|
@ -146,7 +146,6 @@ namespace PKHeX.Core
|
|||
public virtual int Met_Day { get => 0; set { } }
|
||||
public virtual string HT_Name { get; set; } = string.Empty;
|
||||
public virtual int HT_Gender { get; set; }
|
||||
public virtual int HT_Affection { get; set; }
|
||||
public virtual int HT_Friendship { get; set; }
|
||||
public virtual byte Enjoyment { get; set; }
|
||||
public virtual byte Fullness { get; set; }
|
||||
|
@ -234,7 +233,6 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
|
||||
public virtual int OT_Affection { get => 0; set { } }
|
||||
public virtual int RelearnMove1 { get => 0; set { } }
|
||||
public virtual int RelearnMove2 { get => 0; set { } }
|
||||
public virtual int RelearnMove3 { get => 0; set { } }
|
||||
|
|
8
PKHeX.Core/PKM/Shared/IAffection.cs
Normal file
8
PKHeX.Core/PKM/Shared/IAffection.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
public interface IAffection
|
||||
{
|
||||
int OT_Affection { get; set; }
|
||||
int HT_Affection { get; set; }
|
||||
}
|
||||
}
|
|
@ -62,9 +62,13 @@ namespace PKHeX.WinForms
|
|||
M_Enjoyment.Text = pkm.Enjoyment.ToString();
|
||||
|
||||
M_OT_Friendship.Text = pkm.OT_Friendship.ToString();
|
||||
M_OT_Affection.Text = pkm.OT_Affection.ToString();
|
||||
M_CT_Friendship.Text = pkm.HT_Friendship.ToString();
|
||||
M_CT_Affection.Text = pkm.HT_Affection.ToString();
|
||||
|
||||
if (pkm is IAffection a)
|
||||
{
|
||||
M_OT_Affection.Text = a.OT_Affection.ToString();
|
||||
M_CT_Affection.Text = a.HT_Affection.ToString();
|
||||
}
|
||||
|
||||
if (pkm is ITrainerMemories m)
|
||||
{
|
||||
|
@ -163,9 +167,13 @@ namespace PKHeX.WinForms
|
|||
|
||||
// Save 0-255 stats
|
||||
pkm.HT_Friendship = Util.ToInt32(M_CT_Friendship.Text);
|
||||
pkm.HT_Affection = Util.ToInt32(M_CT_Affection.Text);
|
||||
pkm.OT_Friendship = Util.ToInt32(M_OT_Friendship.Text);
|
||||
pkm.OT_Affection = Util.ToInt32(M_OT_Affection.Text);
|
||||
|
||||
if (pkm is IAffection a)
|
||||
{
|
||||
a.OT_Affection = Util.ToInt32(M_OT_Affection.Text);
|
||||
a.HT_Affection = Util.ToInt32(M_CT_Affection.Text);
|
||||
}
|
||||
pkm.Fullness = (byte)Util.ToInt32(M_Fullness.Text);
|
||||
pkm.Enjoyment = (byte)Util.ToInt32(M_Enjoyment.Text);
|
||||
|
||||
|
|
Loading…
Reference in a new issue