Advertisement
Momir

ČAH v1.0.2

Jun 8th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 121.04 KB | None | 0 0
  1. #define _WIN32_WINNT 0x0600
  2. #include <vector>
  3. #include <fstream>
  4. #include <conio.h>
  5. #include <fcntl.h>
  6. #include <windows.h>
  7. #define _O_U8TEXT   0x40000
  8. #define SVETLO 0
  9. #define TAMNO 1
  10. #define SIVO 2
  11. #define BELO 0
  12. #define CRNO 1
  13. #define ISKLJUCENO 0
  14. #define UKLJUCENO 1
  15. #define ZELENO 2
  16. #define NEUTRALNO 0
  17. #define IZABRANO 1
  18. #define NAPADNUTO 2
  19. #define TOP L"♜ "
  20. #define KONJ L"♞ "
  21. #define LOVAC L"♝ "
  22. #define KRALJICA L"♛ "
  23. #define KRALJ L"♚ "
  24. #define PIJUN L"♟ "
  25. #define PRAZNO L"  "
  26. #define TACKA L""
  27.  
  28. using namespace std;
  29.  
  30. typedef struct _CONSOLE_SCREEN_BUFFER_INFOEX
  31. {
  32.     ULONG      cbSize;
  33.     COORD      dwSize;
  34.     COORD      dwCursorPosition;
  35.     WORD       wAttributes;
  36.     SMALL_RECT srWindow;
  37.     COORD      dwMaximumWindowSize;
  38.     WORD       wPopupAttributes;
  39.     BOOL       bFullscreenSupported;
  40.     COLORREF   ColorTable[16];
  41. } CONSOLE_SCREEN_BUFFER_INFOEX, *PCONSOLE_SCREEN_BUFFER_INFOEX;
  42.  
  43. typedef struct _CONSOLE_FONT_INFOEX
  44. {
  45.     ULONG cbSize;
  46.     DWORD nFont;
  47.     COORD dwFontSize;
  48.     UINT  FontFamily;
  49.     UINT  FontWeight;
  50.     WCHAR FaceName[LF_FACESIZE];
  51. } CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
  52.  
  53. #ifdef __cplusplus
  54. extern "C" {
  55. #endif
  56. BOOL WINAPI SetCurrentConsoleFontEx(HANDLE hConsoleOutput, BOOL bMaximumWindow, PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx);
  57. #ifdef __cplusplus
  58. }
  59. #endif
  60.  
  61. #ifdef __cplusplus
  62. extern "C" {
  63. #endif
  64. BOOL WINAPI GetConsoleScreenBufferInfoEx(HANDLE hConsoleOutput, PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
  65. #ifdef __cplusplus
  66. }
  67. #endif
  68.  
  69. #ifdef __cplusplus
  70. extern "C" {
  71. #endif
  72. BOOL WINAPI SetConsoleScreenBufferInfoEx(HANDLE hConsoleOutput, PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
  73. #ifdef __cplusplus
  74. }
  75. #endif
  76.  
  77. #ifdef __cplusplus
  78. extern "C" {
  79. #endif
  80. BOOL WINAPI GetCurrentConsoleFontEx(HANDLE hConsoleOutput, BOOL bMaximumWindow, PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx);
  81. #ifdef __cplusplus
  82. }
  83. #endif
  84.  
  85. #ifdef __cplusplus
  86. extern "C" {
  87. #endif
  88. BOOL WINAPI GetConsoleCursorInfo(HANDLE hConsoleOutput, PCONSOLE_CURSOR_INFO lpConsoleCursorInfo);
  89. #ifdef __cplusplus
  90. }
  91. #endif
  92.  
  93.  
  94. void SakriKursor();
  95. void ObrisiEkran();
  96. void gotoxy(int x, int y);
  97. int UcitajKlik(int &x, int &y);
  98. void CentrirajKonzolu();
  99. void CentrirajKonzolu2();
  100.  
  101. short prviput1 = 1;
  102. short prviput2 = 1;
  103. short prviput3 = 1;
  104. short boja = SVETLO;
  105. short rotacija = ISKLJUCENO;
  106. short sacekaj;
  107. short velicina = 29;
  108. long long int brPoteza = 0;
  109. long winlog;
  110. _CONSOLE_SCREEN_BUFFER_INFOEX screenbuffer;
  111. CONSOLE_CURSOR_INFO kursor;
  112.  
  113. typedef struct
  114. {
  115.     short bojaPolja;
  116.     short stanjePolja;
  117.     wchar_t figura[4];
  118.     short bojaFigure;
  119.     short anpasan;
  120. } Polje;
  121.  
  122. typedef struct
  123. {
  124.     Polje polje[8][8];
  125.     Polje levo[8][2];
  126.     Polje desno[8][2];
  127.     short brlevo;
  128.     short brdesno;
  129.     short malarbeli;
  130.     short velikarbeli;
  131.     short malarcrni;
  132.     short velikarcrni;
  133.     short krajigre;
  134.  
  135. } Tabla;
  136.  
  137. void OsveziTablu(Tabla tabla);
  138. void PodesiKonzolu();
  139. void PodesiKonzolu2();
  140. void NapraviTablu(Tabla &tabla);
  141. void OdstampajTablu(Tabla tabla);
  142. void OdstampajKonzolu();
  143. void PozicijaNaTabli(int &x, int &y);
  144. void NoviPotez(Tabla &tabla);
  145. void PozicijaIzabranog(int &xizb, int &yizb, Tabla tabla);
  146. short JelUnutarTable(int x, int y);
  147. void OdstampajLevoDesno(Tabla tabla);
  148. void ObrnutoOdstampajTablu(Tabla tabla);
  149. void ObrnutaPozicijaNaTabli(int &x, int &y);
  150. void ObrisiAnpasan(Tabla &tabla);
  151. void PodesiVelicinu(int i);
  152. BOOL RegDelnodeRecurse (HKEY hKeyRoot, LPTSTR lpSubKey);
  153. BOOL RegDelnode(HKEY hKeyRoot, LPCTSTR lpSubKey);
  154. void ObrisiTerminal();
  155. Tabla StaviFiguruNaXY(Tabla tabla, int x, int y);
  156. short JelSahBeli(Tabla tabla, int xpomeraj, int ypomeraj);
  157. short JelSahCrni(Tabla tabla, int xpomeraj, int ypomeraj);
  158. short PostaviKralja(Tabla &tabla, int x, int y);
  159. short PostaviPijuna(Tabla &tabla, int x, int y);
  160. short PostaviKonja(Tabla &tabla, int x, int y);
  161. short PostaviTopa(Tabla &tabla, int x, int y);
  162. short PostaviLovca(Tabla &tabla, int x, int y);
  163. short PostaviKraljicu(Tabla &tabla, int x, int y);
  164. short JelMozeIgratiBeli(Tabla tabla);
  165. short JelMozeIgratiCrni(Tabla tabla);
  166. short ZameniPijuna();
  167. int FiguraUBroj(wchar_t figura[]);
  168. wchar_t* BrojUFiguru(int broj);
  169. vector<short> NapraviSacuvaj(vector<Tabla> istorija);
  170. void SacuvajIgru(vector<Tabla> istorija);
  171. void OdaberiVelicinu();
  172. void AnimacijaUcitaj();
  173.  
  174. int main()
  175. {
  176.     SetConsoleOutputCP(852);
  177.     Tabla tabla;
  178.     NapraviTablu(tabla);
  179.     vector<Tabla> istorija(0);
  180.     istorija.push_back(tabla);
  181.  
  182.     AnimacijaUcitaj();
  183.  
  184.     PodesiKonzolu();
  185.     CentrirajKonzolu();
  186.     PodesiKonzolu2();
  187.     OdstampajKonzolu();
  188.     OdstampajTablu(tabla);
  189.  
  190.     int x, y, xizb, yizb, cek = 1;
  191.     HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
  192.     _setmode(_fileno(stdout), _O_U8TEXT);
  193.  
  194.     while(1)
  195.     {
  196.         sacekaj = ISKLJUCENO;
  197.         SetConsoleTextAttribute(console, 82);
  198.  
  199.         UcitajKlik(x, y);
  200.         ObrisiTerminal();
  201.         cek = 1;
  202.  
  203.         if(y == 0 && (x == 4 || x == 5))
  204.         {
  205.             NapraviTablu(tabla);
  206.             istorija.clear();
  207.             istorija.push_back(tabla);
  208.             brPoteza = 0;
  209.             NoviPotez(tabla);
  210.             ObrisiTerminal();
  211.  
  212.             OsveziTablu(tabla);
  213.         }
  214.         else if(y == 0 && (x == 0 || x == 1))
  215.         {
  216.             SacuvajIgru(istorija);
  217.         }
  218.         else if(y == 0 && (x == 2 || x == 3))
  219.         {
  220.             char ime[18], zn;
  221.             short pom;
  222.             ObrisiTerminal();
  223.             HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  224.             SetConsoleCursorInfo(hConsole, &kursor);
  225.  
  226.             if(boja == SVETLO)
  227.                 SetConsoleTextAttribute(hConsole, 82);
  228.             else if(boja == TAMNO)
  229.                 SetConsoleTextAttribute(hConsole, 101);
  230.             else if(boja == SIVO)
  231.                 SetConsoleTextAttribute(hConsole, 152);
  232.  
  233.             _setmode(_fileno(stdout), _O_TEXT);
  234.  
  235.             gotoxy(4, 14);
  236.             printf("Ime igre:  ");
  237.  
  238.             for(int i = 0; i < 18; i++)
  239.             {
  240.                 zn = getch();
  241.  
  242.                 if((zn == 13 && i != 0) || i == 14)
  243.                 {
  244.                     Sleep(100);
  245.                     SakriKursor();
  246.                     ime[i] = '\0';
  247.                     break;
  248.                 }
  249.                 else if(zn == 8)
  250.                 {
  251.                     gotoxy(14 + i, 14);
  252.                     putch(' ');
  253.                     gotoxy(14 + i, 14);
  254.                     i -= 2;
  255.                 }
  256.                 else
  257.                 {
  258.                     gotoxy(15 + i, 14);
  259.                     putch(zn);
  260.                     ime[i] = zn;
  261.                 }
  262.             }
  263.  
  264.             ObrisiTerminal();
  265.  
  266.             ifstream ulaz (strcat(ime, ".igra"));
  267.  
  268.             if(ulaz.is_open())
  269.             {
  270.                 ulaz >> brPoteza;
  271.  
  272.                 istorija.clear();
  273.  
  274.                 for(int a = 0; a <= brPoteza; a++)
  275.                 {
  276.                     ulaz >> tabla.brlevo;
  277.                     ulaz >> tabla.brdesno;
  278.                     ulaz >> tabla.krajigre;
  279.                     ulaz >> tabla.malarbeli;
  280.                     ulaz >> tabla.malarcrni;
  281.                     ulaz >> tabla.velikarbeli;
  282.                     ulaz >> tabla.velikarcrni;
  283.  
  284.                     for(int i = 0; i < 16; i++)
  285.                     {
  286.                         ulaz >> pom;
  287.                         wcscpy(tabla.levo[i / 2][i % 2].figura, BrojUFiguru(pom));
  288.                         ulaz >> pom;
  289.                         wcscpy(tabla.desno[i / 2][i % 2].figura, BrojUFiguru(pom));
  290.                     }
  291.  
  292.                     for(int i = 0; i < 8; i++)
  293.                         for(int j = 0; j < 8; j++)
  294.                         {
  295.                             ulaz >> tabla.polje[i][j].anpasan;
  296.                             ulaz >> tabla.polje[i][j].bojaFigure;
  297.                             ulaz >> pom;
  298.                             wcscpy(tabla.polje[i][j].figura, BrojUFiguru(pom));
  299.                             ulaz >> tabla.polje[i][j].stanjePolja;
  300.                         }
  301.  
  302.                     istorija.push_back(tabla);
  303.                 }
  304.  
  305.                 ulaz.close();
  306.             }
  307.             else
  308.             {
  309.                 ObrisiTerminal();
  310.  
  311.                 gotoxy(4, 14);
  312.  
  313.                 if(boja == SVETLO)
  314.                     SetConsoleTextAttribute(hConsole, 82);
  315.                 else if(boja == TAMNO)
  316.                     SetConsoleTextAttribute(hConsole, 101);
  317.                 else if(boja == SIVO)
  318.                     SetConsoleTextAttribute(hConsole, 152);
  319.  
  320.                 _setmode(_fileno(stdout), _O_U8TEXT);
  321.  
  322.                 wprintf(L"Ne postoji igra sa tim imenom");
  323.                 cek = 0;
  324.             }
  325.  
  326.             OsveziTablu(tabla);
  327.         }
  328.         else if(y == 0 && (x == 6 || x == 7))
  329.         {
  330.             boja++;
  331.  
  332.             if(boja == 3)
  333.                 boja = 0;
  334.  
  335.             OdstampajKonzolu();
  336.             NoviPotez(tabla);
  337.  
  338.             OsveziTablu(tabla);
  339.         }
  340.         else if(y == 0 && (x == 8 || x == 9))
  341.         {
  342.             short pom = velicina;
  343.             OdaberiVelicinu();
  344.  
  345.             if(pom != velicina)
  346.             {
  347.                 PodesiVelicinu(velicina);
  348.                 OdstampajKonzolu();
  349.                 OsveziTablu(tabla);
  350.             }
  351.         }
  352.         else if(y == 0 && (x == 10 || x == 11) && brPoteza > 0)
  353.         {
  354.             tabla = istorija[brPoteza - 1];
  355.             istorija.erase(istorija.begin() + brPoteza);
  356.             brPoteza--;
  357.             ObrisiTerminal();
  358.  
  359.             OsveziTablu(tabla);
  360.         }
  361.         else if(y == 0 && (x == 30 || x == 31))
  362.         {
  363.             if(rotacija == UKLJUCENO)
  364.             {
  365.                 rotacija = ISKLJUCENO;
  366.  
  367.                 if(boja == SVETLO)
  368.                     SetConsoleTextAttribute(console, 36);
  369.                 else if(boja == TAMNO)
  370.                     SetConsoleTextAttribute(console, 87);
  371.                 else if(boja == SIVO)
  372.                     SetConsoleTextAttribute(console, 138);
  373.  
  374.                 gotoxy(30, 0);
  375.                 wprintf(L"");
  376.             }
  377.             else
  378.             {
  379.                 rotacija = UKLJUCENO;
  380.  
  381.                 if(boja == SVETLO)
  382.                     SetConsoleTextAttribute(console, 36);
  383.                 else if(boja == TAMNO)
  384.                     SetConsoleTextAttribute(console, 87);
  385.                 else if(boja == SIVO)
  386.                     SetConsoleTextAttribute(console, 138);
  387.  
  388.                 gotoxy(30, 0);
  389.                 wprintf(L"");
  390.             }
  391.  
  392.             NoviPotez(tabla);
  393.  
  394.             OsveziTablu(tabla);
  395.         }
  396.         else if(y == 0 && (x == 32 || x == 33))
  397.         {
  398.             int a, b;
  399.             SetConsoleTextAttribute(console, 255);
  400.  
  401.             for(int i = 0; i < 20; i++)
  402.                 wprintf(L"\t\t\t\t\t\t");
  403.  
  404.             SetConsoleTextAttribute(console, 241);
  405.             gotoxy(0, 1);
  406.             wprintf(L"\t\tŠAH");
  407.             wprintf(L"\n\n\n  Autor:");
  408.             wprintf(L"\n\n  Momir Stanišić,");
  409.             wprintf(L"\n  CMD Game Developer");
  410.             wprintf(L"\n\n\n\n  Verzija: 1.0.2");
  411.  
  412.             UcitajKlik(a, b);
  413.  
  414.             OdstampajKonzolu();
  415.             OdstampajTablu(tabla);
  416.         }
  417.         else if(y == 0 && (x == 35 || x == 34))
  418.         {
  419.             RegDelnode(HKEY_CURRENT_USER, TEXT("Console"));
  420.  
  421.             char str[20];
  422.             istorija.clear();
  423.  
  424.             SetConsoleTextAttribute(console, 34);
  425.  
  426.             for(int i = 0; i < 20; i++)
  427.                 wprintf(L"\t\t\t\t\t\t");
  428.  
  429.             SetConsoleTextAttribute(console, 35);
  430.             gotoxy(13, 6);
  431.             wprintf(L"DOVIĐENJA!");
  432.             Sleep(1000);
  433.  
  434.             for(int i = 0; i < 18; i++)
  435.             {
  436.                 sprintf(str, "MODE 36, %d", 18 - i);
  437.                 system(str);
  438.             }
  439.  
  440.  
  441.  
  442.             HWND consoleWindow = GetConsoleWindow();
  443.             ShowWindow(consoleWindow, SW_HIDE);
  444.  
  445.             return 0;
  446.         }
  447.         else if(y > 2 && y < 11 && x > 9 && x < 26 && tabla.krajigre == 0)
  448.         {
  449.             if(brPoteza % 2 && rotacija == UKLJUCENO && JelMozeIgratiCrni(tabla))
  450.                 ObrnutaPozicijaNaTabli(x, y);
  451.             else
  452.                 PozicijaNaTabli(x, y);
  453.  
  454.             if(tabla.polje[y][x].stanjePolja == NAPADNUTO && wcscmp(tabla.polje[y][x].figura, KRALJ))
  455.             {
  456.                 PozicijaIzabranog(xizb, yizb, tabla);
  457.  
  458.                 if(tabla.polje[yizb][xizb].bojaFigure == BELO && tabla.brlevo < 8)
  459.                 {
  460.                     if(tabla.polje[y + 1][x].anpasan == UKLJUCENO)
  461.                     {
  462.                         wcscpy(tabla.levo[tabla.brlevo / 2][tabla.brlevo % 2].figura, PIJUN);
  463.                         wcscpy(tabla.polje[y + 1][x].figura, PRAZNO);
  464.                     }
  465.                     else
  466.                         wcscpy(tabla.levo[tabla.brlevo / 2][tabla.brlevo % 2].figura, tabla.polje[y][x].figura);
  467.  
  468.                     tabla.brlevo++;
  469.                 }
  470.                 else if(tabla.brdesno < 8)
  471.                 {
  472.                     if(tabla.polje[y - 1][x].anpasan == UKLJUCENO)
  473.                     {
  474.                         wcscpy(tabla.desno[tabla.brdesno / 2][tabla.brdesno % 2].figura, PIJUN);
  475.                         wcscpy(tabla.polje[y - 1][x].figura, PRAZNO);
  476.                     }
  477.                     else
  478.                         wcscpy(tabla.desno[tabla.brdesno / 2][tabla.brdesno % 2].figura, tabla.polje[y][x].figura);
  479.  
  480.                     tabla.brdesno++;
  481.                 }
  482.  
  483.                 if((xizb == 7 && yizb == 7) || (x == 7 && y == 7))
  484.                     tabla.malarbeli = ISKLJUCENO;
  485.                 else if((xizb == 0 && yizb == 7) || (x == 0 && y == 7))
  486.                     tabla.velikarbeli = ISKLJUCENO;
  487.                 else if((xizb == 0 && yizb == 0) || (x == 0 && y == 0))
  488.                     tabla.velikarcrni = ISKLJUCENO;
  489.                 else if((xizb == 7 && yizb == 0) || (x == 7 && y == 0))
  490.                     tabla.malarcrni = ISKLJUCENO;
  491.                 else if(xizb == 4 && yizb == 7)
  492.                 {
  493.                     tabla.malarbeli = ISKLJUCENO;
  494.                     tabla.velikarbeli = ISKLJUCENO;
  495.                 }
  496.                 else if(xizb == 4 && yizb == 0)
  497.                 {
  498.                     tabla.malarcrni = ISKLJUCENO;
  499.                     tabla.velikarcrni = ISKLJUCENO;
  500.                 }
  501.  
  502.                 wcscpy(tabla.polje[y][x].figura, tabla.polje[yizb][xizb].figura);
  503.                 wcscpy(tabla.polje[yizb][xizb].figura, PRAZNO);
  504.                 tabla.polje[y][x].bojaFigure = tabla.polje[yizb][xizb].bojaFigure;
  505.                 NoviPotez(tabla);
  506.                 ObrisiAnpasan(tabla);
  507.  
  508.                 if(!wcscmp(tabla.polje[y][x].figura, PIJUN) && ((tabla.polje[y][x].bojaFigure == BELO && y == 0) || (tabla.polje[y][x].bojaFigure == CRNO && y == 7)))
  509.                 {
  510.                     OdstampajTablu(tabla);
  511.                     short zamena = ZameniPijuna();
  512.  
  513.                     switch(zamena)
  514.                     {
  515.                     case 0:
  516.                         wcscpy(tabla.polje[y][x].figura, KRALJICA);
  517.                         break;
  518.  
  519.                     case 1:
  520.                         wcscpy(tabla.polje[y][x].figura, TOP);
  521.                         break;
  522.  
  523.                     case 2:
  524.                         wcscpy(tabla.polje[y][x].figura, LOVAC);
  525.                         break;
  526.  
  527.                     case 3:
  528.                         wcscpy(tabla.polje[y][x].figura, KONJ);
  529.                     }
  530.                 }
  531.  
  532.                 if(JelSahBeli(tabla, 0, 0))
  533.                     for(int i = 0; i < 64; i++)
  534.                         if(!wcscmp(tabla.polje[i / 8][i % 8].figura, KRALJ) && tabla.polje[i / 8][i % 8].bojaFigure == BELO)
  535.                             tabla.polje[i / 8][i % 8].stanjePolja = NAPADNUTO;
  536.  
  537.                 if(JelSahCrni(tabla, 0, 0))
  538.                     for(int i = 0; i < 64; i++)
  539.                         if(!wcscmp(tabla.polje[i / 8][i % 8].figura, KRALJ) && tabla.polje[i / 8][i % 8].bojaFigure == CRNO)
  540.                             tabla.polje[i / 8][i % 8].stanjePolja = NAPADNUTO;
  541.  
  542.                 Sleep(260);
  543.  
  544.                 OsveziTablu(tabla);
  545.  
  546.                 NoviPotez(tabla);
  547.  
  548.                 if(JelSahBeli(tabla, 0, 0))
  549.                     for(int i = 0; i < 64; i++)
  550.                         if(!wcscmp(tabla.polje[i / 8][i % 8].figura, KRALJ) && tabla.polje[i / 8][i % 8].bojaFigure == BELO)
  551.                         {
  552.                             tabla.polje[i / 8][i % 8].stanjePolja = NAPADNUTO;
  553.                             OsveziTablu(tabla);
  554.                             break;
  555.                         }
  556.  
  557.                 if(JelSahCrni(tabla, 0, 0))
  558.                     for(int i = 0; i < 64; i++)
  559.                         if(!wcscmp(tabla.polje[i / 8][i % 8].figura, KRALJ) && tabla.polje[i / 8][i % 8].bojaFigure == CRNO)
  560.                         {
  561.                             tabla.polje[i / 8][i % 8].stanjePolja = NAPADNUTO;
  562.                             OsveziTablu(tabla);
  563.                             break;
  564.                         }
  565.  
  566.                 istorija.push_back(tabla);
  567.                 brPoteza++;
  568.                 sacekaj = UKLJUCENO;
  569.  
  570.             }
  571.             else if(!wcscmp(tabla.polje[y][x].figura, KRALJ))
  572.             {
  573.                 if((tabla.polje[y][x].bojaFigure == BELO && brPoteza % 2 == 0) || (tabla.polje[y][x].bojaFigure == CRNO && brPoteza % 2 == 1))
  574.                 {
  575.                     NoviPotez(tabla);
  576.  
  577.                     PostaviKralja(tabla, x, y);
  578.                 }
  579.                 else
  580.                     NoviPotez(tabla);
  581.             }
  582.             else if(!wcscmp(tabla.polje[y][x].figura, PIJUN))
  583.             {
  584.                 if((tabla.polje[y][x].bojaFigure == BELO && brPoteza % 2 == 0) || (tabla.polje[y][x].bojaFigure == CRNO && brPoteza % 2 == 1))
  585.                 {
  586.                     NoviPotez(tabla);
  587.                     PostaviPijuna(tabla, x, y);
  588.                 }
  589.                 else
  590.                     NoviPotez(tabla);
  591.             }
  592.             else if(!wcscmp(tabla.polje[y][x].figura, KONJ))
  593.             {
  594.                 if((tabla.polje[y][x].bojaFigure == BELO && brPoteza % 2 == 0) || (tabla.polje[y][x].bojaFigure == CRNO && brPoteza % 2 == 1))
  595.                 {
  596.                     NoviPotez(tabla);
  597.                     PostaviKonja(tabla, x, y);
  598.                 }
  599.                 else
  600.                     NoviPotez(tabla);
  601.             }
  602.             else if(!wcscmp(tabla.polje[y][x].figura, TOP))
  603.             {
  604.                 if((tabla.polje[y][x].bojaFigure == BELO && brPoteza % 2 == 0) || (tabla.polje[y][x].bojaFigure == CRNO && brPoteza % 2 == 1))
  605.                 {
  606.                     NoviPotez(tabla);
  607.                     PostaviTopa(tabla, x, y);
  608.                 }
  609.                 else
  610.                     NoviPotez(tabla);
  611.             }
  612.             else if(!wcscmp(tabla.polje[y][x].figura, LOVAC))
  613.             {
  614.                 if((tabla.polje[y][x].bojaFigure == BELO && brPoteza % 2 == 0) || (tabla.polje[y][x].bojaFigure == CRNO && brPoteza % 2 == 1))
  615.                 {
  616.                     NoviPotez(tabla);
  617.                     PostaviLovca(tabla, x, y);
  618.                 }
  619.                 else
  620.                     NoviPotez(tabla);
  621.             }
  622.             else if(!wcscmp(tabla.polje[y][x].figura, KRALJICA))
  623.             {
  624.                 if((tabla.polje[y][x].bojaFigure == BELO && brPoteza % 2 == 0) || (tabla.polje[y][x].bojaFigure == CRNO && brPoteza % 2 == 1))
  625.                 {
  626.                     NoviPotez(tabla);
  627.                     PostaviKraljicu(tabla, x, y);
  628.                 }
  629.                 else
  630.                     NoviPotez(tabla);
  631.             }
  632.             else if(!wcscmp(tabla.polje[y][x].figura, PRAZNO))
  633.                 NoviPotez(tabla);
  634.             else if(!wcscmp(tabla.polje[y][x].figura, TACKA))
  635.             {
  636.                 PozicijaIzabranog(xizb, yizb, tabla);
  637.                 wcscpy(tabla.polje[y][x].figura, tabla.polje[yizb][xizb].figura);
  638.                 wcscpy(tabla.polje[yizb][xizb].figura, PRAZNO);
  639.                 tabla.polje[y][x].bojaFigure = tabla.polje[yizb][xizb].bojaFigure;
  640.  
  641.                 ObrisiAnpasan(tabla);
  642.  
  643.                 if(tabla.malarbeli == UKLJUCENO && xizb == 4 && yizb == 7 && x == 6 && y == 7)
  644.                 {
  645.                     wcscpy(tabla.polje[7][7].figura, PRAZNO);
  646.                     wcscpy(tabla.polje[7][5].figura, TOP);
  647.                     tabla.polje[7][5].bojaFigure = BELO;
  648.                 }
  649.  
  650.                 if(tabla.velikarbeli == UKLJUCENO && xizb == 4 && yizb == 7 && x == 1 && y == 7)
  651.                 {
  652.                     wcscpy(tabla.polje[7][0].figura, PRAZNO);
  653.                     wcscpy(tabla.polje[7][2].figura, TOP);
  654.                     tabla.polje[7][2].bojaFigure = BELO;
  655.                 }
  656.  
  657.                 if(tabla.malarcrni == UKLJUCENO && xizb == 4 && yizb == 0 && x == 6 && y == 0)
  658.                 {
  659.                     wcscpy(tabla.polje[0][7].figura, PRAZNO);
  660.                     wcscpy(tabla.polje[0][5].figura, TOP);
  661.                     tabla.polje[0][5].bojaFigure = CRNO;
  662.                 }
  663.  
  664.                 if(tabla.velikarcrni == UKLJUCENO && xizb == 4 && yizb == 0 && x == 1 && y == 0)
  665.                 {
  666.                     wcscpy(tabla.polje[0][0].figura, PRAZNO);
  667.                     wcscpy(tabla.polje[0][2].figura, TOP);
  668.                     tabla.polje[0][2].bojaFigure = CRNO;
  669.                 }
  670.  
  671.                 if(!wcscmp(tabla.polje[y][x].figura, PIJUN) && ((tabla.polje[y][x].bojaFigure == BELO && y == yizb - 2) || (tabla.polje[y][x].bojaFigure == CRNO && y == yizb + 2)))
  672.                     tabla.polje[y][x].anpasan = UKLJUCENO;
  673.  
  674.                 if(xizb == 7 && yizb == 7)
  675.                     tabla.malarbeli = ISKLJUCENO;
  676.                 else if(xizb == 0 && yizb == 7)
  677.                     tabla.velikarbeli = ISKLJUCENO;
  678.                 else if(xizb == 0 && yizb == 0)
  679.                     tabla.velikarcrni = ISKLJUCENO;
  680.                 else if(xizb == 7 && yizb == 0)
  681.                     tabla.malarcrni = ISKLJUCENO;
  682.                 else if(xizb == 4 && yizb == 7)
  683.                 {
  684.                     tabla.malarbeli = ISKLJUCENO;
  685.                     tabla.velikarbeli = ISKLJUCENO;
  686.                 }
  687.                 else if(xizb == 4 && yizb == 0)
  688.                 {
  689.                     tabla.malarcrni = ISKLJUCENO;
  690.                     tabla.velikarcrni = ISKLJUCENO;
  691.                 }
  692.  
  693.                 NoviPotez(tabla);
  694.  
  695.                 if(JelSahBeli(tabla, 0, 0))
  696.                     for(int i = 0; i < 64; i++)
  697.                         if(!wcscmp(tabla.polje[i / 8][i % 8].figura, KRALJ) && tabla.polje[i / 8][i % 8].bojaFigure == BELO)
  698.                         {
  699.                             tabla.polje[i / 8][i % 8].stanjePolja = NAPADNUTO;
  700.                             OsveziTablu(tabla);
  701.                             break;
  702.                         }
  703.  
  704.                 if(JelSahCrni(tabla, 0, 0))
  705.                     for(int i = 0; i < 64; i++)
  706.                         if(!wcscmp(tabla.polje[i / 8][i % 8].figura, KRALJ) && tabla.polje[i / 8][i % 8].bojaFigure == CRNO)
  707.                         {
  708.                             tabla.polje[i / 8][i % 8].stanjePolja = NAPADNUTO;
  709.                             OsveziTablu(tabla);
  710.                             break;
  711.                         }
  712.  
  713.                 istorija.push_back(tabla);
  714.                 brPoteza++;
  715.                 sacekaj = UKLJUCENO;
  716.             }
  717.  
  718.             OsveziTablu(tabla);
  719.         }
  720.  
  721.         if(brPoteza % 2 == 1 && !JelMozeIgratiCrni(tabla) && JelSahCrni(tabla, 0, 0) && cek)
  722.         {
  723.             ObrisiTerminal();
  724.  
  725.             if(boja == SVETLO)
  726.                 SetConsoleTextAttribute(console, 82);
  727.             else if(boja == TAMNO)
  728.                 SetConsoleTextAttribute(console, 101);
  729.             else if(boja == SIVO)
  730.                 SetConsoleTextAttribute(console, 152);
  731.  
  732.             tabla.krajigre = 1;
  733.             gotoxy(10, 14);
  734.             wprintf(L"Beli je pobednik");
  735.         }
  736.         else if (brPoteza % 2 == 0 && !JelMozeIgratiBeli(tabla) && JelSahBeli(tabla, 0, 0) && cek)
  737.         {
  738.             ObrisiTerminal();
  739.  
  740.             if(boja == SVETLO)
  741.                 SetConsoleTextAttribute(console, 82);
  742.             else if(boja == TAMNO)
  743.                 SetConsoleTextAttribute(console, 101);
  744.             else if(boja == SIVO)
  745.                 SetConsoleTextAttribute(console, 152);
  746.  
  747.             tabla.krajigre = 1;
  748.             gotoxy(10, 14);
  749.             wprintf(L"Crni je pobednik");
  750.         }
  751.         else if(brPoteza % 2 == 1 && !JelMozeIgratiCrni(tabla) && cek)
  752.         {
  753.             ObrisiTerminal();
  754.  
  755.             if(boja == SVETLO)
  756.                 SetConsoleTextAttribute(console, 82);
  757.             else if(boja == TAMNO)
  758.                 SetConsoleTextAttribute(console, 101);
  759.             else if(boja == SIVO)
  760.                 SetConsoleTextAttribute(console, 152);
  761.  
  762.             tabla.krajigre = 1;
  763.             gotoxy(8, 14);
  764.             wprintf(L"Beli je napravio pat");
  765.         }
  766.         else if (brPoteza % 2 == 0 && !JelMozeIgratiBeli(tabla) && cek)
  767.         {
  768.             ObrisiTerminal();
  769.  
  770.             if(boja == SVETLO)
  771.                 SetConsoleTextAttribute(console, 82);
  772.             else if(boja == TAMNO)
  773.                 SetConsoleTextAttribute(console, 101);
  774.             else if(boja == SIVO)
  775.                 SetConsoleTextAttribute(console, 152);
  776.  
  777.             tabla.krajigre = 1;
  778.             gotoxy(8, 14);
  779.             wprintf(L"Crni je napravio pat");
  780.         }
  781.     }
  782. }
  783.  
  784. void NapraviTablu(Tabla &tabla)
  785. {
  786.     tabla.brlevo = 0;
  787.     tabla.brdesno = 0;
  788.     tabla.krajigre = 0;
  789.     tabla.malarbeli = UKLJUCENO;
  790.     tabla.malarcrni = UKLJUCENO;
  791.     tabla.velikarbeli = UKLJUCENO;
  792.     tabla.velikarcrni = UKLJUCENO;
  793.  
  794.     for(int i = 0; i < 8; i++)
  795.         for(int j = 0; j < 8; j++)
  796.         {
  797.             tabla.polje[i][j].stanjePolja = NEUTRALNO;
  798.             tabla.polje[i][j].anpasan = ISKLJUCENO;
  799.  
  800.             if((i + j) % 2 == 0)
  801.                 tabla.polje[i][j].bojaPolja = BELO;
  802.             else
  803.                 tabla.polje[i][j].bojaPolja = CRNO;
  804.         }
  805.  
  806.     for(int i = 0; i < 2; i++)
  807.         for(int j = 0; j < 8; j++)
  808.         {
  809.             tabla.polje[i][j].bojaFigure = CRNO;
  810.             tabla.polje[i + 6][j].bojaFigure = BELO;
  811.         }
  812.  
  813.     for(int j = 0; j < 8; j++)
  814.     {
  815.         wcscpy(tabla.polje[1][j].figura, PIJUN);
  816.         wcscpy(tabla.polje[6][j].figura, PIJUN);
  817.     }
  818.  
  819.     wcscpy(tabla.polje[0][0].figura, TOP);
  820.     wcscpy(tabla.polje[0][7].figura, TOP);
  821.     wcscpy(tabla.polje[7][0].figura, TOP);
  822.     wcscpy(tabla.polje[7][7].figura, TOP);
  823.  
  824.     wcscpy(tabla.polje[0][1].figura, KONJ);
  825.     wcscpy(tabla.polje[0][6].figura, KONJ);
  826.     wcscpy(tabla.polje[7][1].figura, KONJ);
  827.     wcscpy(tabla.polje[7][6].figura, KONJ);
  828.  
  829.     wcscpy(tabla.polje[0][2].figura, LOVAC);
  830.     wcscpy(tabla.polje[0][5].figura, LOVAC);
  831.     wcscpy(tabla.polje[7][2].figura, LOVAC);
  832.     wcscpy(tabla.polje[7][5].figura, LOVAC);
  833.  
  834.     wcscpy(tabla.polje[0][3].figura, KRALJICA);
  835.     wcscpy(tabla.polje[7][3].figura, KRALJICA);
  836.  
  837.     wcscpy(tabla.polje[0][4].figura, KRALJ);
  838.     wcscpy(tabla.polje[7][4].figura, KRALJ);
  839.  
  840.     for(int i = 2; i < 6; i++)
  841.         for(int j = 0; j < 8; j++)
  842.         {
  843.             tabla.polje[i][j].bojaFigure = ZELENO;
  844.             wcscpy(tabla.polje[i][j].figura, PRAZNO);
  845.         }
  846.  
  847.     for(int i = 0; i < 8; i++)
  848.         for(int j = 0; j < 2; j++)
  849.         {
  850.             tabla.levo[i][j].anpasan = ISKLJUCENO;
  851.             tabla.levo[i][j].bojaFigure = CRNO;
  852.             tabla.levo[i][j].stanjePolja = NEUTRALNO;
  853.             tabla.desno[i][j].anpasan = ISKLJUCENO;
  854.             tabla.desno[i][j].bojaFigure = BELO;
  855.             tabla.desno[i][j].stanjePolja = NEUTRALNO;
  856.             wcscpy(tabla.levo[i][j].figura, PRAZNO);
  857.             wcscpy(tabla.desno[i][j].figura, PRAZNO);
  858.         }
  859. }
  860.  
  861. void SakriKursor()
  862. {
  863.     HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
  864.  
  865.     if(prviput3)
  866.     {
  867.         GetConsoleCursorInfo(consoleHandle, &kursor);
  868.         prviput3 = 0;
  869.     }
  870.  
  871.     CONSOLE_CURSOR_INFO info;
  872.     info.dwSize = 100;
  873.     info.bVisible = FALSE;
  874.     SetConsoleCursorInfo(consoleHandle, &info);
  875. }
  876.  
  877. void ObrisiEkran()
  878. {
  879.     HANDLE hStdOut;
  880.     CONSOLE_SCREEN_BUFFER_INFO csbi;
  881.     DWORD count;
  882.     DWORD cellCount;
  883.     COORD homeCoords = {0, 0};
  884.  
  885.     hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
  886.  
  887.     if (hStdOut == INVALID_HANDLE_VALUE)
  888.         return;
  889.  
  890.     GetConsoleScreenBufferInfo(hStdOut, &csbi);
  891.     cellCount = csbi.dwSize.X * csbi.dwSize.Y;
  892.  
  893.     FillConsoleOutputCharacter(hStdOut, (TCHAR) ' ', cellCount, homeCoords, &count);
  894.     FillConsoleOutputAttribute(hStdOut, csbi.wAttributes, cellCount, homeCoords, &count);
  895.     SetConsoleCursorPosition(hStdOut, homeCoords);
  896. }
  897.  
  898. void gotoxy(int x, int y)
  899. {
  900.     COORD koordinate;
  901.     koordinate.X = x;
  902.     koordinate.Y = y;
  903.     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), koordinate);
  904. }
  905.  
  906. int UcitajKlik(int &x, int &y)
  907. {
  908.     DWORD info;
  909.     INPUT_RECORD input;
  910.     HANDLE in = GetStdHandle(STD_INPUT_HANDLE);
  911.     SetConsoleMode(in, ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);
  912.     ReadConsoleInput(in, &input, 1, &info);
  913.  
  914.     if(input.Event.MouseEvent.dwButtonState != 0x0001)
  915.     {
  916. GOBACK:
  917.         ReadConsoleInput(in, &input, 1, &info);
  918.  
  919.         if(input.Event.MouseEvent.dwButtonState == 0x0001)
  920.         {
  921. GOBACK2:
  922.             ReadConsoleInput(in, &input, 1, &info);
  923.  
  924.             if(input.Event.MouseEvent.dwButtonState != 0x0001)
  925.             {
  926.                 x = input.Event.MouseEvent.dwMousePosition.X;
  927.                 y = input.Event.MouseEvent.dwMousePosition.Y;
  928.             }
  929.             else
  930.                 goto GOBACK2;
  931.         }
  932.         else
  933.             goto GOBACK;
  934.     }
  935.     else
  936.         UcitajKlik(x, y);
  937.  
  938.     return 0;
  939. }
  940.  
  941. void CentrirajKonzolu2()
  942. {
  943.     RECT rectClient, rectWindow;
  944.     HWND hWnd = GetConsoleWindow();
  945.     GetClientRect(hWnd, &rectClient);
  946.     GetWindowRect(hWnd, &rectWindow);
  947.     SetWindowPos(GetConsoleWindow(), HWND_TOP, GetSystemMetrics(SM_CXSCREEN) / 2 - (rectWindow.right - rectWindow.left) / 2, rectWindow.top, 0, 0, SWP_NOSIZE);
  948. }
  949.  
  950. void CentrirajKonzolu()
  951. {
  952.     RECT rectClient, rectWindow;
  953.     HWND hWnd = GetConsoleWindow();
  954.     GetClientRect(hWnd, &rectClient);
  955.     GetWindowRect(hWnd, &rectWindow);
  956.     int posx, posy;
  957.     posx = GetSystemMetrics(SM_CXSCREEN) / 2 - (rectWindow.right - rectWindow.left) / 2;
  958.     posy = GetSystemMetrics(SM_CYSCREEN) / 2 - (rectWindow.bottom - rectWindow.top) / 2;
  959.  
  960.     SetWindowPos(GetConsoleWindow(), HWND_TOP, posx, posy, 0, 0, SWP_NOSIZE);
  961. }
  962.  
  963. void PodesiKonzolu()
  964. {
  965.     HWND consoleWindow = GetConsoleWindow();
  966.  
  967.     HMENU hmenu = GetSystemMenu(consoleWindow, FALSE);
  968.     EnableMenuItem(hmenu, SC_CLOSE, MF_GRAYED); ////////////////////////////////////////////////////////////////////////////////////////////
  969.  
  970.     if(prviput1)
  971.     {
  972.         winlog = GetWindowLong(consoleWindow, GWL_STYLE);
  973.         SetWindowLong(consoleWindow, GWL_STYLE, winlog & ~WS_MAXIMIZEBOX & ~WS_SIZEBOX & ~WS_VSCROLL);
  974.         prviput1 = 0;
  975.     }
  976.     else
  977.         SetWindowLong(consoleWindow, GWL_STYLE, GetWindowLong(consoleWindow, GWL_STYLE) & ~WS_MAXIMIZEBOX & ~WS_SIZEBOX & ~WS_VSCROLL);
  978.  
  979.  
  980.     SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),  ENABLE_EXTENDED_FLAGS);
  981.  
  982.     _setmode(_fileno(stdout), _O_U8TEXT);
  983.     SetConsoleTitleW(L"ŠAH");
  984.     _setmode(_fileno(stdout), _O_TEXT);
  985.  
  986.     if(boja == SVETLO)
  987.         system("color 23");
  988.     else if(boja == TAMNO)
  989.         system("color 56");
  990.     else if(boja == SIVO)
  991.         system("color 89");
  992.  
  993.     _CONSOLE_SCREEN_BUFFER_INFOEX info;
  994.     info.cbSize = sizeof(info);
  995.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  996.     GetConsoleScreenBufferInfoEx(hConsole, &info);
  997.  
  998.     if(prviput2)
  999.     {
  1000.         screenbuffer = info;
  1001.         prviput2 = 0;
  1002.     }
  1003.  
  1004.     info.dwSize = {36, 19};
  1005.     info.ColorTable[0] = RGB(242, 242, 242);
  1006.     info.ColorTable[1] = RGB(10, 10, 10);
  1007.     info.ColorTable[2] = RGB(198, 175, 141);
  1008.     info.ColorTable[3] = RGB(114, 71, 56);
  1009.     info.ColorTable[4] = RGB(50, 31, 26);
  1010.     info.ColorTable[5] = RGB(132, 94, 73);
  1011.     info.ColorTable[6] = RGB(73, 47, 37);
  1012.     info.ColorTable[7] = RGB(22, 11, 4);
  1013.     info.ColorTable[8] = RGB(158, 158, 158);
  1014.     info.ColorTable[9] = RGB(102, 102, 102);
  1015.     info.ColorTable[10] = RGB(43, 43, 43);
  1016.     info.ColorTable[11] = RGB(0, 119, 65);
  1017.     info.ColorTable[12] = RGB(126, 33, 35);
  1018.     info.ColorTable[13] = RGB(10, 10, 130);
  1019.     info.ColorTable[14] = RGB(240, 191, 40);
  1020.     info.ColorTable[15] = RGB(255, 255, 255);
  1021.  
  1022.     SetConsoleScreenBufferInfoEx(hConsole, &info);
  1023.     PodesiVelicinu(velicina);
  1024.     OdstampajKonzolu();
  1025.     SakriKursor();
  1026.     system("MODE 36, 18");
  1027. }
  1028.  
  1029. void PodesiKonzolu2()
  1030. {
  1031.     _CONSOLE_SCREEN_BUFFER_INFOEX info;
  1032.     info.cbSize = sizeof(info);
  1033.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  1034.     GetConsoleScreenBufferInfoEx(hConsole, &info);
  1035.     info.dwSize = {36, 17};
  1036.     SetConsoleScreenBufferInfoEx(hConsole, &info);
  1037. }
  1038.  
  1039. void PodesiVelicinu(int i)
  1040. {
  1041.     CONSOLE_FONT_INFOEX cfi;
  1042.     cfi.cbSize = sizeof(cfi);
  1043.     cfi.nFont = 0;
  1044.     cfi.dwFontSize.X = 0;
  1045.     cfi.dwFontSize.Y = i;
  1046.     cfi.FontFamily = TMPF_TRUETYPE;
  1047.     cfi.FontWeight = FW_NORMAL;
  1048.     std::wcscpy(cfi.FaceName, L"MS Gothic");
  1049.     SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi);
  1050.  
  1051.     CentrirajKonzolu();
  1052.     CentrirajKonzolu();
  1053.     system("MODE 36, 18");
  1054.     PodesiKonzolu2();
  1055. }
  1056.  
  1057. void OdstampajTablu(Tabla tabla)
  1058. {
  1059.     HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
  1060.     _setmode(_fileno(stdout), _O_U8TEXT);
  1061.  
  1062.     for(int i = 0; i < 8; i++)
  1063.         for(int j = 0; j < 8; j++)
  1064.         {
  1065.             if(tabla.polje[i][j].stanjePolja == IZABRANO && tabla.polje[i][j].bojaFigure == CRNO)
  1066.                 SetConsoleTextAttribute(console, 177);
  1067.             else if(tabla.polje[i][j].stanjePolja == IZABRANO && tabla.polje[i][j].bojaFigure == BELO)
  1068.                 SetConsoleTextAttribute(console, 176);
  1069.             else if(tabla.polje[i][j].stanjePolja == NAPADNUTO && (tabla.polje[i][j].bojaFigure == CRNO || tabla.polje[i][j].bojaFigure == ZELENO))
  1070.                 SetConsoleTextAttribute(console, 193);
  1071.             else if(tabla.polje[i][j].stanjePolja == NAPADNUTO && tabla.polje[i][j].bojaFigure == BELO)
  1072.                 SetConsoleTextAttribute(console, 192);
  1073.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == BELO && boja == SVETLO && tabla.polje[i][j].bojaPolja == BELO)
  1074.                 SetConsoleTextAttribute(console, 32);
  1075.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == CRNO && boja == SVETLO && tabla.polje[i][j].bojaPolja == BELO)
  1076.                 SetConsoleTextAttribute(console, 33);
  1077.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == BELO && boja == TAMNO && tabla.polje[i][j].bojaPolja == BELO)
  1078.                 SetConsoleTextAttribute(console, 80);
  1079.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == CRNO && boja == TAMNO && tabla.polje[i][j].bojaPolja == BELO)
  1080.                 SetConsoleTextAttribute(console, 81);
  1081.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == BELO && boja == SIVO && tabla.polje[i][j].bojaPolja == BELO)
  1082.                 SetConsoleTextAttribute(console, 128);
  1083.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == CRNO && boja == SIVO && tabla.polje[i][j].bojaPolja == BELO)
  1084.                 SetConsoleTextAttribute(console, 129);
  1085.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == BELO && boja == SVETLO && tabla.polje[i][j].bojaPolja == CRNO)
  1086.                 SetConsoleTextAttribute(console, 48);
  1087.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == CRNO && boja == SVETLO && tabla.polje[i][j].bojaPolja == CRNO)
  1088.                 SetConsoleTextAttribute(console, 49);
  1089.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == BELO && boja == TAMNO && tabla.polje[i][j].bojaPolja == CRNO)
  1090.                 SetConsoleTextAttribute(console, 96);
  1091.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == CRNO && boja == TAMNO && tabla.polje[i][j].bojaPolja == CRNO)
  1092.                 SetConsoleTextAttribute(console, 97);
  1093.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == BELO && boja == SIVO && tabla.polje[i][j].bojaPolja == CRNO)
  1094.                 SetConsoleTextAttribute(console, 144);
  1095.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == CRNO && boja == SIVO && tabla.polje[i][j].bojaPolja == CRNO)
  1096.                 SetConsoleTextAttribute(console, 145);
  1097.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == ZELENO && boja == SVETLO && tabla.polje[i][j].bojaPolja == BELO)
  1098.                 SetConsoleTextAttribute(console, 43);
  1099.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == ZELENO && boja == TAMNO && tabla.polje[i][j].bojaPolja == BELO)
  1100.                 SetConsoleTextAttribute(console, 91);
  1101.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == ZELENO && boja == SIVO && tabla.polje[i][j].bojaPolja == BELO)
  1102.                 SetConsoleTextAttribute(console, 139);
  1103.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == ZELENO && boja == SVETLO && tabla.polje[i][j].bojaPolja == CRNO)
  1104.                 SetConsoleTextAttribute(console, 59);
  1105.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == ZELENO && boja == TAMNO && tabla.polje[i][j].bojaPolja == CRNO)
  1106.                 SetConsoleTextAttribute(console, 107);
  1107.             else if(tabla.polje[i][j].stanjePolja == NEUTRALNO && tabla.polje[i][j].bojaFigure == ZELENO && boja == SIVO && tabla.polje[i][j].bojaPolja == CRNO)
  1108.                 SetConsoleTextAttribute(console, 155);
  1109.  
  1110.             gotoxy(10 + j * 2, 3 + i);
  1111.             wprintf(tabla.polje[i][j].figura);
  1112.  
  1113.             if(boja == SVETLO)
  1114.                 SetConsoleTextAttribute(console, 68);
  1115.             else if(boja == TAMNO)
  1116.                 SetConsoleTextAttribute(console, 119);
  1117.             else if(boja == SIVO)
  1118.                 SetConsoleTextAttribute(console, 170);
  1119.  
  1120.             if((j + 1) % 8 == 0)
  1121.             {
  1122.                 gotoxy(26, 3 + i);
  1123.                 wprintf(L"█");
  1124.             }
  1125.  
  1126.         }
  1127.  
  1128.     OdstampajLevoDesno(tabla);
  1129. }
  1130.  
  1131. void ObrnutoOdstampajTablu(Tabla tabla)
  1132. {
  1133.     HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
  1134.     _setmode(_fileno(stdout), _O_U8TEXT);
  1135.  
  1136.     for(int i = 0; i < 8; i++)
  1137.         for(int j = 0; j < 8; j++)
  1138.         {
  1139.             if(tabla.polje[7 - i][7 - j].stanjePolja == IZABRANO && tabla.polje[7 - i][7 - j].bojaFigure == CRNO)
  1140.                 SetConsoleTextAttribute(console, 177);
  1141.             else if(tabla.polje[7 - i][7 - j].stanjePolja == IZABRANO && tabla.polje[7 - i][7 - j].bojaFigure == BELO)
  1142.                 SetConsoleTextAttribute(console, 176);
  1143.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NAPADNUTO && tabla.polje[7 - i][7 - j].bojaFigure == CRNO)
  1144.                 SetConsoleTextAttribute(console, 193);
  1145.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NAPADNUTO && tabla.polje[7 - i][7 - j].bojaFigure == BELO)
  1146.                 SetConsoleTextAttribute(console, 192);
  1147.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NAPADNUTO && !wcscmp(tabla.polje[7 - i][7 - j].figura, PRAZNO))
  1148.                 SetConsoleTextAttribute(console, 192);
  1149.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == BELO && boja == SVETLO && tabla.polje[7 - i][7 - j].bojaPolja == BELO)
  1150.                 SetConsoleTextAttribute(console, 32);
  1151.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == CRNO && boja == SVETLO && tabla.polje[7 - i][7 - j].bojaPolja == BELO)
  1152.                 SetConsoleTextAttribute(console, 33);
  1153.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == BELO && boja == TAMNO && tabla.polje[7 - i][7 - j].bojaPolja == BELO)
  1154.                 SetConsoleTextAttribute(console, 80);
  1155.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == CRNO && boja == TAMNO && tabla.polje[7 - i][7 - j].bojaPolja == BELO)
  1156.                 SetConsoleTextAttribute(console, 81);
  1157.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == BELO && boja == SIVO && tabla.polje[7 - i][7 - j].bojaPolja == BELO)
  1158.                 SetConsoleTextAttribute(console, 128);
  1159.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == CRNO && boja == SIVO && tabla.polje[7 - i][7 - j].bojaPolja == BELO)
  1160.                 SetConsoleTextAttribute(console, 129);
  1161.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == BELO && boja == SVETLO && tabla.polje[7 - i][7 - j].bojaPolja == CRNO)
  1162.                 SetConsoleTextAttribute(console, 48);
  1163.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == CRNO && boja == SVETLO && tabla.polje[7 - i][7 - j].bojaPolja == CRNO)
  1164.                 SetConsoleTextAttribute(console, 49);
  1165.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == BELO && boja == TAMNO && tabla.polje[7 - i][7 - j].bojaPolja == CRNO)
  1166.                 SetConsoleTextAttribute(console, 96);
  1167.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == CRNO && boja == TAMNO && tabla.polje[7 - i][7 - j].bojaPolja == CRNO)
  1168.                 SetConsoleTextAttribute(console, 97);
  1169.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == BELO && boja == SIVO && tabla.polje[7 - i][7 - j].bojaPolja == CRNO)
  1170.                 SetConsoleTextAttribute(console, 144);
  1171.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == CRNO && boja == SIVO && tabla.polje[7 - i][7 - j].bojaPolja == CRNO)
  1172.                 SetConsoleTextAttribute(console, 145);
  1173.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == ZELENO && boja == SVETLO && tabla.polje[7 - i][7 - j].bojaPolja == BELO)
  1174.                 SetConsoleTextAttribute(console, 43);
  1175.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == ZELENO && boja == TAMNO && tabla.polje[7 - i][7 - j].bojaPolja == BELO)
  1176.                 SetConsoleTextAttribute(console, 91);
  1177.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == ZELENO && boja == SIVO && tabla.polje[7 - i][7 - j].bojaPolja == BELO)
  1178.                 SetConsoleTextAttribute(console, 139);
  1179.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == ZELENO && boja == SVETLO && tabla.polje[7 - i][7 - j].bojaPolja == CRNO)
  1180.                 SetConsoleTextAttribute(console, 59);
  1181.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == ZELENO && boja == TAMNO && tabla.polje[7 - i][7 - j].bojaPolja == CRNO)
  1182.                 SetConsoleTextAttribute(console, 107);
  1183.             else if(tabla.polje[7 - i][7 - j].stanjePolja == NEUTRALNO && tabla.polje[7 - i][7 - j].bojaFigure == ZELENO && boja == SIVO && tabla.polje[7 - i][7 - j].bojaPolja == CRNO)
  1184.                 SetConsoleTextAttribute(console, 155);
  1185.  
  1186.             gotoxy(10 + j * 2, 3 + i);
  1187.             wprintf(tabla.polje[7 - i][7 - j].figura);
  1188.  
  1189.             if(boja == SVETLO)
  1190.                 SetConsoleTextAttribute(console, 68);
  1191.             else if(boja == TAMNO)
  1192.                 SetConsoleTextAttribute(console, 119);
  1193.             else if(boja == SIVO)
  1194.                 SetConsoleTextAttribute(console, 170);
  1195.  
  1196.             if((j + 1) % 8 == 0)
  1197.             {
  1198.                 gotoxy(26, 3 + i);
  1199.                 wprintf(L"█");
  1200.             }
  1201.  
  1202.         }
  1203.  
  1204.     OdstampajLevoDesno(tabla);
  1205. }
  1206.  
  1207. void OdstampajLevoDesno(Tabla tabla)
  1208. {
  1209.     HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
  1210.     _setmode(_fileno(stdout), _O_U8TEXT);
  1211.  
  1212.     for(int i = 0; i < 8; i++)
  1213.         for(int j = 0; j < 2; j++)
  1214.         {
  1215.             if(boja == SVETLO)
  1216.                 SetConsoleTextAttribute(console, 81);
  1217.             else if(boja == TAMNO)
  1218.                 SetConsoleTextAttribute(console, 97);
  1219.             else if(boja == SIVO)
  1220.                 SetConsoleTextAttribute(console, 145);
  1221.  
  1222.             gotoxy(2 + j * 2, 3 + i);
  1223.             wprintf(tabla.levo[i][j].figura);
  1224.  
  1225.             if((j + 1) % 2 == 0)
  1226.             {
  1227.                 if(boja == SVETLO)
  1228.                     SetConsoleTextAttribute(console, 36);
  1229.                 else if(boja == TAMNO)
  1230.                     SetConsoleTextAttribute(console, 87);
  1231.                 else if(boja == SIVO)
  1232.                     SetConsoleTextAttribute(console, 138);
  1233.  
  1234.                 gotoxy(6, 3 + i);
  1235.                 wprintf(L"┃");
  1236.             }
  1237.         }
  1238.  
  1239.     for(int i = 0; i < 8; i++)
  1240.         for(int j = 0; j < 2; j++)
  1241.         {
  1242.             if(boja == SVETLO)
  1243.                 SetConsoleTextAttribute(console, 80);
  1244.             else if(boja == TAMNO)
  1245.                 SetConsoleTextAttribute(console, 96);
  1246.             else if(boja == SIVO)
  1247.                 SetConsoleTextAttribute(console, 144);
  1248.  
  1249.             gotoxy(30 + j * 2, 3 + i);
  1250.             wprintf(tabla.desno[i][j].figura);
  1251.  
  1252.             if((j + 1) % 2 == 0)
  1253.             {
  1254.                 if(boja == SVETLO)
  1255.                     SetConsoleTextAttribute(console, 36);
  1256.                 else if(boja == TAMNO)
  1257.                     SetConsoleTextAttribute(console, 87);
  1258.                 else if(boja == SIVO)
  1259.                     SetConsoleTextAttribute(console, 138);
  1260.  
  1261.                 gotoxy(34, 3 + i);
  1262.                 wprintf(L"┃");
  1263.             }
  1264.         }
  1265. }
  1266.  
  1267. void PozicijaNaTabli(int &x, int &y)
  1268. {
  1269.     switch(x)
  1270.     {
  1271.     case 10:
  1272.     case 11:
  1273.         x = 0;
  1274.         break;
  1275.  
  1276.     case 12:
  1277.     case 13:
  1278.         x = 1;
  1279.         break;
  1280.  
  1281.     case 14:
  1282.     case 15:
  1283.         x = 2;
  1284.         break;
  1285.  
  1286.     case 16:
  1287.     case 17:
  1288.         x = 3;
  1289.         break;
  1290.  
  1291.     case 18:
  1292.     case 19:
  1293.         x = 4;
  1294.         break;
  1295.  
  1296.     case 20:
  1297.     case 21:
  1298.         x = 5;
  1299.         break;
  1300.  
  1301.     case 22:
  1302.     case 23:
  1303.         x = 6;
  1304.         break;
  1305.  
  1306.     case 24:
  1307.     case 25:
  1308.         x = 7;
  1309.     }
  1310.  
  1311.     switch(y)
  1312.     {
  1313.     case 10:
  1314.         y = 7;
  1315.         break;
  1316.  
  1317.     case 9:
  1318.         y = 6;
  1319.         break;
  1320.  
  1321.     case 8:
  1322.         y = 5;
  1323.         break;
  1324.  
  1325.     case 7:
  1326.         y = 4;
  1327.         break;
  1328.  
  1329.     case 6:
  1330.         y = 3;
  1331.         break;
  1332.  
  1333.     case 5:
  1334.         y = 2;
  1335.         break;
  1336.  
  1337.     case 4:
  1338.         y = 1;
  1339.         break;
  1340.  
  1341.     case 3:
  1342.         y = 0;
  1343.     }
  1344. }
  1345.  
  1346. void ObrnutaPozicijaNaTabli(int &x, int &y)
  1347. {
  1348.     switch(x)
  1349.     {
  1350.     case 10:
  1351.     case 11:
  1352.         x = 7;
  1353.         break;
  1354.  
  1355.     case 12:
  1356.     case 13:
  1357.         x = 6;
  1358.         break;
  1359.  
  1360.     case 14:
  1361.     case 15:
  1362.         x = 5;
  1363.         break;
  1364.  
  1365.     case 16:
  1366.     case 17:
  1367.         x = 4;
  1368.         break;
  1369.  
  1370.     case 18:
  1371.     case 19:
  1372.         x = 3;
  1373.         break;
  1374.  
  1375.     case 20:
  1376.     case 21:
  1377.         x = 2;
  1378.         break;
  1379.  
  1380.     case 22:
  1381.     case 23:
  1382.         x = 1;
  1383.         break;
  1384.  
  1385.     case 24:
  1386.     case 25:
  1387.         x = 0;
  1388.     }
  1389.  
  1390.     switch(y)
  1391.     {
  1392.     case 10:
  1393.         y = 0;
  1394.         break;
  1395.  
  1396.     case 9:
  1397.         y = 1;
  1398.         break;
  1399.  
  1400.     case 8:
  1401.         y = 2;
  1402.         break;
  1403.  
  1404.     case 7:
  1405.         y = 3;
  1406.         break;
  1407.  
  1408.     case 6:
  1409.         y = 4;
  1410.         break;
  1411.  
  1412.     case 5:
  1413.         y = 5;
  1414.         break;
  1415.  
  1416.     case 4:
  1417.         y = 6;
  1418.         break;
  1419.  
  1420.     case 3:
  1421.         y = 7;
  1422.     }
  1423. }
  1424.  
  1425. void NoviPotez(Tabla &tabla)
  1426. {
  1427.     for(int a = 0; a < 8; a++)
  1428.         for(int b = 0; b < 8; b++)
  1429.         {
  1430.             if(tabla.polje[a][b].stanjePolja == IZABRANO)
  1431.                 tabla.polje[a][b].stanjePolja = NEUTRALNO;
  1432.  
  1433.             if(tabla.polje[a][b].stanjePolja == NAPADNUTO)
  1434.                 tabla.polje[a][b].stanjePolja = NEUTRALNO;
  1435.  
  1436.             if(!wcscmp(tabla.polje[a][b].figura, TACKA))
  1437.                 wcscpy(tabla.polje[a][b].figura, PRAZNO);
  1438.  
  1439.             if(!wcscmp(tabla.polje[a][b].figura, PRAZNO))
  1440.                 tabla.polje[a][b].bojaFigure = ZELENO;
  1441.         }
  1442. }
  1443.  
  1444. void ObrisiAnpasan(Tabla &tabla)
  1445. {
  1446.     for(int a = 0; a < 8; a++)
  1447.         for(int b = 0; b < 8; b++)
  1448.             if(tabla.polje[a][b].anpasan == UKLJUCENO)
  1449.                 tabla.polje[a][b].anpasan = ISKLJUCENO;
  1450.  
  1451. }
  1452.  
  1453. void PozicijaIzabranog(int &xizb, int &yizb, Tabla tabla)
  1454. {
  1455.     for(int a = 0; a < 8; a++)
  1456.         for(int b = 0; b < 8; b++)
  1457.             if(tabla.polje[a][b].stanjePolja == IZABRANO)
  1458.             {
  1459.                 yizb = a;
  1460.                 xizb = b;
  1461.                 return;
  1462.             }
  1463. }
  1464.  
  1465. short JelUnutarTable(int x, int y)
  1466. {
  1467.     if(x >= 0 && x <= 7 && y >= 0 && y <= 7)
  1468.         return 1;
  1469.     else
  1470.         return 0;
  1471. }
  1472.  
  1473. void OdstampajKonzolu()
  1474. {
  1475.     HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
  1476.     _setmode(_fileno(stdout), _O_U8TEXT);
  1477.  
  1478.     gotoxy(0, 0);
  1479.  
  1480.     if(boja == SVETLO)
  1481.         SetConsoleTextAttribute(console, 45);
  1482.     else if(boja == TAMNO)
  1483.         SetConsoleTextAttribute(console, 93);
  1484.     else if(boja == SIVO)
  1485.         SetConsoleTextAttribute(console, 141);
  1486.  
  1487.     wprintf(L"");  // save
  1488.  
  1489.     if(boja == SVETLO)
  1490.         SetConsoleTextAttribute(console, 46);
  1491.     else if(boja == TAMNO)
  1492.         SetConsoleTextAttribute(console, 94);
  1493.     else if(boja == SIVO)
  1494.         SetConsoleTextAttribute(console, 142);
  1495.  
  1496.     wprintf(L"");  // open
  1497.  
  1498.     if(boja == SVETLO)
  1499.         SetConsoleTextAttribute(console, 44);
  1500.     else if(boja == TAMNO)
  1501.         SetConsoleTextAttribute(console, 92);
  1502.     else if(boja == SIVO)
  1503.         SetConsoleTextAttribute(console, 140);
  1504.  
  1505.     wprintf(L"");  // restart      
  1506.  
  1507.     if(boja == SVETLO)
  1508.         SetConsoleTextAttribute(console, 36);
  1509.     else if(boja == TAMNO)
  1510.         SetConsoleTextAttribute(console, 87);
  1511.     else if(boja == SIVO)
  1512.         SetConsoleTextAttribute(console, 138);
  1513.  
  1514.     // gear 
  1515.     wprintf(L"");  // color
  1516.     wprintf(L"");  // resize
  1517.     wprintf(L"");  // back
  1518.     wprintf(L"                  "); // space
  1519.  
  1520.     if(rotacija == UKLJUCENO)
  1521.         wprintf(L"");  // rotation 
  1522.     else
  1523.         wprintf(L"");  // rotation 
  1524.  
  1525.     if(boja == SVETLO)
  1526.         SetConsoleTextAttribute(console, 47);
  1527.     else if(boja == TAMNO)
  1528.         SetConsoleTextAttribute(console, 95);
  1529.     else if(boja == SIVO)
  1530.         SetConsoleTextAttribute(console, 143);
  1531.  
  1532.     wprintf(L"");  // info
  1533.  
  1534.     if(boja == SVETLO)
  1535.         SetConsoleTextAttribute(console, 44);
  1536.     else if(boja == TAMNO)
  1537.         SetConsoleTextAttribute(console, 92);
  1538.     else if(boja == SIVO)
  1539.         SetConsoleTextAttribute(console, 140);
  1540.  
  1541.     wprintf(L"\n");  // quit
  1542.  
  1543.     if(boja == SVETLO)
  1544.         SetConsoleTextAttribute(console, 36);
  1545.     else if(boja == TAMNO)
  1546.         SetConsoleTextAttribute(console, 87);
  1547.     else if(boja == SIVO)
  1548.         SetConsoleTextAttribute(console, 138);
  1549.  
  1550.     wprintf(L"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
  1551.     wprintf(L"┏━━━━━┓                     ┏━━━━━┓ \n");
  1552.     wprintf(L"┃     ┃                     ┃     ┃ \n");
  1553.     wprintf(L"┃     ┃                     ┃     ┃ \n");
  1554.     wprintf(L"┃     ┃                     ┃     ┃ \n");
  1555.     wprintf(L"┃     ┃                     ┃     ┃ \n");
  1556.     wprintf(L"┃     ┃                     ┃     ┃ \n");
  1557.     wprintf(L"┃     ┃                     ┃     ┃ \n");
  1558.     wprintf(L"┃     ┃                     ┃     ┃ \n");
  1559.     wprintf(L"┃     ┃                     ┃     ┃ \n");
  1560.     wprintf(L"┗━━━━━┛                     ┗━━━━━┛ \n");
  1561.     wprintf(L"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ \n");
  1562.     wprintf(L"┃                                 ┃ \n");
  1563.     wprintf(L"┃                                 ┃ \n");
  1564.     wprintf(L"┃                                 ┃ \n");
  1565.     wprintf(L"┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ");
  1566.  
  1567.     ObrisiTerminal();
  1568.  
  1569.     if(boja == SVETLO)
  1570.         SetConsoleTextAttribute(console, 68);
  1571.     else if(boja == TAMNO)
  1572.         SetConsoleTextAttribute(console, 119);
  1573.     else if(boja == SIVO)
  1574.         SetConsoleTextAttribute(console, 170);
  1575.  
  1576.     gotoxy(8, 2);
  1577.     wprintf(L"████████████████████");
  1578.     gotoxy(8, 3);
  1579.     wprintf(L"██");
  1580.     gotoxy(8, 4);
  1581.     wprintf(L"██");
  1582.     gotoxy(8, 5);
  1583.     wprintf(L"██");
  1584.     gotoxy(8, 6);
  1585.     wprintf(L"██");
  1586.     gotoxy(8, 7);
  1587.     wprintf(L"██");
  1588.     gotoxy(8, 8);
  1589.     wprintf(L"██");
  1590.     gotoxy(8, 9);
  1591.     wprintf(L"██");
  1592.     gotoxy(8, 10);
  1593.     wprintf(L"██");
  1594.     gotoxy(26, 3);
  1595.     wprintf(L"██");
  1596.     gotoxy(26, 4);
  1597.     wprintf(L"██");
  1598.     gotoxy(26, 5);
  1599.     wprintf(L"██");
  1600.     gotoxy(26, 6);
  1601.     wprintf(L"██");
  1602.     gotoxy(26, 7);
  1603.     wprintf(L"██");
  1604.     gotoxy(26, 8);
  1605.     wprintf(L"██");
  1606.     gotoxy(26, 9);
  1607.     wprintf(L"██");
  1608.     gotoxy(26, 10);
  1609.     wprintf(L"██");
  1610.     gotoxy(8, 11);
  1611.     wprintf(L"████████████████████");
  1612. }
  1613.  
  1614. void OsveziTablu(Tabla tabla)
  1615. {
  1616.     if((brPoteza % 2 && rotacija == UKLJUCENO && JelMozeIgratiCrni(tabla)) || (!JelMozeIgratiBeli(tabla) && rotacija == UKLJUCENO && brPoteza % 2 == 0))
  1617.     {
  1618.         if(sacekaj == UKLJUCENO && JelMozeIgratiBeli(tabla))
  1619.         {
  1620.             OdstampajTablu(tabla);
  1621.             Sleep(260);
  1622.         }
  1623.  
  1624.         ObrnutoOdstampajTablu(tabla);
  1625.     }
  1626.     else
  1627.     {
  1628.         if(sacekaj == UKLJUCENO && rotacija == UKLJUCENO && JelMozeIgratiCrni(tabla))
  1629.         {
  1630.             ObrnutoOdstampajTablu(tabla);
  1631.             Sleep(260);
  1632.         }
  1633.  
  1634.         OdstampajTablu(tabla);
  1635.     }
  1636. }
  1637.  
  1638. BOOL RegDelnodeRecurse (HKEY hKeyRoot, LPTSTR lpSubKey)
  1639. {
  1640.     LPTSTR lpEnd;
  1641.     LONG lResult;
  1642.     DWORD dwSize;
  1643.     TCHAR szName[MAX_PATH];
  1644.     HKEY hKey;
  1645.     FILETIME ftWrite;
  1646.  
  1647.     lResult = RegDeleteKey(hKeyRoot, lpSubKey);
  1648.  
  1649.     if(lResult == ERROR_SUCCESS)
  1650.         return TRUE;
  1651.  
  1652.     lResult = RegOpenKeyEx (hKeyRoot, lpSubKey, 0, KEY_READ, &hKey);
  1653.  
  1654.     if(lResult == ERROR_FILE_NOT_FOUND && lResult != ERROR_SUCCESS)
  1655.         return TRUE;
  1656.     else if(lResult != ERROR_SUCCESS)
  1657.         return FALSE;
  1658.  
  1659.     lpEnd = lpSubKey + lstrlen(lpSubKey);
  1660.  
  1661.     if(*(lpEnd - 1) != TEXT('\\'))
  1662.     {
  1663.         *lpEnd =  TEXT('\\');
  1664.         lpEnd++;
  1665.         *lpEnd =  TEXT('\0');
  1666.     }
  1667.  
  1668.     dwSize = MAX_PATH;
  1669.     lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL,
  1670.                            NULL, NULL, &ftWrite);
  1671.  
  1672.     if(lResult == ERROR_SUCCESS)
  1673.         do
  1674.         {
  1675.  
  1676.             *lpEnd = TEXT('\0');
  1677.             strcat(lpSubKey, szName);
  1678.  
  1679.             if(!RegDelnodeRecurse(hKeyRoot, lpSubKey))
  1680.             {
  1681.                 break;
  1682.             }
  1683.  
  1684.             dwSize = MAX_PATH;
  1685.  
  1686.             lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL,
  1687.                                    NULL, NULL, &ftWrite);
  1688.  
  1689.         }
  1690.         while (lResult == ERROR_SUCCESS);
  1691.  
  1692.  
  1693.     lpEnd--;
  1694.     *lpEnd = TEXT('\0');
  1695.  
  1696.     RegCloseKey (hKey);
  1697.  
  1698.     lResult = RegDeleteKey(hKeyRoot, lpSubKey);
  1699.  
  1700.     if(lResult == ERROR_SUCCESS)
  1701.         return TRUE;
  1702.  
  1703.     return FALSE;
  1704. }
  1705.  
  1706. BOOL RegDelnode(HKEY hKeyRoot, LPCTSTR lpSubKey)
  1707. {
  1708.     TCHAR szDelKey[MAX_PATH * 2];
  1709.  
  1710.     strcpy(szDelKey, lpSubKey);
  1711.     return RegDelnodeRecurse(hKeyRoot, szDelKey);
  1712.  
  1713. }
  1714.  
  1715. void ObrisiTerminal()
  1716. {
  1717.     HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
  1718.     _setmode(_fileno(stdout), _O_U8TEXT);
  1719.  
  1720.     if(boja == SVETLO)
  1721.         SetConsoleTextAttribute(console, 85);
  1722.     else if(boja == TAMNO)
  1723.         SetConsoleTextAttribute(console, 102);
  1724.     else if(boja == SIVO)
  1725.         SetConsoleTextAttribute(console, 153);
  1726.  
  1727.     gotoxy(2, 13);
  1728.     wprintf(L"████████████████████████████████");
  1729.     gotoxy(2, 14);
  1730.     wprintf(L"████████████████████████████████");
  1731.     gotoxy(2, 15);
  1732.     wprintf(L"████████████████████████████████");
  1733. }
  1734.  
  1735. Tabla StaviFiguruNaXY(Tabla tabla, int x, int y)
  1736. {
  1737.     int xizb, yizb;
  1738.     PozicijaIzabranog(xizb, yizb, tabla);
  1739.     wcscpy(tabla.polje[y][x].figura, tabla.polje[yizb][xizb].figura);
  1740.     wcscpy(tabla.polje[yizb][xizb].figura, PRAZNO);
  1741.     tabla.polje[y][x].bojaFigure = tabla.polje[yizb][xizb].bojaFigure;
  1742.     NoviPotez(tabla);
  1743.  
  1744.     return tabla;
  1745. }
  1746.  
  1747. short JelSahBeli(Tabla tabla, int xpomeraj, int ypomeraj)
  1748. {
  1749.     int x = 0, y = 0;
  1750.  
  1751.     for(int i = 0; i < 64; i++)
  1752.     {
  1753.         if(!wcscmp(tabla.polje[i / 8][i % 8].figura, KRALJ) && tabla.polje[i / 8][i % 8].bojaFigure == BELO)
  1754.         {
  1755.             if(JelUnutarTable(i % 8 + xpomeraj, i / 8 + ypomeraj))
  1756.             {
  1757.                 y = i / 8 + ypomeraj;
  1758.                 x = i % 8 + xpomeraj;
  1759.             }
  1760.             else
  1761.             {
  1762.                 x = i % 8;
  1763.                 y = i / 8;
  1764.             }
  1765.  
  1766.             break;
  1767.         }
  1768.     }
  1769.  
  1770.     if(!wcscmp(tabla.polje[y - 1][x + 1].figura, PIJUN) && tabla.polje[y - 1][x - 1].bojaFigure == CRNO && JelUnutarTable(x + 1, y - 1))
  1771.         return 1;
  1772.  
  1773.     if(!wcscmp(tabla.polje[y - 1][x - 1].figura, PIJUN) && tabla.polje[y - 1][x - 1].bojaFigure == CRNO && JelUnutarTable(x - 1, y - 1))
  1774.         return 1;
  1775.  
  1776.     if(!wcscmp(tabla.polje[y - 2][x - 1].figura, KONJ) && tabla.polje[y - 2][x - 1].bojaFigure == CRNO && JelUnutarTable(x - 1, y - 2))
  1777.         return 1;
  1778.  
  1779.     if(!wcscmp(tabla.polje[y - 2][x + 1].figura, KONJ) && tabla.polje[y - 2][x + 1].bojaFigure == CRNO && JelUnutarTable(x + 1, y - 2))
  1780.         return 1;
  1781.  
  1782.     if(!wcscmp(tabla.polje[y - 1][x + 2].figura, KONJ) && tabla.polje[y - 1][x + 2].bojaFigure == CRNO && JelUnutarTable(x + 2, y - 1))
  1783.         return 1;
  1784.  
  1785.     if(!wcscmp(tabla.polje[y + 1][x + 2].figura, KONJ) && tabla.polje[y + 1][x + 2].bojaFigure == CRNO && JelUnutarTable(x + 2, y + 1))
  1786.         return 1;
  1787.  
  1788.     if(!wcscmp(tabla.polje[y + 2][x + 1].figura, KONJ) && tabla.polje[y + 2][x + 1].bojaFigure == CRNO && JelUnutarTable(x + 1, y + 2))
  1789.         return 1;
  1790.  
  1791.     if(!wcscmp(tabla.polje[y + 2][x - 1].figura, KONJ) && tabla.polje[y + 2][x - 1].bojaFigure == CRNO && JelUnutarTable(x - 1, y + 2))
  1792.         return 1;
  1793.  
  1794.     if(!wcscmp(tabla.polje[y + 1][x - 2].figura, KONJ) && tabla.polje[y + 1][x - 2].bojaFigure == CRNO && JelUnutarTable(x - 2, y + 1))
  1795.         return 1;
  1796.  
  1797.     if(!wcscmp(tabla.polje[y - 1][x - 2].figura, KONJ) && tabla.polje[y - 1][x - 2].bojaFigure == CRNO && JelUnutarTable(x - 2, y - 1))
  1798.         return 1;
  1799.  
  1800.     for(int i = 1; i < 8; i++)
  1801.     {
  1802.         if((!wcscmp(tabla.polje[y][x - i].figura, PRAZNO) || (!wcscmp(tabla.polje[y][x - i].figura, KRALJ) && tabla.polje[y][x - i].bojaFigure == BELO)) && JelUnutarTable(x - i, y));
  1803.         else if((!wcscmp(tabla.polje[y][x - i].figura, TOP) || !wcscmp(tabla.polje[y][x - i].figura, KRALJICA)) && tabla.polje[y][x - i].bojaFigure == CRNO && JelUnutarTable(x - i, y))
  1804.             return 1;
  1805.         else
  1806.             break;
  1807.     }
  1808.  
  1809.     for(int i = 1; i < 8; i++)
  1810.     {
  1811.         if((!wcscmp(tabla.polje[y][x + i].figura, PRAZNO) || (!wcscmp(tabla.polje[y][x + i].figura, KRALJ) && tabla.polje[y][x + i].bojaFigure == BELO)) && JelUnutarTable(x + i, y));
  1812.         else if((!wcscmp(tabla.polje[y][x + i].figura, TOP) || !wcscmp(tabla.polje[y][x + i].figura, KRALJICA)) && tabla.polje[y][x + i].bojaFigure == CRNO && JelUnutarTable(x + i, y))
  1813.             return 1;
  1814.         else
  1815.             break;
  1816.     }
  1817.  
  1818.     for(int i = 1; i < 8; i++)
  1819.     {
  1820.         if((!wcscmp(tabla.polje[y - i][x].figura, PRAZNO) || (!wcscmp(tabla.polje[y - i][x].figura, KRALJ) && tabla.polje[y - i][x].bojaFigure == BELO)) && JelUnutarTable(x, y - i));
  1821.         else if((!wcscmp(tabla.polje[y - i][x].figura, TOP) || !wcscmp(tabla.polje[y - i][x].figura, KRALJICA)) && tabla.polje[y - i][x].bojaFigure == CRNO && JelUnutarTable(x, y - i))
  1822.             return 1;
  1823.         else
  1824.             break;
  1825.     }
  1826.  
  1827.     for(int i = 1; i < 8; i++)
  1828.     {
  1829.         if((!wcscmp(tabla.polje[y + i][x].figura, PRAZNO) || (!wcscmp(tabla.polje[y + i][x].figura, KRALJ) && tabla.polje[y + i][x].bojaFigure == BELO)) && JelUnutarTable(x, y + i));
  1830.         else if((!wcscmp(tabla.polje[y + i][x].figura, TOP) || !wcscmp(tabla.polje[y + i][x].figura, KRALJICA)) && tabla.polje[y + i][x].bojaFigure == CRNO && JelUnutarTable(x, y + i))
  1831.             return 1;
  1832.         else
  1833.             break;
  1834.     }
  1835.  
  1836.     for(int i = 1; i < 8; i++)
  1837.     {
  1838.         if((!wcscmp(tabla.polje[y - i][x - i].figura, PRAZNO) || (!wcscmp(tabla.polje[y - i][x - i].figura, KRALJ) && tabla.polje[y - i][x - i].bojaFigure == BELO)) && JelUnutarTable(x - i, y - i));
  1839.         else if((!wcscmp(tabla.polje[y - i][x - i].figura, LOVAC) || !wcscmp(tabla.polje[y - i][x - i].figura, KRALJICA)) && tabla.polje[y - i][x - i].bojaFigure == CRNO && JelUnutarTable(x - i, y - i))
  1840.             return 1;
  1841.         else
  1842.             break;
  1843.     }
  1844.  
  1845.     for(int i = 1; i < 8; i++)
  1846.     {
  1847.         if((!wcscmp(tabla.polje[y - i][x + i].figura, PRAZNO) || (!wcscmp(tabla.polje[y - i][x + i].figura, KRALJ) && tabla.polje[y - i][x + i].bojaFigure == BELO)) && JelUnutarTable(x + i, y - i));
  1848.         else if((!wcscmp(tabla.polje[y - i][x + i].figura, LOVAC) || !wcscmp(tabla.polje[y - i][x + i].figura, KRALJICA)) && tabla.polje[y - i][x + i].bojaFigure == CRNO && JelUnutarTable(x + i, y - i))
  1849.             return 1;
  1850.         else
  1851.             break;
  1852.     }
  1853.  
  1854.     for(int i = 1; i < 8; i++)
  1855.     {
  1856.         if((!wcscmp(tabla.polje[y + i][x - i].figura, PRAZNO) || (!wcscmp(tabla.polje[y + i][x - i].figura, KRALJ) && tabla.polje[y + i][x - i].bojaFigure == BELO)) && JelUnutarTable(x - i, y + i));
  1857.         else if((!wcscmp(tabla.polje[y + i][x - i].figura, LOVAC) || !wcscmp(tabla.polje[y + i][x - i].figura, KRALJICA)) && tabla.polje[y + i][x - i].bojaFigure == CRNO && JelUnutarTable(x - i, y + i))
  1858.             return 1;
  1859.         else
  1860.             break;
  1861.     }
  1862.  
  1863.     for(int i = 1; i < 8; i++)
  1864.     {
  1865.         if((!wcscmp(tabla.polje[y + i][x + i].figura, PRAZNO) || (!wcscmp(tabla.polje[y + i][x + i].figura, KRALJ) && tabla.polje[y + i][x + i].bojaFigure == BELO)) && JelUnutarTable(x + i, y + i));
  1866.         else if((!wcscmp(tabla.polje[y + i][x + i].figura, LOVAC) || !wcscmp(tabla.polje[y + i][x + i].figura, KRALJICA)) && tabla.polje[y + i][x + i].bojaFigure == CRNO && JelUnutarTable(x + i, y + i))
  1867.             return 1;
  1868.         else
  1869.             break;
  1870.     }
  1871.  
  1872.     if(!wcscmp(tabla.polje[y][x - 1].figura, KRALJ) && tabla.polje[y][x - 1].bojaFigure == CRNO && JelUnutarTable(x - 1, y))
  1873.         return 1;
  1874.  
  1875.     if(!wcscmp(tabla.polje[y][x + 1].figura, KRALJ) && tabla.polje[y][x + 1].bojaFigure == CRNO && JelUnutarTable(x + 1, y))
  1876.         return 1;
  1877.  
  1878.     if(!wcscmp(tabla.polje[y - 1][x].figura, KRALJ) && tabla.polje[y - 1][x].bojaFigure == CRNO && JelUnutarTable(x, y - 1))
  1879.         return 1;
  1880.  
  1881.     if(!wcscmp(tabla.polje[y + 1][x].figura, KRALJ) && tabla.polje[y + 1][x].bojaFigure == CRNO && JelUnutarTable(x, y + 1))
  1882.         return 1;
  1883.  
  1884.     if(!wcscmp(tabla.polje[y - 1][x - 1].figura, KRALJ) && tabla.polje[y - 1][x - 1].bojaFigure == CRNO && JelUnutarTable(x - 1, y - 1))
  1885.         return 1;
  1886.  
  1887.     if(!wcscmp(tabla.polje[y - 1][x + 1].figura, KRALJ) && tabla.polje[y - 1][x + 1].bojaFigure == CRNO && JelUnutarTable(x + 1, y - 1))
  1888.         return 1;
  1889.  
  1890.     if(!wcscmp(tabla.polje[y + 1][x - 1].figura, KRALJ) && tabla.polje[y + 1][x - 1].bojaFigure == CRNO && JelUnutarTable(x - 1, y + 1))
  1891.         return 1;
  1892.  
  1893.     if(!wcscmp(tabla.polje[y + 1][x + 1].figura, KRALJ) && tabla.polje[y + 1][x + 1].bojaFigure == CRNO && JelUnutarTable(x + 1, y + 1))
  1894.         return 1;
  1895.  
  1896.     return 0;
  1897. }
  1898.  
  1899. short JelSahCrni(Tabla tabla, int xpomeraj, int ypomeraj)
  1900. {
  1901.     int x = 0, y = 0;
  1902.  
  1903.     for(int i = 0; i < 64; i++)
  1904.     {
  1905.         if(!wcscmp(tabla.polje[i / 8][i % 8].figura, KRALJ) && tabla.polje[i / 8][i % 8].bojaFigure == CRNO)
  1906.         {
  1907.             if(JelUnutarTable(i % 8 + xpomeraj, i / 8 + ypomeraj))
  1908.             {
  1909.                 y = i / 8 + ypomeraj;
  1910.                 x = i % 8 + xpomeraj;
  1911.             }
  1912.             else
  1913.             {
  1914.                 x = i % 8;
  1915.                 y = i / 8;
  1916.             }
  1917.  
  1918.             break;
  1919.         }
  1920.     }
  1921.  
  1922.     if(!wcscmp(tabla.polje[y + 1][x + 1].figura, PIJUN) && tabla.polje[y + 1][x - 1].bojaFigure == BELO && JelUnutarTable(x + 1, y + 1))
  1923.         return 1;
  1924.  
  1925.     if(!wcscmp(tabla.polje[y + 1][x - 1].figura, PIJUN) && tabla.polje[y + 1][x - 1].bojaFigure == BELO && JelUnutarTable(x - 1, y + 1))
  1926.         return 1;
  1927.  
  1928.     if(!wcscmp(tabla.polje[y - 2][x - 1].figura, KONJ) && tabla.polje[y - 2][x - 1].bojaFigure == BELO && JelUnutarTable(x - 1, y - 2))
  1929.         return 1;
  1930.  
  1931.     if(!wcscmp(tabla.polje[y - 2][x + 1].figura, KONJ) && tabla.polje[y - 2][x + 1].bojaFigure == BELO && JelUnutarTable(x + 1, y - 2))
  1932.         return 1;
  1933.  
  1934.     if(!wcscmp(tabla.polje[y - 1][x + 2].figura, KONJ) && tabla.polje[y - 1][x + 2].bojaFigure == BELO && JelUnutarTable(x + 2, y - 1))
  1935.         return 1;
  1936.  
  1937.     if(!wcscmp(tabla.polje[y + 1][x + 2].figura, KONJ) && tabla.polje[y + 1][x + 2].bojaFigure == BELO && JelUnutarTable(x + 2, y + 1))
  1938.         return 1;
  1939.  
  1940.     if(!wcscmp(tabla.polje[y + 2][x + 1].figura, KONJ) && tabla.polje[y + 2][x + 1].bojaFigure == BELO && JelUnutarTable(x + 1, y + 2))
  1941.         return 1;
  1942.  
  1943.     if(!wcscmp(tabla.polje[y + 2][x - 1].figura, KONJ) && tabla.polje[y + 2][x - 1].bojaFigure == BELO && JelUnutarTable(x - 1, y + 2))
  1944.         return 1;
  1945.  
  1946.     if(!wcscmp(tabla.polje[y + 1][x - 2].figura, KONJ) && tabla.polje[y + 1][x - 2].bojaFigure == BELO && JelUnutarTable(x - 2, y + 1))
  1947.         return 1;
  1948.  
  1949.     if(!wcscmp(tabla.polje[y - 1][x - 2].figura, KONJ) && tabla.polje[y - 1][x - 2].bojaFigure == BELO && JelUnutarTable(x - 2, y - 1))
  1950.         return 1;
  1951.  
  1952.     for(int i = 1; i < 8; i++)
  1953.     {
  1954.         if((!wcscmp(tabla.polje[y][x - i].figura, PRAZNO) || (!wcscmp(tabla.polje[y][x - i].figura, KRALJ) && tabla.polje[y][x - i].bojaFigure == CRNO)) && JelUnutarTable(x - i, y));
  1955.         else if((!wcscmp(tabla.polje[y][x - i].figura, TOP) || !wcscmp(tabla.polje[y][x - i].figura, KRALJICA)) && tabla.polje[y][x - i].bojaFigure == BELO && JelUnutarTable(x - i, y))
  1956.             return 1;
  1957.         else
  1958.             break;
  1959.     }
  1960.  
  1961.     for(int i = 1; i < 8; i++)
  1962.     {
  1963.         if((!wcscmp(tabla.polje[y][x + i].figura, PRAZNO) || (!wcscmp(tabla.polje[y][x + i].figura, KRALJ) && tabla.polje[y][x + i].bojaFigure == CRNO)) && JelUnutarTable(x + i, y));
  1964.         else if((!wcscmp(tabla.polje[y][x + i].figura, TOP) || !wcscmp(tabla.polje[y][x + i].figura, KRALJICA)) && tabla.polje[y][x + i].bojaFigure == BELO && JelUnutarTable(x + i, y))
  1965.             return 1;
  1966.         else
  1967.             break;
  1968.     }
  1969.  
  1970.     for(int i = 1; i < 8; i++)
  1971.     {
  1972.         if((!wcscmp(tabla.polje[y - i][x].figura, PRAZNO) || (!wcscmp(tabla.polje[y - i][x].figura, KRALJ) && tabla.polje[y - i][x].bojaFigure == CRNO)) && JelUnutarTable(x, y - i));
  1973.         else if((!wcscmp(tabla.polje[y - i][x].figura, TOP) || !wcscmp(tabla.polje[y - i][x].figura, KRALJICA)) && tabla.polje[y - i][x].bojaFigure == BELO && JelUnutarTable(x, y - i))
  1974.             return 1;
  1975.         else
  1976.             break;
  1977.     }
  1978.  
  1979.     for(int i = 1; i < 8; i++)
  1980.     {
  1981.         if((!wcscmp(tabla.polje[y + i][x].figura, PRAZNO) || (!wcscmp(tabla.polje[y + i][x].figura, KRALJ) && tabla.polje[y + i][x].bojaFigure == CRNO)) && JelUnutarTable(x, y + i));
  1982.         else if((!wcscmp(tabla.polje[y + i][x].figura, TOP) || !wcscmp(tabla.polje[y + i][x].figura, KRALJICA)) && tabla.polje[y + i][x].bojaFigure == BELO && JelUnutarTable(x, y + i))
  1983.             return 1;
  1984.         else
  1985.             break;
  1986.     }
  1987.  
  1988.     for(int i = 1; i < 8; i++)
  1989.     {
  1990.         if((!wcscmp(tabla.polje[y - i][x - i].figura, PRAZNO) || (!wcscmp(tabla.polje[y - i][x - i].figura, KRALJ) && tabla.polje[y - i][x - i].bojaFigure == CRNO)) && JelUnutarTable(x - i, y - i));
  1991.         else if((!wcscmp(tabla.polje[y - i][x - i].figura, LOVAC) || !wcscmp(tabla.polje[y - i][x - i].figura, KRALJICA)) && tabla.polje[y - i][x - i].bojaFigure == BELO && JelUnutarTable(x - i, y - i))
  1992.             return 1;
  1993.         else
  1994.             break;
  1995.     }
  1996.  
  1997.     for(int i = 1; i < 8; i++)
  1998.     {
  1999.         if((!wcscmp(tabla.polje[y - i][x + i].figura, PRAZNO) || (!wcscmp(tabla.polje[y - i][x + i].figura, KRALJ) && tabla.polje[y - i][x + i].bojaFigure == CRNO)) && JelUnutarTable(x + i, y - i));
  2000.         else if((!wcscmp(tabla.polje[y - i][x + i].figura, LOVAC) || !wcscmp(tabla.polje[y - i][x + i].figura, KRALJICA)) && tabla.polje[y - i][x + i].bojaFigure == BELO && JelUnutarTable(x + i, y - i))
  2001.             return 1;
  2002.         else
  2003.             break;
  2004.     }
  2005.  
  2006.     for(int i = 1; i < 8; i++)
  2007.     {
  2008.         if((!wcscmp(tabla.polje[y + i][x - i].figura, PRAZNO) || (!wcscmp(tabla.polje[y + i][x - i].figura, KRALJ) && tabla.polje[y + i][x - i].bojaFigure == CRNO)) && JelUnutarTable(x - i, y + i));
  2009.         else if((!wcscmp(tabla.polje[y + i][x - i].figura, LOVAC) || !wcscmp(tabla.polje[y + i][x - i].figura, KRALJICA)) && tabla.polje[y + i][x - i].bojaFigure == BELO && JelUnutarTable(x - i, y + i))
  2010.             return 1;
  2011.         else
  2012.             break;
  2013.     }
  2014.  
  2015.     for(int i = 1; i < 8; i++)
  2016.     {
  2017.         if((!wcscmp(tabla.polje[y + i][x + i].figura, PRAZNO) || (!wcscmp(tabla.polje[y + i][x + i].figura, KRALJ) && tabla.polje[y + i][x + i].bojaFigure == CRNO)) && JelUnutarTable(x + i, y + i));
  2018.         else if((!wcscmp(tabla.polje[y + i][x + i].figura, LOVAC) || !wcscmp(tabla.polje[y + i][x + i].figura, KRALJICA)) && tabla.polje[y + i][x + i].bojaFigure == BELO && JelUnutarTable(x + i, y + i))
  2019.             return 1;
  2020.         else
  2021.             break;
  2022.     }
  2023.  
  2024.     if(!wcscmp(tabla.polje[y][x - 1].figura, KRALJ) && tabla.polje[y][x - 1].bojaFigure == BELO && JelUnutarTable(x - 1, y))
  2025.         return 1;
  2026.  
  2027.     if(!wcscmp(tabla.polje[y][x + 1].figura, KRALJ) && tabla.polje[y][x + 1].bojaFigure == BELO && JelUnutarTable(x + 1, y))
  2028.         return 1;
  2029.  
  2030.     if(!wcscmp(tabla.polje[y - 1][x].figura, KRALJ) && tabla.polje[y - 1][x].bojaFigure == BELO && JelUnutarTable(x, y - 1))
  2031.         return 1;
  2032.  
  2033.     if(!wcscmp(tabla.polje[y + 1][x].figura, KRALJ) && tabla.polje[y + 1][x].bojaFigure == BELO && JelUnutarTable(x, y + 1))
  2034.         return 1;
  2035.  
  2036.     if(!wcscmp(tabla.polje[y - 1][x - 1].figura, KRALJ) && tabla.polje[y - 1][x - 1].bojaFigure == BELO && JelUnutarTable(x - 1, y - 1))
  2037.         return 1;
  2038.  
  2039.     if(!wcscmp(tabla.polje[y - 1][x + 1].figura, KRALJ) && tabla.polje[y - 1][x + 1].bojaFigure == BELO && JelUnutarTable(x + 1, y - 1))
  2040.         return 1;
  2041.  
  2042.     if(!wcscmp(tabla.polje[y + 1][x - 1].figura, KRALJ) && tabla.polje[y + 1][x - 1].bojaFigure == BELO && JelUnutarTable(x - 1, y + 1))
  2043.         return 1;
  2044.  
  2045.     if(!wcscmp(tabla.polje[y + 1][x + 1].figura, KRALJ) && tabla.polje[y + 1][x + 1].bojaFigure == BELO && JelUnutarTable(x + 1, y + 1))
  2046.         return 1;
  2047.  
  2048.     return 0;
  2049. }
  2050.  
  2051. short PostaviKralja(Tabla &tabla, int x, int y)
  2052. {
  2053.     short ret = 0;
  2054.  
  2055.     tabla.polje[y][x].stanjePolja = IZABRANO;
  2056.  
  2057.     if(tabla.polje[y][x].bojaFigure == BELO)
  2058.     {
  2059.         if(!wcscmp(tabla.polje[y - 1][x - 1].figura, PRAZNO) && JelUnutarTable(x - 1, y - 1) && !JelSahBeli(tabla, -1, -1))
  2060.         {
  2061.             wcscpy(tabla.polje[y - 1][x - 1].figura, TACKA);
  2062.             tabla.polje[y - 1][x - 1].bojaFigure = ZELENO;
  2063.             ret = 1;
  2064.         }
  2065.         else if(wcscmp(tabla.polje[y - 1][x - 1].figura, PRAZNO) && tabla.polje[y - 1][x - 1].bojaFigure == CRNO && JelUnutarTable(x - 1, y - 1) && !JelSahBeli(tabla, -1, -1))
  2066.         {
  2067.             tabla.polje[y - 1][x - 1].stanjePolja = NAPADNUTO;
  2068.             ret = 1;
  2069.         }
  2070.  
  2071.         if(!wcscmp(tabla.polje[y - 1][x + 1].figura, PRAZNO) && JelUnutarTable(x + 1, y - 1) && !JelSahBeli(tabla, 1, -1))
  2072.         {
  2073.             wcscpy(tabla.polje[y - 1][x + 1].figura, TACKA);
  2074.             tabla.polje[y - 1][x + 1].bojaFigure = ZELENO;
  2075.             ret = 1;
  2076.         }
  2077.         else if(wcscmp(tabla.polje[y - 1][x + 1].figura, PRAZNO) && tabla.polje[y - 1][x + 1].bojaFigure == CRNO && JelUnutarTable(x + 1, y - 1) && !JelSahBeli(tabla, 1, -1))
  2078.         {
  2079.             tabla.polje[y - 1][x + 1].stanjePolja = NAPADNUTO;
  2080.             ret = 1;
  2081.         }
  2082.  
  2083.         if(!wcscmp(tabla.polje[y + 1][x - 1].figura, PRAZNO) && JelUnutarTable(x - 1, y + 1) && !JelSahBeli(tabla, -1, 1))
  2084.         {
  2085.             wcscpy(tabla.polje[y + 1][x - 1].figura, TACKA);
  2086.             tabla.polje[y + 1][x - 1].bojaFigure = ZELENO;
  2087.             ret = 1;
  2088.         }
  2089.         else if(wcscmp(tabla.polje[y + 1][x - 1].figura, PRAZNO) && tabla.polje[y + 1][x - 1].bojaFigure == CRNO && JelUnutarTable(x - 1, y + 1) && !JelSahBeli(tabla, -1, 1))
  2090.         {
  2091.             tabla.polje[y + 1][x - 1].stanjePolja = NAPADNUTO;
  2092.             ret = 1;
  2093.         }
  2094.  
  2095.         if(!wcscmp(tabla.polje[y + 1][x + 1].figura, PRAZNO) && JelUnutarTable(x + 1, y + 1) && !JelSahBeli(tabla, 1, 1))
  2096.         {
  2097.             wcscpy(tabla.polje[y + 1][x + 1].figura, TACKA);
  2098.             tabla.polje[y + 1][x + 1].bojaFigure = ZELENO;
  2099.             ret = 1;
  2100.         }
  2101.         else if(wcscmp(tabla.polje[y + 1][x + 1].figura, PRAZNO) && tabla.polje[y + 1][x + 1].bojaFigure == CRNO && JelUnutarTable(x + 1, y + 1) && !JelSahBeli(tabla, 1, 1))
  2102.         {
  2103.             tabla.polje[y + 1][x + 1].stanjePolja = NAPADNUTO;
  2104.             ret = 1;
  2105.         }
  2106.  
  2107.         if(!wcscmp(tabla.polje[y][x + 1].figura, PRAZNO) && JelUnutarTable(x + 1, y) && !JelSahBeli(tabla, 1, 0))
  2108.         {
  2109.             wcscpy(tabla.polje[y][x + 1].figura, TACKA);
  2110.             tabla.polje[y][x + 1].bojaFigure = ZELENO;
  2111.             ret = 1;
  2112.         }
  2113.         else if(wcscmp(tabla.polje[y][x + 1].figura, PRAZNO) && tabla.polje[y][x + 1].bojaFigure == CRNO && JelUnutarTable(x + 1, y) && !JelSahBeli(tabla, 1, 0))
  2114.         {
  2115.             tabla.polje[y][x + 1].stanjePolja = NAPADNUTO;
  2116.             ret = 1;
  2117.         }
  2118.  
  2119.         if(!wcscmp(tabla.polje[y + 1][x].figura, PRAZNO) && JelUnutarTable(x, y + 1) && !JelSahBeli(tabla, 0, 1))
  2120.         {
  2121.             wcscpy(tabla.polje[y + 1][x].figura, TACKA);
  2122.             tabla.polje[y + 1][x].bojaFigure = ZELENO;
  2123.             ret = 1;
  2124.         }
  2125.         else if(wcscmp(tabla.polje[y + 1][x].figura, PRAZNO) && tabla.polje[y + 1][x].bojaFigure == CRNO && JelUnutarTable(x, y + 1) && !JelSahBeli(tabla, 0, 1))
  2126.         {
  2127.             tabla.polje[y + 1][x].stanjePolja = NAPADNUTO;
  2128.             ret = 1;
  2129.         }
  2130.  
  2131.         if(!wcscmp(tabla.polje[y][x - 1].figura, PRAZNO) && JelUnutarTable(x - 1, y) && !JelSahBeli(tabla, -1, 0))
  2132.         {
  2133.             wcscpy(tabla.polje[y][x - 1].figura, TACKA);
  2134.             tabla.polje[y][x - 1].bojaFigure = ZELENO;
  2135.             ret = 1;
  2136.         }
  2137.         else if(wcscmp(tabla.polje[y][x - 1].figura, PRAZNO) && tabla.polje[y][x - 1].bojaFigure == CRNO && JelUnutarTable(x - 1, y) && !JelSahBeli(tabla, -1, 0))
  2138.         {
  2139.             tabla.polje[y][x - 1].stanjePolja = NAPADNUTO;
  2140.             ret = 1;
  2141.         }
  2142.  
  2143.         if(!wcscmp(tabla.polje[y - 1][x].figura, PRAZNO) && JelUnutarTable(x, y - 1) && !JelSahBeli(tabla, 0, -1))
  2144.         {
  2145.             wcscpy(tabla.polje[y - 1][x].figura, TACKA);
  2146.             tabla.polje[y - 1][x].bojaFigure = ZELENO;
  2147.             ret = 1;
  2148.         }
  2149.         else if(wcscmp(tabla.polje[y - 1][x].figura, PRAZNO) && tabla.polje[y - 1][x].bojaFigure == CRNO && JelUnutarTable(x, y - 1) && !JelSahBeli(tabla, 0, -1))
  2150.         {
  2151.             tabla.polje[y - 1][x].stanjePolja = NAPADNUTO;
  2152.             ret = 1;
  2153.         }
  2154.  
  2155.         if(tabla.malarbeli == UKLJUCENO && !wcscmp(tabla.polje[7][5].figura, TACKA) && !wcscmp(tabla.polje[7][6].figura, PRAZNO) && !JelSahBeli(tabla, 0, 0) && !JelSahBeli(tabla, 1, 0) && !JelSahBeli(tabla, 2, 0))
  2156.         {
  2157.             wcscpy(tabla.polje[7][6].figura, TACKA);
  2158.             tabla.polje[7][6].bojaFigure = ZELENO;
  2159.             ret = 1;
  2160.         }
  2161.  
  2162.         if(tabla.velikarbeli == UKLJUCENO && !wcscmp(tabla.polje[7][3].figura, TACKA) && !wcscmp(tabla.polje[7][2].figura, PRAZNO) && !wcscmp(tabla.polje[7][1].figura, PRAZNO) && !JelSahBeli(tabla, 0, 0) && !JelSahBeli(tabla, -1, 0) && !JelSahBeli(tabla, -2, 0) && !JelSahBeli(tabla, -3, 0))
  2163.         {
  2164.             wcscpy(tabla.polje[7][1].figura, TACKA);
  2165.             tabla.polje[7][1].bojaFigure = ZELENO;
  2166.             ret = 1;
  2167.         }
  2168.  
  2169.     }
  2170.     else
  2171.     {
  2172.         if(!wcscmp(tabla.polje[y - 1][x - 1].figura, PRAZNO) && JelUnutarTable(x - 1, y - 1) && !JelSahCrni(tabla, -1, -1))
  2173.         {
  2174.             wcscpy(tabla.polje[y - 1][x - 1].figura, TACKA);
  2175.             tabla.polje[y - 1][x - 1].bojaFigure = ZELENO;
  2176.             ret = 1;
  2177.         }
  2178.         else if(wcscmp(tabla.polje[y - 1][x - 1].figura, PRAZNO) && tabla.polje[y - 1][x - 1].bojaFigure == BELO && JelUnutarTable(x - 1, y - 1) && !JelSahCrni(tabla, -1, -1))
  2179.         {
  2180.             tabla.polje[y - 1][x - 1].stanjePolja = NAPADNUTO;
  2181.             ret = 1;
  2182.         }
  2183.  
  2184.         if(!wcscmp(tabla.polje[y - 1][x + 1].figura, PRAZNO) && JelUnutarTable(x + 1, y - 1) && !JelSahCrni(tabla, 1, -1))
  2185.         {
  2186.             wcscpy(tabla.polje[y - 1][x + 1].figura, TACKA);
  2187.             tabla.polje[y - 1][x + 1].bojaFigure = ZELENO;
  2188.             ret = 1;
  2189.         }
  2190.         else if(wcscmp(tabla.polje[y - 1][x + 1].figura, PRAZNO) && tabla.polje[y - 1][x + 1].bojaFigure == BELO && JelUnutarTable(x + 1, y - 1) && !JelSahCrni(tabla, 1, -1))
  2191.         {
  2192.             tabla.polje[y - 1][x + 1].stanjePolja = NAPADNUTO;
  2193.             ret = 1;
  2194.         }
  2195.  
  2196.         if(!wcscmp(tabla.polje[y + 1][x - 1].figura, PRAZNO) && JelUnutarTable(x - 1, y + 1) && !JelSahCrni(tabla, -1, 1))
  2197.         {
  2198.             wcscpy(tabla.polje[y + 1][x - 1].figura, TACKA);
  2199.             tabla.polje[y + 1][x - 1].bojaFigure = ZELENO;
  2200.         }
  2201.         else if(wcscmp(tabla.polje[y + 1][x - 1].figura, PRAZNO) && tabla.polje[y + 1][x - 1].bojaFigure == BELO && JelUnutarTable(x - 1, y + 1) && !JelSahCrni(tabla, -1, 1))
  2202.         {
  2203.             tabla.polje[y + 1][x - 1].stanjePolja = NAPADNUTO;
  2204.             ret = 1;
  2205.         }
  2206.  
  2207.         if(!wcscmp(tabla.polje[y + 1][x + 1].figura, PRAZNO) && JelUnutarTable(x + 1, y + 1) && !JelSahCrni(tabla, 1, 1))
  2208.         {
  2209.             wcscpy(tabla.polje[y + 1][x + 1].figura, TACKA);
  2210.             tabla.polje[y + 1][x + 1].bojaFigure = ZELENO;
  2211.             ret = 1;
  2212.         }
  2213.         else if(wcscmp(tabla.polje[y + 1][x + 1].figura, PRAZNO) && tabla.polje[y + 1][x + 1].bojaFigure == BELO && JelUnutarTable(x + 1, y + 1) && !JelSahCrni(tabla, 1, 1))
  2214.         {
  2215.             tabla.polje[y + 1][x + 1].stanjePolja = NAPADNUTO;
  2216.             ret = 1;
  2217.         }
  2218.  
  2219.         if(!wcscmp(tabla.polje[y][x + 1].figura, PRAZNO) && JelUnutarTable(x + 1, y) && !JelSahCrni(tabla, 1, 0))
  2220.         {
  2221.             wcscpy(tabla.polje[y][x + 1].figura, TACKA);
  2222.             tabla.polje[y][x + 1].bojaFigure = ZELENO;
  2223.             ret = 1;
  2224.         }
  2225.         else if(wcscmp(tabla.polje[y][x + 1].figura, PRAZNO) && tabla.polje[y][x + 1].bojaFigure == BELO && JelUnutarTable(x + 1, y) && !JelSahCrni(tabla, 1, 0))
  2226.         {
  2227.             tabla.polje[y][x + 1].stanjePolja = NAPADNUTO;
  2228.             ret = 1;
  2229.         }
  2230.  
  2231.         if(!wcscmp(tabla.polje[y + 1][x].figura, PRAZNO) && JelUnutarTable(x, y + 1) && !JelSahCrni(tabla, 0, 1))
  2232.         {
  2233.             wcscpy(tabla.polje[y + 1][x].figura, TACKA);
  2234.             tabla.polje[y + 1][x].bojaFigure = ZELENO;
  2235.             ret = 1;
  2236.         }
  2237.         else if(wcscmp(tabla.polje[y + 1][x].figura, PRAZNO) && tabla.polje[y + 1][x].bojaFigure == BELO && JelUnutarTable(x, y + 1) && !JelSahCrni(tabla, 0, 1))
  2238.         {
  2239.             tabla.polje[y + 1][x].stanjePolja = NAPADNUTO;
  2240.             ret = 1;
  2241.         }
  2242.  
  2243.         if(!wcscmp(tabla.polje[y][x - 1].figura, PRAZNO) && JelUnutarTable(x - 1, y) && !JelSahCrni(tabla, -1, 0))
  2244.         {
  2245.             wcscpy(tabla.polje[y][x - 1].figura, TACKA);
  2246.             tabla.polje[y][x - 1].bojaFigure = ZELENO;
  2247.             ret = 1;
  2248.         }
  2249.         else if(wcscmp(tabla.polje[y][x - 1].figura, PRAZNO) && tabla.polje[y][x - 1].bojaFigure == BELO && JelUnutarTable(x - 1, y) && !JelSahCrni(tabla, -1, 0))
  2250.         {
  2251.             tabla.polje[y][x - 1].stanjePolja = NAPADNUTO;
  2252.             ret = 1;
  2253.         }
  2254.  
  2255.         if(!wcscmp(tabla.polje[y - 1][x].figura, PRAZNO) && JelUnutarTable(x, y - 1) && !JelSahCrni(tabla, 0, -1))
  2256.         {
  2257.             wcscpy(tabla.polje[y - 1][x].figura, TACKA);
  2258.             tabla.polje[y - 1][x].bojaFigure = ZELENO;
  2259.             ret = 1;
  2260.         }
  2261.         else if(wcscmp(tabla.polje[y - 1][x].figura, PRAZNO) && tabla.polje[y - 1][x].bojaFigure == BELO && JelUnutarTable(x, y - 1) && !JelSahCrni(tabla, 0, -1))
  2262.         {
  2263.             tabla.polje[y - 1][x].stanjePolja = NAPADNUTO;
  2264.             ret = 1;
  2265.         }
  2266.  
  2267.         if(tabla.malarcrni == UKLJUCENO && !wcscmp(tabla.polje[0][5].figura, TACKA) && !wcscmp(tabla.polje[0][6].figura, PRAZNO) && !JelSahCrni(tabla, 0, 0) && !JelSahCrni(tabla, 1, 0) && !JelSahCrni(tabla, 2, 0))
  2268.         {
  2269.             wcscpy(tabla.polje[0][6].figura, TACKA);
  2270.             tabla.polje[0][6].bojaFigure = ZELENO;
  2271.             ret = 1;
  2272.         }
  2273.  
  2274.         if(tabla.velikarcrni == UKLJUCENO && !wcscmp(tabla.polje[0][3].figura, TACKA) && !wcscmp(tabla.polje[0][2].figura, PRAZNO) && !wcscmp(tabla.polje[0][1].figura, PRAZNO) && !JelSahCrni(tabla, 0, 0) && !JelSahCrni(tabla, -1, 0) && !JelSahCrni(tabla, -2, 0) && !JelSahCrni(tabla, -3, 0))
  2275.         {
  2276.             wcscpy(tabla.polje[0][1].figura, TACKA);
  2277.             tabla.polje[0][1].bojaFigure = ZELENO;
  2278.             ret = 1;
  2279.         }
  2280.     }
  2281.  
  2282.     return ret;
  2283. }
  2284.  
  2285. short PostaviPijuna(Tabla &tabla, int x, int y)
  2286. {
  2287.     short ret = 0;
  2288.  
  2289.     tabla.polje[y][x].stanjePolja = IZABRANO;
  2290.  
  2291.     if(tabla.polje[y][x].bojaFigure == BELO)
  2292.     {
  2293.         if(!wcscmp(tabla.polje[y - 1][x].figura, PRAZNO) && JelUnutarTable(x, y - 1) && !JelSahBeli(StaviFiguruNaXY(tabla, x, y - 1), 0, 0))
  2294.         {
  2295.             wcscpy(tabla.polje[y - 1][x].figura, TACKA);
  2296.             tabla.polje[y - 1][x].bojaFigure = ZELENO;
  2297.             ret = 1;
  2298.         }
  2299.  
  2300.         if(y == 6 && !wcscmp(tabla.polje[y - 2][x].figura, PRAZNO) && !wcscmp(tabla.polje[y - 1][x].figura, TACKA) && JelUnutarTable(x, y - 2) && !JelSahBeli(StaviFiguruNaXY(tabla, x, y - 2), 0, 0))
  2301.         {
  2302.             wcscpy(tabla.polje[y - 2][x].figura, TACKA);
  2303.             tabla.polje[y - 2][x].bojaFigure = ZELENO;
  2304.             ret = 1;
  2305.         }
  2306.  
  2307.         if(wcscmp(tabla.polje[y - 1][x + 1].figura, PRAZNO) && tabla.polje[y - 1][x + 1].bojaFigure == CRNO && JelUnutarTable(x + 1, y - 1) && !JelSahBeli(StaviFiguruNaXY(tabla, x + 1, y - 1), 0, 0))
  2308.         {
  2309.             tabla.polje[y - 1][x + 1].stanjePolja = NAPADNUTO;
  2310.             ret = 1;
  2311.         }
  2312.  
  2313.         if(wcscmp(tabla.polje[y - 1][x - 1].figura, PRAZNO) && tabla.polje[y - 1][x - 1].bojaFigure == CRNO && JelUnutarTable(x - 1, y - 1) && !JelSahBeli(StaviFiguruNaXY(tabla, x - 1, y - 1), 0, 0))
  2314.         {
  2315.             tabla.polje[y - 1][x - 1].stanjePolja = NAPADNUTO;
  2316.             ret = 1;
  2317.         }
  2318.  
  2319.         if(!wcscmp(tabla.polje[y][x + 1].figura, PIJUN) && tabla.polje[y][x + 1].bojaFigure == CRNO && tabla.polje[y][x + 1].anpasan == UKLJUCENO && JelUnutarTable(x + 1, y - 1) && !JelSahBeli(StaviFiguruNaXY(tabla, x + 1, y - 1), 0, 0))
  2320.         {
  2321.             tabla.polje[y - 1][x + 1].stanjePolja = NAPADNUTO;
  2322.             ret = 1;
  2323.         }
  2324.  
  2325.         if(!wcscmp(tabla.polje[y][x - 1].figura, PIJUN) && tabla.polje[y][x - 1].bojaFigure == CRNO && tabla.polje[y][x - 1].anpasan == UKLJUCENO && JelUnutarTable(x - 1, y - 1) && !JelSahBeli(StaviFiguruNaXY(tabla, x - 1, y - 1), 0, 0))
  2326.         {
  2327.             tabla.polje[y - 1][x - 1].stanjePolja = NAPADNUTO;
  2328.             ret = 1;
  2329.         }
  2330.     }
  2331.     else
  2332.     {
  2333.         if(!wcscmp(tabla.polje[y + 1][x].figura, PRAZNO) && JelUnutarTable(x, y + 1) && !JelSahCrni(StaviFiguruNaXY(tabla, x, y + 1), 0, 0))
  2334.         {
  2335.             wcscpy(tabla.polje[y + 1][x].figura, TACKA);
  2336.             tabla.polje[y + 1][x].bojaFigure = ZELENO;
  2337.             ret = 1;
  2338.         }
  2339.  
  2340.         if(y == 1 && !wcscmp(tabla.polje[y + 2][x].figura, PRAZNO) && !wcscmp(tabla.polje[y + 1][x].figura, TACKA) && JelUnutarTable(x, y + 2) && !JelSahCrni(StaviFiguruNaXY(tabla, x, y + 2), 0, 0))
  2341.         {
  2342.             wcscpy(tabla.polje[y + 2][x].figura, TACKA);
  2343.             tabla.polje[y + 2][x].bojaFigure = ZELENO;
  2344.             ret = 1;
  2345.         }
  2346.  
  2347.         if(wcscmp(tabla.polje[y + 1][x + 1].figura, PRAZNO) && tabla.polje[y + 1][x + 1].bojaFigure == BELO && JelUnutarTable(x + 1, y + 1) && !JelSahCrni(StaviFiguruNaXY(tabla, x + 1, y + 1), 0, 0))
  2348.         {
  2349.             tabla.polje[y + 1][x + 1].stanjePolja = NAPADNUTO;
  2350.             ret = 1;
  2351.         }
  2352.  
  2353.         if(wcscmp(tabla.polje[y + 1][x - 1].figura, PRAZNO) && tabla.polje[y + 1][x - 1].bojaFigure == BELO && JelUnutarTable(x - 1, y + 1) && !JelSahCrni(StaviFiguruNaXY(tabla, x - 1, y + 1), 0, 0))
  2354.         {
  2355.             tabla.polje[y + 1][x - 1].stanjePolja = NAPADNUTO;
  2356.             ret = 1;
  2357.         }
  2358.  
  2359.         if(!wcscmp(tabla.polje[y][x - 1].figura, PIJUN) && tabla.polje[y][x - 1].bojaFigure == BELO && tabla.polje[y][x - 1].anpasan == UKLJUCENO && JelUnutarTable(x - 1, y + 1) && !JelSahCrni(StaviFiguruNaXY(tabla, x - 1, y + 1), 0, 0))
  2360.         {
  2361.             tabla.polje[y + 1][x - 1].stanjePolja = NAPADNUTO;
  2362.             ret = 1;
  2363.         }
  2364.  
  2365.         if(!wcscmp(tabla.polje[y][x + 1].figura, PIJUN) && tabla.polje[y][x + 1].bojaFigure == BELO && tabla.polje[y][x + 1].anpasan == UKLJUCENO && JelUnutarTable(x + 1, y + 1) && !JelSahCrni(StaviFiguruNaXY(tabla, x + 1, y + 1), 0, 0))
  2366.         {
  2367.             tabla.polje[y + 1][x + 1].stanjePolja = NAPADNUTO;
  2368.             ret = 1;
  2369.         }
  2370.     }
  2371.  
  2372.     return ret;
  2373. }
  2374.  
  2375. short PostaviKonja(Tabla &tabla, int x, int y)
  2376. {
  2377.     short ret = 0;
  2378.     tabla.polje[y][x].stanjePolja = IZABRANO;
  2379.  
  2380.     if(!wcscmp(tabla.polje[y - 2][x - 1].figura, PRAZNO) && JelUnutarTable(x - 1, y - 2) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x - 1, y - 2), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x - 1, y - 2), 0, 0))))
  2381.     {
  2382.         wcscpy(tabla.polje[y - 2][x - 1].figura, TACKA);
  2383.         tabla.polje[y - 2][x - 1].bojaFigure = ZELENO;
  2384.         ret = 1;
  2385.     }
  2386.     else if(wcscmp(tabla.polje[y - 2][x - 1].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y - 2][x - 1].bojaFigure == CRNO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y - 2][x - 1].bojaFigure == BELO)) && JelUnutarTable(x - 1, y - 2)  && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x - 1, y - 2), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x - 1, y - 2), 0, 0))))
  2387.     {
  2388.         tabla.polje[y - 2][x - 1].stanjePolja = NAPADNUTO;
  2389.         ret = 1;
  2390.     }
  2391.  
  2392.     if(!wcscmp(tabla.polje[y - 2][x + 1].figura, PRAZNO) && JelUnutarTable(x + 1, y - 2) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x + 1, y - 2), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x + 1, y - 2), 0, 0))))
  2393.     {
  2394.         wcscpy(tabla.polje[y - 2][x + 1].figura, TACKA);
  2395.         tabla.polje[y - 2][x + 1].bojaFigure = ZELENO;
  2396.         ret = 1;
  2397.     }
  2398.     else if(wcscmp(tabla.polje[y - 2][x + 1].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y - 2][x + 1].bojaFigure == CRNO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y - 2][x + 1].bojaFigure == BELO)) && JelUnutarTable(x + 1, y - 2)  && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x + 1, y - 2), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x + 1, y - 2), 0, 0))))
  2399.     {
  2400.         tabla.polje[y - 2][x + 1].stanjePolja = NAPADNUTO;
  2401.         ret = 1;
  2402.     }
  2403.  
  2404.     if(!wcscmp(tabla.polje[y - 1][x + 2].figura, PRAZNO) && JelUnutarTable(x + 2, y - 1) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x + 2, y - 1), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x + 2, y - 1), 0, 0))))
  2405.     {
  2406.         wcscpy(tabla.polje[y - 1][x + 2].figura, TACKA);
  2407.         tabla.polje[y - 1][x + 2].bojaFigure = ZELENO;
  2408.         ret = 1;
  2409.     }
  2410.     else if(wcscmp(tabla.polje[y - 1][x + 2].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y - 1][x + 2].bojaFigure == CRNO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y - 1][x + 2].bojaFigure == BELO)) && JelUnutarTable(x + 2, y - 1)  && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x + 2, y - 1), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x + 2, y - 1), 0, 0))))
  2411.     {
  2412.         tabla.polje[y - 1][x + 2].stanjePolja = NAPADNUTO;
  2413.         ret = 1;
  2414.     }
  2415.  
  2416.     if(!wcscmp(tabla.polje[y + 1][x + 2].figura, PRAZNO) && JelUnutarTable(x + 2, y + 1) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x + 2, y + 1), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x + 2, y + 1), 0, 0))))
  2417.     {
  2418.         wcscpy(tabla.polje[y + 1][x + 2].figura, TACKA);
  2419.         tabla.polje[y + 1][x + 2].bojaFigure = ZELENO;
  2420.         ret = 1;
  2421.     }
  2422.     else if(wcscmp(tabla.polje[y + 1][x + 2].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y + 1][x + 2].bojaFigure == CRNO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y + 1][x + 2].bojaFigure == BELO)) && JelUnutarTable(x + 2, y + 1) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x + 2, y + 1), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x + 2, y + 1), 0, 0))))
  2423.     {
  2424.         tabla.polje[y + 1][x + 2].stanjePolja = NAPADNUTO;
  2425.         ret = 1;
  2426.     }
  2427.  
  2428.     if(!wcscmp(tabla.polje[y + 2][x + 1].figura, PRAZNO) && JelUnutarTable(x + 1, y + 2) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x + 1, y + 2), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x + 1, y + 2), 0, 0))))
  2429.     {
  2430.         wcscpy(tabla.polje[y + 2][x + 1].figura, TACKA);
  2431.         tabla.polje[y + 2][x + 1].bojaFigure = ZELENO;
  2432.         ret = 1;
  2433.     }
  2434.     else if(wcscmp(tabla.polje[y + 2][x + 1].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y + 2][x + 1].bojaFigure == CRNO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y + 2][x + 1].bojaFigure == BELO)) && JelUnutarTable(x + 1, y + 2) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x + 1, y + 2), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x + 1, y + 2), 0, 0))))
  2435.     {
  2436.         tabla.polje[y + 2][x + 1].stanjePolja = NAPADNUTO;
  2437.         ret = 1;
  2438.     }
  2439.  
  2440.     if(!wcscmp(tabla.polje[y + 2][x - 1].figura, PRAZNO) && JelUnutarTable(x - 1, y + 2) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x - 1, y + 2), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x - 1, y + 2), 0, 0))))
  2441.     {
  2442.         wcscpy(tabla.polje[y + 2][x - 1].figura, TACKA);
  2443.         tabla.polje[y + 2][x - 1].bojaFigure = ZELENO;
  2444.         ret = 1;
  2445.     }
  2446.     else if(wcscmp(tabla.polje[y + 2][x - 1].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y + 2][x - 1].bojaFigure == CRNO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y + 2][x - 1].bojaFigure == BELO)) && JelUnutarTable(x - 1, y + 2) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x - 1, y + 2), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x - 1, y + 2), 0, 0))))
  2447.     {
  2448.         tabla.polje[y + 2][x - 1].stanjePolja = NAPADNUTO;
  2449.         ret = 1;
  2450.     }
  2451.  
  2452.     if(!wcscmp(tabla.polje[y + 1][x - 2].figura, PRAZNO) && JelUnutarTable(x - 2, y + 1) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x - 2, y + 1), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x - 2, y + 1), 0, 0))))
  2453.     {
  2454.         wcscpy(tabla.polje[y + 1][x - 2].figura, TACKA);
  2455.         tabla.polje[y + 1][x - 2].bojaFigure = ZELENO;
  2456.         ret = 1;
  2457.     }
  2458.     else if(wcscmp(tabla.polje[y + 1][x - 2].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y + 1][x - 2].bojaFigure == CRNO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y + 1][x - 2].bojaFigure == BELO)) && JelUnutarTable(x - 2, y + 1) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x - 2, y + 1), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x - 2, y + 1), 0, 0))))
  2459.     {
  2460.         tabla.polje[y + 1][x - 2].stanjePolja = NAPADNUTO;
  2461.         ret = 1;
  2462.     }
  2463.  
  2464.     if(!wcscmp(tabla.polje[y - 1][x - 2].figura, PRAZNO) && JelUnutarTable(x - 2, y - 1) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x - 2, y - 1), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x - 2, y - 1), 0, 0))))
  2465.     {
  2466.         wcscpy(tabla.polje[y - 1][x - 2].figura, TACKA);
  2467.         tabla.polje[y - 1][x - 2].bojaFigure = ZELENO;
  2468.         ret = 1;
  2469.     }
  2470.     else if(wcscmp(tabla.polje[y - 1][x - 2].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y - 1][x - 2].bojaFigure == CRNO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y - 1][x - 2].bojaFigure == BELO)) && JelUnutarTable(x - 2, y - 1)  && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x - 2, y - 1), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x - 2, y - 1), 0, 0))))
  2471.     {
  2472.         tabla.polje[y - 1][x - 2].stanjePolja = NAPADNUTO;
  2473.         ret = 1;
  2474.     }
  2475.  
  2476.     return ret;
  2477. }
  2478.  
  2479. short PostaviTopa(Tabla &tabla, int x, int y)
  2480. {
  2481.     short ret = 0;
  2482.  
  2483.     tabla.polje[y][x].stanjePolja = IZABRANO;
  2484.  
  2485.     for(int i = 1; i < 8; i++)
  2486.     {
  2487.         if(!wcscmp(tabla.polje[y][x - i].figura, PRAZNO) && JelUnutarTable(x - i, y) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x - i, y), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x - i, y), 0, 0))))
  2488.         {
  2489.             wcscpy(tabla.polje[y][x - i].figura, TACKA);
  2490.             tabla.polje[y][x - i].bojaFigure = ZELENO;
  2491.             ret = 1;
  2492.         }
  2493.         else if(wcscmp(tabla.polje[y][x - i].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y][x - i].bojaFigure == CRNO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y][x - i].bojaFigure == BELO)) && JelUnutarTable(x - i, y) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x - i, y), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x - i, y), 0, 0))))
  2494.         {
  2495.             tabla.polje[y][x - i].stanjePolja = NAPADNUTO;
  2496.             ret = 1;
  2497.             break;
  2498.         }
  2499.         else if(wcscmp(tabla.polje[y][x - i].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y][x - i].bojaFigure == BELO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y][x - i].bojaFigure == CRNO)) && JelUnutarTable(x - i, y))
  2500.             break;
  2501.     }
  2502.  
  2503.     for(int i = 1; i < 8; i++)
  2504.     {
  2505.         if(!wcscmp(tabla.polje[y][x + i].figura, PRAZNO) && JelUnutarTable(x + i, y) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x + i, y), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x + i, y), 0, 0))))
  2506.         {
  2507.             wcscpy(tabla.polje[y][x + i].figura, TACKA);
  2508.             tabla.polje[y][x + i].bojaFigure = ZELENO;
  2509.             ret = 1;
  2510.         }
  2511.         else if(wcscmp(tabla.polje[y][x + i].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y][x + i].bojaFigure == CRNO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y][x + i].bojaFigure == BELO)) && JelUnutarTable(x + i, y) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x + i, y), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x + i, y), 0, 0))))
  2512.         {
  2513.             tabla.polje[y][x + i].stanjePolja = NAPADNUTO;
  2514.             ret = 1;
  2515.             break;
  2516.         }
  2517.         else if(wcscmp(tabla.polje[y][x + i].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y][x + i].bojaFigure == BELO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y][x + i].bojaFigure == CRNO)) && JelUnutarTable(x + i, y))
  2518.             break;
  2519.     }
  2520.  
  2521.     for(int i = 1; i < 8; i++)
  2522.     {
  2523.         if(!wcscmp(tabla.polje[y - i][x].figura, PRAZNO) && JelUnutarTable(x, y - i) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x, y - i), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x, y - i), 0, 0))))
  2524.         {
  2525.             wcscpy(tabla.polje[y - i][x].figura, TACKA);
  2526.             tabla.polje[y - i][x].bojaFigure = ZELENO;
  2527.             ret = 1;
  2528.         }
  2529.         else if(wcscmp(tabla.polje[y - i][x].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y - i][x].bojaFigure == CRNO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y - i][x].bojaFigure == BELO)) && JelUnutarTable(x, y - i) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x, y - i), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x, y - i), 0, 0))))
  2530.         {
  2531.             tabla.polje[y - i][x].stanjePolja = NAPADNUTO;
  2532.             ret = 1;
  2533.             break;
  2534.         }
  2535.         else if(wcscmp(tabla.polje[y - i][x].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y - i][x].bojaFigure == BELO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y - i][x].bojaFigure == CRNO)) && JelUnutarTable(x, y - i))
  2536.             break;
  2537.     }
  2538.  
  2539.     for(int i = 1; i < 8; i++)
  2540.     {
  2541.         if(!wcscmp(tabla.polje[y + i][x].figura, PRAZNO) && JelUnutarTable(x, y + i) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x, y + i), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x, y + i), 0, 0))))
  2542.         {
  2543.             wcscpy(tabla.polje[y + i][x].figura, TACKA);
  2544.             tabla.polje[y + i][x].bojaFigure = ZELENO;
  2545.             ret = 1;
  2546.         }
  2547.         else if(wcscmp(tabla.polje[y + i][x].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y + i][x].bojaFigure == CRNO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y + i][x].bojaFigure == BELO)) && JelUnutarTable(x, y + i) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x, y + i), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x, y + i), 0, 0))))
  2548.         {
  2549.             tabla.polje[y + i][x].stanjePolja = NAPADNUTO;
  2550.             ret = 1;
  2551.             break;
  2552.         }
  2553.         else if(wcscmp(tabla.polje[y + i][x].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y + i][x].bojaFigure == BELO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y + i][x].bojaFigure == CRNO)) && JelUnutarTable(x, y + i))
  2554.             break;
  2555.     }
  2556.  
  2557.     return ret;
  2558. }
  2559.  
  2560. short PostaviLovca(Tabla &tabla, int x, int y)
  2561. {
  2562.     short ret = 0;
  2563.  
  2564.     tabla.polje[y][x].stanjePolja = IZABRANO;
  2565.  
  2566.     for(int i = 1; i < 8; i++)
  2567.     {
  2568.         if(!wcscmp(tabla.polje[y - i][x - i].figura, PRAZNO) && JelUnutarTable(x - i, y - i) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x - i, y - i), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x - i, y - i), 0, 0))))
  2569.         {
  2570.             wcscpy(tabla.polje[y - i][x - i].figura, TACKA);
  2571.             tabla.polje[y - i][x - i].bojaFigure = ZELENO;
  2572.             ret = 1;
  2573.         }
  2574.         else if(wcscmp(tabla.polje[y - i][x - i].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y - i][x - i].bojaFigure == CRNO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y - i][x - i].bojaFigure == BELO)) && JelUnutarTable(x - i, y - i) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x - i, y - i), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x - i, y - i), 0, 0))))
  2575.         {
  2576.             tabla.polje[y - i][x - i].stanjePolja = NAPADNUTO;
  2577.             ret = 1;
  2578.             break;
  2579.         }
  2580.         else if(wcscmp(tabla.polje[y - i][x - i].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y - i][x - i].bojaFigure == BELO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y - i][x - i].bojaFigure == CRNO)) && JelUnutarTable(x - i, y - i))
  2581.             break;
  2582.     }
  2583.  
  2584.     for(int i = 1; i < 8; i++)
  2585.     {
  2586.         if(!wcscmp(tabla.polje[y - i][x + i].figura, PRAZNO) && JelUnutarTable(x + i, y - i) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x + i, y - i), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x + i, y - i), 0, 0))))
  2587.         {
  2588.             wcscpy(tabla.polje[y - i][x + i].figura, TACKA);
  2589.             tabla.polje[y - i][x + i].bojaFigure = ZELENO;
  2590.             ret = 1;
  2591.         }
  2592.         else if(wcscmp(tabla.polje[y - i][x + i].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y - i][x + i].bojaFigure == CRNO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y - i][x + i].bojaFigure == BELO)) && JelUnutarTable(x + i, y - i) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x + i, y - i), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x + i, y - i), 0, 0))))
  2593.         {
  2594.             tabla.polje[y - i][x + i].stanjePolja = NAPADNUTO;
  2595.             ret = 1;
  2596.             break;
  2597.         }
  2598.         else if(wcscmp(tabla.polje[y - i][x + i].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y - i][x + i].bojaFigure == BELO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y - i][x + i].bojaFigure == CRNO)) && JelUnutarTable(x + i, y - i))
  2599.             break;
  2600.     }
  2601.  
  2602.     for(int i = 1; i < 8; i++)
  2603.     {
  2604.         if(!wcscmp(tabla.polje[y + i][x - i].figura, PRAZNO) && JelUnutarTable(x - i, y + i) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x - i, y + i), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x - i, y + i), 0, 0))))
  2605.         {
  2606.             wcscpy(tabla.polje[y + i][x - i].figura, TACKA);
  2607.             tabla.polje[y + i][x - i].bojaFigure = ZELENO;
  2608.             ret = 1;
  2609.         }
  2610.         else if(wcscmp(tabla.polje[y + i][x - i].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y + i][x - i].bojaFigure == CRNO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y + i][x - i].bojaFigure == BELO)) && JelUnutarTable(x - i, y + i) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x - i, y + i), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x - i, y + i), 0, 0))))
  2611.         {
  2612.             tabla.polje[y + i][x - i].stanjePolja = NAPADNUTO;
  2613.             ret = 1;
  2614.             break;
  2615.         }
  2616.         else if(wcscmp(tabla.polje[y + i][x - i].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y + i][x - i].bojaFigure == BELO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y + i][x - i].bojaFigure == CRNO)) && JelUnutarTable(x - i, y + i))
  2617.             break;
  2618.     }
  2619.  
  2620.     for(int i = 1; i < 8; i++)
  2621.     {
  2622.         if(!wcscmp(tabla.polje[y + i][x +  i].figura, PRAZNO) && JelUnutarTable(x + i, y + i) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x + i, y + i), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x + i, y + i), 0, 0))))
  2623.         {
  2624.             wcscpy(tabla.polje[y + i][x + i].figura, TACKA);
  2625.             tabla.polje[y + i][x + i].bojaFigure = ZELENO;
  2626.             ret = 1;
  2627.         }
  2628.         else if(wcscmp(tabla.polje[y + i][x + i].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y + i][x + i].bojaFigure == CRNO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y + i][x + i].bojaFigure == BELO)) && JelUnutarTable(x + i, y + i) && ((tabla.polje[y][x].bojaFigure == BELO && !JelSahBeli(StaviFiguruNaXY(tabla, x + i, y + i), 0, 0)) || (tabla.polje[y][x].bojaFigure == CRNO && !JelSahCrni(StaviFiguruNaXY(tabla, x + i, y + i), 0, 0))))
  2629.         {
  2630.             tabla.polje[y + i][x + i].stanjePolja = NAPADNUTO;
  2631.             ret = 1;
  2632.             break;
  2633.         }
  2634.         else if(wcscmp(tabla.polje[y + i][x + i].figura, PRAZNO) && ((tabla.polje[y][x].bojaFigure == BELO && tabla.polje[y + i][x + i].bojaFigure == BELO) || (tabla.polje[y][x].bojaFigure == CRNO && tabla.polje[y + i][x + i].bojaFigure == CRNO)) && JelUnutarTable(x + i, y + i))
  2635.             break;
  2636.     }
  2637.  
  2638.     return ret;
  2639. }
  2640.  
  2641. short PostaviKraljicu(Tabla &tabla, int x, int y)
  2642. {
  2643.     int ret = 0;
  2644.     ret += PostaviLovca(tabla, x, y);
  2645.     ret += PostaviTopa(tabla, x, y);
  2646.  
  2647.     if(ret != 0)
  2648.         ret = 1;
  2649.  
  2650.     return ret;
  2651. }
  2652.  
  2653. short JelMozeIgratiBeli(Tabla tabla)
  2654. {
  2655.     short ret = 0;
  2656.  
  2657.     for(int y = 0; y < 8; y++)
  2658.         for(int x = 0; x < 8; x++)
  2659.             if(tabla.polje[y][x].bojaFigure == BELO)
  2660.             {
  2661.                 if(!wcscmp(tabla.polje[y][x].figura, KRALJ))
  2662.                 {
  2663.                     ret += PostaviKralja(tabla, x, y);
  2664.  
  2665.                     NoviPotez(tabla);
  2666.                 }
  2667.                 else if(!wcscmp(tabla.polje[y][x].figura, PIJUN))
  2668.                 {
  2669.                     ret += PostaviPijuna(tabla, x, y);
  2670.  
  2671.                     NoviPotez(tabla);
  2672.                 }
  2673.                 else if(!wcscmp(tabla.polje[y][x].figura, KONJ))
  2674.                 {
  2675.                     ret += PostaviKonja(tabla, x, y);
  2676.  
  2677.                     NoviPotez(tabla);
  2678.                 }
  2679.                 else if(!wcscmp(tabla.polje[y][x].figura, TOP))
  2680.                 {
  2681.                     ret += PostaviTopa(tabla, x, y);
  2682.  
  2683.                     NoviPotez(tabla);
  2684.                 }
  2685.                 else if(!wcscmp(tabla.polje[y][x].figura, LOVAC))
  2686.                 {
  2687.                     ret += PostaviLovca(tabla, x, y);
  2688.  
  2689.                     NoviPotez(tabla);
  2690.                 }
  2691.                 else if(!wcscmp(tabla.polje[y][x].figura, KRALJICA))
  2692.                 {
  2693.                     ret += PostaviKraljicu(tabla, x, y);
  2694.  
  2695.                     NoviPotez(tabla);
  2696.                 }
  2697.             }
  2698.  
  2699.     if(ret != 0)
  2700.         ret = 1;
  2701.  
  2702.     return ret;
  2703. }
  2704.  
  2705. short JelMozeIgratiCrni(Tabla tabla)
  2706. {
  2707.     short ret = 0;
  2708.  
  2709.     for(int y = 0; y < 8; y++)
  2710.         for(int x = 0; x < 8; x++)
  2711.             if(tabla.polje[y][x].bojaFigure == CRNO)
  2712.             {
  2713.                 if(!wcscmp(tabla.polje[y][x].figura, KRALJ))
  2714.                 {
  2715.                     ret += PostaviKralja(tabla, x, y);
  2716.  
  2717.                     NoviPotez(tabla);
  2718.                 }
  2719.                 else if(!wcscmp(tabla.polje[y][x].figura, PIJUN))
  2720.                 {
  2721.                     ret += PostaviPijuna(tabla, x, y);
  2722.  
  2723.                     NoviPotez(tabla);
  2724.                 }
  2725.                 else if(!wcscmp(tabla.polje[y][x].figura, KONJ))
  2726.                 {
  2727.                     ret += PostaviKonja(tabla, x, y);
  2728.  
  2729.                     NoviPotez(tabla);
  2730.                 }
  2731.                 else if(!wcscmp(tabla.polje[y][x].figura, TOP))
  2732.                 {
  2733.                     ret += PostaviTopa(tabla, x, y);
  2734.  
  2735.                     NoviPotez(tabla);
  2736.                 }
  2737.                 else if(!wcscmp(tabla.polje[y][x].figura, LOVAC))
  2738.                 {
  2739.                     ret += PostaviLovca(tabla, x, y);
  2740.  
  2741.                     NoviPotez(tabla);
  2742.                 }
  2743.                 else if(!wcscmp(tabla.polje[y][x].figura, KRALJICA))
  2744.                 {
  2745.                     ret += PostaviKraljicu(tabla, x, y);
  2746.  
  2747.                     NoviPotez(tabla);
  2748.                 }
  2749.             }
  2750.  
  2751.     if(ret != 0)
  2752.         ret = 1;
  2753.  
  2754.     return ret;
  2755. }
  2756.  
  2757. short ZameniPijuna()
  2758. {
  2759.     int x, y, pom = 1, izb;
  2760.  
  2761.     HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
  2762.     _setmode(_fileno(stdout), _O_U8TEXT);
  2763.  
  2764.     if(boja == SVETLO)
  2765.         SetConsoleTextAttribute(console, 82);
  2766.     else if(boja == TAMNO)
  2767.         SetConsoleTextAttribute(console, 101);
  2768.     else if(boja == SIVO)
  2769.         SetConsoleTextAttribute(console, 152);
  2770.  
  2771.     gotoxy(8, 14);
  2772.     wprintf(KRALJICA);
  2773.     wprintf(L"    ");
  2774.     wprintf(TOP);
  2775.     wprintf(L"    ");
  2776.     wprintf(LOVAC);
  2777.     wprintf(L"    ");
  2778.     wprintf(KONJ);
  2779.  
  2780.     while(pom)
  2781.     {
  2782.         pom = 0;
  2783.         UcitajKlik(x, y);
  2784.  
  2785.         if((x == 8 || x == 9) && y == 14)
  2786.             izb = 0;
  2787.         else if((x == 14 || x == 15) && y == 14)
  2788.             izb = 1;
  2789.         else if((x == 20 || x == 21) && y == 14)
  2790.             izb = 2;
  2791.         else if((x == 26 || x == 27) && y == 14)
  2792.             izb = 3;
  2793.         else
  2794.             pom = 1;
  2795.     }
  2796.  
  2797.     ObrisiTerminal();
  2798.  
  2799.     return izb;
  2800. }
  2801.  
  2802. int FiguraUBroj(wchar_t figura[])
  2803. {
  2804.     _setmode(_fileno(stdout), _O_U8TEXT);
  2805.  
  2806.     if(!wcscmp(figura, KRALJ))
  2807.         return 0;
  2808.     else if(!wcscmp(figura, KRALJICA))
  2809.         return 1;
  2810.     else if(!wcscmp(figura, TOP))
  2811.         return 2;
  2812.     else if(!wcscmp(figura, LOVAC))
  2813.         return 3;
  2814.     else if(!wcscmp(figura, KONJ))
  2815.         return 4;
  2816.     else if(!wcscmp(figura, PIJUN))
  2817.         return 5;
  2818.     else if(!wcscmp(figura, PRAZNO))
  2819.         return 6;
  2820. }
  2821.  
  2822. wchar_t* BrojUFiguru(int broj)
  2823. {
  2824.     _setmode(_fileno(stdout), _O_U8TEXT);
  2825.  
  2826.     switch(broj)
  2827.     {
  2828.     case 0:
  2829.         return KRALJ;
  2830.  
  2831.     case 1:
  2832.         return KRALJICA;
  2833.  
  2834.     case 2:
  2835.         return TOP;
  2836.  
  2837.     case 3:
  2838.         return LOVAC;
  2839.  
  2840.     case 4:
  2841.         return KONJ;
  2842.  
  2843.     case 5:
  2844.         return PIJUN;
  2845.  
  2846.     case 6:
  2847.         return PRAZNO;
  2848.     }
  2849. }
  2850.  
  2851. vector<short> NapraviSacuvaj(vector<Tabla> istorija)
  2852. {
  2853.     vector<short> memo;
  2854.     memo.clear();
  2855.  
  2856.     for(int a = 0; a <= brPoteza; a++)
  2857.     {
  2858.         memo.push_back(istorija[a].brdesno);
  2859.         memo.push_back(istorija[a].brlevo);
  2860.         memo.push_back(istorija[a].krajigre);
  2861.         memo.push_back(istorija[a].malarbeli);
  2862.         memo.push_back(istorija[a].malarcrni);
  2863.         memo.push_back(istorija[a].velikarbeli);
  2864.         memo.push_back(istorija[a].velikarcrni);
  2865.  
  2866.         for(int i = 0; i < 16; i++)
  2867.         {
  2868.             memo.push_back(FiguraUBroj(istorija[a].levo[i / 2][i % 2].figura));
  2869.             memo.push_back(FiguraUBroj(istorija[a].desno[i / 2][i % 2].figura));
  2870.         }
  2871.  
  2872.         for(int i = 0; i < 8; i++)
  2873.             for(int j = 0; j < 8; j++)
  2874.             {
  2875.                 memo.push_back(istorija[a].polje[i][j].anpasan);
  2876.                 memo.push_back(istorija[a].polje[i][j].bojaFigure);
  2877.                 memo.push_back(FiguraUBroj(istorija[a].polje[i][j].figura));
  2878.                 memo.push_back(istorija[a].polje[i][j].stanjePolja);
  2879.             }
  2880.     }
  2881.  
  2882.     return memo;
  2883. }
  2884.  
  2885. void SacuvajIgru(vector<Tabla> istorija)
  2886. {
  2887.     char ime[18], zn;
  2888.     vector<short> memo;
  2889.     ObrisiTerminal();
  2890.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  2891.     SetConsoleCursorInfo(hConsole, &kursor);
  2892.  
  2893.     if(boja == SVETLO)
  2894.         SetConsoleTextAttribute(hConsole, 82);
  2895.     else if(boja == TAMNO)
  2896.         SetConsoleTextAttribute(hConsole, 101);
  2897.     else if(boja == SIVO)
  2898.         SetConsoleTextAttribute(hConsole, 152);
  2899.  
  2900.     _setmode(_fileno(stdout), _O_TEXT);
  2901.  
  2902.     gotoxy(4, 14);
  2903.     printf("Ime igre:  ");
  2904.  
  2905.     for(int i = 0; i < 18; i++)
  2906.     {
  2907.         fflush(stdin);
  2908.         zn = getch();
  2909.         fflush(stdin);
  2910.  
  2911.         if((zn == 13 && i != 0) || i == 14)
  2912.         {
  2913.             Sleep(100);
  2914.             SakriKursor();
  2915.             ime[i] = '\0';
  2916.             break;
  2917.         }
  2918.         else if(zn == 8)
  2919.         {
  2920.             gotoxy(14 + i, 14);
  2921.             putch(' ');
  2922.             gotoxy(14 + i, 14);
  2923.             i -= 2;
  2924.         }
  2925.         else
  2926.         {
  2927.             gotoxy(15 + i, 14);
  2928.             putch(zn);
  2929.             ime[i] = zn;
  2930.         }
  2931.     }
  2932.  
  2933.     ObrisiTerminal();
  2934.     gotoxy(4, 14);
  2935.  
  2936.     memo = NapraviSacuvaj(istorija);
  2937.  
  2938.     ofstream izlaz (strcat(ime, ".igra"));
  2939.  
  2940.     if(izlaz.is_open())
  2941.     {
  2942.         izlaz << brPoteza;
  2943.  
  2944.         for(int i = 0; i < (brPoteza + 1) * 295; i++)
  2945.         {
  2946.             if(!(i % 295))
  2947.                 izlaz << endl;
  2948.  
  2949.             izlaz << memo[i] << " ";
  2950.         }
  2951.  
  2952.         izlaz.close();
  2953.     }
  2954. }
  2955.  
  2956. void OdaberiVelicinu()
  2957. {
  2958.     velicina = (velicina - 9) / 2;
  2959.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  2960.     ObrisiTerminal();
  2961.  
  2962.     if(boja == SVETLO)
  2963.         SetConsoleTextAttribute(hConsole, 82);
  2964.     else if(boja == TAMNO)
  2965.         SetConsoleTextAttribute(hConsole, 101);
  2966.     else if(boja == SIVO)
  2967.         SetConsoleTextAttribute(hConsole, 152);
  2968.  
  2969.     _setmode(_fileno(stdout), _O_U8TEXT);
  2970.  
  2971.     if(velicina > 9)
  2972.         gotoxy(30, 14);
  2973.     else
  2974.         gotoxy(31, 14);
  2975.  
  2976.     wprintf(L"%d", velicina);
  2977.  
  2978.     gotoxy(4, 14);
  2979.     wprintf(L"Veličina: ");
  2980.  
  2981.     for(int i = 1; i < velicina; i++)
  2982.     {
  2983.         if(boja == SVETLO)
  2984.             SetConsoleTextAttribute(hConsole, 51);
  2985.         else if(boja == TAMNO)
  2986.             SetConsoleTextAttribute(hConsole, 68);
  2987.         else if(boja == SIVO)
  2988.             SetConsoleTextAttribute(hConsole, 170);
  2989.  
  2990.         wprintf(L"█");
  2991.     }
  2992.  
  2993.     if(boja == SVETLO)
  2994.         SetConsoleTextAttribute(hConsole, 102);
  2995.     else if(boja == TAMNO)
  2996.         SetConsoleTextAttribute(hConsole, 119);
  2997.     else if(boja == SIVO)
  2998.         SetConsoleTextAttribute(hConsole, 17);
  2999.  
  3000.     wprintf(L"█");
  3001.  
  3002.     for(int i = 15; i > velicina; i--)
  3003.     {
  3004.         if(boja == SVETLO)
  3005.             SetConsoleTextAttribute(hConsole, 34);
  3006.         else if(boja == TAMNO)
  3007.             SetConsoleTextAttribute(hConsole, 85);
  3008.         else if(boja == SIVO)
  3009.             SetConsoleTextAttribute(hConsole, 136);
  3010.  
  3011.         wprintf(L"█");
  3012.     }
  3013.  
  3014.     DWORD info;
  3015.     INPUT_RECORD input;
  3016.     HANDLE in = GetStdHandle(STD_INPUT_HANDLE);
  3017.     SetConsoleMode(in, ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);
  3018.  
  3019. GOBACK0:
  3020.     ReadConsoleInput(in, &input, 1, &info);
  3021.  
  3022.     if(input.Event.MouseEvent.dwButtonState != 0x0001)
  3023.     {
  3024. GOBACK:
  3025.         ReadConsoleInput(in, &input, 1, &info);
  3026.  
  3027.         if(input.Event.MouseEvent.dwButtonState == 0x0001 && input.Event.MouseEvent.dwMousePosition.Y == 14 && input.Event.MouseEvent.dwMousePosition.X > 13 && input.Event.MouseEvent.dwMousePosition.X < 29)
  3028.         {
  3029. GOBACK2:
  3030.             ReadConsoleInput(in, &input, 1, &info);
  3031.  
  3032.             velicina = input.Event.MouseEvent.dwMousePosition.X - 13;
  3033.  
  3034.             if(velicina < 1)
  3035.                 velicina = 1;
  3036.  
  3037.             if(velicina > 15)
  3038.                 velicina = 15;
  3039.  
  3040.             if(boja == SVETLO)
  3041.                 SetConsoleTextAttribute(hConsole, 82);
  3042.             else if(boja == TAMNO)
  3043.                 SetConsoleTextAttribute(hConsole, 101);
  3044.             else if(boja == SIVO)
  3045.                 SetConsoleTextAttribute(hConsole, 152);
  3046.  
  3047.             gotoxy(30, 14);
  3048.  
  3049.             if(velicina < 10)
  3050.                 wprintf(L" ");
  3051.  
  3052.             wprintf(L"%d", velicina);
  3053.  
  3054.             gotoxy(14, 14);
  3055.  
  3056.             for(int i = 1; i < velicina; i++)
  3057.             {
  3058.                 if(boja == SVETLO)
  3059.                     SetConsoleTextAttribute(hConsole, 51);
  3060.                 else if(boja == TAMNO)
  3061.                     SetConsoleTextAttribute(hConsole, 68);
  3062.                 else if(boja == SIVO)
  3063.                     SetConsoleTextAttribute(hConsole, 170);
  3064.  
  3065.                 wprintf(L"█");
  3066.             }
  3067.  
  3068.             if(boja == SVETLO)
  3069.                 SetConsoleTextAttribute(hConsole, 102);
  3070.             else if(boja == TAMNO)
  3071.                 SetConsoleTextAttribute(hConsole, 119);
  3072.             else if(boja == SIVO)
  3073.                 SetConsoleTextAttribute(hConsole, 17);
  3074.  
  3075.             wprintf(L"█");
  3076.  
  3077.             for(int i = 15; i > velicina; i--)
  3078.             {
  3079.                 if(boja == SVETLO)
  3080.                     SetConsoleTextAttribute(hConsole, 34);
  3081.                 else if(boja == TAMNO)
  3082.                     SetConsoleTextAttribute(hConsole, 85);
  3083.                 else if(boja == SIVO)
  3084.                     SetConsoleTextAttribute(hConsole, 136);
  3085.  
  3086.                 wprintf(L"█");
  3087.             }
  3088.  
  3089.             if(input.Event.MouseEvent.dwButtonState == 0x0001)
  3090.                 goto GOBACK2;
  3091.         }
  3092.         else
  3093.             goto GOBACK;
  3094.     }
  3095.     else
  3096.         goto GOBACK0;
  3097.  
  3098.     Sleep(300);
  3099.     ObrisiTerminal();
  3100.     velicina = velicina * 2 + 9;
  3101. }
  3102.  
  3103. void AnimacijaUcitaj()
  3104. {
  3105.     system("MODE 36, 18");
  3106.     PodesiVelicinu(velicina);
  3107.     system("MODE 36, 1");
  3108.  
  3109.     HWND consoleWindow = GetConsoleWindow();
  3110.     HMENU hmenu = GetSystemMenu(consoleWindow, FALSE);
  3111.     EnableMenuItem(hmenu, SC_CLOSE, MF_GRAYED); ////////////////////////////////////////////////////////////////////////////////////////////
  3112.  
  3113.     winlog = GetWindowLong(consoleWindow, GWL_STYLE);
  3114.     SetWindowLong(consoleWindow, GWL_STYLE, winlog & ~WS_MAXIMIZEBOX & ~WS_SIZEBOX & ~WS_VSCROLL);
  3115.     SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),  ENABLE_EXTENDED_FLAGS);
  3116.     _setmode(_fileno(stdout), _O_U8TEXT);
  3117.     SetConsoleTitleW(L"ŠAH");
  3118.     _CONSOLE_SCREEN_BUFFER_INFOEX info;
  3119.     info.cbSize = sizeof(info);
  3120.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  3121.     GetConsoleScreenBufferInfoEx(hConsole, &info);
  3122.  
  3123.     info.ColorTable[2] = RGB(198, 175, 141);
  3124.     info.ColorTable[3] = RGB(114, 71, 56);
  3125.  
  3126.     SetConsoleScreenBufferInfoEx(hConsole, &info);
  3127.     SakriKursor();
  3128.  
  3129.     system("color 23");
  3130.  
  3131.     char str[20];
  3132.  
  3133.     for(int i = 1; i < 18; i++)
  3134.     {
  3135.         sprintf(str, "MODE 36, %d", i);
  3136.         system(str);
  3137.  
  3138.         if(_kbhit())
  3139.             goto KRAJ;
  3140.     }
  3141.  
  3142.     Sleep(200);
  3143.  
  3144.     if(_kbhit())
  3145.         goto KRAJ;
  3146.  
  3147.     gotoxy(6, 2);
  3148.     wprintf(L"Najbolja igrica na svetu");
  3149.     gotoxy(12, 4);
  3150.     wprintf(L"se učitava...");
  3151.  
  3152.     for(int i = 0; i < 2; i++)
  3153.     {
  3154.         if(_kbhit())
  3155.             goto KRAJ;
  3156.  
  3157.         gotoxy(17, 8);
  3158.         wprintf(L"●");
  3159.         Sleep(300);
  3160.  
  3161.         if(_kbhit())
  3162.             goto KRAJ;
  3163.  
  3164.         gotoxy(21, 9);
  3165.         wprintf(L"●");
  3166.         Sleep(270);
  3167.  
  3168.         if(_kbhit())
  3169.             goto KRAJ;
  3170.  
  3171.         gotoxy(23, 11);
  3172.         wprintf(L"●");
  3173.         Sleep(200);
  3174.  
  3175.         if(_kbhit())
  3176.             goto KRAJ;
  3177.  
  3178.         gotoxy(21, 13);
  3179.         wprintf(L"●");
  3180.         Sleep(120);
  3181.  
  3182.         if(_kbhit())
  3183.             goto KRAJ;
  3184.  
  3185.         gotoxy(17, 14);
  3186.         wprintf(L"●");
  3187.         Sleep(140);
  3188.  
  3189.         if(_kbhit())
  3190.             goto KRAJ;
  3191.  
  3192.         gotoxy(13, 13);
  3193.         wprintf(L"●");
  3194.         Sleep(155);
  3195.  
  3196.         if(_kbhit())
  3197.             goto KRAJ;
  3198.  
  3199.         gotoxy(11, 11);
  3200.         wprintf(L"●");
  3201.         Sleep(170);
  3202.  
  3203.         if(_kbhit())
  3204.             goto KRAJ;
  3205.  
  3206.         gotoxy(13, 9);
  3207.         wprintf(L"●");
  3208.         Sleep(310);
  3209.  
  3210.         if(_kbhit())
  3211.             goto KRAJ;
  3212.  
  3213.         gotoxy(21, 9);
  3214.         wprintf(L" ");
  3215.         Sleep(300);
  3216.  
  3217.         if(_kbhit())
  3218.             goto KRAJ;
  3219.  
  3220.         gotoxy(23, 11);
  3221.         wprintf(L" ");
  3222.         Sleep(270);
  3223.  
  3224.         if(_kbhit())
  3225.             goto KRAJ;
  3226.  
  3227.         gotoxy(21, 13);
  3228.         wprintf(L" ");
  3229.         Sleep(200);
  3230.  
  3231.         if(_kbhit())
  3232.             goto KRAJ;
  3233.  
  3234.         gotoxy(17, 14);
  3235.         wprintf(L" ");
  3236.         Sleep(120);
  3237.  
  3238.         if(_kbhit())
  3239.             goto KRAJ;
  3240.  
  3241.         gotoxy(13, 13);
  3242.         wprintf(L" ");
  3243.         Sleep(140);
  3244.  
  3245.         if(_kbhit())
  3246.             goto KRAJ;
  3247.  
  3248.         gotoxy(11, 11);
  3249.         wprintf(L" ");
  3250.         Sleep(155);
  3251.  
  3252.         if(_kbhit())
  3253.             goto KRAJ;
  3254.  
  3255.         gotoxy(13, 9);
  3256.         wprintf(L" ");
  3257.         Sleep(310);
  3258.  
  3259.         if(_kbhit())
  3260.             goto KRAJ;
  3261.  
  3262.         if(i)
  3263.         {
  3264.             if(_kbhit())
  3265.                 goto KRAJ;
  3266.  
  3267.             gotoxy(17, 8);
  3268.             wprintf(L"●");
  3269.             Sleep(300);
  3270.  
  3271.             if(_kbhit())
  3272.                 goto KRAJ;
  3273.  
  3274.             gotoxy(21, 9);
  3275.             wprintf(L"●");
  3276.             Sleep(270);
  3277.  
  3278.             if(_kbhit())
  3279.                 goto KRAJ;
  3280.  
  3281.             gotoxy(23, 11);
  3282.             wprintf(L"●");
  3283.             Sleep(200);
  3284.  
  3285.             if(_kbhit())
  3286.                 goto KRAJ;
  3287.  
  3288.             gotoxy(21, 13);
  3289.             wprintf(L"●");
  3290.  
  3291.             Sleep(600);
  3292.         }
  3293.  
  3294.     }
  3295.  
  3296. KRAJ:
  3297.     ;
  3298. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement