Advertisement
daisukiseiya

duel arena v4

Dec 21st, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 13.43 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. struct player {
  10.     string name = "";
  11.     int hp = 99;
  12.     int max = 25;
  13.     int hit = 0;
  14. };
  15.  
  16. struct stats {
  17.     float wins = 0;
  18.     float loss = 0;
  19.     float winsPerc = 0;
  20.     float lossPerc = 0;
  21. };
  22.  
  23. class duelarena {
  24. public:
  25.     void PrintMenu();
  26.     void myPause();
  27.  
  28. private:
  29.     //betting & credits
  30.     int bet;
  31.     int choice;
  32.     int avaCredits = 10000;
  33.  
  34.     player p1;
  35.     player p2;
  36.     stats dice;
  37.     stats stake;
  38.     stats diceduel;
  39.  
  40.     //cheats switch
  41.     bool strcheat = false;
  42.     bool hpcheat = false;
  43.  
  44.     //cheatcode holder
  45.     string code;
  46.     string person;
  47.     string winner;
  48.  
  49.     void credits();
  50.     void print_stats(stats & x);
  51.     void Play_Dicing();
  52.     void Play_DiceDuel();
  53.     void Play_Staking();
  54.     void cheatCodes();
  55.     void store();
  56. };
  57.  
  58. //credit system
  59. void duelarena::credits() {
  60.     cout << "Enter betting amount: ";
  61.     cin >> bet;
  62.  
  63.     if (avaCredits == 0) {
  64.         cout << "You don't have enough coins to continue. # cleaned.";
  65.         cout << " " << endl;
  66.         PrintMenu();
  67.     }
  68.  
  69.     while (bet > avaCredits) {
  70.         cout << "You don't have enough coins. \nEnter again: ";
  71.         cin >> bet;
  72.     }
  73. }
  74.  
  75. void duelarena::print_stats(stats &x) {
  76.     if (x.wins > 0 || x.loss > 0) {
  77.         x.winsPerc = (x.wins / (x.wins + dice.loss)) * 100;
  78.         x.lossPerc = (x.loss / (x.wins + dice.loss)) * 100;
  79.     }
  80.  
  81.     cout << " " << endl;
  82.     cout << "---------------------------------------------" << endl;
  83.     cout << "Wins: " << x.wins << " || %" << x.winsPerc << endl;
  84.     cout << "Loss: " << x.loss << " || %" << x.lossPerc << endl;
  85.     cout << "---------------------------------------------" << endl;
  86.     cout << " " << endl;
  87.  
  88.     cout << "Coins: $" << avaCredits << endl;
  89.     cout << "" << endl;
  90.  
  91.     credits();
  92. }
  93.  
  94. //Dicing System
  95. void duelarena::Play_Dicing() {
  96.     char again;
  97.  
  98.     do {
  99.  
  100.         int diceRoll = (rand() % 100);
  101.         string plusminus;
  102.  
  103.         cout << "  __________________________________________   " << endl;
  104.         cout << "<| ======    DUEL ARENA - Dicing     ====== |>" << endl;
  105.         cout << "<|__________________________________________|> " << endl;
  106.         cout << " " << endl;
  107.         cout << "Roll a 55 or higher to win your bet. " << endl;
  108.  
  109.         print_stats(dice);
  110.  
  111.         cout << "     ____              " << endl;
  112.         cout << "    /\\' .\\    _____    " << endl;
  113.         cout << "   /: \\___\\  / .  /\\   " << endl;
  114.         cout << "   \\' / . / /____/..\\  " << endl;
  115.         cout << "    \\/___/  \\'  '\\  /  " << endl;
  116.         cout << "             \\'__'\\/   " << endl;
  117.  
  118.         cout << " " << endl;
  119.         cout << "[Rolling dice: " << diceRoll << "]" << endl;
  120.         cout << " " << endl;
  121.  
  122.         if (diceRoll > 55) {
  123.             cout << "Congratulations, you won the bet!" << endl;
  124.             avaCredits = avaCredits - bet;
  125.             avaCredits = avaCredits + (bet * 2);
  126.  
  127.             plusminus = "+";
  128.  
  129.             ++dice.wins;
  130.         }
  131.         else {
  132.             cout << "Sorry, you loss the bet!" << endl;
  133.             avaCredits = avaCredits - bet;
  134.  
  135.             plusminus = "-";
  136.  
  137.             ++dice.loss;
  138.         }
  139.  
  140.         cout << " " << endl;
  141.         cout << "Spoils = " << plusminus << " " << bet << endl;
  142.  
  143.         cout << " " << endl;
  144.  
  145.         cout << "=============================================" << endl;
  146.         cout << "Coins: " << "$" << avaCredits << endl;
  147.         cout << "=============================================" << endl;
  148.  
  149.         cout << "Play Again? (y/n): ";
  150.         cin >> again;
  151.  
  152.     } while (again == 'y');
  153.     if (again == 'n') {
  154.         PrintMenu();
  155.     }
  156. }
  157.  
  158.  
  159. //Dicing System
  160. void duelarena::Play_DiceDuel() {
  161.     char again;
  162.  
  163.     do {
  164.         int p1_diceRoll = (rand() % 100);
  165.         int p2_diceRoll = (rand() % 100);
  166.  
  167.         string plusminus;
  168.  
  169.         cout << "  __________________________________________   " << endl;
  170.         cout << "<| ======   DUEL ARENA - Dice Duel   ====== |>" << endl;
  171.         cout << "<|__________________________________________|> " << endl;
  172.         cout << " " << endl;
  173.         cout << "Roll higher than Player 2 to win your bet. " << endl;
  174.  
  175.         print_stats(diceduel);
  176.  
  177.         cout << "     ____              " << endl;
  178.         cout << "    /\\' .\\    _____    " << endl;
  179.         cout << "   /: \\___\\  / .  /\\   " << endl;
  180.         cout << "   \\' / . / /____/..\\  " << endl;
  181.         cout << "    \\/___/  \\'  '\\  /  " << endl;
  182.         cout << "             \\'__'\\/   " << endl;
  183.  
  184.  
  185.         cout << " " << endl;
  186.         cout << "[Player 1 rolls: " << p1_diceRoll << "]" << endl;
  187.         cout << "[Player 2 rolls: " << p2_diceRoll << "]" << endl;
  188.         cout << " " << endl;
  189.  
  190.         if (p1_diceRoll == p2_diceRoll) {
  191.             cout << "You both roll the same number. its a tie!" << endl;
  192.         }
  193.  
  194.         if (p1_diceRoll > p2_diceRoll) {
  195.             cout << "Congratulations, you won the bet!" << endl;
  196.             avaCredits = avaCredits - bet;
  197.             avaCredits = avaCredits + (bet * 2);
  198.  
  199.             plusminus = "+";
  200.  
  201.             ++diceduel.wins;
  202.  
  203.             cout << " " << endl;
  204.             cout << "Spoils = " << plusminus << " " << bet << endl;
  205.  
  206.             cout << " " << endl;
  207.  
  208.         }
  209.         else {
  210.             cout << "Sorry, you loss the bet!" << endl;
  211.             avaCredits = avaCredits - bet;
  212.  
  213.             plusminus = "-";
  214.  
  215.             ++diceduel.loss;
  216.  
  217.             cout << " " << endl;
  218.             cout << "Spoils = " << plusminus << " " << bet << endl;
  219.  
  220.             cout << " " << endl;
  221.  
  222.         }
  223.  
  224.         cout << "=============================================" << endl;
  225.         cout << "Coins: " << "$" << avaCredits << endl;
  226.         cout << "=============================================" << endl;
  227.  
  228.         cout << "Play Again? (y/n): ";
  229.         cin >> again;
  230.  
  231.     } while (again == 'y');
  232.     if (again == 'n') {
  233.         PrintMenu();
  234.     }
  235. }
  236.  
  237. //Staking System
  238. void duelarena::Play_Staking() {
  239.  
  240.     char again;
  241.  
  242.     do {
  243.  
  244.         if (strcheat == true) {
  245.             p1.max = 35;
  246.         }
  247.  
  248.         if (hpcheat == true){
  249.             p1.hp = 99999;
  250.         }
  251.  
  252.         string plusminus;
  253.         int i = 0;
  254.         int pid = 1 + (rand() % 2);
  255.  
  256.         cout << "  __________________________________________   " << endl;
  257.         cout << "<| ======    DUEL ARENA - Staking    ====== |>" << endl;
  258.         cout << "<|__________________________________________|> " << endl;
  259.         cout << " " << endl;
  260.         cout << "Player 1 and Player 2 fight to the death." << endl;
  261.  
  262.         print_stats(stake);
  263.  
  264.         cout << " " << endl;
  265.  
  266.         cout << "(1) Player 1" << endl;
  267.         cout << "(2) Player 2" << endl;
  268.         cout << " " << endl;
  269.         cout << "Bet on Player(?): ";
  270.         cin >> choice;
  271.  
  272.         while (choice > 2 || choice == 0) {
  273.             cout << "Invalid player choice, enter again: ";
  274.             cin >> choice;
  275.         }
  276.  
  277.         if (choice == 1) {
  278.             person = "Player 1";
  279.         }
  280.         else if (choice == 2) {
  281.             person = "Player 2";
  282.         }
  283.  
  284.         cout << " " << endl;
  285.         cout << "           /\\                            " << endl;
  286.         cout << " _         )( ___________________________      " << endl;
  287.         cout << "(_)///////(**)_______Fight!!!____________>     " << endl;
  288.         cout << "           )(                          " << endl;
  289.         cout << "           \\/                            " << endl;
  290.         cout << " " << endl;
  291.  
  292.         if (pid == 1) {
  293.             while (p1.hp > 0 && p2.hp > 0) {
  294.                 ++i;
  295.  
  296.                 if (p1.hp > 0 && p2.hp > 0) {
  297.                     p1.hit = rand() % p1.max;
  298.                     cout << "Player 1: Hits = " << left << setw(15) << p1.hit << "HP = " << p1.hp << endl;
  299.                     p2.hp = p2.hp - p1.hit;
  300.                 }
  301.  
  302.                 if (p1.hp > 0 && p2.hp > 0) {
  303.                     p2.hit = rand() % 25;
  304.                     cout << "Player 2: Hits = " << left << setw(15) << p2.hit << "HP = " << p2.hp << endl;
  305.                     p1.hp = p1.hp - p2.hit;
  306.                 }
  307.             }
  308.         }
  309.  
  310.         else if (pid == 2) {
  311.             while (p1.hp > 0 && p2.hp > 0) {
  312.                 ++i;
  313.  
  314.                 if (p1.hp > 0 && p2.hp > 0) {
  315.                     p2.hit = rand() % 25;
  316.                     cout << "Player 2: Hits = " << left << setw(15) << p2.hit << "HP = " << p2.hp << endl;
  317.                     p1.hp = p1.hp - p2.hit;
  318.                 }
  319.  
  320.                 if (p1.hp > 0 && p2.hp > 0) {
  321.                     p1.hit = rand() % p1.max;
  322.                     cout << "Player 1: Hits = " << left << setw(15) << p1.hit<< "HP = " << p1.hp << endl;
  323.                     p2.hp = p2.hp - p1.hit;
  324.                 }
  325.             }
  326.         }
  327.  
  328.         if (p1.hp <= 0) {
  329.             cout << " " << endl;
  330.             cout << "Player 1 DEFEATED with HP = " << p1.hp << endl;
  331.             cout << " " << endl;
  332.             cout << "---------------------------------------------" << endl;
  333.             cout << " " << endl;
  334.  
  335.             if (choice == 2) {
  336.                 cout << "Congratulation, you won the bet!" << endl;
  337.                 avaCredits = avaCredits - bet;
  338.                 avaCredits = avaCredits + (bet * 2);
  339.  
  340.                 winner = "Player 2";
  341.  
  342.                 plusminus = "+";
  343.  
  344.                 ++stake.wins;
  345.             }
  346.             else if (choice == 1) {
  347.                 cout << "Sorry, you loss the bet!" << endl;
  348.                 avaCredits = avaCredits - bet;
  349.  
  350.                 winner = "Player 1";
  351.                 plusminus = "-";
  352.  
  353.                 ++stake.loss;
  354.             }
  355.         }
  356.  
  357.         else if (p2.hp <= 0) {
  358.             cout << " " << endl;
  359.             cout << "Player 2 DEFEATED with HP = " << p2.hp << endl;
  360.             cout << " " << endl;
  361.             cout << "---------------------------------------------" << endl;
  362.             cout << " " << endl;
  363.  
  364.  
  365.             if (choice == 1) {
  366.                 cout << "Congratulation, you won the bet!" << endl;
  367.                 avaCredits = avaCredits - bet;
  368.                 avaCredits = avaCredits + (bet * 2);
  369.  
  370.                 winner = "Player 1";
  371.                 plusminus = "+";
  372.  
  373.                 ++stake.wins;
  374.             }
  375.             else if (choice == 2) {
  376.                 cout << "Sorry, you loss the bet!" << endl;
  377.                 avaCredits = avaCredits - bet;
  378.  
  379.                 winner = "Player 2";
  380.                 plusminus = "-";
  381.  
  382.                 ++stake.loss;
  383.             }
  384.         }
  385.  
  386.         cout << " " << endl;
  387.         cout << "Winner = " << person << endl;
  388.         cout << "Spoils = " << plusminus << " " << bet << endl;
  389.  
  390.         p1.hp = 99;
  391.         p2.hp = 99;
  392.         choice = 0;
  393.  
  394.         cout << " " << endl;
  395.  
  396.         cout << "=============================================" << endl;
  397.         cout << "Coins: " << "$" << avaCredits << endl;
  398.         cout << "=============================================" << endl;
  399.  
  400.         cout << "Play Again? (y/n): ";
  401.         cin >> again;
  402.  
  403.     } while (again == 'y');
  404.     if (again == 'n') {
  405.         PrintMenu();
  406.     }
  407. }
  408.  
  409. void pause() {
  410.     cout << "Press [Enter] to continue." << endl;
  411.     cin.get();
  412. }
  413.  
  414. //Cheat System
  415. void duelarena::cheatCodes() {
  416.     cout << "  __________________________________________   " << endl;
  417.     cout << "<| ========        Add Coins       ======== |>" << endl;
  418.     cout << "<|__________________________________________|> " << endl;
  419.     cout << "" << endl;
  420.     cout << "Enter code: ";
  421.     cin >> code;
  422.  
  423.     cout << " " << endl;
  424.  
  425.     if (code == "money1") {
  426.         avaCredits = avaCredits + 10000;
  427.         cout << "[You successfully redeem 'money1' for 10,000 coins]" << endl;
  428.     }
  429.     else if (code == "money2") {
  430.         avaCredits = avaCredits + 100000;
  431.         cout << "[You successfully redeem 'money2' for 100,000 coins]" << endl;
  432.     }
  433.     else if (code == "bank") {
  434.         avaCredits = avaCredits + 1000000;
  435.         cout << "[You successfully redeem 'bank' for 1,000,000 coins]" << endl;
  436.     }
  437.     else if (code == "cash") {
  438.         avaCredits = avaCredits + 10000000;
  439.         cout << "[You successfully redeem 'cash' for 10,000,000 coins]" << endl;
  440.     }
  441.     else if (code == "showmethemoney") {
  442.         avaCredits = avaCredits + 100000000;
  443.         cout << "[You successfully redeem 'showmethemoney' for 100,000,000 coins]" << endl;
  444.     }
  445.     else if (code == "strengthpot") {
  446.         strcheat = true;
  447.         cout << "[Player 1 max hit increased to 35]" << endl;
  448.     }
  449.     else if (code == "hacker") {
  450.         hpcheat = true;
  451.         cout << "[Player 1 hp set to 9999]" << endl;
  452.     }
  453.     else {
  454.         cout << "You entered an invalid code, please try again." << endl;
  455.     }
  456.  
  457.     cout << " " << endl;
  458.     cout << "---------------------------------------------" << endl;
  459.  
  460.     PrintMenu();
  461.  
  462. }
  463.  
  464. void duelarena::store() {
  465.     cout << "  __________________________________________   " << endl;
  466.     cout << "<| ========          Store         ======== |>" << endl;
  467.     cout << "<|__________________________________________|> " << endl;
  468.     cout << "" << endl;
  469.  
  470.     cout << "Coming soon..." << endl;
  471.     cout << " " << endl;
  472.     cout << "---------------------------------------------" << endl;
  473.  
  474.     PrintMenu();
  475. }
  476.  
  477. void duelarena::PrintMenu()
  478. {
  479.     int myChoice = 0;
  480.  
  481.     cout << " " << endl;
  482.     cout << "  __________________________________________   " << endl;
  483.     cout << "<| ========        Main Menu       ======== |>" << endl;
  484.     cout << "<|__________________________________________|> " << endl;
  485.     cout << " " << endl;
  486.     cout << "(1): [Play] Dicing." << endl;
  487.     cout << "(2): [Play] Dice Duel." << endl;
  488.     cout << "(3): [Play] Staking." << endl;
  489.     cout << "(4): [Add] Code." << endl;
  490.     cout << "(5): [Buy] Store." << endl;
  491.     cout << "(6): About." << endl;
  492.     cout << " " << endl;
  493.     cout << "---------------------------------------------" << endl;
  494.     cout << " " << endl;
  495.     cout << "Enter menu(?): ";
  496.     cin >> myChoice;
  497.  
  498.     while (myChoice > 6 || myChoice < 0) {
  499.         cout << "Invalid choice. Enter Menu(?): ";
  500.         cin >> myChoice;
  501.     }
  502.  
  503.     switch (myChoice)
  504.     {
  505.         case 1:
  506.  
  507.             Play_Dicing();
  508.  
  509.             break;
  510.         case 2:
  511.  
  512.             Play_DiceDuel();
  513.  
  514.             break;
  515.         case 3:
  516.  
  517.             Play_Staking();
  518.  
  519.             break;
  520.         case 4:
  521.  
  522.             cheatCodes();
  523.  
  524.             break;
  525.  
  526.         case 5:
  527.  
  528.             store();
  529.  
  530.             break;
  531.         case 6:
  532.  
  533.             cout << "  __________________________________________   " << endl;
  534.             cout << "<| Created by iSayChris - Version 0.95 Beta |>" << endl;
  535.             cout << "<|__________________________________________|> " << endl;
  536.             cout << " " << endl;
  537.             cout << "Redeemable codes:" << endl;
  538.             cout << "'money1' = 10k" << endl;
  539.             cout << "'money2' = 100k" << endl;
  540.             cout << "'bank' = 1M" << endl;
  541.             cout << "'cash' = 10M" << endl;
  542.             cout << "'showmethemoney' = 100M" << endl;
  543.             cout << "'strengthpot' = increases max hit to 35." << endl;
  544.             cout << "'hacker' = ???" << endl;
  545.             cout << " " << endl;
  546.             cout << "---------------------------------------------" << endl;
  547.             cout << "" << endl;
  548.  
  549.             myPause();
  550.  
  551.             PrintMenu();
  552.  
  553.             break;
  554.     }
  555. }
  556.  
  557. void duelarena::myPause()
  558. {
  559.     cout << "Press [Enter] to go back to Main Menu." << endl;
  560.     cin.clear();
  561.     cin.sync();
  562.     cin.get();
  563. }
  564.  
  565. int main()
  566. {
  567.     duelarena o;
  568.  
  569.     cout << " " << endl;
  570.     cout << "// Gambling Simulator 2016" << endl;
  571.     cout << "// Created by iSayChris" << endl;
  572.     cout << "// Version : 1.1" << endl;
  573.  
  574.     srand(time(0));
  575.     o.PrintMenu();
  576.  
  577.     return 0;
  578. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement