// Metoda pro ohodnocení možného tahu public void EvaluateMove(int row, int col, int newRow, int newCol, GameBoard board, out int moveResult) { if (board.Position(newRow, newCol) == (int)GameConstants.States.empty) { /* * Console.WriteLine("Moved"); * board[newRow, newCol] = board[row, col]; * Empty(row, col); */ board.Move(row, col, newRow, newCol); moveResult = (int)GameConstants.MoveResult.Moved; } else if (board.Occupied(newRow, newCol) && board.Enemy(row, col, newRow, newCol)) { /* * Console.WriteLine("Freezed"); * Freeze(newRow, newCol); * Empty(row, col); */ board.Freeze(row, col, newRow, newCol); moveResult = (int)GameConstants.MoveResult.Frozen; } else { moveResult = (int)GameConstants.MoveResult.Fail; } }
// Metoda pro rozhodnutí zda-li je tah v souladu s pravidly public bool ValidMove(int row, int col, int newRow, int newCol, GameBoard board) { if (ValidPosition(row, col) && ValidPosition(newRow, newCol)) { //Console.WriteLine("Valid position, Valid new position"); if (ValidDistance(row, col, newRow, newCol)) { if (board.Occupied(row, col) && !board.Frozen(row, col) && !board.Frozen(newRow, newCol)) { if (board.IsKing(row, col) && board.Occupied(newRow, newCol)) { return(false); } else if (board.Occupied(newRow, newCol) && !board.Enemy(row, col, newRow, newCol)) { return(false); } else { return(true); } } else { return(false); //Console.WriteLine("Empty or frozen field."); } } else { return(false); } } else { return(false); //Console.WriteLine("Not valid position."); } }