Advertisement
daisukiseiya

gambling

Apr 18th, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 15.22 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. #include <string>
  5. #include <iomanip>
  6.  
  7. using namespace std;
  8.  
  9. //betting & credits
  10. int bet;
  11. int choice;
  12. int avaCredits = 1000000;
  13. int amountm;
  14. string stringbet;
  15. string stringamount;
  16.  
  17. //display
  18. float displayBet;
  19. float displayCred;
  20. string str1("k");
  21. string str2("m");
  22. string str3("b");
  23.  
  24. // wins & lose for dicing
  25. float d_wins;
  26. float d_loss;
  27. float d_winsPerc;
  28. float d_lossPerc;
  29. int winstreak;
  30. int losestreak;
  31.  
  32. //Staking
  33. int p1_HP = 99;
  34. int p2_HP = 99;
  35. int p1_Hit[30];
  36. int p2_Hit[30];
  37. int p1_Str[30];
  38. string player;
  39. string winner;
  40.  
  41. // wins & lose for dice duel
  42. float d2_wins;
  43. float d2_loss;
  44. float d2_winsPerc;
  45. float d2_lossPerc;
  46.  
  47. // wins & lose for staking
  48. float s_wins;
  49. float s_loss;
  50. float s_winsPerc;
  51. float s_lossPerc;
  52.  
  53. //cheats switch
  54. bool strcheat = true;
  55. bool hpcheat = false;
  56.  
  57.  
  58. //prototypes
  59. void PrintMenu();
  60. void myPause();
  61.  
  62. void Deposit() {
  63.     if (stringbet.find(str1)!= std::string::npos) {
  64.     stringbet.replace(stringbet.find(str1),str1.length(),"000"); }
  65.  
  66.     if (stringbet.find(str2)!= std::string::npos) {
  67.     stringbet.replace(stringbet.find(str2),str2.length(),"000000"); }
  68.  
  69.     if (stringbet.find(str3)!= std::string::npos) {
  70.     stringbet.replace(stringbet.find(str3),str3.length(),"000000000"); }
  71. }
  72.  
  73. void amountDisplay() {
  74.         if (avaCredits >= 10000 && avaCredits <= 999999){
  75.                 displayCred = avaCredits / 1000;
  76.                 cout <<" (" << displayCred << "k)" << endl; }
  77.  
  78.         else if (avaCredits >= 1000000 && avaCredits <= 999999999){
  79.                 displayCred = avaCredits / 1000000;
  80.                 cout <<" (" << displayCred << "M)" << endl; }
  81.  
  82.         else if (avaCredits >= 1000000000) {
  83.                 displayCred = avaCredits / 1000000000;
  84.                 cout <<" (" << displayCred << "B)" << endl;
  85.         }
  86. }
  87.  
  88. //credit system
  89. void credits() {
  90.     cout << "Enter betting amount: ";
  91.     cin >> stringbet;
  92.  
  93.     Deposit();
  94.  
  95.     bet = atoi(stringbet.c_str());
  96.  
  97.     if (avaCredits == 0) {
  98.         cout << "You don't have enough coins to continue. # cleaned.";
  99.         cout << " " << endl;
  100.         PrintMenu();
  101.     }
  102.  
  103.     while (bet > avaCredits) {
  104.         cout << "You don't have enough coins. \nEnter again: ";
  105.     cin >> stringbet;
  106.  
  107.     Deposit();
  108.  
  109.     bet = atoi(stringbet.c_str());
  110.     }
  111. }
  112.  
  113. //Dicing System
  114. void Play_Dicing() {
  115.     char again;
  116.  
  117.     do{
  118.  
  119.         int diceRoll = (rand() % 100);
  120.         string plusminus;
  121.  
  122.         cout << "  __________________________________________   " << endl;
  123.         cout << "<| ======    DUEL ARENA - Dicing     ====== |>" << endl;
  124.         cout << "<|__________________________________________|> " << endl;
  125.         cout << " " << endl;
  126.         cout << "Roll a 50 or higher to win your bet. " << endl;
  127.  
  128.         if (d_wins > 0 || d_loss > 0) {
  129.             d_winsPerc = (d_wins / (d_wins + d_loss)) * 100;
  130.             d_lossPerc = (d_loss / (d_wins + d_loss)) * 100;
  131.         }
  132.  
  133.         cout << " " << endl;
  134.         cout << "---------------------------------------------" << endl;
  135.         cout << "Wins: " << d_wins << " || %" << d_winsPerc << endl;
  136.         cout << "Loss: " << d_loss << " || %" << d_lossPerc << endl;
  137.         cout << "Streak: ";
  138.         if (winstreak >= 1) {
  139.             cout << "Win " << winstreak << endl; }
  140.         else if (losestreak >= 1) {
  141.             cout << "Lose " << losestreak << endl;
  142.         }
  143.         cout << endl;
  144.         cout << "---------------------------------------------" << endl;
  145.         cout << " " << endl;
  146.  
  147.         cout << "Coins: $" << avaCredits;
  148.  
  149.         amountDisplay();
  150.         cout << endl;
  151.  
  152.         cout << "" << endl;
  153.  
  154.         credits();
  155.  
  156.         cout << "     ____              " << endl;
  157.         cout << "    /\\' .\\    _____    " << endl;
  158.         cout << "   /: \\___\\  / .  /\\   " << endl;
  159.         cout << "   \\' / . / /____/..\\  " << endl;
  160.         cout << "    \\/___/  \\'  '\\  /  " << endl;
  161.         cout << "             \\'__'\\/   " << endl;
  162.  
  163.         cout << " " << endl;
  164.         cout << "[Rolling dice: " << diceRoll << "]" << endl;
  165.         cout << " " << endl;
  166.  
  167.         if (diceRoll > 50) {
  168.                 losestreak = 0;
  169.             cout << "Congratulations, you won the bet!" << endl;
  170.             avaCredits = avaCredits - bet;
  171.             avaCredits = avaCredits + (bet * 2);
  172.  
  173.             plusminus = "+";
  174.  
  175.             ++d_wins;
  176.             ++winstreak;
  177.         }
  178.         else {
  179.             winstreak = 0;
  180.             cout << "Sorry, you loss the bet!" << endl;
  181.             avaCredits = avaCredits - bet;
  182.  
  183.             plusminus = "-";
  184.  
  185.             ++d_loss;
  186.             ++losestreak;
  187.         }
  188.  
  189.         cout << " " << endl;
  190.         cout << "Spoils = " << plusminus << " " << bet;
  191.  
  192.          if (bet >= 10000 && bet <= 999999){
  193.                 displayBet = bet / 1000;
  194.                 cout <<" (" << displayBet << "K)" << endl; }
  195.  
  196.         else if (bet>= 1000000 && bet <= 999999999){
  197.                 displayCred = bet / 1000000;
  198.                 cout <<" (" << displayBet << "M)" << endl; }
  199.  
  200.         else if (bet >= 1000000000) {
  201.                 displayCred = bet / 1000000000;
  202.                 cout <<" (" << displayBet << "B)" << endl;
  203.         }
  204. cout << endl;
  205.         cout << " " << endl;
  206.  
  207.         cout << "=============================================" << endl;
  208.         cout << "Coins: " << "$" << avaCredits;
  209.  
  210.  
  211.         amountDisplay();
  212.         cout << endl;
  213.  
  214.         cout << "=============================================" << endl;
  215.  
  216.         cout << "Play Again? (y/n): ";
  217.         cin >> again;
  218.  
  219.     } while (again == 'y');
  220.  
  221.     if (again == 'n') {
  222.         PrintMenu();
  223.     }
  224. }
  225.  
  226.  
  227.  
  228. //Dicing System
  229. void Play_DiceDuel() {
  230.     char again;
  231.  
  232.     do{
  233.         int p1_diceRoll = (rand() % 100);
  234.         int p2_diceRoll = (rand() % 100);
  235.  
  236.         string plusminus;
  237.  
  238.         cout << "  __________________________________________   " << endl;
  239.         cout << "<| ======   DUEL ARENA - Dice Duel   ====== |>" << endl;
  240.         cout << "<|__________________________________________|> " << endl;
  241.         cout << " " << endl;
  242.         cout << "Roll higher than Player 2 to win your bet. " << endl;
  243.  
  244.         if (d2_wins > 0 || d2_loss > 0) {
  245.             d2_winsPerc = (d2_wins / (d2_wins + d2_loss)) * 100;
  246.             d2_lossPerc = (d2_loss / (d2_wins + d2_loss)) * 100;
  247.         }
  248.  
  249.         cout << " " << endl;
  250.         cout << "---------------------------------------------" << endl;
  251.         cout << "Wins: " << d2_wins << " || %" << d2_winsPerc << endl;
  252.         cout << "Loss: " << d2_loss << " || %" << d2_lossPerc << endl;
  253.         cout << "---------------------------------------------" << endl;
  254.         cout << " " << endl;
  255.  
  256.  
  257.         cout << "Coins: $" << avaCredits;
  258.         amountDisplay();
  259.         cout << endl;
  260.  
  261.  
  262.         cout << "" << endl;
  263.  
  264.         credits();
  265.  
  266.         cout << "     ____              " << endl;
  267.         cout << "    /\\' .\\    _____    " << endl;
  268.         cout << "   /: \\___\\  / .  /\\   " << endl;
  269.         cout << "   \\' / . / /____/..\\  " << endl;
  270.         cout << "    \\/___/  \\'  '\\  /  " << endl;
  271.         cout << "             \\'__'\\/   " << endl;
  272.  
  273.  
  274.         cout << " " << endl;
  275.         cout << "[Player 1 rolls: " << p1_diceRoll << "]" << endl;
  276.         cout << "[Player 2 rolls: " << p2_diceRoll << "]" << endl;
  277.         cout << " " << endl;
  278.  
  279.         if (p1_diceRoll == p2_diceRoll) {
  280.             cout << "You both roll the same number. its a tie!" << endl;
  281.         }
  282.  
  283.             if (p1_diceRoll > p2_diceRoll) {
  284.                 cout << "Congratulations, you won the bet!" << endl;
  285.                 avaCredits = avaCredits - bet;
  286.                 avaCredits = avaCredits + (bet * 2);
  287.  
  288.                 plusminus = "+";
  289.  
  290.                 ++d2_wins;
  291.  
  292.                 cout << " " << endl;
  293.                 cout << "Spoils = " << plusminus << " " << bet << endl;
  294.  
  295.                 cout << " " << endl;
  296.  
  297.             }
  298.             else {
  299.                 cout << "Sorry, you loss the bet!" << endl;
  300.                 avaCredits = avaCredits - bet;
  301.  
  302.                 plusminus = "-";
  303.  
  304.                 ++d2_loss;
  305.  
  306.                 cout << " " << endl;
  307.                 cout << "Spoils = " << plusminus << " " << bet << endl;
  308.  
  309.                 cout << " " << endl;
  310.  
  311.             }
  312.  
  313.             cout << "=============================================" << endl;
  314.         cout << "Coins: " << "$" << avaCredits;
  315.  
  316.  
  317.         amountDisplay();
  318.         cout << endl;
  319.  
  320.             cout << "=============================================" << endl;
  321.  
  322.             cout << "Play Again? (y/n): ";
  323.             cin >> again;
  324.  
  325.         } while (again == 'y');
  326.         if (again == 'n') {
  327.             PrintMenu();
  328.         }
  329.     }
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336. //Staking System
  337. void Play_Staking() {
  338.  
  339.     char again;
  340.  
  341.     do{
  342.  
  343.         string plusminus;
  344.         int i = 0;
  345.         int pid = 1 + (rand() % 2);
  346.  
  347.         for (int i = 0; i < 20; ++i) {
  348.             p1_Hit[i] = (rand() % 25);
  349.             p2_Hit[i] = (rand() % 25);
  350.             p1_Str[i] = (rand() % 35);
  351.         }
  352.  
  353.         cout << "  __________________________________________   " << endl;
  354.         cout << "<| ======    DUEL ARENA - Staking    ====== |>" << endl;
  355.         cout << "<|__________________________________________|> " << endl;
  356.         cout << " " << endl;
  357.         cout << "Player 1 and Player 2 fight to the death." << endl;
  358.  
  359.         if (s_wins > 0 || s_loss > 0) {
  360.             s_winsPerc = (s_wins / (s_wins + s_loss)) * 100;
  361.             s_lossPerc = (s_loss / (s_wins + s_loss)) * 100;
  362.         }
  363.  
  364.         cout << " " << endl;
  365.         cout << "---------------------------------------------" << endl;
  366.         cout << "Wins: " << s_wins << " || %" << s_winsPerc << endl;
  367.         cout << "Loss: " << s_loss << " || %" << s_lossPerc << endl;
  368.         cout << "---------------------------------------------" << endl;
  369.         cout << " " << endl;
  370.  
  371.         cout << "Coins: $" << avaCredits;
  372.         amountDisplay();
  373.         cout << endl;
  374.  
  375.         cout << "" << endl;
  376.  
  377.         credits();
  378.  
  379.         cout << " " << endl;
  380.  
  381.         cout << "(1) Player 1" << endl;
  382.         cout << "(2) Player 2" << endl;
  383.         cout << " " << endl;
  384.         cout << "Bet on Player(?): ";
  385.         cin >> choice;
  386.  
  387.         while (choice > 2 || choice == 0) {
  388.             cout << "Invalid player choice, enter again: ";
  389.             cin >> choice;
  390.         }
  391.  
  392.         if (choice == 1) {
  393.             player = "Player 1";
  394.         }
  395.         else if (choice == 2) {
  396.             player = "Player 2";
  397.         }
  398.  
  399.         cout << " " << endl;
  400.         cout << "           /\\                            " << endl;
  401.         cout << " _         )( ___________________________      " << endl;
  402.         cout << "(_)///////(**)_______Fight!!!____________>     " << endl;
  403.         cout << "           )(                          " << endl;
  404.         cout << "           \\/                            " << endl;
  405.         cout << " " << endl;
  406.  
  407.         if (pid == 1) {
  408.             while (p1_HP > 0 && p2_HP > 0) {
  409.                 ++i;
  410.  
  411.                 if (p1_HP > 0 && p2_HP > 0) {
  412.  
  413.                     cout << "Player 1: Hits = " << left << setw(15) << p1_Hit[i] << "HP = " << p1_HP << endl;
  414.                     p2_HP = p2_HP - p1_Hit[i];
  415.                 }
  416.  
  417.                 if (p1_HP > 0 && p2_HP > 0) {
  418.  
  419.                     cout << "Player 2: Hits = " << left << setw(15) << p2_Hit[i] << "HP = " << p2_HP << endl;
  420.                     p1_HP = p1_HP - p2_Hit[i];
  421.                 }
  422.             }
  423.         }
  424.  
  425.         else if (pid == 2) {
  426.             while (p1_HP > 0 && p2_HP > 0) {
  427.                 ++i;
  428.  
  429.                 if (p1_HP > 0 && p2_HP > 0) {
  430.  
  431.                     cout << "Player 2: Hits = " << left << setw(15) << p2_Hit[i] << "HP = " << p2_HP << endl;
  432.                     p1_HP = p1_HP - p2_Hit[i];
  433.                 }
  434.  
  435.                 if (p1_HP > 0 && p2_HP > 0) {
  436.  
  437.                     cout << "Player 1: Hits = " << left << setw(15) << p1_Hit[i] << "HP = " << p1_HP << endl;
  438.                     p2_HP = p2_HP - p1_Hit[i];
  439.                 }
  440.             }
  441.         }
  442.  
  443.         if (p1_HP <= 0) {
  444.             cout << " " << endl;
  445.             cout << "Player 1 DEFEATED with HP = " << p1_HP << endl;
  446.             cout << " " << endl;
  447.             cout << "---------------------------------------------" << endl;
  448.             cout << " " << endl;
  449.  
  450.             if (choice == 2) {
  451.                 cout << "Congratulation, you won the bet!" << endl;
  452.                 avaCredits = avaCredits - bet;
  453.                 avaCredits = avaCredits + (bet * 2);
  454.  
  455.                 winner = "Player 2";
  456.  
  457.                 plusminus = "+";
  458.  
  459.                 ++s_wins;
  460.             }
  461.             else if (choice == 1) {
  462.                 cout << "Sorry, you loss the bet!" << endl;
  463.                 avaCredits = avaCredits - bet;
  464.  
  465.                 winner = "Player 1";
  466.                 plusminus = "-";
  467.  
  468.                 ++s_loss;
  469.             }
  470.         }
  471.  
  472.         else if (p2_HP <= 0) {
  473.             cout << " " << endl;
  474.             cout << "Player 2 DEFEATED with HP = " << p2_HP << endl;
  475.             cout << " " << endl;
  476.             cout << "---------------------------------------------" << endl;
  477.             cout << " " << endl;
  478.  
  479.  
  480.             if (choice == 1) {
  481.                 cout << "Congratulation, you won the bet!" << endl;
  482.                 avaCredits = avaCredits - bet;
  483.                 avaCredits = avaCredits + (bet * 2);
  484.  
  485.                 winner = "Player 1";
  486.                 plusminus = "+";
  487.  
  488.                 ++s_wins;
  489.             }
  490.             else if (choice == 2) {
  491.                 cout << "Sorry, you loss the bet!" << endl;
  492.                 avaCredits = avaCredits - bet;
  493.  
  494.                 winner = "Player 2";
  495.                 plusminus = "-";
  496.  
  497.                 ++s_loss;
  498.             }
  499.         }
  500.  
  501.         cout << " " << endl;
  502.         cout << "Winner = " << player << endl;
  503.         cout << "Spoils = " << plusminus << " " << bet << endl;
  504.  
  505.  
  506.         p1_HP = 99;
  507.         p2_HP = 99;
  508.         choice = 0;
  509.  
  510.         cout << " " << endl;
  511.  
  512.         cout << "=============================================" << endl;
  513.         cout << "Coins: " << "$" << avaCredits;
  514.  
  515.  
  516.         amountDisplay();
  517.         cout << endl;
  518.         cout << "=============================================" << endl;
  519.  
  520.         cout << "Play Again? (y/n): ";
  521.         cin >> again;
  522.  
  523.     } while (again == 'y');
  524.     if (again == 'n') {
  525.         PrintMenu();
  526.     }
  527. }
  528.  
  529. void pause() {
  530.     cout << "Press [Enter] to continue." << endl;
  531.     cin.get();
  532. }
  533.  
  534. //Cheat System
  535. void cheatCodes() {
  536.     cout << "  __________________________________________   " << endl;
  537.     cout << "<| ========        Add Coins       ======== |>" << endl;
  538.     cout << "<|__________________________________________|> " << endl;
  539.     cout << "" << endl;
  540.     cout << "Enter amount: ";
  541.     cin >> stringamount;
  542.  
  543.     if (stringamount.find(str1)!= std::string::npos) {
  544.     stringamount.replace(stringamount.find(str1),str1.length(),"000"); }
  545.  
  546.     if (stringamount.find(str2)!= std::string::npos) {
  547.     stringamount.replace(stringamount.find(str2),str2.length(),"000000"); }
  548.  
  549.     if (stringamount.find(str3)!= std::string::npos) {
  550.     stringamount.replace(stringamount.find(str3),str3.length(),"000000000"); }
  551.  
  552.     amountm = atoi(stringamount.c_str());
  553.  
  554.     avaCredits = avaCredits + amountm;
  555.     cout << "[You successfully added '" << amountm << "' coins to your account]" << endl;
  556.  
  557.     cout << " " << endl;
  558.     cout << "---------------------------------------------" << endl;
  559.  
  560.     PrintMenu();
  561.  
  562. }
  563.  
  564. void PrintMenu()
  565. {
  566.     int myChoice = 0;
  567.     cout << " " << endl;
  568.     cout << "  __________________________________________   " << endl;
  569.     cout << "<| ========        Main Menu       ======== |>" << endl;
  570.     cout << "<|__________________________________________|> " << endl;
  571.     cout << " " << endl;
  572.     cout << "(1): [Play] Dicing." << endl;
  573.     cout << "(2): [Play] Dice Duel." << endl;
  574.     cout << "(3): [Play] Staking." << endl;
  575.     cout << "(4): [Add] Coins." << endl;
  576.     cout << "(5): About." << endl;
  577.     cout << " " << endl;
  578.     cout << "---------------------------------------------" << endl;
  579.     cout << " " << endl;
  580.     cout << "Enter menu(?): ";
  581.     cin >> myChoice;
  582.  
  583.     while (myChoice > 4 || myChoice == 0) {
  584.         cout << "Invalid choice. Enter Menu(?): ";
  585.         cin >> myChoice;
  586.     }
  587.  
  588.     switch (myChoice)
  589.     {
  590.     case 1:
  591.  
  592.         Play_Dicing();
  593.  
  594.         break;
  595.     case 2:
  596.  
  597.         Play_DiceDuel();
  598.  
  599.         break;
  600.     case 3:
  601.  
  602.         Play_Staking();
  603.  
  604.         break;
  605.     case 4:
  606.  
  607.         cheatCodes();
  608.  
  609.         break;
  610.     case 5:
  611.  
  612.         cout << "  __________________________________________   " << endl;
  613.         cout << "<| Created by iSayChris - Version 0.95 Beta |>" << endl;
  614.         cout << "<|__________________________________________|> " << endl;
  615.         cout << " " << endl;
  616.         cout << "Do you have what it takes to becomes the next Billionare?" << endl;
  617.         cout << "Tip: You can use the k, m, and b amount multiplier." << endl;
  618.         cout << " " << endl;
  619.         cout << "---------------------------------------------" << endl;
  620.         cout << "" << endl;
  621.  
  622.         myPause();
  623.  
  624.         PrintMenu();
  625.  
  626.         break;
  627.     }
  628. }
  629.  
  630. void myPause()
  631. {
  632.     cout << "Press [Enter] to go back to Main Menu." << endl;
  633.     cin.clear();
  634.     cin.sync();
  635.     cin.get();
  636. }
  637.  
  638. int main()
  639. {
  640.     cout << " " << endl;
  641.     cout << "// Gambling Simulator 2015" << endl;
  642.     cout << "// Created by iSayChris" << endl;
  643.     cout << "// Version : BETA 0.5" << endl;
  644.  
  645.     srand(time(0));
  646.     PrintMenu();
  647.  
  648.     return 0;
  649. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement