PKHeX/PKHeX.Core/Editing/Saves/BoxManipClearComplex.cs
Kurt d7e1f65faa Add some xmldoc, file scoped namespaces
Not much of a git diff history for these files so I don't mind them being reformatted.
2021-12-09 18:58:30 -08:00

24 lines
1.2 KiB
C#

using System;
namespace PKHeX.Core;
/// <summary>
/// Clears contents of boxes by deleting all that satisfy a <see cref="Criteria"/> based on a <see cref="SaveFile"/>.
/// </summary>
public sealed class BoxManipClearComplex : BoxManipBase
{
private readonly Func<PKM, SaveFile, bool> Criteria;
public BoxManipClearComplex(BoxManipType type, Func<PKM, SaveFile, bool> criteria) : this(type, criteria, _ => true) { }
public BoxManipClearComplex(BoxManipType type, Func<PKM, SaveFile, bool> criteria, Func<SaveFile, bool> usable) : base(type, usable) => Criteria = criteria;
public override string GetPrompt(bool all) => all ? MessageStrings.MsgSaveBoxClearAll : MessageStrings.MsgSaveBoxClearCurrent;
public override string GetFail(bool all) => all ? MessageStrings.MsgSaveBoxClearAllFailBattle : MessageStrings.MsgSaveBoxClearCurrentFailBattle;
public override string GetSuccess(bool all) => all ? MessageStrings.MsgSaveBoxClearAllSuccess : MessageStrings.MsgSaveBoxClearCurrentSuccess;
public override int Execute(SaveFile sav, BoxManipParam param)
{
var (start, stop, reverse) = param;
bool Method(PKM p) => reverse ^ Criteria(p, sav);
return sav.ClearBoxes(start, stop, Method);
}
}