mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 14:44:24 +00:00
Show shiny state of encounter in db
Force shiny state for GO encounters For encounters, this interface property is mainly just for exposing metadata for sprites.
This commit is contained in:
parent
4c8772ff14
commit
565f161226
12 changed files with 49 additions and 3 deletions
|
@ -18,6 +18,7 @@ namespace PKHeX.Core
|
|||
public readonly int Level;
|
||||
public int Generation { get; }
|
||||
public GameVersion Version { get; }
|
||||
public bool IsShiny => false;
|
||||
|
||||
public EncounterEgg(int species, int form, int level, int gen, GameVersion game)
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace PKHeX.Core
|
|||
public bool EggEncounter { get; }
|
||||
public int Generation { get; }
|
||||
public GameVersion Version { get; }
|
||||
public bool IsShiny => false;
|
||||
|
||||
public string Name => "Invalid";
|
||||
public string LongName => "Invalid";
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace PKHeX.Core
|
|||
public int LevelMax { get; }
|
||||
public abstract int Generation { get; }
|
||||
public bool EggEncounter => false;
|
||||
public virtual bool IsShiny => false;
|
||||
|
||||
protected EncounterSlot(EncounterArea area, int species, int form, int min, int max)
|
||||
{
|
||||
|
|
|
@ -22,6 +22,8 @@ namespace PKHeX.Core
|
|||
/// <inheritdoc/>
|
||||
public Gender Gender { get; }
|
||||
|
||||
public override bool IsShiny => Shiny.IsShiny();
|
||||
|
||||
protected EncounterSlotGO(EncounterArea area, int species, int form, int start, int end, Shiny shiny, Gender gender, PogoType type) : base(area, species, form, type.GetMinLevel(), EncountersGO.MAX_LEVEL)
|
||||
{
|
||||
Start = start;
|
||||
|
@ -126,5 +128,22 @@ namespace PKHeX.Core
|
|||
return false;
|
||||
return (pkm.GetIV(0) & 1) == 1; // HP
|
||||
}
|
||||
|
||||
protected override void SetPINGA(PKM pk, EncounterCriteria criteria)
|
||||
{
|
||||
base.SetPINGA(pk, criteria);
|
||||
switch (Shiny)
|
||||
{
|
||||
case Shiny.Random when !pk.IsShiny && criteria.Shiny.IsShiny():
|
||||
case Shiny.Always when !pk.IsShiny: // Force Square
|
||||
pk.PID = (uint)(((pk.TID ^ 0 ^ (pk.PID & 0xFFFF) ^ 0) << 16) | (pk.PID & 0xFFFF));
|
||||
break;
|
||||
|
||||
case Shiny.Random when pk.IsShiny && !criteria.Shiny.IsShiny():
|
||||
case Shiny.Never when pk.IsShiny: // Force Not Shiny
|
||||
pk.PID ^= 0x1000_0000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace PKHeX.Core
|
|||
private const string _name = "Static Encounter";
|
||||
public string Name => _name;
|
||||
public string LongName => Version == GameVersion.Any ? _name : $"{_name} ({Version})";
|
||||
public bool IsShiny => Shiny.IsShiny();
|
||||
|
||||
protected EncounterStatic(GameVersion game) => Version = game;
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ namespace PKHeX.Core
|
|||
public string Name => _name;
|
||||
public string LongName => _name;
|
||||
public bool IsNicknamed { get; init; } = true;
|
||||
public bool IsShiny => Shiny.IsShiny();
|
||||
|
||||
public IReadOnlyList<string> Nicknames { get; internal set; } = Array.Empty<string>();
|
||||
public IReadOnlyList<string> TrainerNames { get; internal set; } = Array.Empty<string>();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
public interface IEncounterTemplate : ISpeciesForm, IVersion, IGeneration
|
||||
public interface IEncounterTemplate : ISpeciesForm, IVersion, IGeneration, IShiny
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates if the encounter originated as an egg.
|
||||
|
|
|
@ -46,5 +46,13 @@
|
|||
Shiny.AlwaysStar => pkm.ShinyXor == 1,
|
||||
_ => true
|
||||
};
|
||||
|
||||
public static bool IsShiny(this Shiny s) => s switch
|
||||
{
|
||||
Shiny.Always => true,
|
||||
Shiny.AlwaysSquare => true,
|
||||
Shiny.AlwaysStar => true,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Object representing a <see cref="PKM"/>'s data and derived properties.
|
||||
/// </summary>
|
||||
public abstract class PKM : ISpeciesForm, ITrainerID, IGeneration, ILangNick, IGameValueLimit, INature
|
||||
public abstract class PKM : ISpeciesForm, ITrainerID, IGeneration, IShiny, ILangNick, IGameValueLimit, INature
|
||||
{
|
||||
public static readonly string[] Extensions = PKX.GetPKMExtensions();
|
||||
public abstract int SIZE_PARTY { get; }
|
||||
|
|
13
PKHeX.Core/PKM/Shared/IShiny.cs
Normal file
13
PKHeX.Core/PKM/Shared/IShiny.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface that exposes a boolean indicating if the object is a shiny.
|
||||
/// </summary>
|
||||
public interface IShiny
|
||||
{
|
||||
/// <summary>
|
||||
/// Is definitively a shiny.
|
||||
/// </summary>
|
||||
bool IsShiny { get; }
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ namespace PKHeX.Core
|
|||
public int LevelMin => Level;
|
||||
public int LevelMax => Level;
|
||||
public int Generation => Version.GetGeneration();
|
||||
public bool IsShiny => false;
|
||||
|
||||
private readonly byte[] Data;
|
||||
public const int SIZE = 0x30;
|
||||
|
|
|
@ -314,7 +314,7 @@ namespace PKHeX.WinForms
|
|||
for (int i = 0; i < end; i++)
|
||||
{
|
||||
var enc = Results[i + begin];
|
||||
PKXBOXES[i].Image = SpriteUtil.GetSprite(enc.Species, enc.Form, 0, 0, 0, enc.EggEncounter, false, enc.Generation);
|
||||
PKXBOXES[i].Image = SpriteUtil.GetSprite(enc.Species, enc.Form, 0, 0, 0, enc.EggEncounter, enc.IsShiny, enc.Generation);
|
||||
}
|
||||
for (int i = end; i < RES_MAX; i++)
|
||||
PKXBOXES[i].Image = null;
|
||||
|
|
Loading…
Reference in a new issue