Fixes for AI logic.

This commit is contained in:
Ashby Issac 2026-01-28 17:34:06 +05:30
parent 675dc73ae7
commit 031b3201c6

View File

@ -227,11 +227,11 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
SwitchPlayer();
CanRollDice = true;
}
else if (botTypesInGame.Contains(currentPlayerTypeTurn) && CanRollDiceAgain)
{
Debug.Log($"RollDiceForBot");
Invoke(nameof(RollDiceForBot), 1f);
}
// else if (botTypesInGame.Contains(currentPlayerTypeTurn) && CanRollDiceAgain)
// {
// Debug.Log($"Invoking RollDiceForBot");
// Invoke(nameof(RollDiceForBot), 1f);
// }
}
private void RollDiceForBot()
@ -249,7 +249,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
// What happens when you get a 6
private void SelectPawnFromBotBase()
{
if (availPlayers.Count() < 1 && !CanRollDiceAgain || !botTypesInGame.Contains(currentPlayerTypeTurn)) return;
if (availPlayers.Count() < 1 && !CanRollDiceAgain || !botTypesInGame.Contains(currentPlayerTypeTurn)) return; // Have a better check here
Debug.Log($"CallTest: SelectPawnFromBotBase: {currentPlayerTypeTurn}");
var botPawnsDictForCurrentPlayer = botRuntimeMovementData[currentPlayerTypeTurn]; // set the data inside this dict
@ -263,6 +263,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
int savedPlayerId = -1;
PlayerPawn pawn = null;
Debug.Log($"SelectPawnFromBotBase: availPlayers.Count(): {availPlayers.Count()}, CanRollDiceAgain: {CanRollDiceAgain}");
if (availPlayers.Count() < 1 && CanRollDiceAgain) // got a 6 roll value
{
pawn = playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Values.FirstOrDefault(pawn => pawn.GetPlayerState() == PlayerState.InHome);
@ -463,6 +465,12 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
playerPawn.SetPlayerState(playerState);
}
private void CheckDiceRollForBot(PlayerPawn playerPawn)
{
if (CanRollDiceAgain)
RollDiceForBot();
}
public void OnPawnSelected(PlayerPawn playerPawn)
{
EnablePlayerSelectionStates(false);
@ -480,6 +488,9 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
{
CanRollDice = true;
UpdatePlayerState(playerPawn, PlayerState.InSafeZone);
if (playerPawn.IsBotPlayer)
CheckDiceRollForBot(playerPawn);
}, playerGameData.startIndex);
return;