mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-04-24 07:08:35 -05:00
Allow pkm batch editor to take readonlyspan property names concrete types over `default` for clarity encounterverifier: use const values for egg levels for clarity batchediting: fetch all properties only once etrade4: reduce object size/init by having Contest as a property
20 lines
821 B
C#
20 lines
821 B
C#
using System;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
/// <inheritdoc cref="IComplexSet"/>
|
|
public sealed class ComplexSet([ConstantExpected] string PropertyName, Action<PKM, StringInstruction> Action) : IComplexSet
|
|
{
|
|
public readonly string PropertyName = PropertyName;
|
|
public readonly Func<ReadOnlySpan<char>, bool> IsValueCompatible = _ => true;
|
|
|
|
public ComplexSet([ConstantExpected] string PropertyName, Func<ReadOnlySpan<char>, bool> criteria, Action<PKM, StringInstruction> Action)
|
|
: this(PropertyName, Action) => IsValueCompatible = criteria;
|
|
|
|
public bool IsMatch(ReadOnlySpan<char> name, ReadOnlySpan<char> value)
|
|
=> name.SequenceEqual(PropertyName) && IsValueCompatible(value);
|
|
|
|
public void Modify(PKM pk, StringInstruction instr) => Action(pk, instr);
|
|
}
|