2021-05-07 06:26:38 +00:00
|
|
|
using System;
|
2018-07-15 18:12:02 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
2019-07-14 00:43:05 +00:00
|
|
|
namespace PKHeX.Core
|
2018-07-15 18:12:02 +00:00
|
|
|
{
|
2019-07-14 00:43:05 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Bindable summary object that can fetch strings that summarize a <see cref="PKM"/>.
|
|
|
|
/// </summary>
|
2021-06-08 03:02:57 +00:00
|
|
|
public class EntitySummary // do NOT seal, allow inheritance
|
2018-07-15 18:12:02 +00:00
|
|
|
{
|
2019-07-14 00:43:05 +00:00
|
|
|
private static readonly IReadOnlyList<string> GenderSymbols = GameInfo.GenderSymbolASCII;
|
|
|
|
|
|
|
|
private readonly GameStrings Strings;
|
2018-07-15 18:12:02 +00:00
|
|
|
private readonly ushort[] Stats;
|
2019-07-14 00:43:05 +00:00
|
|
|
protected readonly PKM pkm; // protected for children generating extra properties
|
|
|
|
|
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately
Don't store within the object, track the slot origin data separately.
Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.
- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code
* Remove WasLink virtual in PKM
Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.
* Use Fateful to directly check gen5 mysterygift origins
No other encounter types in gen5 apply Fateful
* Simplify double ball comparison
Used to be separate for deferral cases, now no longer needed to be separate.
* Grab move/relearn reference and update locally
Fix relearn move identifier
* Inline defog HM transfer preference check
HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.
* Extract more met location metadata checks: WasBredEgg
* Replace Console.Write* with Debug.Write*
There's no console output UI, so don't include them in release builds.
* Inline WasGiftEgg, WasEvent, and WasEventEgg logic
Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
|
|
|
public virtual string Position => "???";
|
2018-07-15 18:12:02 +00:00
|
|
|
public string Nickname => pkm.Nickname;
|
2018-08-04 17:06:06 +00:00
|
|
|
public string Species => Get(Strings.specieslist, pkm.Species);
|
2019-11-16 01:34:18 +00:00
|
|
|
public string Nature => Get(Strings.natures, pkm.StatNature);
|
2019-07-14 00:43:05 +00:00
|
|
|
public string Gender => Get(GenderSymbols, pkm.Gender);
|
2018-07-15 18:12:02 +00:00
|
|
|
public string ESV => pkm.PSV.ToString("0000");
|
2018-08-04 17:06:06 +00:00
|
|
|
public string HP_Type => Get(Strings.types, pkm.HPType + 1);
|
|
|
|
public string Ability => Get(Strings.abilitylist, pkm.Ability);
|
|
|
|
public string Move1 => Get(Strings.movelist, pkm.Move1);
|
|
|
|
public string Move2 => Get(Strings.movelist, pkm.Move2);
|
|
|
|
public string Move3 => Get(Strings.movelist, pkm.Move3);
|
|
|
|
public string Move4 => Get(Strings.movelist, pkm.Move4);
|
2021-05-07 06:26:38 +00:00
|
|
|
public string HeldItem => GetSpan(Strings.GetItemStrings(pkm.Format), pkm.HeldItem);
|
2018-07-15 18:12:02 +00:00
|
|
|
public string HP => Stats[0].ToString();
|
|
|
|
public string ATK => Stats[1].ToString();
|
|
|
|
public string DEF => Stats[2].ToString();
|
|
|
|
public string SPA => Stats[4].ToString();
|
|
|
|
public string SPD => Stats[5].ToString();
|
|
|
|
public string SPE => Stats[3].ToString();
|
|
|
|
public string MetLoc => pkm.GetLocationString(eggmet: false);
|
|
|
|
public string EggLoc => pkm.GetLocationString(eggmet: true);
|
2018-08-04 17:06:06 +00:00
|
|
|
public string Ball => Get(Strings.balllist, pkm.Ball);
|
2018-07-15 18:12:02 +00:00
|
|
|
public string OT => pkm.OT_Name;
|
2018-08-04 17:06:06 +00:00
|
|
|
public string Version => Get(Strings.gamelist, pkm.Version);
|
2020-12-28 19:56:00 +00:00
|
|
|
public string OTLang => ((LanguageID)pkm.Language).ToString();
|
2018-07-15 18:12:02 +00:00
|
|
|
public string Legal { get { var la = new LegalityAnalysis(pkm); return la.Parsed ? la.Valid.ToString() : "-"; } }
|
|
|
|
|
|
|
|
#region Extraneous
|
|
|
|
public string EC => pkm.EncryptionConstant.ToString("X8");
|
|
|
|
public string PID => pkm.PID.ToString("X8");
|
|
|
|
public int HP_IV => pkm.IV_HP;
|
|
|
|
public int ATK_IV => pkm.IV_ATK;
|
|
|
|
public int DEF_IV => pkm.IV_DEF;
|
|
|
|
public int SPA_IV => pkm.IV_SPA;
|
|
|
|
public int SPD_IV => pkm.IV_SPD;
|
|
|
|
public int SPE_IV => pkm.IV_SPE;
|
|
|
|
public uint EXP => pkm.EXP;
|
|
|
|
public int Level => pkm.CurrentLevel;
|
|
|
|
public int HP_EV => pkm.EV_HP;
|
|
|
|
public int ATK_EV => pkm.EV_ATK;
|
|
|
|
public int DEF_EV => pkm.EV_DEF;
|
|
|
|
public int SPA_EV => pkm.EV_SPA;
|
|
|
|
public int SPD_EV => pkm.EV_SPD;
|
|
|
|
public int SPE_EV => pkm.EV_SPE;
|
|
|
|
public int Cool => pkm is IContestStats s ? s.CNT_Cool : 0;
|
|
|
|
public int Beauty => pkm is IContestStats s ? s.CNT_Beauty : 0;
|
|
|
|
public int Cute => pkm is IContestStats s ? s.CNT_Cute : 0;
|
|
|
|
public int Smart => pkm is IContestStats s ? s.CNT_Smart : 0;
|
|
|
|
public int Tough => pkm is IContestStats s ? s.CNT_Tough : 0;
|
|
|
|
public int Sheen => pkm is IContestStats s ? s.CNT_Sheen : 0;
|
|
|
|
public int Markings => pkm.MarkValue;
|
|
|
|
|
|
|
|
public string NotOT => pkm.Format > 5 ? pkm.HT_Name : "N/A";
|
|
|
|
|
|
|
|
public int AbilityNum => pkm.Format > 5 ? pkm.AbilityNumber : -1;
|
|
|
|
public int GenderFlag => pkm.Gender;
|
2020-12-11 04:42:30 +00:00
|
|
|
public int Form => pkm.Form;
|
2018-07-15 18:12:02 +00:00
|
|
|
public int PKRS_Strain => pkm.PKRS_Strain;
|
|
|
|
public int PKRS_Days => pkm.PKRS_Days;
|
|
|
|
public int MetLevel => pkm.Met_Level;
|
|
|
|
public int OT_Gender => pkm.OT_Gender;
|
|
|
|
|
|
|
|
public bool FatefulFlag => pkm.FatefulEncounter;
|
|
|
|
public bool IsEgg => pkm.IsEgg;
|
|
|
|
public bool IsNicknamed => pkm.IsNicknamed;
|
|
|
|
public bool IsShiny => pkm.IsShiny;
|
|
|
|
|
2019-02-10 18:31:20 +00:00
|
|
|
public int TID => pkm.DisplayTID;
|
|
|
|
public int SID => pkm.DisplaySID;
|
2018-07-15 18:12:02 +00:00
|
|
|
public int TSV => pkm.TSV;
|
|
|
|
public int Move1_PP => pkm.Move1_PP;
|
|
|
|
public int Move2_PP => pkm.Move2_PP;
|
|
|
|
public int Move3_PP => pkm.Move3_PP;
|
|
|
|
public int Move4_PP => pkm.Move4_PP;
|
|
|
|
public int Move1_PPUp => pkm.Move1_PPUps;
|
|
|
|
public int Move2_PPUp => pkm.Move2_PPUps;
|
|
|
|
public int Move3_PPUp => pkm.Move3_PPUps;
|
|
|
|
public int Move4_PPUp => pkm.Move4_PPUps;
|
2018-08-04 17:06:06 +00:00
|
|
|
public string Relearn1 => Get(Strings.movelist, pkm.RelearnMove1);
|
|
|
|
public string Relearn2 => Get(Strings.movelist, pkm.RelearnMove2);
|
|
|
|
public string Relearn3 => Get(Strings.movelist, pkm.RelearnMove3);
|
|
|
|
public string Relearn4 => Get(Strings.movelist, pkm.RelearnMove4);
|
2018-07-15 18:12:02 +00:00
|
|
|
public ushort Checksum => pkm.Checksum;
|
|
|
|
public int Friendship => pkm.OT_Friendship;
|
|
|
|
public int Egg_Year => pkm.EggMetDate.GetValueOrDefault().Year;
|
|
|
|
public int Egg_Month => pkm.EggMetDate.GetValueOrDefault().Month;
|
|
|
|
public int Egg_Day => pkm.EggMetDate.GetValueOrDefault().Day;
|
|
|
|
public int Met_Year => pkm.MetDate.GetValueOrDefault().Year;
|
|
|
|
public int Met_Month => pkm.MetDate.GetValueOrDefault().Month;
|
|
|
|
public int Met_Day => pkm.MetDate.GetValueOrDefault().Day;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2021-06-08 03:02:57 +00:00
|
|
|
protected EntitySummary(PKM p, GameStrings strings)
|
2018-07-15 18:12:02 +00:00
|
|
|
{
|
|
|
|
pkm = p;
|
2018-08-04 17:06:06 +00:00
|
|
|
Strings = strings;
|
2018-07-15 18:12:02 +00:00
|
|
|
Stats = pkm.GetStats(pkm.PersonalInfo);
|
|
|
|
}
|
|
|
|
|
2019-07-14 00:43:05 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Safely fetches the string from the array.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="arr">Array of strings</param>
|
|
|
|
/// <param name="val">Index to fetch</param>
|
|
|
|
/// <returns>Null if array is null</returns>
|
2020-01-19 00:57:25 +00:00
|
|
|
private static string Get(IReadOnlyList<string> arr, int val) => (uint)val < arr.Count ? arr[val] : string.Empty;
|
2021-05-07 06:26:38 +00:00
|
|
|
private static string GetSpan(ReadOnlySpan<string> arr, int val) => (uint)val < arr.Length ? arr[val] : string.Empty;
|
2018-07-15 18:12:02 +00:00
|
|
|
}
|
2021-05-07 06:26:38 +00:00
|
|
|
}
|