mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Allow TypeSuggestion to operate on interfaces
Add ganbaru clear/suggest, lgpe iawakened clear/suggest, hyperatrain/geolocation clear
This commit is contained in:
parent
843e065fb4
commit
03b8ceb5ab
2 changed files with 16 additions and 12 deletions
|
@ -9,14 +9,16 @@ namespace PKHeX.Core
|
|||
{
|
||||
public static readonly List<ISuggestModification> SuggestionMods = new()
|
||||
{
|
||||
// PB7 Specific
|
||||
new TypeSuggestion<PB7>(nameof(PB7.Stat_CP), p => p.ResetCP()),
|
||||
new TypeSuggestion<PB7>(nameof(PB7.HeightAbsolute), p => p.HeightAbsolute = p.CalcHeightAbsolute),
|
||||
new TypeSuggestion<PB7>(nameof(PB7.WeightAbsolute), p => p.WeightAbsolute = p.CalcWeightAbsolute),
|
||||
|
||||
// PA8 Specific
|
||||
new TypeSuggestion<PA8>(nameof(PA8.HeightAbsolute), p => p.HeightAbsolute = p.CalcHeightAbsolute),
|
||||
new TypeSuggestion<PA8>(nameof(PA8.WeightAbsolute), p => p.WeightAbsolute = p.CalcWeightAbsolute),
|
||||
// Interface Specific
|
||||
new TypeSuggestion<ICombatPower>(nameof(ICombatPower.Stat_CP), p => p.ResetCP()),
|
||||
new TypeSuggestion<IScaledSizeValue>(nameof(IScaledSizeValue.HeightAbsolute), p => p.ResetHeight()),
|
||||
new TypeSuggestion<IScaledSizeValue>(nameof(IScaledSizeValue.WeightAbsolute), p => p.ResetWeight()),
|
||||
new TypeSuggestion<IHyperTrain>(nameof(Extensions.HyperTrainClear), p => p.HyperTrainClear()),
|
||||
new TypeSuggestion<IGeoTrack>(nameof(Extensions.ClearGeoLocationData), p => p.ClearGeoLocationData()),
|
||||
new TypeSuggestion<IAwakened>(nameof(Extensions.AwakeningClear), p => p.AwakeningClear()),
|
||||
new TypeSuggestion<IAwakened>(nameof(Extensions.AwakeningMax), p => p.AwakeningMax()),
|
||||
new TypeSuggestion<IGanbaru>(nameof(GanbaruExtensions.ClearGanbaruValues), p => p.ClearGanbaruValues()),
|
||||
new TypeSuggestion<IGanbaru>(nameof(GanbaruExtensions.SetSuggestedGanbaruValues), p => p.SetSuggestedGanbaruValues((PKM)p)),
|
||||
|
||||
// Date Copy
|
||||
new TypeSuggestion<PKM>(nameof(PKM.EggMetDate), p => p.EggMetDate = p.MetDate),
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
/// <inheritdoc cref="ISuggestModification"/>
|
||||
/// <typeparam name="T">Specific (or not) type</typeparam>
|
||||
public sealed class TypeSuggestion<T> : ISuggestModification where T : PKM
|
||||
public sealed class TypeSuggestion<T> : ISuggestModification
|
||||
{
|
||||
public readonly string Keyword;
|
||||
public readonly Action<T, string> Action;
|
||||
|
@ -28,10 +28,12 @@ namespace PKHeX.Core
|
|||
|
||||
public ModifyResult Modify(string name, string value, BatchInfo info)
|
||||
{
|
||||
var pk = (T) info.Entity;
|
||||
if (!Criteria(pk))
|
||||
var pk = info.Entity;
|
||||
if (pk is not T x)
|
||||
return ModifyResult.Invalid;
|
||||
Action(pk, value);
|
||||
if (!Criteria(x))
|
||||
return ModifyResult.Invalid;
|
||||
Action(x, value);
|
||||
return ModifyResult.Modified;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue