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