Advertisement
Momir

ČAH v1.2.1 (VS edition)

Jan 24th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 103.98 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  Terminal Game Developer");
  413.             wprintf(L"\n\n\n\n  Verzija: 1.2.1");
  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.     lResult = RegDeleteKey(hKeyRoot, lpSubKey);
  1590.  
  1591.     if (lResult == ERROR_SUCCESS)
  1592.         return TRUE;
  1593.  
  1594.     lResult = RegOpenKeyEx(hKeyRoot, lpSubKey, 0, KEY_READ, &hKey);
  1595.  
  1596.     if (lResult != ERROR_SUCCESS)
  1597.     {
  1598.         if (lResult == ERROR_FILE_NOT_FOUND) {
  1599.             printf("Key not found.\n");
  1600.             return TRUE;
  1601.         }
  1602.         else {
  1603.             printf("Error opening key.\n");
  1604.             return FALSE;
  1605.         }
  1606.     }
  1607.  
  1608.     lpEnd = lpSubKey + lstrlen(lpSubKey);
  1609.  
  1610.     if (*(lpEnd - 1) != TEXT('\\'))
  1611.     {
  1612.         *lpEnd = TEXT('\\');
  1613.         lpEnd++;
  1614.         *lpEnd = TEXT('\0');
  1615.     }
  1616.  
  1617.     dwSize = MAX_PATH;
  1618.     lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL,
  1619.         NULL, NULL, &ftWrite);
  1620.  
  1621.     if (lResult == ERROR_SUCCESS)
  1622.     {
  1623.         do {
  1624.  
  1625.             *lpEnd = TEXT('\0');
  1626.             StringCchCat(lpSubKey, MAX_PATH * 2, szName);
  1627.  
  1628.             if (!RegDelnodeRecurse(hKeyRoot, lpSubKey)) {
  1629.                 break;
  1630.             }
  1631.  
  1632.             dwSize = MAX_PATH;
  1633.  
  1634.             lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL,
  1635.                 NULL, NULL, &ftWrite);
  1636.  
  1637.         } while (lResult == ERROR_SUCCESS);
  1638.     }
  1639.  
  1640.     lpEnd--;
  1641.     *lpEnd = TEXT('\0');
  1642.  
  1643.     RegCloseKey(hKey);
  1644.  
  1645.     lResult = RegDeleteKey(hKeyRoot, lpSubKey);
  1646.  
  1647.     if (lResult == ERROR_SUCCESS)
  1648.         return TRUE;
  1649.  
  1650.     return FALSE;
  1651. }
  1652.  
  1653. void ObrisiTerminal()
  1654. {
  1655.     HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
  1656.     _setmode(_fileno(stdout), _O_U8TEXT);
  1657.  
  1658.     if (boja == SVETLO)
  1659.         SetConsoleTextAttribute(console, 85);
  1660.     else if (boja == TAMNO)
  1661.         SetConsoleTextAttribute(console, 102);
  1662.     else if (boja == SIVO)
  1663.         SetConsoleTextAttribute(console, 153);
  1664.  
  1665.     gotoxy(2, 13);
  1666.     wprintf(L"████████████████████████████████");
  1667.     gotoxy(2, 14);
  1668.     wprintf(L"████████████████████████████████");
  1669.     gotoxy(2, 15);
  1670.     wprintf(L"████████████████████████████████");
  1671. }
  1672.  
  1673. Tabla StaviFiguruNaXY(Tabla tabla, int x, int y)
  1674. {
  1675.     int xizb, yizb;
  1676.     PozicijaIzabranog(xizb, yizb, tabla);
  1677.     wcscpy(tabla.polje[y][x].figura, tabla.polje[yizb][xizb].figura);
  1678.     wcscpy(tabla.polje[yizb][xizb].figura, PRAZNO);
  1679.     tabla.polje[y][x].bojaFigure = tabla.polje[yizb][xizb].bojaFigure;
  1680.     NoviPotez(tabla);
  1681.  
  1682.     return tabla;
  1683. }
  1684.  
  1685. short JelSahBeli(Tabla tabla, int xpomeraj, int ypomeraj)
  1686. {
  1687.     int x = 0, y = 0;
  1688.  
  1689.     for (int i = 0; i < 64; i++)
  1690.     {
  1691.         if (!wcscmp(tabla.polje[i / 8][i % 8].figura, KRALJ) && tabla.polje[i / 8][i % 8].bojaFigure == BELO)
  1692.         {
  1693.             if (JelUnutarTable(i % 8 + xpomeraj, i / 8 + ypomeraj))
  1694.             {
  1695.                 y = i / 8 + ypomeraj;
  1696.                 x = i % 8 + xpomeraj;
  1697.             }
  1698.             else
  1699.             {
  1700.                 x = i % 8;
  1701.                 y = i / 8;
  1702.             }
  1703.  
  1704.             break;
  1705.         }
  1706.     }
  1707.  
  1708.     if (!wcscmp(tabla.polje[y - 1][x + 1].figura, PIJUN) && tabla.polje[y - 1][x + 1].bojaFigure == CRNO && JelUnutarTable(x + 1, y - 1))
  1709.         return 1;
  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 - 2][x - 1].figura, KONJ) && tabla.polje[y - 2][x - 1].bojaFigure == CRNO && JelUnutarTable(x - 1, y - 2))
  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 - 1][x + 2].figura, KONJ) && tabla.polje[y - 1][x + 2].bojaFigure == CRNO && JelUnutarTable(x + 2, y - 1))
  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 + 2][x + 1].figura, KONJ) && tabla.polje[y + 2][x + 1].bojaFigure == CRNO && JelUnutarTable(x + 1, y + 2))
  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 + 1][x - 2].figura, KONJ) && tabla.polje[y + 1][x - 2].bojaFigure == CRNO && JelUnutarTable(x - 2, y + 1))
  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.     for (int i = 1; i < 8; i++)
  1739.     {
  1740.         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));
  1741.         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))
  1742.             return 1;
  1743.         else
  1744.             break;
  1745.     }
  1746.  
  1747.     for (int i = 1; i < 8; i++)
  1748.     {
  1749.         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));
  1750.         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))
  1751.             return 1;
  1752.         else
  1753.             break;
  1754.     }
  1755.  
  1756.     for (int i = 1; i < 8; i++)
  1757.     {
  1758.         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));
  1759.         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))
  1760.             return 1;
  1761.         else
  1762.             break;
  1763.     }
  1764.  
  1765.     for (int i = 1; i < 8; i++)
  1766.     {
  1767.         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));
  1768.         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))
  1769.             return 1;
  1770.         else
  1771.             break;
  1772.     }
  1773.  
  1774.     for (int i = 1; i < 8; i++)
  1775.     {
  1776.         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));
  1777.         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))
  1778.             return 1;
  1779.         else
  1780.             break;
  1781.     }
  1782.  
  1783.     for (int i = 1; i < 8; i++)
  1784.     {
  1785.         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));
  1786.         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))
  1787.             return 1;
  1788.         else
  1789.             break;
  1790.     }
  1791.  
  1792.     for (int i = 1; i < 8; i++)
  1793.     {
  1794.         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));
  1795.         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))
  1796.             return 1;
  1797.         else
  1798.             break;
  1799.     }
  1800.  
  1801.     for (int i = 1; i < 8; i++)
  1802.     {
  1803.         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));
  1804.         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))
  1805.             return 1;
  1806.         else
  1807.             break;
  1808.     }
  1809.  
  1810.     if (!wcscmp(tabla.polje[y][x - 1].figura, KRALJ) && tabla.polje[y][x - 1].bojaFigure == CRNO && JelUnutarTable(x - 1, y))
  1811.         return 1;
  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 - 1][x].figura, KRALJ) && tabla.polje[y - 1][x].bojaFigure == CRNO && JelUnutarTable(x, y - 1))
  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 - 1].figura, KRALJ) && tabla.polje[y - 1][x - 1].bojaFigure == CRNO && JelUnutarTable(x - 1, 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.     return 0;
  1835. }
  1836.  
  1837. short JelSahCrni(Tabla tabla, int xpomeraj, int ypomeraj)
  1838. {
  1839.     int x = 0, y = 0;
  1840.  
  1841.     for (int i = 0; i < 64; i++)
  1842.     {
  1843.         if (!wcscmp(tabla.polje[i / 8][i % 8].figura, KRALJ) && tabla.polje[i / 8][i % 8].bojaFigure == CRNO)
  1844.         {
  1845.             if (JelUnutarTable(i % 8 + xpomeraj, i / 8 + ypomeraj))
  1846.             {
  1847.                 y = i / 8 + ypomeraj;
  1848.                 x = i % 8 + xpomeraj;
  1849.             }
  1850.             else
  1851.             {
  1852.                 x = i % 8;
  1853.                 y = i / 8;
  1854.             }
  1855.  
  1856.             break;
  1857.         }
  1858.     }
  1859.  
  1860.     if (!wcscmp(tabla.polje[y + 1][x + 1].figura, PIJUN) && tabla.polje[y + 1][x + 1].bojaFigure == BELO && JelUnutarTable(x + 1, y + 1))
  1861.         return 1;
  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 - 2][x - 1].figura, KONJ) && tabla.polje[y - 2][x - 1].bojaFigure == BELO && JelUnutarTable(x - 1, y - 2))
  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 - 1][x + 2].figura, KONJ) && tabla.polje[y - 1][x + 2].bojaFigure == BELO && JelUnutarTable(x + 2, y - 1))
  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 + 2][x + 1].figura, KONJ) && tabla.polje[y + 2][x + 1].bojaFigure == BELO && JelUnutarTable(x + 1, y + 2))
  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 + 1][x - 2].figura, KONJ) && tabla.polje[y + 1][x - 2].bojaFigure == BELO && JelUnutarTable(x - 2, y + 1))
  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.     for (int i = 1; i < 8; i++)
  1891.     {
  1892.         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));
  1893.         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))
  1894.             return 1;
  1895.         else
  1896.             break;
  1897.     }
  1898.  
  1899.     for (int i = 1; i < 8; i++)
  1900.     {
  1901.         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));
  1902.         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))
  1903.             return 1;
  1904.         else
  1905.             break;
  1906.     }
  1907.  
  1908.     for (int i = 1; i < 8; i++)
  1909.     {
  1910.         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));
  1911.         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))
  1912.             return 1;
  1913.         else
  1914.             break;
  1915.     }
  1916.  
  1917.     for (int i = 1; i < 8; i++)
  1918.     {
  1919.         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));
  1920.         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))
  1921.             return 1;
  1922.         else
  1923.             break;
  1924.     }
  1925.  
  1926.     for (int i = 1; i < 8; i++)
  1927.     {
  1928.         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));
  1929.         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))
  1930.             return 1;
  1931.         else
  1932.             break;
  1933.     }
  1934.  
  1935.     for (int i = 1; i < 8; i++)
  1936.     {
  1937.         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));
  1938.         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))
  1939.             return 1;
  1940.         else
  1941.             break;
  1942.     }
  1943.  
  1944.     for (int i = 1; i < 8; i++)
  1945.     {
  1946.         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));
  1947.         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))
  1948.             return 1;
  1949.         else
  1950.             break;
  1951.     }
  1952.  
  1953.     for (int i = 1; i < 8; i++)
  1954.     {
  1955.         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));
  1956.         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))
  1957.             return 1;
  1958.         else
  1959.             break;
  1960.     }
  1961.  
  1962.     if (!wcscmp(tabla.polje[y][x - 1].figura, KRALJ) && tabla.polje[y][x - 1].bojaFigure == BELO && JelUnutarTable(x - 1, y))
  1963.         return 1;
  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 - 1][x].figura, KRALJ) && tabla.polje[y - 1][x].bojaFigure == BELO && JelUnutarTable(x, y - 1))
  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 - 1].figura, KRALJ) && tabla.polje[y - 1][x - 1].bojaFigure == BELO && JelUnutarTable(x - 1, 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.     return 0;
  1987. }
  1988.  
  1989. short PostaviKralja(Tabla& tabla, int x, int y)
  1990. {
  1991.     short ret = 0;
  1992.  
  1993.     tabla.polje[y][x].stanjePolja = IZABRANO;
  1994.  
  1995.     if (tabla.polje[y][x].bojaFigure == BELO)
  1996.     {
  1997.         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))
  1998.         {
  1999.             wcscpy(tabla.polje[y - 1][x - 1].figura, TACKA);
  2000.             tabla.polje[y - 1][x - 1].bojaFigure = ZELENO;
  2001.             ret = 1;
  2002.         }
  2003.         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))
  2004.         {
  2005.             tabla.polje[y - 1][x - 1].stanjePolja = NAPADNUTO;
  2006.             ret = 1;
  2007.         }
  2008.  
  2009.         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))
  2010.         {
  2011.             wcscpy(tabla.polje[y - 1][x + 1].figura, TACKA);
  2012.             tabla.polje[y - 1][x + 1].bojaFigure = ZELENO;
  2013.             ret = 1;
  2014.         }
  2015.         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))
  2016.         {
  2017.             tabla.polje[y - 1][x + 1].stanjePolja = NAPADNUTO;
  2018.             ret = 1;
  2019.         }
  2020.  
  2021.         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))
  2022.         {
  2023.             wcscpy(tabla.polje[y + 1][x - 1].figura, TACKA);
  2024.             tabla.polje[y + 1][x - 1].bojaFigure = ZELENO;
  2025.             ret = 1;
  2026.         }
  2027.         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))
  2028.         {
  2029.             tabla.polje[y + 1][x - 1].stanjePolja = NAPADNUTO;
  2030.             ret = 1;
  2031.         }
  2032.  
  2033.         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))
  2034.         {
  2035.             wcscpy(tabla.polje[y + 1][x + 1].figura, TACKA);
  2036.             tabla.polje[y + 1][x + 1].bojaFigure = ZELENO;
  2037.             ret = 1;
  2038.         }
  2039.         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))
  2040.         {
  2041.             tabla.polje[y + 1][x + 1].stanjePolja = NAPADNUTO;
  2042.             ret = 1;
  2043.         }
  2044.  
  2045.         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))
  2046.         {
  2047.             wcscpy(tabla.polje[y][x + 1].figura, TACKA);
  2048.             tabla.polje[y][x + 1].bojaFigure = ZELENO;
  2049.             ret = 1;
  2050.         }
  2051.         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))
  2052.         {
  2053.             tabla.polje[y][x + 1].stanjePolja = NAPADNUTO;
  2054.             ret = 1;
  2055.         }
  2056.  
  2057.         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))
  2058.         {
  2059.             wcscpy(tabla.polje[y + 1][x].figura, TACKA);
  2060.             tabla.polje[y + 1][x].bojaFigure = ZELENO;
  2061.             ret = 1;
  2062.         }
  2063.         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))
  2064.         {
  2065.             tabla.polje[y + 1][x].stanjePolja = NAPADNUTO;
  2066.             ret = 1;
  2067.         }
  2068.  
  2069.         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))
  2070.         {
  2071.             wcscpy(tabla.polje[y][x - 1].figura, TACKA);
  2072.             tabla.polje[y][x - 1].bojaFigure = ZELENO;
  2073.             ret = 1;
  2074.         }
  2075.         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))
  2076.         {
  2077.             tabla.polje[y][x - 1].stanjePolja = NAPADNUTO;
  2078.             ret = 1;
  2079.         }
  2080.  
  2081.         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))
  2082.         {
  2083.             wcscpy(tabla.polje[y - 1][x].figura, TACKA);
  2084.             tabla.polje[y - 1][x].bojaFigure = ZELENO;
  2085.             ret = 1;
  2086.         }
  2087.         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))
  2088.         {
  2089.             tabla.polje[y - 1][x].stanjePolja = NAPADNUTO;
  2090.             ret = 1;
  2091.         }
  2092.  
  2093.         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))
  2094.         {
  2095.             wcscpy(tabla.polje[7][6].figura, TACKA);
  2096.             tabla.polje[7][6].bojaFigure = ZELENO;
  2097.             ret = 1;
  2098.         }
  2099.  
  2100.         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))
  2101.         {
  2102.             wcscpy(tabla.polje[7][1].figura, TACKA);
  2103.             tabla.polje[7][1].bojaFigure = ZELENO;
  2104.             ret = 1;
  2105.         }
  2106.  
  2107.     }
  2108.     else
  2109.     {
  2110.         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))
  2111.         {
  2112.             wcscpy(tabla.polje[y - 1][x - 1].figura, TACKA);
  2113.             tabla.polje[y - 1][x - 1].bojaFigure = ZELENO;
  2114.             ret = 1;
  2115.         }
  2116.         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))
  2117.         {
  2118.             tabla.polje[y - 1][x - 1].stanjePolja = NAPADNUTO;
  2119.             ret = 1;
  2120.         }
  2121.  
  2122.         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))
  2123.         {
  2124.             wcscpy(tabla.polje[y - 1][x + 1].figura, TACKA);
  2125.             tabla.polje[y - 1][x + 1].bojaFigure = ZELENO;
  2126.             ret = 1;
  2127.         }
  2128.         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))
  2129.         {
  2130.             tabla.polje[y - 1][x + 1].stanjePolja = NAPADNUTO;
  2131.             ret = 1;
  2132.         }
  2133.  
  2134.         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))
  2135.         {
  2136.             wcscpy(tabla.polje[y + 1][x - 1].figura, TACKA);
  2137.             tabla.polje[y + 1][x - 1].bojaFigure = ZELENO;
  2138.             ret = 1;
  2139.         }
  2140.         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))
  2141.         {
  2142.             tabla.polje[y + 1][x - 1].stanjePolja = NAPADNUTO;
  2143.             ret = 1;
  2144.         }
  2145.  
  2146.         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))
  2147.         {
  2148.             wcscpy(tabla.polje[y + 1][x + 1].figura, TACKA);
  2149.             tabla.polje[y + 1][x + 1].bojaFigure = ZELENO;
  2150.             ret = 1;
  2151.         }
  2152.         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))
  2153.         {
  2154.             tabla.polje[y + 1][x + 1].stanjePolja = NAPADNUTO;
  2155.             ret = 1;
  2156.         }
  2157.  
  2158.         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))
  2159.         {
  2160.             wcscpy(tabla.polje[y][x + 1].figura, TACKA);
  2161.             tabla.polje[y][x + 1].bojaFigure = ZELENO;
  2162.             ret = 1;
  2163.         }
  2164.         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))
  2165.         {
  2166.             tabla.polje[y][x + 1].stanjePolja = NAPADNUTO;
  2167.             ret = 1;
  2168.         }
  2169.  
  2170.         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))
  2171.         {
  2172.             wcscpy(tabla.polje[y + 1][x].figura, TACKA);
  2173.             tabla.polje[y + 1][x].bojaFigure = ZELENO;
  2174.             ret = 1;
  2175.         }
  2176.         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))
  2177.         {
  2178.             tabla.polje[y + 1][x].stanjePolja = NAPADNUTO;
  2179.             ret = 1;
  2180.         }
  2181.  
  2182.         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))
  2183.         {
  2184.             wcscpy(tabla.polje[y][x - 1].figura, TACKA);
  2185.             tabla.polje[y][x - 1].bojaFigure = ZELENO;
  2186.             ret = 1;
  2187.         }
  2188.         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))
  2189.         {
  2190.             tabla.polje[y][x - 1].stanjePolja = NAPADNUTO;
  2191.             ret = 1;
  2192.         }
  2193.  
  2194.         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))
  2195.         {
  2196.             wcscpy(tabla.polje[y - 1][x].figura, TACKA);
  2197.             tabla.polje[y - 1][x].bojaFigure = ZELENO;
  2198.             ret = 1;
  2199.         }
  2200.         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))
  2201.         {
  2202.             tabla.polje[y - 1][x].stanjePolja = NAPADNUTO;
  2203.             ret = 1;
  2204.         }
  2205.  
  2206.         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))
  2207.         {
  2208.             wcscpy(tabla.polje[0][6].figura, TACKA);
  2209.             tabla.polje[0][6].bojaFigure = ZELENO;
  2210.             ret = 1;
  2211.         }
  2212.  
  2213.         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))
  2214.         {
  2215.             wcscpy(tabla.polje[0][1].figura, TACKA);
  2216.             tabla.polje[0][1].bojaFigure = ZELENO;
  2217.             ret = 1;
  2218.         }
  2219.     }
  2220.  
  2221.     return ret;
  2222. }
  2223.  
  2224. short PostaviPijuna(Tabla& tabla, int x, int y)
  2225. {
  2226.     short ret = 0;
  2227.  
  2228.     tabla.polje[y][x].stanjePolja = IZABRANO;
  2229.  
  2230.     if (tabla.polje[y][x].bojaFigure == BELO)
  2231.     {
  2232.         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))
  2233.         {
  2234.             wcscpy(tabla.polje[y - 1][x].figura, TACKA);
  2235.             tabla.polje[y - 1][x].bojaFigure = ZELENO;
  2236.             ret = 1;
  2237.         }
  2238.  
  2239.         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))
  2240.         {
  2241.             wcscpy(tabla.polje[y - 2][x].figura, TACKA);
  2242.             tabla.polje[y - 2][x].bojaFigure = ZELENO;
  2243.             ret = 1;
  2244.         }
  2245.  
  2246.         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))
  2247.         {
  2248.             tabla.polje[y - 1][x + 1].stanjePolja = NAPADNUTO;
  2249.             ret = 1;
  2250.         }
  2251.  
  2252.         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))
  2253.         {
  2254.             tabla.polje[y - 1][x - 1].stanjePolja = NAPADNUTO;
  2255.             ret = 1;
  2256.         }
  2257.  
  2258.         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))
  2259.         {
  2260.             tabla.polje[y - 1][x + 1].stanjePolja = NAPADNUTO;
  2261.             ret = 1;
  2262.         }
  2263.  
  2264.         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))
  2265.         {
  2266.             tabla.polje[y - 1][x - 1].stanjePolja = NAPADNUTO;
  2267.             ret = 1;
  2268.         }
  2269.     }
  2270.     else
  2271.     {
  2272.         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))
  2273.         {
  2274.             wcscpy(tabla.polje[y + 1][x].figura, TACKA);
  2275.             tabla.polje[y + 1][x].bojaFigure = ZELENO;
  2276.             ret = 1;
  2277.         }
  2278.  
  2279.         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))
  2280.         {
  2281.             wcscpy(tabla.polje[y + 2][x].figura, TACKA);
  2282.             tabla.polje[y + 2][x].bojaFigure = ZELENO;
  2283.             ret = 1;
  2284.         }
  2285.  
  2286.         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))
  2287.         {
  2288.             tabla.polje[y + 1][x + 1].stanjePolja = NAPADNUTO;
  2289.             ret = 1;
  2290.         }
  2291.  
  2292.         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))
  2293.         {
  2294.             tabla.polje[y + 1][x - 1].stanjePolja = NAPADNUTO;
  2295.             ret = 1;
  2296.         }
  2297.  
  2298.         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))
  2299.         {
  2300.             tabla.polje[y + 1][x - 1].stanjePolja = NAPADNUTO;
  2301.             ret = 1;
  2302.         }
  2303.  
  2304.         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))
  2305.         {
  2306.             tabla.polje[y + 1][x + 1].stanjePolja = NAPADNUTO;
  2307.             ret = 1;
  2308.         }
  2309.     }
  2310.  
  2311.     return ret;
  2312. }
  2313.  
  2314. short PostaviKonja(Tabla& tabla, int x, int y)
  2315. {
  2316.     short ret = 0;
  2317.     tabla.polje[y][x].stanjePolja = IZABRANO;
  2318.  
  2319.     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))))
  2320.     {
  2321.         wcscpy(tabla.polje[y - 2][x - 1].figura, TACKA);
  2322.         tabla.polje[y - 2][x - 1].bojaFigure = ZELENO;
  2323.         ret = 1;
  2324.     }
  2325.     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))))
  2326.     {
  2327.         tabla.polje[y - 2][x - 1].stanjePolja = NAPADNUTO;
  2328.         ret = 1;
  2329.     }
  2330.  
  2331.     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))))
  2332.     {
  2333.         wcscpy(tabla.polje[y - 2][x + 1].figura, TACKA);
  2334.         tabla.polje[y - 2][x + 1].bojaFigure = ZELENO;
  2335.         ret = 1;
  2336.     }
  2337.     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))))
  2338.     {
  2339.         tabla.polje[y - 2][x + 1].stanjePolja = NAPADNUTO;
  2340.         ret = 1;
  2341.     }
  2342.  
  2343.     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))))
  2344.     {
  2345.         wcscpy(tabla.polje[y - 1][x + 2].figura, TACKA);
  2346.         tabla.polje[y - 1][x + 2].bojaFigure = ZELENO;
  2347.         ret = 1;
  2348.     }
  2349.     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))))
  2350.     {
  2351.         tabla.polje[y - 1][x + 2].stanjePolja = NAPADNUTO;
  2352.         ret = 1;
  2353.     }
  2354.  
  2355.     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))))
  2356.     {
  2357.         wcscpy(tabla.polje[y + 1][x + 2].figura, TACKA);
  2358.         tabla.polje[y + 1][x + 2].bojaFigure = ZELENO;
  2359.         ret = 1;
  2360.     }
  2361.     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))))
  2362.     {
  2363.         tabla.polje[y + 1][x + 2].stanjePolja = NAPADNUTO;
  2364.         ret = 1;
  2365.     }
  2366.  
  2367.     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))))
  2368.     {
  2369.         wcscpy(tabla.polje[y + 2][x + 1].figura, TACKA);
  2370.         tabla.polje[y + 2][x + 1].bojaFigure = ZELENO;
  2371.         ret = 1;
  2372.     }
  2373.     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))))
  2374.     {
  2375.         tabla.polje[y + 2][x + 1].stanjePolja = NAPADNUTO;
  2376.         ret = 1;
  2377.     }
  2378.  
  2379.     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))))
  2380.     {
  2381.         wcscpy(tabla.polje[y + 2][x - 1].figura, TACKA);
  2382.         tabla.polje[y + 2][x - 1].bojaFigure = ZELENO;
  2383.         ret = 1;
  2384.     }
  2385.     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))))
  2386.     {
  2387.         tabla.polje[y + 2][x - 1].stanjePolja = NAPADNUTO;
  2388.         ret = 1;
  2389.     }
  2390.  
  2391.     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))))
  2392.     {
  2393.         wcscpy(tabla.polje[y + 1][x - 2].figura, TACKA);
  2394.         tabla.polje[y + 1][x - 2].bojaFigure = ZELENO;
  2395.         ret = 1;
  2396.     }
  2397.     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))))
  2398.     {
  2399.         tabla.polje[y + 1][x - 2].stanjePolja = NAPADNUTO;
  2400.         ret = 1;
  2401.     }
  2402.  
  2403.     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))))
  2404.     {
  2405.         wcscpy(tabla.polje[y - 1][x - 2].figura, TACKA);
  2406.         tabla.polje[y - 1][x - 2].bojaFigure = ZELENO;
  2407.         ret = 1;
  2408.     }
  2409.     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))))
  2410.     {
  2411.         tabla.polje[y - 1][x - 2].stanjePolja = NAPADNUTO;
  2412.         ret = 1;
  2413.     }
  2414.  
  2415.     return ret;
  2416. }
  2417.  
  2418. short PostaviTopa(Tabla& tabla, int x, int y)
  2419. {
  2420.     short ret = 0;
  2421.  
  2422.     tabla.polje[y][x].stanjePolja = IZABRANO;
  2423.  
  2424.     for (int i = 1; i < 8; i++)
  2425.     {
  2426.         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))))
  2427.         {
  2428.             wcscpy(tabla.polje[y][x - i].figura, TACKA);
  2429.             tabla.polje[y][x - i].bojaFigure = ZELENO;
  2430.             ret = 1;
  2431.         }
  2432.         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))))
  2433.         {
  2434.             tabla.polje[y][x - i].stanjePolja = NAPADNUTO;
  2435.             ret = 1;
  2436.             break;
  2437.         }
  2438.         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))
  2439.             break;
  2440.     }
  2441.  
  2442.     for (int i = 1; i < 8; i++)
  2443.     {
  2444.         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))))
  2445.         {
  2446.             wcscpy(tabla.polje[y][x + i].figura, TACKA);
  2447.             tabla.polje[y][x + i].bojaFigure = ZELENO;
  2448.             ret = 1;
  2449.         }
  2450.         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))))
  2451.         {
  2452.             tabla.polje[y][x + i].stanjePolja = NAPADNUTO;
  2453.             ret = 1;
  2454.             break;
  2455.         }
  2456.         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))
  2457.             break;
  2458.     }
  2459.  
  2460.     for (int i = 1; i < 8; i++)
  2461.     {
  2462.         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))))
  2463.         {
  2464.             wcscpy(tabla.polje[y - i][x].figura, TACKA);
  2465.             tabla.polje[y - i][x].bojaFigure = ZELENO;
  2466.             ret = 1;
  2467.         }
  2468.         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))))
  2469.         {
  2470.             tabla.polje[y - i][x].stanjePolja = NAPADNUTO;
  2471.             ret = 1;
  2472.             break;
  2473.         }
  2474.         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))
  2475.             break;
  2476.     }
  2477.  
  2478.     for (int i = 1; i < 8; i++)
  2479.     {
  2480.         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))))
  2481.         {
  2482.             wcscpy(tabla.polje[y + i][x].figura, TACKA);
  2483.             tabla.polje[y + i][x].bojaFigure = ZELENO;
  2484.             ret = 1;
  2485.         }
  2486.         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))))
  2487.         {
  2488.             tabla.polje[y + i][x].stanjePolja = NAPADNUTO;
  2489.             ret = 1;
  2490.             break;
  2491.         }
  2492.         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))
  2493.             break;
  2494.     }
  2495.  
  2496.     return ret;
  2497. }
  2498.  
  2499. short PostaviLovca(Tabla& tabla, int x, int y) {
  2500.     short ret = 0;
  2501.  
  2502.     tabla.polje[y][x].stanjePolja = IZABRANO;
  2503.  
  2504.     for (int i = 1; i < 8; i++)
  2505.     {
  2506.         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))))
  2507.         {
  2508.             wcscpy(tabla.polje[y - i][x - i].figura, TACKA);
  2509.             tabla.polje[y - i][x - i].bojaFigure = ZELENO;
  2510.             ret = 1;
  2511.         }
  2512.         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))))
  2513.         {
  2514.             tabla.polje[y - i][x - i].stanjePolja = NAPADNUTO;
  2515.             ret = 1;
  2516.             break;
  2517.         }
  2518.         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))
  2519.             break;
  2520.     }
  2521.  
  2522.     for (int i = 1; i < 8; i++)
  2523.     {
  2524.         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))))
  2525.         {
  2526.             wcscpy(tabla.polje[y - i][x + i].figura, TACKA);
  2527.             tabla.polje[y - i][x + i].bojaFigure = ZELENO;
  2528.             ret = 1;
  2529.         }
  2530.         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))))
  2531.         {
  2532.             tabla.polje[y - i][x + i].stanjePolja = NAPADNUTO;
  2533.             ret = 1;
  2534.             break;
  2535.         }
  2536.         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))
  2537.             break;
  2538.     }
  2539.  
  2540.     for (int i = 1; i < 8; i++)
  2541.     {
  2542.         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))))
  2543.         {
  2544.             wcscpy(tabla.polje[y + i][x - i].figura, TACKA);
  2545.             tabla.polje[y + i][x - i].bojaFigure = ZELENO;
  2546.             ret = 1;
  2547.         }
  2548.         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))))
  2549.         {
  2550.             tabla.polje[y + i][x - i].stanjePolja = NAPADNUTO;
  2551.             ret = 1;
  2552.             break;
  2553.         }
  2554.         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))
  2555.             break;
  2556.     }
  2557.  
  2558.     for (int i = 1; i < 8; i++)
  2559.     {
  2560.         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))))
  2561.         {
  2562.             wcscpy(tabla.polje[y + i][x + i].figura, TACKA);
  2563.             tabla.polje[y + i][x + i].bojaFigure = ZELENO;
  2564.             ret = 1;
  2565.         }
  2566.         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))))
  2567.         {
  2568.             tabla.polje[y + i][x + i].stanjePolja = NAPADNUTO;
  2569.             ret = 1;
  2570.             break;
  2571.         }
  2572.         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))
  2573.             break;
  2574.     }
  2575.  
  2576.     return ret;
  2577. }
  2578.  
  2579. short PostaviKraljicu(Tabla& tabla, int x, int y)
  2580. {
  2581.     int ret = 0;
  2582.     ret += PostaviLovca(tabla, x, y);
  2583.     ret += PostaviTopa(tabla, x, y);
  2584.  
  2585.     if (ret != 0)
  2586.         ret = 1;
  2587.  
  2588.     return ret;
  2589. }
  2590.  
  2591. short JelMozeIgratiBeli(Tabla tabla)
  2592. {
  2593.     short ret = 0;
  2594.  
  2595.     for (int y = 0; y < 8; y++)
  2596.         for (int x = 0; x < 8; x++)
  2597.             if (tabla.polje[y][x].bojaFigure == BELO)
  2598.             {
  2599.                 if (!wcscmp(tabla.polje[y][x].figura, KRALJ))
  2600.                 {
  2601.                     ret += PostaviKralja(tabla, x, y);
  2602.  
  2603.                     NoviPotez(tabla);
  2604.                 }
  2605.                 else if (!wcscmp(tabla.polje[y][x].figura, PIJUN))
  2606.                 {
  2607.                     ret += PostaviPijuna(tabla, x, y);
  2608.  
  2609.                     NoviPotez(tabla);
  2610.                 }
  2611.                 else if (!wcscmp(tabla.polje[y][x].figura, KONJ))
  2612.                 {
  2613.                     ret += PostaviKonja(tabla, x, y);
  2614.  
  2615.                     NoviPotez(tabla);
  2616.                 }
  2617.                 else if (!wcscmp(tabla.polje[y][x].figura, TOP))
  2618.                 {
  2619.                     ret += PostaviTopa(tabla, x, y);
  2620.  
  2621.                     NoviPotez(tabla);
  2622.                 }
  2623.                 else if (!wcscmp(tabla.polje[y][x].figura, LOVAC))
  2624.                 {
  2625.                     ret += PostaviLovca(tabla, x, y);
  2626.  
  2627.                     NoviPotez(tabla);
  2628.                 }
  2629.                 else if (!wcscmp(tabla.polje[y][x].figura, KRALJICA))
  2630.                 {
  2631.                     ret += PostaviKraljicu(tabla, x, y);
  2632.  
  2633.                     NoviPotez(tabla);
  2634.                 }
  2635.             }
  2636.  
  2637.     if (ret != 0)
  2638.         ret = 1;
  2639.  
  2640.     return ret;
  2641. }
  2642.  
  2643. short JelMozeIgratiCrni(Tabla tabla)
  2644. {
  2645.     short ret = 0;
  2646.  
  2647.     for (int y = 0; y < 8; y++)
  2648.         for (int x = 0; x < 8; x++)
  2649.             if (tabla.polje[y][x].bojaFigure == CRNO)
  2650.             {
  2651.                 if (!wcscmp(tabla.polje[y][x].figura, KRALJ))
  2652.                 {
  2653.                     ret += PostaviKralja(tabla, x, y);
  2654.  
  2655.                     NoviPotez(tabla);
  2656.                 }
  2657.                 else if (!wcscmp(tabla.polje[y][x].figura, PIJUN))
  2658.                 {
  2659.                     ret += PostaviPijuna(tabla, x, y);
  2660.  
  2661.                     NoviPotez(tabla);
  2662.                 }
  2663.                 else if (!wcscmp(tabla.polje[y][x].figura, KONJ))
  2664.                 {
  2665.                     ret += PostaviKonja(tabla, x, y);
  2666.  
  2667.                     NoviPotez(tabla);
  2668.                 }
  2669.                 else if (!wcscmp(tabla.polje[y][x].figura, TOP))
  2670.                 {
  2671.                     ret += PostaviTopa(tabla, x, y);
  2672.  
  2673.                     NoviPotez(tabla);
  2674.                 }
  2675.                 else if (!wcscmp(tabla.polje[y][x].figura, LOVAC))
  2676.                 {
  2677.                     ret += PostaviLovca(tabla, x, y);
  2678.  
  2679.                     NoviPotez(tabla);
  2680.                 }
  2681.                 else if (!wcscmp(tabla.polje[y][x].figura, KRALJICA))
  2682.                 {
  2683.                     ret += PostaviKraljicu(tabla, x, y);
  2684.  
  2685.                     NoviPotez(tabla);
  2686.                 }
  2687.             }
  2688.  
  2689.     if (ret != 0)
  2690.         ret = 1;
  2691.  
  2692.     return ret;
  2693. }
  2694.  
  2695. short ZameniPijuna()
  2696. {
  2697.     int x, y, pom = 1, izb;
  2698.  
  2699.     HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
  2700.     _setmode(_fileno(stdout), _O_U8TEXT);
  2701.  
  2702.     if (boja == SVETLO)
  2703.         SetConsoleTextAttribute(console, 82);
  2704.     else if (boja == TAMNO)
  2705.         SetConsoleTextAttribute(console, 101);
  2706.     else if (boja == SIVO)
  2707.         SetConsoleTextAttribute(console, 152);
  2708.  
  2709.     gotoxy(8, 14);
  2710.     wprintf(KRALJICA);
  2711.     wprintf(L"    ");
  2712.     wprintf(TOP);
  2713.     wprintf(L"    ");
  2714.     wprintf(LOVAC);
  2715.     wprintf(L"    ");
  2716.     wprintf(KONJ);
  2717.  
  2718.     while (pom)
  2719.     {
  2720.         pom = 0;
  2721.         UcitajKlik(x, y);
  2722.  
  2723.         if ((x == 8 || x == 9) && y == 14)
  2724.             izb = 0;
  2725.         else if ((x == 14 || x == 15) && y == 14)
  2726.             izb = 1;
  2727.         else if ((x == 20 || x == 21) && y == 14)
  2728.             izb = 2;
  2729.         else if ((x == 26 || x == 27) && y == 14)
  2730.             izb = 3;
  2731.         else
  2732.             pom = 1;
  2733.     }
  2734.  
  2735.     ObrisiTerminal();
  2736.  
  2737.     return izb;
  2738. }
  2739.  
  2740. int FiguraUBroj(wchar_t figura[])
  2741. {
  2742.     _setmode(_fileno(stdout), _O_U8TEXT);
  2743.  
  2744.     if (!wcscmp(figura, KRALJ))
  2745.         return 0;
  2746.     else if (!wcscmp(figura, KRALJICA))
  2747.         return 1;
  2748.     else if (!wcscmp(figura, TOP))
  2749.         return 2;
  2750.     else if (!wcscmp(figura, LOVAC))
  2751.         return 3;
  2752.     else if (!wcscmp(figura, KONJ))
  2753.         return 4;
  2754.     else if (!wcscmp(figura, PIJUN))
  2755.         return 5;
  2756.     else if (!wcscmp(figura, PRAZNO))
  2757.         return 6;
  2758.     else if (!wcscmp(figura, TACKA))
  2759.         return 7;
  2760. }
  2761.  
  2762. const wchar_t* BrojUFiguru(int broj)
  2763. {
  2764.     _setmode(_fileno(stdout), _O_U8TEXT);
  2765.  
  2766.     switch (broj)
  2767.     {
  2768.     case 0:
  2769.         return KRALJ;
  2770.  
  2771.     case 1:
  2772.         return KRALJICA;
  2773.  
  2774.     case 2:
  2775.         return TOP;
  2776.  
  2777.     case 3:
  2778.         return LOVAC;
  2779.  
  2780.     case 4:
  2781.         return KONJ;
  2782.  
  2783.     case 5:
  2784.         return PIJUN;
  2785.  
  2786.     case 6:
  2787.         return PRAZNO;
  2788.  
  2789.     case 7:
  2790.         return TACKA;
  2791.     }
  2792. }
  2793.  
  2794. vector<short> NapraviSacuvaj(vector<Tabla> istorija)
  2795. {
  2796.     vector<short> memo;
  2797.     memo.clear();
  2798.  
  2799.     for (int a = 0; a <= brPoteza; a++)
  2800.     {
  2801.         memo.push_back(istorija[a].brdesno);
  2802.         memo.push_back(istorija[a].brlevo);
  2803.         memo.push_back(istorija[a].krajigre);
  2804.         memo.push_back(istorija[a].malarbeli);
  2805.         memo.push_back(istorija[a].malarcrni);
  2806.         memo.push_back(istorija[a].velikarbeli);
  2807.         memo.push_back(istorija[a].velikarcrni);
  2808.  
  2809.         for (int i = 0; i < 16; i++)
  2810.         {
  2811.             memo.push_back(FiguraUBroj(istorija[a].levo[i / 2][i % 2].figura));
  2812.             memo.push_back(FiguraUBroj(istorija[a].desno[i / 2][i % 2].figura));
  2813.         }
  2814.  
  2815.         for (int i = 0; i < 8; i++)
  2816.             for (int j = 0; j < 8; j++)
  2817.             {
  2818.                 memo.push_back(istorija[a].polje[i][j].anpasan);
  2819.                 memo.push_back(istorija[a].polje[i][j].bojaFigure);
  2820.                 memo.push_back(FiguraUBroj(istorija[a].polje[i][j].figura));
  2821.                 memo.push_back(istorija[a].polje[i][j].stanjePolja);
  2822.             }
  2823.     }
  2824.  
  2825.     return memo;
  2826. }
  2827.  
  2828. void SacuvajIgru(vector<Tabla> istorija)
  2829. {
  2830.     char ime[18], zn;
  2831.     vector<short> memo;
  2832.     ObrisiTerminal();
  2833.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  2834.     SetConsoleCursorInfo(hConsole, &kursor);
  2835.  
  2836.     if (boja == SVETLO)
  2837.         SetConsoleTextAttribute(hConsole, 82);
  2838.     else if (boja == TAMNO)
  2839.         SetConsoleTextAttribute(hConsole, 101);
  2840.     else if (boja == SIVO)
  2841.         SetConsoleTextAttribute(hConsole, 152);
  2842.  
  2843.     _setmode(_fileno(stdout), _O_TEXT);
  2844.  
  2845.     gotoxy(4, 14);
  2846.     printf("Ime igre:  ");
  2847.  
  2848.     for (int i = 0; i < 18; i++)
  2849.     {
  2850.         fflush(stdin);
  2851.         zn = getch();
  2852.         fflush(stdin);
  2853.  
  2854.         if ((zn == 13 && i != 0) || i == 14)
  2855.         {
  2856.             Sleep(100);
  2857.             SakriKursor();
  2858.             ime[i] = '\0';
  2859.             break;
  2860.         }
  2861.         else if (zn == 8)
  2862.         {
  2863.             gotoxy(14 + i, 14);
  2864.             putchar(' ');
  2865.             gotoxy(14 + i, 14);
  2866.             i -= 2;
  2867.         }
  2868.         else
  2869.         {
  2870.             gotoxy(15 + i, 14);
  2871.             putchar(zn);
  2872.             ime[i] = zn;
  2873.         }
  2874.     }
  2875.  
  2876.     ObrisiTerminal();
  2877.     gotoxy(4, 14);
  2878.  
  2879.     memo = NapraviSacuvaj(istorija);
  2880.  
  2881.     ofstream izlaz(strcat(ime, ".igra"));
  2882.  
  2883.     if (izlaz.is_open())
  2884.     {
  2885.         izlaz << brPoteza;
  2886.  
  2887.         for (int i = 0; i < (brPoteza + 1) * 295; i++)
  2888.         {
  2889.             if (!(i % 295))
  2890.                 izlaz << endl;
  2891.  
  2892.             izlaz << memo[i] << " ";
  2893.         }
  2894.  
  2895.         izlaz.close();
  2896.     }
  2897. }
  2898.  
  2899. void OdaberiVelicinu()
  2900. {
  2901.     velicina = (velicina - 15) / 2;
  2902.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  2903.     ObrisiTerminal();
  2904.  
  2905.     if (boja == SVETLO)
  2906.         SetConsoleTextAttribute(hConsole, 82);
  2907.     else if (boja == TAMNO)
  2908.         SetConsoleTextAttribute(hConsole, 101);
  2909.     else if (boja == SIVO)
  2910.         SetConsoleTextAttribute(hConsole, 152);
  2911.  
  2912.     _setmode(_fileno(stdout), _O_U8TEXT);
  2913.  
  2914.     if (velicina > 9)
  2915.         gotoxy(30, 14);
  2916.     else
  2917.         gotoxy(31, 14);
  2918.  
  2919.     wprintf(L"%d", velicina);
  2920.  
  2921.     gotoxy(4, 14);
  2922.     wprintf(L"Veličina: ");
  2923.  
  2924.     for (int i = 1; i < velicina; i++)
  2925.     {
  2926.         if (boja == SVETLO)
  2927.             SetConsoleTextAttribute(hConsole, 51);
  2928.         else if (boja == TAMNO)
  2929.             SetConsoleTextAttribute(hConsole, 68);
  2930.         else if (boja == SIVO)
  2931.             SetConsoleTextAttribute(hConsole, 170);
  2932.  
  2933.         wprintf(L"█");
  2934.     }
  2935.  
  2936.     if (boja == SVETLO)
  2937.         SetConsoleTextAttribute(hConsole, 102);
  2938.     else if (boja == TAMNO)
  2939.         SetConsoleTextAttribute(hConsole, 119);
  2940.     else if (boja == SIVO)
  2941.         SetConsoleTextAttribute(hConsole, 17);
  2942.  
  2943.     wprintf(L"█");
  2944.  
  2945.     for (int i = 15; i > velicina; i--)
  2946.     {
  2947.         if (boja == SVETLO)
  2948.             SetConsoleTextAttribute(hConsole, 34);
  2949.         else if (boja == TAMNO)
  2950.             SetConsoleTextAttribute(hConsole, 85);
  2951.         else if (boja == SIVO)
  2952.             SetConsoleTextAttribute(hConsole, 136);
  2953.  
  2954.         wprintf(L"█");
  2955.     }
  2956.  
  2957.     DWORD info;
  2958.     INPUT_RECORD input;
  2959.     HANDLE in = GetStdHandle(STD_INPUT_HANDLE);
  2960.     SetConsoleMode(in, ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);
  2961.  
  2962. GOBACK0:
  2963.     ReadConsoleInput(in, &input, 1, &info);
  2964.  
  2965.     if (input.Event.MouseEvent.dwButtonState != 0x0001)
  2966.     {
  2967.     GOBACK:
  2968.         ReadConsoleInput(in, &input, 1, &info);
  2969.  
  2970.         if (input.Event.MouseEvent.dwButtonState == 0x0001 && input.Event.MouseEvent.dwMousePosition.Y == 14 && input.Event.MouseEvent.dwMousePosition.X > 13 && input.Event.MouseEvent.dwMousePosition.X < 29)
  2971.         {
  2972.         GOBACK2:
  2973.             ReadConsoleInput(in, &input, 1, &info);
  2974.  
  2975.             velicina = input.Event.MouseEvent.dwMousePosition.X - 13;
  2976.  
  2977.             if (velicina < 1)
  2978.                 velicina = 1;
  2979.  
  2980.             if (velicina > 15)
  2981.                 velicina = 15;
  2982.  
  2983.             if (boja == SVETLO)
  2984.                 SetConsoleTextAttribute(hConsole, 82);
  2985.             else if (boja == TAMNO)
  2986.                 SetConsoleTextAttribute(hConsole, 101);
  2987.             else if (boja == SIVO)
  2988.                 SetConsoleTextAttribute(hConsole, 152);
  2989.  
  2990.             gotoxy(30, 14);
  2991.  
  2992.             if (velicina < 10)
  2993.                 wprintf(L" ");
  2994.  
  2995.             wprintf(L"%d", velicina);
  2996.  
  2997.             gotoxy(14, 14);
  2998.  
  2999.             for (int i = 1; i < velicina; i++)
  3000.             {
  3001.                 if (boja == SVETLO)
  3002.                     SetConsoleTextAttribute(hConsole, 51);
  3003.                 else if (boja == TAMNO)
  3004.                     SetConsoleTextAttribute(hConsole, 68);
  3005.                 else if (boja == SIVO)
  3006.                     SetConsoleTextAttribute(hConsole, 170);
  3007.  
  3008.                 wprintf(L"█");
  3009.             }
  3010.  
  3011.             if (boja == SVETLO)
  3012.                 SetConsoleTextAttribute(hConsole, 102);
  3013.             else if (boja == TAMNO)
  3014.                 SetConsoleTextAttribute(hConsole, 119);
  3015.             else if (boja == SIVO)
  3016.                 SetConsoleTextAttribute(hConsole, 17);
  3017.  
  3018.             wprintf(L"█");
  3019.  
  3020.             for (int i = 15; i > velicina; i--)
  3021.             {
  3022.                 if (boja == SVETLO)
  3023.                     SetConsoleTextAttribute(hConsole, 34);
  3024.                 else if (boja == TAMNO)
  3025.                     SetConsoleTextAttribute(hConsole, 85);
  3026.                 else if (boja == SIVO)
  3027.                     SetConsoleTextAttribute(hConsole, 136);
  3028.  
  3029.                 wprintf(L"█");
  3030.             }
  3031.  
  3032.             if (input.Event.MouseEvent.dwButtonState == 0x0001)
  3033.                 goto GOBACK2;
  3034.         }
  3035.         else
  3036.             goto GOBACK;
  3037.     }
  3038.     else
  3039.         goto GOBACK0;
  3040.  
  3041.     Sleep(300);
  3042.     ObrisiTerminal();
  3043.     velicina = velicina * 2 + 15;
  3044. }
  3045.  
  3046. void AnimacijaUcitaj()
  3047. {
  3048.     system("MODE 36, 18");
  3049.     PodesiVelicinu(velicina);
  3050.     system("MODE 36, 1");
  3051.  
  3052.     HWND consoleWindow = GetConsoleWindow();
  3053.     HMENU hmenu = GetSystemMenu(consoleWindow, FALSE);
  3054.     EnableMenuItem(hmenu, SC_CLOSE, MF_GRAYED); ////////////////////////////////////////////////////////////////////////////////////////////
  3055.  
  3056.     winlog = GetWindowLong(consoleWindow, GWL_STYLE);
  3057.     SetWindowLong(consoleWindow, GWL_STYLE, winlog & ~WS_MAXIMIZEBOX & ~WS_SIZEBOX & ~WS_VSCROLL);
  3058.     SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ENABLE_EXTENDED_FLAGS);
  3059.     _setmode(_fileno(stdout), _O_U8TEXT);
  3060.     SetConsoleTitleW(L"ŠAH");
  3061.     _CONSOLE_SCREEN_BUFFER_INFOEX info;
  3062.     info.cbSize = sizeof(info);
  3063.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  3064.     GetConsoleScreenBufferInfoEx(hConsole, &info);
  3065.  
  3066.     info.ColorTable[2] = RGB(198, 175, 141);
  3067.     info.ColorTable[3] = RGB(114, 71, 56);
  3068.  
  3069.     SetConsoleScreenBufferInfoEx(hConsole, &info);
  3070.     SakriKursor();
  3071.  
  3072.     system("color 23");
  3073.  
  3074.     char str[20];
  3075.  
  3076.     for (int i = 1; i < 18; i++)
  3077.     {
  3078.         sprintf(str, "MODE 36, %d", i);
  3079.         system(str);
  3080.         if (_kbhit())
  3081.             return;
  3082.     }
  3083.  
  3084.     Sleep(200);
  3085.     if (_kbhit())
  3086.         return;
  3087.  
  3088.     gotoxy(6, 2);
  3089.     wprintf(L"Najbolja igrica na svetu");
  3090.     gotoxy(12, 4);
  3091.     wprintf(L"se učitava...");
  3092.  
  3093.     for (int i = 0; i < 2; i++)
  3094.     {
  3095.         if (_kbhit())
  3096.             return;
  3097.  
  3098.         gotoxy(17, 8);
  3099.         wprintf(L"● ");
  3100.         Sleep(250);
  3101.  
  3102.         if (_kbhit())
  3103.             return;
  3104.  
  3105.         gotoxy(21, 9);
  3106.         wprintf(L"● ");
  3107.         Sleep(220);
  3108.  
  3109.         if (_kbhit())
  3110.             return;
  3111.  
  3112.         gotoxy(23, 11);
  3113.         wprintf(L"● ");
  3114.         Sleep(150);
  3115.  
  3116.         if (_kbhit())
  3117.             return;
  3118.  
  3119.         gotoxy(21, 13);
  3120.         wprintf(L"● ");
  3121.         Sleep(70);
  3122.  
  3123.         if (_kbhit())
  3124.             return;
  3125.  
  3126.         gotoxy(17, 14);
  3127.         wprintf(L"● ");
  3128.         Sleep(90);
  3129.  
  3130.         if (_kbhit())
  3131.             return;
  3132.  
  3133.         gotoxy(13, 13);
  3134.         wprintf(L"● ");
  3135.         Sleep(105);
  3136.  
  3137.         if (_kbhit())
  3138.             return;
  3139.  
  3140.         gotoxy(11, 11);
  3141.         wprintf(L"● ");
  3142.         Sleep(120);
  3143.  
  3144.         if (_kbhit())
  3145.             return;
  3146.  
  3147.         gotoxy(13, 9);
  3148.         wprintf(L"● ");
  3149.         Sleep(260);
  3150.  
  3151.         if (_kbhit())
  3152.             return;
  3153.  
  3154.         gotoxy(21, 9);
  3155.         wprintf(L"  ");
  3156.         Sleep(250);
  3157.  
  3158.         if (_kbhit())
  3159.             return;
  3160.  
  3161.         gotoxy(23, 11);
  3162.         wprintf(L"  ");
  3163.         Sleep(220);
  3164.  
  3165.         if (_kbhit())
  3166.             return;
  3167.  
  3168.         gotoxy(21, 13);
  3169.         wprintf(L"  ");
  3170.         Sleep(150);
  3171.  
  3172.         if (_kbhit())
  3173.             return;
  3174.  
  3175.         gotoxy(17, 14);
  3176.         wprintf(L"  ");
  3177.         Sleep(70);
  3178.  
  3179.         if (_kbhit())
  3180.             return;
  3181.  
  3182.         gotoxy(13, 13);
  3183.         wprintf(L"  ");
  3184.         Sleep(90);
  3185.  
  3186.         if (_kbhit())
  3187.             return;
  3188.  
  3189.         gotoxy(11, 11);
  3190.         wprintf(L"  ");
  3191.         Sleep(105);
  3192.  
  3193.         if (_kbhit())
  3194.             return;
  3195.  
  3196.         gotoxy(13, 9);
  3197.         wprintf(L"  ");
  3198.         Sleep(260);
  3199.  
  3200.         if (_kbhit())
  3201.             return;
  3202.  
  3203.         if (i)
  3204.         {
  3205.             if (_kbhit())
  3206.                 return;
  3207.  
  3208.             gotoxy(17, 8);
  3209.             wprintf(L"● ");
  3210.             Sleep(250);
  3211.  
  3212.             if (_kbhit())
  3213.                 return;
  3214.  
  3215.             gotoxy(21, 9);
  3216.             wprintf(L"● ");
  3217.             Sleep(220);
  3218.  
  3219.             if (_kbhit())
  3220.                 return;
  3221.  
  3222.             gotoxy(23, 11);
  3223.             wprintf(L"● ");
  3224.             Sleep(150);
  3225.  
  3226.             if (_kbhit())
  3227.                 return;
  3228.  
  3229.             gotoxy(21, 13);
  3230.             wprintf(L"● ");
  3231.  
  3232.             Sleep(550);
  3233.         }
  3234.  
  3235.     }
  3236.  
  3237.     return;
  3238. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement