ItsMeLucifer

CasinoRoyal

Apr 5th, 2019
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 25.65 KB | None | 0 0
  1. // ConsoleApplication1.cpp : Ten plik zawiera funkcję „main”. W nim rozpoczyna się i kończy wykonywanie programu.
  2. //
  3.  
  4. #include "pch.h"
  5. #include <iostream>
  6. #include <cstdlib>
  7. #include <ctime>
  8. #include <windows.h>
  9. #include <string>
  10. #include <stdio.h>
  11. #include <clocale>
  12. #include <string.h>
  13. #include <io.h>
  14. #include <fcntl.h>
  15. #include <fstream>
  16. #include <conio.h>
  17. #include <locale.h>
  18. #include <fstream>
  19. #include <sstream>
  20. #include <cmath>
  21.  
  22. using namespace std;
  23. void clear() {
  24.     COORD topLeft = { 0, 0 };
  25.     HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
  26.     CONSOLE_SCREEN_BUFFER_INFO screen;
  27.     DWORD written;
  28.  
  29.     GetConsoleScreenBufferInfo(console, &screen);
  30.     FillConsoleOutputCharacterA(
  31.         console, ' ', screen.dwSize.X * screen.dwSize.Y, topLeft, &written
  32.     );
  33.     FillConsoleOutputAttribute(
  34.         console, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE,
  35.         screen.dwSize.X * screen.dwSize.Y, topLeft, &written
  36.     );
  37.     SetConsoleCursorPosition(console, topLeft);
  38. }
  39.  
  40. int ruletka(int hajs, string obst, const char gp[], const char gl[], const char dp[], const char dl[], const char pion[], const char poziom[], string nick) {
  41.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  42.     ifstream topr;
  43.     ofstream topr2;
  44.     topr.open("top100r.txt");
  45.     string top100rI[100];
  46.     int top100rW[100];
  47.     int ilee, profit;
  48.     bool teraz=false,koniec=false;
  49.     string line = "", wynik = "", imie = "", temp;
  50.     int nr_linii = 1;
  51.     while (getline(topr, line)) {
  52.         for (int h = 0; h < line.length(); h++) {
  53.             if (line.at(h) == 32) {
  54.                 ilee = h;
  55.                 break;
  56.             }
  57.         }
  58.         for (int a = 0; a < line.length(); a++) {
  59.             if (a < ilee) {
  60.                 string temp(1, line.at(a));
  61.                 imie.append(temp);
  62.             }
  63.             if (a > ilee) {
  64.                 string temp2(1, line.at(a));
  65.                 wynik.append(temp2);
  66.             }
  67.         }
  68.         top100rW[nr_linii - 1] = atoi(wynik.c_str());
  69.         top100rI[nr_linii - 1] = imie;
  70.         wynik = "";
  71.         imie = "";
  72.         nr_linii++;
  73.     }
  74.     bool znaj=false;
  75.     while (obst != ";") {
  76.         int czarne[] = { 2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35 };
  77.         int wybrane[37];
  78.         int los=0, ile=0,miejsce=0,profit=0;
  79.         bool czar=false, wygrana = false, wiele = false, wyg = false;
  80.         SetConsoleTextAttribute(hConsole, 12);
  81.         cout << "Aby wrocic do menu, wpisz srednik(;)" << endl;
  82.         SetConsoleTextAttribute(hConsole, 15);
  83.         SetConsoleTextAttribute(hConsole, 11);
  84.         cout << "Jak zamierzasz obstawiac?\nDla jednej liczby: Wpisz liczbe przypisana do pola w ruletce (0-36)\nDla wielu liczb: Wpisuj (P)oszczegolne liczby, aby zakonczyc - wpisz (K)\nDla czarnych pol: (B)lack\nDla czerwonych pol: (R)ed" << endl;
  85.         SetConsoleTextAttribute(hConsole, 15);
  86.         cin >> obst;
  87.         if (obst == ";") break;
  88.         int konwert = atoi(obst.c_str());
  89.         if (obst == "R" || obst == "r") {
  90.             do {
  91.                 cout << "Ile zamierzasz obstawic?" << endl;
  92.                 cin >> ile;
  93.                 if (ile > hajs) cout << "Wybacz, ale nie posiadasz tyle srodkow na koncie!" << endl;
  94.             } while (ile > hajs);
  95.             hajs -= ile;
  96.             czar = false;
  97.             los = rand() % 37;
  98.             cout << "Losuje:" << endl;
  99.             for (int i = 0; i < 18; i++) {
  100.                 if (czarne[i] == los) {
  101.                     czar = true;
  102.                 }
  103.             }
  104.             if (czar == false) {
  105.                 wyg = true;
  106.                 hajs += 2 * ile;
  107.                 profit = 2 * ile;
  108.             }
  109.             else {
  110.                 wyg = false;
  111.             }
  112.         }
  113.         else if (obst == "B" || obst == "b") {
  114.             do {
  115.                 cout << "Ile zamierzasz obstawic?" << endl;
  116.                 cin >> ile;
  117.                 if (ile > hajs) cout << "Wybacz, ale nie posiadasz tyle srodkow na koncie!" << endl;
  118.             } while (ile > hajs);
  119.             hajs -= ile;
  120.             czar = false;
  121.             los = rand() % 37;
  122.             cout << "Losuje:" << endl;
  123.             for (int i = 0; i < 18; i++) {
  124.                 if (czarne[i] == los) {
  125.                     czar = true;
  126.                 }
  127.             }
  128.             if (czar == false) {
  129.                 wyg = false;
  130.             }
  131.             else {
  132.                 wyg = true;
  133.                 hajs += 2 * ile;
  134.                 profit = 2 * ile;
  135.             }
  136.         }
  137.         else if (obst == "P" || obst == "p") {
  138.  
  139.             int temp, licznik = 0;
  140.             for (int i = 0; i < 37; i++) {
  141.                 cin >> temp;
  142.                 if (cin) {
  143.                     wybrane[i] = temp;
  144.                     licznik++;
  145.                 }
  146.                 else {
  147.                     cin.clear();
  148.                     cin.sync();
  149.                     break;
  150.                 }
  151.             }
  152.             do {
  153.                 cout << "Ile zamierzasz obstawic na kazde z pol?" << endl;
  154.                 cin >> ile;
  155.                 if ((licznik*ile) > hajs) {
  156.                     cout << "Wybacz, ale nie posiadasz tyle srodkow na koncie!" << endl;
  157.                 }
  158.                 else if (!cin) { cout << "Wybacz,ale podales zly format liczby(tylko calkowite)" << endl; cin.clear(); cin.sync(); }
  159.                 else { hajs -= (licznik*ile); }
  160.             } while ((licznik*ile) > hajs || !cin);
  161.             los = rand() % 37;
  162.             cout << "Losuje:" << endl;
  163.             for (int i = 0; i < 36; i++) {
  164.                 if (los == wybrane[i]) {
  165.                     wygrana = true;
  166.                 }
  167.             }
  168.             if (wygrana == true) {
  169.                 wyg = true;
  170.                 hajs += 18 * ile;
  171.                 profit = 18 * ile;
  172.             }
  173.             else {
  174.                 wyg = false;
  175.             }
  176.  
  177.  
  178.         }
  179.         else if (konwert >= 0 && konwert <= 36) {
  180.             do {
  181.                 cout << "Ile zamierzasz obstawic?" << endl;
  182.                 cin >> ile;
  183.                 if (ile > hajs) cout << "Wybacz, ale nie posiadasz tyle srodkow na koncie!" << endl;
  184.             } while (ile > hajs);
  185.             hajs -= ile;
  186.             los = rand() % 37;
  187.             cout << "Losuje:" << endl;
  188.             for (int i = 0; i < 18; i++) {
  189.                 if (czarne[i] == los) {
  190.                     czar = true;
  191.                 }
  192.             }
  193.             if (los == konwert) {
  194.                 hajs += 18 * ile;
  195.                 profit = 18 * ile;
  196.                 wyg = true;
  197.             }
  198.             else {
  199.                 wyg = false;
  200.             }
  201.  
  202.         }
  203.         cout << "\x1B[2J\x1B[H";
  204.         if (czar == false) {
  205.             cout << gl << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << gp << endl;
  206.             cout << pion;
  207.             for (int i = 0; i < 5; i++) { cout << "_ "; Sleep(600); }
  208.             SetConsoleTextAttribute(hConsole, 12);
  209.             if (los > 9) {
  210.                 cout << "|" << los << "| ";
  211.             }
  212.             else { cout << "|0" << los << "| "; }
  213.             SetConsoleTextAttribute(hConsole, 15);
  214.             for (int i = 0; i < 5; i++) { Sleep(600); cout << "_ "; }
  215.             cout << pion << endl;
  216.             cout << dl << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << dp << endl;
  217.             Sleep(50);
  218.         }
  219.         else {
  220.             cout << gl << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << gp << endl;
  221.             cout << pion;
  222.             for (int i = 0; i < 5; i++) { cout << "_ "; Sleep(600); }
  223.             SetConsoleTextAttribute(hConsole, 8);
  224.             if (los > 9) {
  225.                 cout << "|" << los << "| ";
  226.             }
  227.             else { cout << "|0" << los << "| "; }
  228.             SetConsoleTextAttribute(hConsole, 15);
  229.             for (int i = 0; i < 5; i++) { Sleep(600); cout << "_ "; }
  230.             cout << pion << endl;
  231.             cout << dl << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << poziom << dp << endl;
  232.             Sleep(50);
  233.         }
  234.        
  235.         if (wyg == false) {
  236.             cout << "Niestety nie udalo sie tym razem, sprobuj ponownie!" << endl;
  237.             SetConsoleTextAttribute(hConsole, 14);
  238.             cout << "Srodki: " << hajs << "zl" << endl;
  239.             SetConsoleTextAttribute(hConsole, 15);
  240.         }
  241.         else {
  242.             koniec = false;
  243.             for (int i = 0; i < 100 && koniec == false; i++) {
  244.                 if (top100rW[i] < profit && top100rW[i] > 0) {
  245.                     for (int j = 99; j > i; j--) {
  246.                         top100rW[j] = top100rW[j - 1];
  247.                     }
  248.                     top100rW[i] = profit;
  249.                     for (int k = 99; k > i; k--) {
  250.                         top100rI[k] = top100rI[k - 1];
  251.                     }
  252.                     top100rI[i] = nick;
  253.                     koniec = true;
  254.                 }
  255.                 if (top100rW[i] == 0) { top100rW[i] = profit; top100rI[i] = nick; koniec = true; }
  256.             }
  257.             topr2.open("top100r.txt");
  258.             for (int h = 0; h < 100; h++) {
  259.                 topr2 << top100rI[h] << " " << top100rW[h] << endl;
  260.             }
  261.             topr2.close();
  262.             cout << "Brawo! Udalo ci sie!" << endl;
  263.             SetConsoleTextAttribute(hConsole, 14);
  264.             cout << "Srodki: " << hajs << "zl" << endl;
  265.             SetConsoleTextAttribute(hConsole, 15);
  266.         }
  267.     }
  268.     return hajs;
  269. }
  270. int blackjack(int hajs, const char pion[], const char poziom[], const char gp[], const char gl[], const char dl[], const char dp[], string nick) {
  271.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  272.     ifstream topb;
  273.     ofstream topb2;
  274.     topb.open("top100b.txt");
  275.     string talia[] = { "2W","2C","2Z","2D","3W","3C","3Z","3D","4W","4C","4Z","4D","5W","5C","5Z","5D","6W","6C","6Z","6D","7W","7C","7Z","7D","8W","8C","8Z","8D","9W","9C","9Z","9D","TW","TC","TZ","TD","JW","JC","JZ","JD","QW","QC","QZ","QD","KW","KC","KZ","KD","AW","AC","AZ","AD" };
  276.     int ile, los, sleep = 300, licznik = 0, punkty = 0, punktyK = 0, k = 0, miejsce = 0;
  277.     string dob, grasz, figura, kolor;
  278.     bool wygrana = true, krupier = true, znaj = true, teraz = false, czykrupier = true;
  279.     const char trefl[] = "\xe2\x99\xa3";
  280.     const char karo[] = "\xe2\x99\xa6";
  281.     const char pik[] = "\xe2\x99\xa0";
  282.     const char kier[] = "\xe2\x99\xa5";
  283.     string top100bI[100];
  284.     int top100bW[100];
  285.     string line = "", wynik = "", imie = "", temp, temp2;
  286.     int nr_linii = 1, ilee = 0;
  287.     bool czymoge = true,koniec=false;
  288.     while (topb.good()) {
  289.         getline(topb, line);
  290.         for (int h = 0; h < line.length(); h++) {
  291.             if (line.at(h) == 32) {
  292.                 ilee = h;
  293.                 break;
  294.             }
  295.         }
  296.         for (int a = 0; a < line.length(); a++) {
  297.             if (a < ilee) {
  298.                 string temp(1, line.at(a));
  299.                 imie.append(temp);
  300.             }
  301.             if (a > ilee) {
  302.                 string temp2(1, line.at(a));
  303.                 wynik.append(temp2);
  304.             }
  305.         }
  306.         top100bW[nr_linii - 1] = atoi(wynik.c_str());
  307.         top100bI[nr_linii - 1] = imie;
  308.         wynik = "";
  309.         imie = "";
  310.         nr_linii++;
  311.     }
  312.     topb.close();
  313.     do {
  314.         punkty = 0;
  315.         cin.clear();
  316.         cin.sync();
  317.         do {
  318.             cout << "Ile obstawiasz?" << endl;
  319.             cin >> ile;
  320.             if (ile > hajs) { cout << "Nie posiadasz takiej kwoty!" << endl; }
  321.             else if (!cin) { cin.clear(); cin.sync(); SetConsoleTextAttribute(hConsole, 12); cout << "Zly format liczby!"; SetConsoleTextAttribute(hConsole, 15); ile = hajs + 1; }
  322.         } while (ile > hajs);
  323.         hajs -= ile;
  324.         punkty = 0;
  325.         cout <<"Twoje punkty: "<< punkty;
  326.         do {
  327.             dob = "n";
  328.             licznik = 0;
  329.             for (int i = 0; i < 52; i++) {
  330.                 if (talia[i] != "") {
  331.                     licznik++;
  332.                 }
  333.             }
  334.             cout << "\x1B[2J\x1B[H";
  335.             SetConsoleTextAttribute(hConsole, 12);
  336.             cout << "KART: " << licznik << endl;
  337.             SetConsoleTextAttribute(hConsole, 15);
  338.             if (licznik == 0) break;
  339.             cout << "Dobieram karte"; Sleep(sleep); cout << "."; Sleep(sleep); cout << "."; Sleep(sleep); cout << "." << endl;
  340.             do {
  341.                 los = rand() % 52;
  342.             } while (talia[los] == "");
  343.             if (talia[los].at(0) != 84 && talia[los].at(0) != 65 && talia[los].at(0) != 81 && talia[los].at(0) != 74 && talia[los].at(0) != 75) {
  344.                 figura = talia[los].at(0);
  345.                 punkty += (talia[los].at(0) - 48);
  346.             }
  347.             else if (talia[los].at(0) == 84) {
  348.                 punkty += 10;
  349.             }
  350.             else if (talia[los].at(0) == 65) {
  351.                 figura = talia[los].at(0);
  352.                 if (punkty == 11) { punkty += 1;
  353.                 }else { punkty += 11; }
  354.             }
  355.             else if (talia[los].at(0) == 81) {
  356.                 figura = talia[los].at(0);
  357.                 punkty += 3;
  358.             }
  359.             else if (talia[los].at(0) == 74) {
  360.                 figura = talia[los].at(0);
  361.                 punkty += 2;
  362.             }
  363.             else if (talia[los].at(0) == 75) {
  364.                 figura = talia[los].at(0);
  365.                 punkty += 4;
  366.             }
  367.             if (talia[los].at(1) == 90) {
  368.                 kolor = "\xe2\x99\xa3";
  369.                 k = 1;
  370.             }
  371.             else if (talia[los].at(1) == 68) {
  372.                 kolor = "\xe2\x99\xa6";
  373.                 k = 2;
  374.             }
  375.             else if (talia[los].at(1) == 67) {
  376.                 kolor = "\xe2\x99\xa5";
  377.                 k = 2;
  378.             }
  379.             else if (talia[los].at(1) == 87) {
  380.                 kolor = "\xe2\x99\xa0";
  381.                 k = 1;
  382.             }
  383.             cout << gl;
  384.             for (int i = 0; i < 11; i++) cout << poziom;
  385.             cout << gp << endl;
  386.             Sleep(sleep);
  387.             cout << pion;
  388.             if (k == 1) {
  389.                 SetConsoleTextAttribute(hConsole, 8);
  390.             }
  391.             else if (k == 2) { SetConsoleTextAttribute(hConsole, 12); }
  392.             cout << figura << kolor;
  393.             SetConsoleTextAttribute(hConsole, 15);
  394.             cout << "         " << pion << endl;
  395.             Sleep(sleep);
  396.             cout << pion << "           " << pion << endl;
  397.             Sleep(sleep);
  398.             cout << pion << "           " << pion << endl;
  399.             Sleep(sleep);
  400.             cout << pion << "     ";
  401.             if (k == 1) {
  402.                 SetConsoleTextAttribute(hConsole, 8);
  403.             }
  404.             else if (k == 2) { SetConsoleTextAttribute(hConsole, 12); }
  405.             cout << kolor;
  406.             SetConsoleTextAttribute(hConsole, 15);
  407.             cout << "     " << pion << endl;
  408.             Sleep(sleep);
  409.             cout << pion << "           " << pion << endl;
  410.             Sleep(sleep);
  411.             cout << pion << "           " << pion << endl;
  412.             Sleep(sleep);
  413.             cout << pion << "         ";
  414.             if (k == 1) {
  415.                 SetConsoleTextAttribute(hConsole, 8);
  416.             }
  417.             else if (k == 2) { SetConsoleTextAttribute(hConsole, 12); }
  418.             cout << kolor << figura;
  419.             SetConsoleTextAttribute(hConsole, 15);
  420.             cout << pion << endl;
  421.             cout << dl;
  422.             for (int i = 0; i < 11; i++) cout << poziom;
  423.             cout << dp << endl;
  424.             talia[los] = "";
  425.             if (punkty < 21) {
  426.                 cout << "Aktualna punktacja: " << punkty << "\nDobierasz dalej?(t/n)" << endl;
  427.                 cin >> dob;
  428.                 czykrupier = true;
  429.             }
  430.             else if (punkty == 21) {
  431.                 cout << "Blackjack!" << endl;
  432.                 czykrupier = false;
  433.                 krupier = false;
  434.                 dob = "n";
  435.             }
  436.             else {
  437.                 cout << "Niestety, przekroczyles dopuszczalna wartosc! " << endl;
  438.                 czykrupier = false;
  439.                 krupier = true;
  440.                 dob = "n";
  441.             }
  442.         } while (dob == "t");
  443.         if (czykrupier==true) {
  444.             cout << "Krupier dobiera karty"; Sleep(sleep); cout << "."; Sleep(sleep); cout << "."; Sleep(sleep); cout << "." << endl;
  445.             do {
  446.                 do {
  447.                     los = rand() % 52;
  448.                 } while (talia[los] == "");
  449.                 if (talia[los].at(0) > 49 && talia[los].at(0) < 58) {
  450.                     punktyK += (talia[los].at(0) - 48);
  451.                 }
  452.                 else if (talia[los].at(0) == 84) {
  453.                     punktyK += 10;
  454.                 }
  455.                 else if (talia[los].at(0) == 74) {
  456.                     punktyK += 2;
  457.                 }
  458.                 else if (talia[los].at(0) == 75) {
  459.                     punktyK += 4;
  460.                 }
  461.                 else if (talia[los].at(0) == 81) {
  462.                     punktyK += 3;
  463.                 }
  464.                 else if (talia[los].at(0) == 65) {
  465.                     punktyK += 11;
  466.                 }
  467.                 talia[los] = "";
  468.             } while (punktyK <= 16);
  469.             if (punktyK > 21) {
  470.                 cout << "Krupier przekroczyl 21! Brawo, wygrywasz!" << endl;
  471.                 krupier = false;
  472.             }
  473.             else if (punktyK < punkty) {
  474.                 SetConsoleTextAttribute(hConsole, 12);
  475.                 cout << "Krupier przegral!" << endl;
  476.                 SetConsoleTextAttribute(hConsole, 15);
  477.                 krupier = false;
  478.             }
  479.             else if (punktyK == punkty) {
  480.                 SetConsoleTextAttribute(hConsole, 12);
  481.                 cout << "Remis w punktach! Brawo, wygrywasz!" << endl;
  482.                 SetConsoleTextAttribute(hConsole, 15);
  483.                 krupier = false;
  484.             }
  485.             else { krupier = true; }
  486.         }
  487.         if (krupier == false) {
  488.             hajs += 2 * ile;
  489.             koniec = false;
  490.             for (int i = 0; i < 100 && koniec==false; i++) {
  491.                 if (top100bW[i] < (2 * ile) && top100bW[i] > 0) {
  492.                     for (int j = 99; j > i; j--) {
  493.                         top100bW[j] = top100bW[j - 1];
  494.                     }
  495.                     top100bW[i] = (2 * ile);
  496.                     for (int k = 99; k > i; k--) {
  497.                         top100bI[k] = top100bI[k - 1];
  498.                     }
  499.                     top100bI[i] = nick;
  500.                     koniec = true;
  501.                 }
  502.                 if (top100bW[i] == 0) { top100bW[i] = (2 * ile); top100bI[i] = nick; koniec = true; }
  503.             }
  504.             topb2.open("top100b.txt");
  505.             for (int h = 0; h < 100; h++) {
  506.                 topb2 << top100bI[h] << " " << top100bW[h] << endl;
  507.             }
  508.             topb2.close();
  509.         }
  510.         cout << "Twoje punkty: " << punkty << endl;
  511.         if(czykrupier==true) cout<<"Punkty krupiera: " << punktyK << endl;
  512.         SetConsoleTextAttribute(hConsole, 14);
  513.         cout << "Srodki: " << hajs << "zl" << endl;
  514.         SetConsoleTextAttribute(hConsole, 15);
  515.         cout << "Grasz dalej?(t/n)" << endl;
  516.         cin >> grasz;
  517.        
  518.         if (licznik == 0) {
  519.             cout << "Ups!Koniec talii!" << endl;
  520.             grasz = "n";
  521.             break;
  522.         }
  523.         if (licznik < 5) {
  524.             cout << "Konczy sie talia! Wlasnie przygotowujemy nowa" << endl;
  525.             grasz = "n";
  526.             break;
  527.         }
  528.     } while (grasz == "t");
  529.    
  530.     return hajs;
  531. }
  532. int bandyta(int hajs, const char pion[], const char poziom[], const char gp[], const char gl[], const char dl[], const char dp[], string obst, string nick) {
  533.     ifstream topj;
  534.     ofstream topj2;
  535.     topj.open("top100j.txt");
  536.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  537.     int ile, los, los2, los3, miejsce;
  538.     string tab2[] = { "\xe2\x82\xaa","\xe2\x82\xb4","\xe2\x82\xbf","\xe2\x82\xb9","\xe2\x82\xbb","\xe2\x84\x97" };
  539.     string top100jI[100];
  540.     bool znaj,teraz=false,koniec=false;
  541.     int top100jW[100],ilee;
  542.     string line = "", wynik = "", imie = "", temp;
  543.     int nr_linii = 1;
  544.     while (getline(topj, line)) {
  545.         for (int h = 0; h < line.length(); h++) {
  546.             if (line.at(h) == 32) {
  547.                 ilee = h;
  548.                 break;
  549.             }
  550.         }
  551.         for (int a = 0; a < line.length(); a++) {
  552.             if (a < ilee) {
  553.                 string temp(1, line.at(a));
  554.                 imie.append(temp);
  555.             }
  556.             if (a > ilee) {
  557.                 string temp2(1, line.at(a));
  558.                 wynik.append(temp2);
  559.             }
  560.         }
  561.         top100jW[nr_linii - 1] = atoi(wynik.c_str());
  562.         top100jI[nr_linii - 1] = imie;
  563.         wynik = "";
  564.         imie = "";
  565.         nr_linii++;
  566.     }
  567.     topj.close();
  568.     while (obst != ";") {
  569.         if (obst == "") cin >> obst;
  570.         if (obst == ";") break;
  571.         do {
  572.             cin.clear();
  573.             cin.sync();
  574.             cout << "Ile zamierzasz obstawic?" << endl;
  575.             cin >> ile;
  576.             if (ile > hajs) { cout << "Wybacz, ale nie posiadasz tyle srodkow na koncie!" << endl; }
  577.             else if (!cin) { cout << "Niestety, ale podales bledny format liczby"; cin.clear(); cin.sync(); ile = hajs + 1; }
  578.         } while (ile > hajs);
  579.         hajs -= ile;
  580.         cout << "Uruchamiam maszyne";
  581.         Sleep(500);
  582.         cout << ".";
  583.         Sleep(500);
  584.         cout << ".";
  585.         Sleep(500);
  586.         cout << "." << endl;
  587.         cin.clear();
  588.         cin.sync();
  589.         SetConsoleTextAttribute(hConsole, 64);
  590.         cout << gl << poziom << poziom << poziom << poziom << poziom << poziom << poziom << gp << endl;
  591.         los = rand() % 6;
  592.         Sleep(500);
  593.         cout << pion << " " << tab2[los] << " ";
  594.         los2 = rand() % 6;
  595.         Sleep(500);
  596.         cout << tab2[los2] << " ";
  597.         los3 = rand() % 6;
  598.         Sleep(500);
  599.         cout << tab2[los3] << " " << pion << endl;
  600.         Sleep(500);
  601.         cout << dl << poziom << poziom << poziom << poziom << poziom << poziom << poziom << dp << endl;
  602.         if (los == los2 && los2 == los3) {
  603.             cout << "Brawo! Trafiłeś trzy takie same symbole!"; hajs += 5 * ile;
  604.             koniec = false;
  605.             for (int i = 0; i < 100 && koniec == false; i++) {
  606.                 if (top100jW[i] < (2 * ile) && top100jW[i] > 0) {
  607.                     for (int j = 99; j > i; j--) {
  608.                         top100jW[j] = top100jW[j - 1];
  609.                     }
  610.                     top100jW[i] = (2 * ile);
  611.                     for (int k = 99; k > i; k--) {
  612.                         top100jI[k] = top100jI[k - 1];
  613.                     }
  614.                     top100jI[i] = nick;
  615.                     koniec = true;
  616.                 }
  617.                 if (top100jW[i] == 0) { top100jW[i] = (2 * ile); top100jI[i] = nick; koniec = true; }
  618.             }
  619.             topj2.open("top100j.txt");
  620.             for (int h = 0; h < 100; h++) {
  621.                 topj2 << top100jI[h] << " " << top100jW[h] << endl;
  622.             }
  623.             topj2.close();
  624.         }
  625.         SetConsoleTextAttribute(hConsole, 14);
  626.         cout << "Srodki: " << hajs << "zl" << endl;
  627.         SetConsoleTextAttribute(hConsole, 6);
  628.         cout << "Grasz dalej?(t/;)" << endl;
  629.         SetConsoleTextAttribute(hConsole, 15);
  630.         cout << los << los2 << los3;
  631.         obst = "";
  632.     }
  633.     return hajs;
  634. }
  635. int main()
  636. {
  637.     system("chcp 65001");
  638.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  639.     char wybor;
  640.     const char pion[] = "\xe2\x95\x91", gp[] = "\xe2\x95\x97", dp[] = "\xe2\x95\x9d", gl[] = "\xe2\x95\x94", dl[] = "\xe2\x95\x9a", poziom[] = "\xe2\x95\x90";
  641.     string obst, nick;
  642.     char spr;
  643.     string top100I[100];
  644.     int top100W[100];
  645.     int hajs = 0, ilee = 0;
  646.     srand(time(0));
  647.     if (hajs <= 0) { hajs = (rand() % 300) + 200; }
  648.     for (;;) {
  649.         cout << "Witaj w Polish Casino! Na poczatek podaj swoje imie/nick pod ktorym bedziesz gral w naszym kasynie!" << endl;
  650.         getline(cin, nick);
  651.         for (int h = 0; h < nick.size(); h++) {
  652.             if (nick.at(h) == 32) {
  653.                 nick.at(h) = 0x5F;
  654.             }
  655.         }
  656.         do {
  657.             SetConsoleTextAttribute(hConsole, 14);
  658.             cout << "Srodki: " << hajs << "zl" << endl;
  659.             SetConsoleTextAttribute(hConsole, 15);
  660.             cout << "Witaj " << nick << ". Wybierz gre w jaka chcesz zagrac!\n(R)uletka\n(B)lackJack\n(J)ednoreki Bandyta\n(T)op 100 Graczy!" << endl;
  661.             cin >> wybor;
  662.             if (wybor > 96) {
  663.                 wybor -= 32;
  664.             }
  665.             switch (wybor)
  666.             {
  667.             case 82:
  668.                 cout << "\x1B[2J\x1B[H";
  669.                 SetConsoleTextAttribute(hConsole, 11);
  670.                 cout << "Wybrales gre w Ruletke!" << endl;
  671.                 SetConsoleTextAttribute(hConsole, 12);
  672.                 cout << "Aby wrocic do menu, wpisz srednik(;)" << endl;
  673.                 SetConsoleTextAttribute(hConsole, 15);
  674.                 hajs = ruletka(hajs, obst, gp, gl, dp, dl, pion, poziom, nick);
  675.                 cout << "\x1B[2J\x1B[H";
  676.                 break;
  677.             case 66:
  678.                 cout << "\x1B[2J\x1B[H";
  679.                 SetConsoleTextAttribute(hConsole, 11);
  680.                 cout << "Wybrales gre w BlackJacka!" << endl;
  681.                 SetConsoleTextAttribute(hConsole, 15);
  682.                 hajs = blackjack(hajs, pion, poziom, gp, gl, dl, dp, nick);
  683.                 cout << "\x1B[2J\x1B[H";
  684.                 break;
  685.             case 74:
  686.                 cout << "\x1B[2J\x1B[H";
  687.                 SetConsoleTextAttribute(hConsole, 11);
  688.                 cout << "Wybrales gre w Jednorekiego Bandyte!\nTraf trzy takie same symbole, a wplacona stawka będzie 5 razy wyższa!\nJezeli wchodzisz, wpisz (T)ak" << endl;
  689.                 SetConsoleTextAttribute(hConsole, 12);
  690.                 cout << "Aby wrocic do menu, wpisz srednik(;)" << endl;
  691.                 SetConsoleTextAttribute(hConsole, 15);
  692.                 cin >> obst;
  693.                 if (obst == "t" || obst == "T") hajs = bandyta(hajs, pion, poziom, gp, gl, dl, dp, obst, nick);
  694.                 cout << "\x1B[2J\x1B[H";
  695.                 break;
  696.             case 84:
  697.                 cout << "\x1B[2J\x1B[H";
  698.                 SetConsoleTextAttribute(hConsole, 11);
  699.                 cout << "Witamy w rankingu naszych graczy! Wybierz gre, z ktorej chcesz sprawdzic top100!\n(R)uletka\n(B)lackJack\n(J)ednoreki Bandyta" << endl;
  700.                 SetConsoleTextAttribute(hConsole, 12);
  701.                 cin >> spr;
  702.                 string line, imie = "", wynik = "";
  703.                 int nr_linii = 1, dlugosc = 0, dlug;
  704.                 ifstream topr;
  705.                 ifstream topb;
  706.                 ifstream topj;
  707.                 stringstream konw;
  708.                 switch (toupper(spr)) {
  709.                 case 82:
  710.                     nr_linii = 1;
  711.                     topr.open("top100r.txt");
  712.                     while (getline(topr, line)) {
  713.                         for (int h = 0; h < line.length(); h++) {
  714.                             if (line.at(h) == 32) {
  715.                                 ilee = h;
  716.                             }
  717.                         }
  718.                         for (int a = 0; a < ilee; a++) {
  719.                             string temp(1, line.at(a));
  720.                             imie.append(temp);
  721.                         }
  722.                         for (int a = ilee + 1; a < line.length(); a++) {
  723.                             string temp2(1, line.at(a));
  724.                             wynik.append(temp2);
  725.                         }
  726.                         top100W[nr_linii - 1] = atoi(wynik.c_str());
  727.                         top100I[nr_linii - 1] = imie;
  728.                         wynik = "";
  729.                         imie = "";
  730.                         nr_linii++;
  731.                     }
  732.                     for (int i = 1; i != 100; i += 10) {
  733.                         dlug = 8 - top100I[i - 1].length();
  734.                         abs(dlug);
  735.                         printf("%3d", i);
  736.                         cout << "." << top100I[i - 1];
  737.                         for (int k = 0; k < dlug; k++) {
  738.                             cout << " ";
  739.                         }
  740.                         if (top100W[i - 1] < 10) {
  741.                             cout << ":   " << top100W[i - 1] << " | ";
  742.                         }
  743.                         else if (top100W[i - 1] < 100) {
  744.                             cout << ":  " << top100W[i - 1] << " | ";
  745.                         }
  746.                         else {
  747.                             cout << ": " << top100W[i - 1] << " | ";
  748.                         }
  749.                         if (i > 90) { cout << endl; i -= 99; }
  750.                     }
  751.                     cout << "100." << top100I[99] << ":   " << top100W[99] << " | ";
  752.                     cout << "\n";
  753.                     topr.close();
  754.                     break;
  755.                 case 66:
  756.                     nr_linii = 1;
  757.                     topb.open("top100b.txt");
  758.                     while (getline(topb, line)) {
  759.                         for (int h = 0; h < line.length(); h++) {
  760.                             if (line.at(h) == 32) {
  761.                                 ilee = h;
  762.                             }
  763.                         }
  764.                         for (int a = 0; a < ilee; a++) {
  765.                             string temp(1, line.at(a));
  766.                             imie.append(temp);
  767.                         }
  768.                         for (int a = ilee + 1; a < line.length(); a++) {
  769.                             string temp2(1, line.at(a));
  770.                             wynik.append(temp2);
  771.                         }
  772.                         top100W[nr_linii - 1] = atoi(wynik.c_str());
  773.                         top100I[nr_linii - 1] = imie;
  774.                         wynik = "";
  775.                         imie = "";
  776.                         nr_linii++;
  777.                     }
  778.                     for (int i = 1; i != 100; i += 10) {
  779.                         dlug = 8 - top100I[i - 1].length();
  780.                         abs(dlug);
  781.                         printf("%3d", i);
  782.                         cout << "." << top100I[i - 1];
  783.                         for (int k = 0; k < dlug; k++) {
  784.                             cout << " ";
  785.                         }
  786.                         if (top100W[i - 1] < 10) {
  787.                             cout << ":   " << top100W[i - 1] << " | ";
  788.                         }
  789.                         else if (top100W[i - 1] < 100) {
  790.                             cout << ":  " << top100W[i - 1] << " | ";
  791.                         }
  792.                         else {
  793.                             cout << ": " << top100W[i - 1] << " | ";
  794.                         }
  795.                         if (i > 90) { cout << endl; i -= 99; }
  796.                     }
  797.                     cout << "100." << top100I[99] << ":   " << top100W[99] << " | ";
  798.                     cout << "\n";
  799.                     topb.close();
  800.                     break;
  801.                 case 74:
  802.                     nr_linii = 1;
  803.                     topj.open("top100j.txt");
  804.                     while (getline(topj, line)) {
  805.                         for (int h = 0; h < line.length(); h++) {
  806.                             if (line.at(h) == 32) {
  807.                                 ilee = h;
  808.                             }
  809.                         }
  810.                         for (int a = 0; a < ilee; a++) {
  811.                             string temp(1, line.at(a));
  812.                             imie.append(temp);
  813.                         }
  814.                         for (int a = ilee + 1; a < line.length(); a++) {
  815.                             string temp2(1, line.at(a));
  816.                             wynik.append(temp2);
  817.                         }
  818.                         top100W[nr_linii - 1] = atoi(wynik.c_str());
  819.                         top100I[nr_linii - 1] = imie;
  820.                         wynik = "";
  821.                         imie = "";
  822.                         nr_linii++;
  823.                     }
  824.                     for (int i = 1; i != 100; i += 10) {
  825.                         dlug = 8 - top100I[i - 1].length();
  826.                         abs(dlug);
  827.                         printf("%3d", i);
  828.                         cout << "." << top100I[i - 1];
  829.                         for (int k = 0; k < dlug; k++) {
  830.                             cout << " ";
  831.                         }
  832.                         if (top100W[i - 1] < 10) {
  833.                             cout << ":   " << top100W[i - 1] << " | ";
  834.                         }
  835.                         else if (top100W[i - 1] < 100) {
  836.                             cout << ":  " << top100W[i - 1] << " | ";
  837.                         }
  838.                         else {
  839.                             cout << ": " << top100W[i - 1] << " | ";
  840.                         }
  841.                         if (i > 90) { cout << endl; i -= 99; }
  842.                     }
  843.                     cout << "100." << top100I[99] << ":   " << top100W[99] << " | ";
  844.                     cout << "\n";
  845.                     topj.close();
  846.                     break;
  847.                 }
  848.  
  849.             }
  850.  
  851.         } while (wybor != 82 || wybor != 66 || wybor != 74 || wybor != 84);
  852.  
  853.     }
  854.  
  855.     return 0;
  856. }
Add Comment
Please, Sign In to add comment