Advertisement
Leedwon

Untitled

Jun 16th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.81 KB | None | 0 0
  1. bool Board::CoordsApproval(int x, int y)
  2. {
  3.     bool checks[9];
  4.     for (int i = 0; i < 9; i++)
  5.         checks[i] = false;
  6.     if (privateBoard[x][y] == 0) // x, y
  7.         checks[0] = true;
  8.     if (x + 1 > 9) // x + 1, y poza mapa
  9.         checks[1] = true;
  10.     else if ((x + 1 > 9) == false) // x + 1, y w mapie
  11.     {
  12.         if (privateBoard[x + 1][y] == 0)
  13.             checks[1] = true;
  14.     }
  15.     if (x + 1 > 9 || y + 1 > 9) // x+1, y+1 poza mapa
  16.         checks[2] = true;
  17.     else if ((x + 1 > 9 || y + 1 > 9) == false) // x+1, y+1 w mapie
  18.     {
  19.         if(privateBoard[x + 1][y + 1] == 0)
  20.             checks[2] = true;
  21.     }
  22.     if (y + 1 > 9) // x, y+1 poza mapa 
  23.         checks[3] = true;
  24.     else if ((y + 1 > 9) == false) // x, y+1 w mapie
  25.     {
  26.         if (privateBoard[x][y + 1] == 0)
  27.             checks[3] = true;
  28.     }
  29.     if (x - 1 < 0 || y + 1 > 9) // x-1, y+1 poza mapa
  30.         checks[4] = true;
  31.     else if ((x - 1 < 0 || y + 1 > 9) == false) // x-1, y+1 w mapie
  32.     {
  33.         if (privateBoard[x - 1][y + 1] == 0)
  34.             checks[4] = true;
  35.     }
  36.     if (x - 1 < 0) // x-1, y poza mapa
  37.         checks[5] = true;
  38.     else if ((x - 1 < 0) == false)
  39.     {
  40.         if (privateBoard[x - 1][y] == 0)
  41.             checks[5] = true;
  42.     }
  43.     if (x - 1 < 0 || y - 1 < 0) // x-1, y-1 poza mapa
  44.         checks[6] = true;
  45.     else if ((x - 1 < 0 || y - 1 < 0) == false)
  46.     {
  47.         if (privateBoard[x - 1][y - 1] == 0)
  48.             checks[6] = true;
  49.     }
  50.     if (y - 1 < 0) // x, y-1 poza mapa
  51.         checks[7] = true;
  52.     else if ((y - 1 < 0) == false)
  53.     {
  54.         if (privateBoard[x][y - 1] == 0)
  55.             checks[7] = true;
  56.     }
  57.     if ( x + 1 > 9 || y - 1 < 0) // x+1, y-1 poza mapa
  58.         checks[8] = true;
  59.     else if ((x + 1 > 9 || y - 1 < 0) == false)
  60.     {
  61.         if (privateBoard[x + 1][y - 1] == 0)
  62.             checks[8] = true;
  63.     }
  64.    
  65.     int checkCount = 0;
  66.     for (int i = 0; i < 9; i++) // sprawdzenie wszystkich "check markow"
  67.     {
  68.         if (checks[i] == true)
  69.             checkCount++;
  70.     }
  71.     if (checkCount == 9)
  72.         return true;
  73.     else
  74.         return false;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement