Advertisement
Momir

ČAH v1.2.3 (VS edition)

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