private static Vector2 executeSpecificPcMove(GameBoard io_GameBoard, int i_MoveNumber, ref Vector2 io_StartLocation) { Vector2 currLocation = new Vector2(0, 0), nextLocation = new Vector2(0, 0); Vector2 finalNextLocation = new Vector2(-1, -1); int moveCounter = 0; string move = string.Empty; for (int i = 0; i < io_GameBoard.BoardHeight; i++) { currLocation.GetRow = i; for (int j = 0; j < io_GameBoard.BoardHeight; j++) { currLocation.GetColumn = j; if (io_GameBoard[currLocation] != null && io_GameBoard[currLocation].GetGroup == GameLogic.s_currentPlayerGroup) { if (countEmptyLocationesAroundCurrentLocation(i_MoveNumber, out finalNextLocation, ref moveCounter, currLocation, io_GameBoard)) { Piece currentPiece = io_GameBoard[currLocation]; if (currentPiece.Move(finalNextLocation, io_GameBoard)) { io_StartLocation = currLocation; i = io_GameBoard.BoardHeight; break; } } } } } return(finalNextLocation); }
public static bool CheckMove(Piece i_CurrentPiece, Vector.Vector2 i_Destinition, GameBoard io_GameBoard, ref bool io_HasAnotherEatMove, ref bool o_PrintMustEatError, bool i_IsPcMove, ref Vector2 o_PcMoveLocation) { bool result = false, hasMoved = false, didEat = false, isEatMove, isGenericEatMoveAvailable = false; Vector2 pcStartMoveLocation = new Vector2(-1, -1); o_PrintMustEatError = false; if (!i_IsPcMove) { if (i_CurrentPiece != null) { if (CheckBordersOfMove(i_CurrentPiece.GetLocation, i_Destinition, io_GameBoard.BoardHeight) && i_CurrentPiece.GetGroup == s_currentPlayerGroup) { isEatMove = didEat = i_CurrentPiece.TryEat(false, i_Destinition, io_GameBoard); if (!isEatMove) { isGenericEatMoveAvailable = isEatMoveAvailable(io_GameBoard, (Piece.eSoldierTypes)i_CurrentPiece.GetPieceType); if (isGenericEatMoveAvailable) { o_PrintMustEatError = true; result = false; } } if (!isGenericEatMoveAvailable) { if (didEat) { io_HasAnotherEatMove = isSpecificEatMoveAvailable(io_GameBoard, io_GameBoard[i_Destinition]); if (!io_HasAnotherEatMove) { result = true; } } if ((!io_HasAnotherEatMove || isEatMove) && !didEat) { hasMoved = i_CurrentPiece.Move(i_Destinition, io_GameBoard); result = hasMoved || didEat; } else if (io_HasAnotherEatMove && !isEatMove) { o_PrintMustEatError = true; } if (io_HasAnotherEatMove) { result = !true; } } } } } else { o_PcMoveLocation = MakePcRandomMove(io_GameBoard, ref hasMoved, ref io_HasAnotherEatMove, out pcStartMoveLocation); if (!hasMoved || io_HasAnotherEatMove) { result = false; } else { result = true; } } return(result); }