Some initial work on prescient AI, AI runner, and some random fixes
All checks were successful
Build / Build (push) Successful in 1m3s
All checks were successful
Build / Build (push) Successful in 1m3s
This commit is contained in:
@@ -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 />
|
||||
|
||||
Reference in New Issue
Block a user