From 031b3201c62c57ec218cf77e81aa59cf982486b1 Mon Sep 17 00:00:00 2001 From: Ashby Issac Date: Wed, 28 Jan 2026 17:34:06 +0530 Subject: [PATCH] Fixes for AI logic. --- Assets/Scripts/Gameplay/GameplayManager.cs | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Assets/Scripts/Gameplay/GameplayManager.cs b/Assets/Scripts/Gameplay/GameplayManager.cs index fc23d20..de2c435 100644 --- a/Assets/Scripts/Gameplay/GameplayManager.cs +++ b/Assets/Scripts/Gameplay/GameplayManager.cs @@ -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;