Simplify "Flag" field in move source tracking

This commit is contained in:
Kurt
2020-10-17 13:40:12 -07:00
parent 83f886382a
commit c09fb9a0ec
3 changed files with 22 additions and 5 deletions

View File

@@ -456,7 +456,7 @@ public IReadOnlyList<int> GetSuggestedRelearnMovesFromEncounter()
return Info.RelearnBase;
List<int> window = new List<int>(Info.RelearnBase.Where(z => z != 0));
window.AddRange(pkm.Moves.Where((z, i) => z != 0 && !Info.Moves[i].Valid || Info.Moves[i].Flag));
window.AddRange(pkm.Moves.Where((_, i) => Info.Moves[i].ShouldBeInRelearnMoves()));
window = window.Distinct().ToList();
int[] moves = new int[4];
int start = Math.Max(0, window.Count - 4);

View File

@@ -232,7 +232,7 @@ private static CheckMoveResult[] ParseMovesRelearn(PKM pkm, IReadOnlyList<int> c
var relearn = pkm.RelearnMoves;
for (int i = 0; i < 4; i++)
{
if ((pkm.IsEgg || res[i].Flag) && !relearn.Contains(currentMoves[i]))
if ((pkm.IsEgg || res[i].IsRelearn) && !relearn.Contains(currentMoves[i]))
res[i] = new CheckMoveResult(res[i], Invalid, string.Format(LMoveRelearnFMiss_0, res[i].Comment), res[i].Identifier);
}
@@ -259,7 +259,7 @@ private static CheckMoveResult[] ParseMoves(PKM pkm, MoveParseSource source, Leg
if (source.CurrentMoves[m] == 0)
res[m] = new CheckMoveResult(None, pkm.Format, m < required ? Fishy : Valid, LMoveSourceEmpty, Move);
else if (reset == 0 && info.EncounterMoves.Relearn.Contains(source.CurrentMoves[m]))
res[m] = new CheckMoveResult(Relearn, info.Generation, Valid, LMoveSourceRelearn, Move) { Flag = true };
res[m] = new CheckMoveResult(Relearn, info.Generation, Valid, LMoveSourceRelearn, Move);
}
if (AllParsed())
@@ -468,7 +468,7 @@ private static void ParseEggMoves(PKM pkm, CheckMoveResult[] res, int gen, Learn
}
else
{
res[m] = new CheckMoveResult(EggMove, gen, Valid, LMoveSourceEgg, Move) { Flag = true };
res[m] = new CheckMoveResult(EggMove, gen, Valid, LMoveSourceEgg, Move);
}
learnInfo.EggMovesLearned.Add(m);

View File

@@ -26,9 +26,26 @@ public enum MoveSource
/// </summary>
public sealed class CheckMoveResult : CheckResult
{
/// <summary>
/// Method of learning the move.
/// </summary>
public readonly MoveSource Source;
/// <summary>
/// Generation the move was learned in.
/// </summary>
public readonly int Generation;
public bool Flag;
/// <summary>
/// Indicates if the source of the move was validated from the <see cref="PKM.RelearnMoves"/>
/// </summary>
public bool IsRelearn => Source == MoveSource.Relearn;
/// <summary>
/// Checks if the Move should be present in a Relearn move pool (assuming Gen6+ origins).
/// </summary>
/// <remarks>Invalid moves that can't be validated should be here, hence the inclusion.</remarks>
public bool ShouldBeInRelearnMoves() => Source != MoveSource.None && (!Valid || IsRelearn);
internal CheckMoveResult(MoveSource m, int g, CheckIdentifier i)
: base(i)