Advertisement
Momir

ČAH v1.0.1

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