using System;
namespace PKHeX.Core;
///
/// Clears contents of boxes by deleting all that satisfy a based on a .
///
public sealed class BoxManipClearComplex : BoxManipBase
{
private readonly Func Criteria;
public BoxManipClearComplex(BoxManipType type, Func criteria) : this(type, criteria, _ => true) { }
public BoxManipClearComplex(BoxManipType type, Func criteria, Func 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);
}
}