Some initial work on prescient AI, AI runner, and some random fixes
All checks were successful
Build / Build (push) Successful in 1m3s

This commit is contained in:
2025-07-05 17:48:51 +02:00
parent 7b25161a8d
commit d57076374f
9 changed files with 174 additions and 21 deletions

View File

@@ -325,7 +325,7 @@ public class BattleImpl : ScriptSource, IBattle
// Always allow moves such as Struggle. If we block this, we can run into an infinite loop
if (Library.MiscLibrary.IsReplacementChoice(choice))
return true;
if (HasForcedTurn(choice.User, out var forcedChoice) && !Equals(choice, forcedChoice))
if (HasForcedTurn(choice.User, out var forcedChoice) && !IsValidForForcedTurn(forcedChoice, choice))
return false;
if (choice is IMoveChoice moveChoice)
@@ -343,6 +343,20 @@ public class BattleImpl : ScriptSource, IBattle
}
return true;
bool IsValidForForcedTurn(ITurnChoice forcedChoice, ITurnChoice choiceToCheck)
{
// If the forced choice is a move choice, we can only use it if the move is the same
if (forcedChoice is IMoveChoice forcedMove && choiceToCheck is IMoveChoice moveChoice)
{
return forcedMove.ChosenMove.MoveData.Name == moveChoice.ChosenMove.MoveData.Name;
}
if (forcedChoice is IPassChoice && choiceToCheck is IPassChoice)
{
return true; // Both are pass choices, so they are valid
}
return forcedChoice.Equals(choiceToCheck);
}
}
/// <inheritdoc />