Advertisement
Momir

ČAH v1.2.2 (VS edition)

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