public static bool IsPlayerInputValid(string move) { var isMoveStringLengthValid = IsMoveStringLengthValid(move); if (!isMoveStringLengthValid) { SysLogger.DisplayMessageToTheConsole("InvalidCoordinates"); return(false); } var isInputDelimiterValid = IsInputDelimiterValid(move); var isInputDigitsValid = false; if (isInputDelimiterValid) { isInputDigitsValid = IsInputDigitsValid(move); } var isInputValid = isInputDelimiterValid && isInputDigitsValid; if (!isInputValid) { SysLogger.DisplayMessageToTheConsole("InvalidCoordinates"); } return(isInputValid); }
public static bool IsPlayerGivingUp(string moveInput) { if (moveInput == "q" || moveInput == "'q'") { SysLogger.DisplayMessageToTheConsole("PlayerLostGame"); return(true); } return(false); }
public static bool IsCellFree(string moveInput) { var row = int.Parse(moveInput.Split(Move.GetValidDelimiter())[0]); var column = int.Parse(moveInput.Split(Move.GetValidDelimiter())[1]); var isCellFree = GameField[row - 1, column - 1] == GetEmptyCellChar(); if (!isCellFree) { SysLogger.DisplayMessageToTheConsole("CellOccupied"); } return(isCellFree); }
public static bool IsThereWinner() { var currentPlayerSymbol = Player.GetCurrentPlayerSymbol(); var isThereWinner = FieldValidator.IsThereWinningColumn(currentPlayerSymbol) || FieldValidator.IsThereWinningRow(currentPlayerSymbol) || FieldValidator.IsThereWinningTopLeftBottomRightDiagonal(currentPlayerSymbol) || FieldValidator.IsThereWinningBottomLeftTopRightDiagonal(currentPlayerSymbol); if (isThereWinner) { DrawField(); SysLogger.DisplayMessageToTheConsole("GameOver"); } return(isThereWinner); }
public static bool IsMoreMovesPossible() { for (var row = 0; row < Size; row++) { for (var column = 0; column < Size; column++) { if (GameField[row, column] == GetEmptyCellChar()) { return(true); } } } SysLogger.DisplayMessageToTheConsole("NoMoreTurns"); DrawField(); return(false); }
public static Field CreateField(int inputSize = 0) { var size = inputSize; if (size == 0) { SysLogger.DisplayMessageToTheConsole("EnterFieldSize"); var userSizeInput = Console.ReadLine(); if (!FieldValidator.IsFieldSizeValid(userSizeInput)) { return(null); } size = int.Parse(userSizeInput); } return(new Field(size)); }
public static string PromptForNextMove() { SysLogger.DisplayMessageToTheConsole("EnterNextMove"); return(Console.ReadLine()); }
private Field(int value) { Size = value; PopulateField(); SysLogger.DisplayMessageToTheConsole("GameStart"); }