mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-25 11:53:11 +00:00
16e52cdb19
$suggestAll -> get all $suggestNone -> remove all $suggest -> get current moves
110 lines
3.7 KiB
C#
110 lines
3.7 KiB
C#
using System;
|
|
using System.Globalization;
|
|
|
|
namespace PKHeX.Core
|
|
{
|
|
/// <summary>
|
|
/// Modifications using <see cref="BatchInfo"/> legality.
|
|
/// </summary>
|
|
internal static class BatchModifications
|
|
{
|
|
private static bool IsAll(string p) => p.EndsWith("All", true, CultureInfo.CurrentCulture);
|
|
private static bool IsNone(string p) => p.EndsWith("None", true, CultureInfo.CurrentCulture);
|
|
|
|
public static ModifyResult SetSuggestedRelearnData(BatchInfo info, string propValue)
|
|
{
|
|
var pk = info.Entity;
|
|
if (pk is ITechRecord8 t)
|
|
{
|
|
t.ClearRecordFlags();
|
|
if (IsAll(propValue))
|
|
t.SetRecordFlags(); // all
|
|
else if (!IsNone(propValue))
|
|
t.SetRecordFlags(pk.Moves); // whatever fit the current moves
|
|
}
|
|
|
|
pk.SetRelearnMoves(info.SuggestedRelearn);
|
|
return ModifyResult.Modified;
|
|
}
|
|
|
|
public static ModifyResult SetSuggestedMasteryData(BatchInfo info, string propValue)
|
|
{
|
|
var pk = info.Entity;
|
|
if (pk is IMoveShop8Mastery t)
|
|
{
|
|
if (IsAll(propValue))
|
|
{
|
|
t.SetMoveShopFlags();
|
|
t.SetMoveShopFlagsMastered();
|
|
}
|
|
else if (!IsNone(propValue))
|
|
{
|
|
// whatever fit the current moves
|
|
t.SetMoveShopFlags(pk.Moves);
|
|
t.SetMoveShopFlagsMastered();
|
|
}
|
|
else
|
|
{
|
|
t.ClearMoveShopFlags();
|
|
}
|
|
return ModifyResult.Modified;
|
|
}
|
|
return ModifyResult.Invalid;
|
|
}
|
|
|
|
public static ModifyResult SetSuggestedRibbons(BatchInfo info, string value)
|
|
{
|
|
var pk = info.Entity;
|
|
if (IsNone(value))
|
|
RibbonApplicator.RemoveAllValidRibbons(pk);
|
|
else // All
|
|
RibbonApplicator.SetAllValidRibbons(pk);
|
|
return ModifyResult.Modified;
|
|
}
|
|
|
|
public static ModifyResult SetSuggestedMetData(BatchInfo info)
|
|
{
|
|
var pk = info.Entity;
|
|
var encounter = EncounterSuggestion.GetSuggestedMetInfo(pk);
|
|
if (encounter == null)
|
|
return ModifyResult.Error;
|
|
|
|
int level = encounter.LevelMin;
|
|
int location = encounter.Location;
|
|
int minimumLevel = EncounterSuggestion.GetLowestLevel(pk, encounter.LevelMin);
|
|
|
|
pk.Met_Level = level;
|
|
pk.Met_Location = location;
|
|
pk.CurrentLevel = Math.Max(minimumLevel, level);
|
|
|
|
return ModifyResult.Modified;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the provided moves in a random order.
|
|
/// </summary>
|
|
/// <param name="pk">Pokémon to modify.</param>
|
|
/// <param name="moves">Moves to apply.</param>
|
|
public static ModifyResult SetMoves(PKM pk, int[] moves)
|
|
{
|
|
pk.SetMoves(moves);
|
|
pk.HealPP();
|
|
return ModifyResult.Modified;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the contests stats as requested.
|
|
/// </summary>
|
|
/// <param name="pk">Pokémon to modify.</param>
|
|
/// <param name="enc">Encounter matched to.</param>
|
|
/// <param name="option">Option to apply with</param>
|
|
public static ModifyResult SetContestStats(PKM pk, IEncounterTemplate enc, string option)
|
|
{
|
|
if (option.Length != 0 && option[BatchEditing.CONST_SUGGEST.Length..] is not "0")
|
|
pk.SetMaxContestStats(enc);
|
|
else
|
|
pk.SetSuggestedContestStats(enc);
|
|
return ModifyResult.Modified;
|
|
}
|
|
}
|
|
}
|