2018-09-02 18:31:34 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
2021-12-10 02:58:30 +00:00
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Clears contents of boxes by deleting all that satisfy a <see cref="Criteria"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class BoxManipClear : BoxManipBase
|
2018-09-02 18:31:34 +00:00
|
|
|
|
{
|
2021-12-10 02:58:30 +00:00
|
|
|
|
private readonly Func<PKM, bool> Criteria;
|
|
|
|
|
public BoxManipClear(BoxManipType type, Func<PKM, bool> criteria) : this(type, criteria, _ => true) { }
|
|
|
|
|
public BoxManipClear(BoxManipType type, Func<PKM, bool> criteria, Func<SaveFile, bool> usable) : base(type, usable) => Criteria = criteria;
|
2018-09-02 18:31:34 +00:00
|
|
|
|
|
2021-12-10 02:58:30 +00:00
|
|
|
|
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;
|
2019-02-19 01:19:25 +00:00
|
|
|
|
|
2021-12-10 02:58:30 +00:00
|
|
|
|
public override int Execute(SaveFile sav, BoxManipParam param)
|
|
|
|
|
{
|
|
|
|
|
var (start, stop, reverse) = param;
|
|
|
|
|
bool Method(PKM p) => reverse ^ Criteria(p);
|
|
|
|
|
return sav.ClearBoxes(start, stop, Method);
|
2018-09-02 18:31:34 +00:00
|
|
|
|
}
|
2021-12-10 02:58:30 +00:00
|
|
|
|
}
|