Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Board::CoordsApproval(int x, int y)
- {
- bool checks[9];
- for (int i = 0; i < 9; i++)
- checks[i] = false;
- if (privateBoard[x][y] == 0) // x, y
- checks[0] = true;
- if (x + 1 > 9) // x + 1, y poza mapa
- checks[1] = true;
- else if ((x + 1 > 9) == false) // x + 1, y w mapie
- {
- if (privateBoard[x + 1][y] == 0)
- checks[1] = true;
- }
- if (x + 1 > 9 || y + 1 > 9) // x+1, y+1 poza mapa
- checks[2] = true;
- else if ((x + 1 > 9 || y + 1 > 9) == false) // x+1, y+1 w mapie
- {
- if(privateBoard[x + 1][y + 1] == 0)
- checks[2] = true;
- }
- if (y + 1 > 9) // x, y+1 poza mapa
- checks[3] = true;
- else if ((y + 1 > 9) == false) // x, y+1 w mapie
- {
- if (privateBoard[x][y + 1] == 0)
- checks[3] = true;
- }
- if (x - 1 < 0 || y + 1 > 9) // x-1, y+1 poza mapa
- checks[4] = true;
- else if ((x - 1 < 0 || y + 1 > 9) == false) // x-1, y+1 w mapie
- {
- if (privateBoard[x - 1][y + 1] == 0)
- checks[4] = true;
- }
- if (x - 1 < 0) // x-1, y poza mapa
- checks[5] = true;
- else if ((x - 1 < 0) == false)
- {
- if (privateBoard[x - 1][y] == 0)
- checks[5] = true;
- }
- if (x - 1 < 0 || y - 1 < 0) // x-1, y-1 poza mapa
- checks[6] = true;
- else if ((x - 1 < 0 || y - 1 < 0) == false)
- {
- if (privateBoard[x - 1][y - 1] == 0)
- checks[6] = true;
- }
- if (y - 1 < 0) // x, y-1 poza mapa
- checks[7] = true;
- else if ((y - 1 < 0) == false)
- {
- if (privateBoard[x][y - 1] == 0)
- checks[7] = true;
- }
- if ( x + 1 > 9 || y - 1 < 0) // x+1, y-1 poza mapa
- checks[8] = true;
- else if ((x + 1 > 9 || y - 1 < 0) == false)
- {
- if (privateBoard[x + 1][y - 1] == 0)
- checks[8] = true;
- }
- int checkCount = 0;
- for (int i = 0; i < 9; i++) // sprawdzenie wszystkich "check markow"
- {
- if (checks[i] == true)
- checkCount++;
- }
- if (checkCount == 9)
- return true;
- else
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement