Advertisement
Momir

ČAH v1.2.0 (VS edition)

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