From b58938ff7418413ce604adfb005d1d3bb37b6d67 Mon Sep 17 00:00:00 2001 From: jason riggs Date: Thu, 14 Mar 2019 17:50:25 +0000 Subject: [PATCH] change --- Error.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/Error.cpp b/Error.cpp index e69de29..1432052 100644 --- a/Error.cpp +++ b/Error.cpp @@ -0,0 +1,63 @@ +#include +#include +using namespace std; + +#include "Error.h" + +bool Error::isValidAdjacent(int row, int col, char board[][8], char oppTurn) { + if (board[row + 1][col] == oppTurn) { + return true; + } + else if (board[row - 1][col] == oppTurn) { + return true; + } + else if (board[row][col + 1] == oppTurn) { + return true; + } + else if (board[row][col - 1] == oppTurn) { + return true; + } + else if (board[row - 1][col - 1] == oppTurn) { + return true; + } + else if (board[row - 1][col + 1] == oppTurn) { + return true; + } + else if (board[row + 1][col - 1] == oppTurn) { + return true; + } + else if (board[row + 1][col + 1] == oppTurn) { + return true; + } + return false; +} + +bool isValidFlip(int row, int col, char board[][8], char playerTurn) { + for (int i = 2; i < 8; i++) { + if (board[row][col + i] == playerTurn) { + return true; + } + else if (board[row][col - i] == playerTurn) { + return true; + } + else if (board[row + i][col] == playerTurn) { + return true; + } + else if (board[row - i][col] == playerTurn) { + return true; + } + else if (board[row + i][col + i] == playerTurn) { + return true; + } + else if (board[row + i][col - i] == playerTurn) { + return true; + } + else if (board[row - i][col + i] == playerTurn) { + return true; + } + else if (board[row - i][col - i] == playerTurn) { + return true; + } + } + return false; +} \ No newline at end of file -- GitLab