2021-01-01 20:21:46 +00:00
|
|
|
|
namespace PKHeX.Core
|
2018-03-24 17:36:48 +00:00
|
|
|
|
{
|
|
|
|
|
public interface IContestStats
|
|
|
|
|
{
|
2021-01-01 21:39:08 +00:00
|
|
|
|
byte CNT_Cool { get; }
|
|
|
|
|
byte CNT_Beauty { get; }
|
|
|
|
|
byte CNT_Cute { get; }
|
|
|
|
|
byte CNT_Smart { get; }
|
|
|
|
|
byte CNT_Tough { get; }
|
|
|
|
|
byte CNT_Sheen { get; }
|
2018-03-24 17:36:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-24 08:06:40 +00:00
|
|
|
|
public interface IContestStatsMutable
|
2018-03-24 17:36:48 +00:00
|
|
|
|
{
|
2021-01-01 21:39:08 +00:00
|
|
|
|
byte CNT_Cool { set; }
|
|
|
|
|
byte CNT_Beauty { set; }
|
|
|
|
|
byte CNT_Cute { set; }
|
|
|
|
|
byte CNT_Smart { set; }
|
|
|
|
|
byte CNT_Tough { set; }
|
|
|
|
|
byte CNT_Sheen { set; }
|
2020-12-24 08:06:40 +00:00
|
|
|
|
}
|
2018-03-24 17:36:48 +00:00
|
|
|
|
|
2020-12-24 08:06:40 +00:00
|
|
|
|
public static partial class Extensions
|
|
|
|
|
{
|
2021-01-01 21:39:08 +00:00
|
|
|
|
public static byte[] GetContestStats(this IContestStats stats) => new[]
|
2018-06-03 04:19:03 +00:00
|
|
|
|
{
|
|
|
|
|
stats.CNT_Cool,
|
|
|
|
|
stats.CNT_Beauty,
|
|
|
|
|
stats.CNT_Cute,
|
|
|
|
|
stats.CNT_Smart,
|
|
|
|
|
stats.CNT_Tough,
|
2021-08-20 20:49:20 +00:00
|
|
|
|
stats.CNT_Sheen,
|
2018-06-03 04:19:03 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Checks if any contest stat value is nonzero.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="stats">Object containing contest stat data.</param>
|
|
|
|
|
/// <returns>True if has any nonzero contest stat, false if all are zero.</returns>
|
|
|
|
|
public static bool HasContestStats(this IContestStats stats)
|
|
|
|
|
{
|
|
|
|
|
if (stats.CNT_Cool != 0)
|
|
|
|
|
return true;
|
|
|
|
|
if (stats.CNT_Beauty != 0)
|
|
|
|
|
return true;
|
|
|
|
|
if (stats.CNT_Cute != 0)
|
|
|
|
|
return true;
|
|
|
|
|
if (stats.CNT_Smart != 0)
|
|
|
|
|
return true;
|
|
|
|
|
if (stats.CNT_Tough != 0)
|
|
|
|
|
return true;
|
|
|
|
|
if (stats.CNT_Sheen != 0)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-07-29 20:27:48 +00:00
|
|
|
|
|
2018-06-03 04:19:03 +00:00
|
|
|
|
public static bool IsContestBelow(this IContestStats current, IContestStats initial) => !current.IsContestAboveOrEqual(initial);
|
2018-07-29 20:27:48 +00:00
|
|
|
|
|
2018-06-03 04:19:03 +00:00
|
|
|
|
public static bool IsContestAboveOrEqual(this IContestStats current, IContestStats initial)
|
2018-03-24 17:36:48 +00:00
|
|
|
|
{
|
|
|
|
|
if (current.CNT_Cool < initial.CNT_Cool)
|
|
|
|
|
return false;
|
|
|
|
|
if (current.CNT_Beauty < initial.CNT_Beauty)
|
|
|
|
|
return false;
|
|
|
|
|
if (current.CNT_Cute < initial.CNT_Cute)
|
|
|
|
|
return false;
|
|
|
|
|
if (current.CNT_Smart < initial.CNT_Smart)
|
|
|
|
|
return false;
|
|
|
|
|
if (current.CNT_Tough < initial.CNT_Tough)
|
|
|
|
|
return false;
|
|
|
|
|
if (current.CNT_Sheen < initial.CNT_Sheen)
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-03-31 07:43:41 +00:00
|
|
|
|
|
2021-12-07 08:54:39 +00:00
|
|
|
|
public static bool IsContestEqual(this IContestStats current, IContestStats initial)
|
|
|
|
|
{
|
|
|
|
|
if (current.CNT_Cool != initial.CNT_Cool)
|
|
|
|
|
return false;
|
|
|
|
|
if (current.CNT_Beauty != initial.CNT_Beauty)
|
|
|
|
|
return false;
|
|
|
|
|
if (current.CNT_Cute != initial.CNT_Cute)
|
|
|
|
|
return false;
|
|
|
|
|
if (current.CNT_Smart != initial.CNT_Smart)
|
|
|
|
|
return false;
|
|
|
|
|
if (current.CNT_Tough != initial.CNT_Tough)
|
|
|
|
|
return false;
|
|
|
|
|
if (current.CNT_Sheen != initial.CNT_Sheen)
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-24 08:06:40 +00:00
|
|
|
|
public static void CopyContestStatsTo(this IContestStats source, IContestStatsMutable dest)
|
2018-03-31 07:43:41 +00:00
|
|
|
|
{
|
|
|
|
|
dest.CNT_Cool = source.CNT_Cool;
|
|
|
|
|
dest.CNT_Beauty = source.CNT_Beauty;
|
|
|
|
|
dest.CNT_Cute = source.CNT_Cute;
|
|
|
|
|
dest.CNT_Smart = source.CNT_Smart;
|
|
|
|
|
dest.CNT_Tough = source.CNT_Tough;
|
|
|
|
|
dest.CNT_Sheen = source.CNT_Sheen;
|
|
|
|
|
}
|
2021-12-07 08:54:39 +00:00
|
|
|
|
|
|
|
|
|
public static void SetAllContestStatsTo(this IContestStatsMutable dest, byte value, byte sheen)
|
|
|
|
|
{
|
|
|
|
|
dest.CNT_Cool = value;
|
|
|
|
|
dest.CNT_Beauty = value;
|
|
|
|
|
dest.CNT_Cute = value;
|
|
|
|
|
dest.CNT_Smart = value;
|
|
|
|
|
dest.CNT_Tough = value;
|
|
|
|
|
dest.CNT_Sheen = sheen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private const byte CONTEST_MAX = 255;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Check if any contest stat besides <see cref="IContestStats.CNT_Sheen"/> is equal to <see cref="CONTEST_MAX"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="s">Entity to check</param>
|
|
|
|
|
/// <returns>True if any equals <see cref="CONTEST_MAX"/></returns>
|
|
|
|
|
public static bool IsAnyContestStatMax(this IContestStats s) => CONTEST_MAX == s.CNT_Cool
|
|
|
|
|
|| CONTEST_MAX == s.CNT_Beauty
|
|
|
|
|
|| CONTEST_MAX == s.CNT_Cute
|
|
|
|
|
|| CONTEST_MAX == s.CNT_Smart
|
|
|
|
|
|| CONTEST_MAX == s.CNT_Tough;
|
2018-03-24 17:36:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|