2023-08-12 23:01:16 +00:00
|
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
2021-06-30 03:58:06 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Verifies the <see cref="PK4.GroundTile"/>.
|
|
|
|
/// </summary>
|
|
|
|
public sealed class GroundTileVerifier : Verifier
|
2021-06-30 03:58:06 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.Encounter;
|
2021-06-30 03:58:06 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override void Verify(LegalityAnalysis data)
|
|
|
|
{
|
|
|
|
if (data.Entity is not IGroundTile e)
|
|
|
|
return;
|
2023-08-12 23:01:16 +00:00
|
|
|
var enc = data.EncounterMatch;
|
|
|
|
bool valid = IsGroundTileValid(enc, e);
|
|
|
|
var result = !valid ? GetInvalid(LEncTypeMismatch) : GetValid(LEncTypeMatch);
|
2022-06-18 18:04:24 +00:00
|
|
|
data.AddLine(result);
|
2021-06-30 03:58:06 +00:00
|
|
|
}
|
2023-08-12 23:01:16 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Indicates if the <see cref="IGroundTile"/> is valid for the <see cref="IEncounterTemplate"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="enc">Encounter Template</param>
|
|
|
|
/// <param name="e">Entity with a stored <see cref="IGroundTile.GroundTile"/> value.</param>
|
|
|
|
/// <returns>True if stored ground tile value is permitted.</returns>
|
|
|
|
public static bool IsGroundTileValid(IEncounterTemplate enc, IGroundTile e)
|
|
|
|
{
|
|
|
|
var type = enc is IGroundTypeTile t ? t.GroundTile : GroundTileAllowed.None;
|
|
|
|
return type.Contains(e.GroundTile);
|
|
|
|
}
|
2021-06-30 03:58:06 +00:00
|
|
|
}
|