Refactored changes.

This commit is contained in:
Ashby Issac 2026-01-29 16:17:19 +05:30
parent d247307e51
commit aaaf88c72a

View File

@ -290,19 +290,20 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
} }
// TODO :: Double check // TODO :: Double check
// foreach (var key in botPawnsDictForCurrentPlayer.Keys) foreach (var key in botPawnsDictForCurrentPlayer.Keys)
{
Debug.Log($"b :: botPawnsDictForCurrentPlayer[key]: {botPawnsDictForCurrentPlayer[key]}");
// botPawnsDictForCurrentPlayer[key] = BotMove.NoMoves; // botPawnsDictForCurrentPlayer[key] = BotMove.NoMoves;
Debug.Log($"a :: botPawnsDictForCurrentPlayer[key]: {botPawnsDictForCurrentPlayer[key]}");
}
Debug.Log($"Before Iterating");
foreach (var playerPawn in availPlayers) foreach (var playerPawn in availPlayers)
{ {
Debug.Log($"Iterating");
var possibleLandingIndex = playerPawn.CurrentTileIndex + diceRolledValue; var possibleLandingIndex = playerPawn.CurrentTileIndex + diceRolledValue;
if (playerPawn.GetPlayerState() == PlayerState.HasFinished)
{
botPawnsDictForCurrentPlayer.Remove(playerPawn.PlayerId); // TODO :: Double check logic
continue;
}
int lastIndex = tilesManager.GetGeneralTilesLength() - 1; int lastIndex = tilesManager.GetGeneralTilesLength() - 1;
int index = possibleLandingIndex > lastIndex ? possibleLandingIndex - lastIndex - 1 : possibleLandingIndex; int index = possibleLandingIndex > lastIndex ? possibleLandingIndex - lastIndex - 1 : possibleLandingIndex;
Tile possibleTileData = tilesManager.RetrieveTileBasedOnIndex(index); Tile possibleTileData = tilesManager.RetrieveTileBasedOnIndex(index);
@ -313,6 +314,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath || possibleLandingIndex > playerGameDatasDict[currentPlayerTypeTurn].endIndex) if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath || possibleLandingIndex > playerGameDatasDict[currentPlayerTypeTurn].endIndex)
{ {
Debug.Log($"AI playerPawn :: {playerPawn.name} :: {playerPawn.PlayerId} :: inFinishingPath :: canSelectPlayer: {playerPawn.CanSelectPlayer}");
if (playerPawn.CanSelectPlayer) if (playerPawn.CanSelectPlayer)
{ {
botPawnsDictForCurrentPlayer[playerPawn.PlayerId] = BotMove.FinishingPathMove; botPawnsDictForCurrentPlayer[playerPawn.PlayerId] = BotMove.FinishingPathMove;
@ -324,12 +326,14 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
botPawnsDictForCurrentPlayer[playerPawn.PlayerId] = BotMove.NoMoves; botPawnsDictForCurrentPlayer[playerPawn.PlayerId] = BotMove.NoMoves;
} }
} }
else if (possibleTileData.IsSafeZone || playerPawn.GetPlayerState() == PlayerState.InHome) else if (possibleTileData.IsSafeZone)
{ {
Debug.Log($"AI playerPawn :: {playerPawn.name} :: {playerPawn.PlayerId} :: safeMove");
botPawnsDictForCurrentPlayer[playerPawn.PlayerId] = BotMove.SafeMove; botPawnsDictForCurrentPlayer[playerPawn.PlayerId] = BotMove.SafeMove;
} }
else if (possibleTileData.PlayerPawn != null) else if (possibleTileData.PlayerPawn != null)
{ {
Debug.Log($"AI playerPawn :: {playerPawn.name} :: {playerPawn.PlayerId} :: attackMove");
botPawnsDictForCurrentPlayer[playerPawn.PlayerId] = BotMove.AttackMove; botPawnsDictForCurrentPlayer[playerPawn.PlayerId] = BotMove.AttackMove;
} }
else else
@ -456,7 +460,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
for (int i = 0; i < availPlayers.Count; i++) for (int i = 0; i < availPlayers.Count; i++)
{ {
Debug.Log($"## playerPawn.GetPlayerState(): {availPlayers[i].GetPlayerState()}"); Debug.Log($"## playerPawn.GetPlayerState(): {availPlayers[i].GetPlayerState()}");
if (availPlayers[i].GetPlayerState() == PlayerState.HasFinished || availPlayers[i].GetPlayerState() == PlayerState.InHome) continue;
if (availPlayers[i].GetPlayerState() == PlayerState.InFinishingPath) if (availPlayers[i].GetPlayerState() == PlayerState.InFinishingPath)
{ {