Advertisement
Momir

ČAH v1.0.3

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