public void Logic(string[,] gameBg, PlayerOne playerOne, AiPlayer aiPlayer, WatchReplay watchReplay) { //checks if there any checkers left on the board IsItWin(gameBg, playerOne, aiPlayer); //adds first move to replay watchReplay.AddToQueue(gameBg); //checks if its players one turn if (playerOne.IsItMyTurn == true) { //draws the gameboard game.Draw(gameBg, playerOne, aiPlayer); //sets pickIsValid and MoveIsValid valid.PickIsValid = false; valid.MoveIsValid = false; //checks if if a checkertaken is true and anothermove is false or Movecomplete is true and anotherMove is false... checks if the players turn has ended then passes to the next player if (detection.CheckerTaken == true && detection.AnotherMove == false || detection.MoveComplete == true && detection.AnotherMove == false) { detection.CheckerTaken = false; playerOne.YourTurn(); aiPlayer.MyTurn(); game.Draw(gameBg, playerOne, aiPlayer); } else { Console.Clear(); game.Draw(gameBg, playerOne, aiPlayer); //checks if the player has anyforce moves to make move.ForceJumpPlayerOne(gameBg); //gets players move input Console.WriteLine("\n\n{0} Enter the Row of the Checker you want to Move", playerOne.PlayerName.ToUpper()); pickRow = Console.ReadKey().KeyChar; Console.WriteLine("\nEnter the Column of the Checker you want to Move"); pickCol = Console.ReadKey().KeyChar; //checks if the player input is valid valid.IsItValidFirstMove(gameBg, pickRow, pickCol, playerOne, aiPlayer); } //checks if player pick row and column is valid if (playerOne.IsItMyTurn == true && valid.PickIsValid == true) { detection.MoveComplete = false; //checks if the force move list has any elements if (move.MustPickRowAndCol.Count > 0) { int convertedPickCol = Convert.ToInt16(pickCol.ToString()); //checks if the player pick input is contained in the list if (move.MustPickRowAndCol.Contains(pickRow.ToString() + convertedPickCol.ToString()) == true) { Console.WriteLine("\nEnter the Row you want to move to", playerOne.PlayerName); moveRow = Console.ReadKey().KeyChar; Console.WriteLine("\nEnter the Column you want to move to", playerOne.PlayerName); moveCol = Console.ReadKey().KeyChar; //checks if the player input is valid valid.IsItValidSecondMove(moveRow, moveCol, valid.PickIsValid); } else { Console.WriteLine("\nyou must must pick one of the moves in the list above"); Console.ReadKey(); } } //checks if the list contains any values else { Console.WriteLine("\nEnter the Row you want to move to", playerOne.PlayerName); moveRow = Console.ReadKey().KeyChar; Console.WriteLine("\nEnter the Column you want to move to", playerOne.PlayerName); moveCol = Console.ReadKey().KeyChar; //checks if the player input is valid valid.IsItValidSecondMove(moveRow, moveCol, valid.PickIsValid); } } //checks if playerOne and moveIsValid is true if (playerOne.IsItMyTurn == true && valid.MoveIsValid == true) { //checks if the list contains any values if (move.MustMoveRowAndCol.Count > 0) { int convertedMoveCol = Convert.ToInt16(moveCol.ToString()); //checks if the players move input is contained in the list if (move.MustMoveRowAndCol.Contains(moveRow.ToString() + convertedMoveCol.ToString()) == true) { Console.WriteLine("\n\nyou have elected to move\n {0}{1} To {2}{3}", pickRow.ToString().ToUpper(), pickCol, moveRow.ToString().ToUpper(), moveCol); Console.ReadKey(); //adds gameBg move to stack undo.AddToUndoStack(gameBg); //updates the gameboard detection.CheckAndUpdate(gameBg, valid.ConvRow, valid.ConvCol, valid.NewConvRow, valid.NewConvCol, playerOne, aiPlayer); //adds gameBg move to Queue watchReplay.AddToQueue(gameBg); //adds gameBg to redo stack undo.AddToRedoStack(gameBg); //redraws the gameboard game.Draw(gameBg, playerOne, aiPlayer); //if the players move is complete and asks if they want to undo thier move if (detection.AnotherMove == false && playerOne.PlayerTurnCount != 0) { undo.UndoPlayerMove(gameBg, playerOne, aiPlayer); } } //if the move is not in list shows error message else { Console.WriteLine("you must select one of the moves above"); Console.ReadKey(); detection.MoveComplete = false; } } else { Console.WriteLine("\n\nyou have elected to move\n {0}{1} To {2}{3}", pickRow.ToString().ToUpper(), pickCol, moveRow.ToString().ToUpper(), moveCol); Console.ReadKey(); //adds gameBg move to stack undo.AddToUndoStack(gameBg); //updates the gameboard detection.CheckAndUpdate(gameBg, valid.ConvRow, valid.ConvCol, valid.NewConvRow, valid.NewConvCol, playerOne, aiPlayer); //adds gameBg move to Queue watchReplay.AddToQueue(gameBg); //adds gameBg to redo stack undo.AddToRedoStack(gameBg); //redraws the gameboard game.Draw(gameBg, playerOne, aiPlayer); //adds one to turn count playerOne.GetPlayerTurnCount(); //if the players move is complete and asks if they want to undo thier move if (detection.AnotherMove == false && playerOne.PlayerTurnCount != 0) { undo.UndoPlayerMove(gameBg, playerOne, aiPlayer); } } } else { detection.MoveComplete = false; } } //**************ai player movement***************************************************************************************************************** else if (aiPlayer.IsItMyTurn == true) { if (detection.CheckerTaken == true && detection.AnotherMove == false || detection.MoveComplete == true && detection.AnotherMove == false) { detection.CheckerTaken = false; aiPlayer.YourTurn(); playerOne.MyTurn(); game.Draw(gameBg, playerOne, aiPlayer); } //ai checks if it can move any checkers aiPlayer.AvailableMoves(gameBg, detection); //randomly picks a move from one of it lists aiPlayer.PickMove(); //converts the move to row and col format aiPlayer.CovertMove(); //ai player makes the move aiPlayer.MakeMove(gameBg); //redraws the board game.Draw(gameBg, playerOne, aiPlayer); aiPlayer.GetPlayerTurnCount(); //ends ai players turn aiPlayer.IsItMyTurn = false; //starts playerOnes turn playerOne.IsItMyTurn = true; } }