Advertisement
Guest User

My Social Studies RPG

a guest
Feb 21st, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 13.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. #include <time.h>
  5. using namespace std;
  6. int health = 100;
  7. int ohealth = 100;
  8. int ans;
  9. int dmgTaken,dmgTakenn;
  10. bool life = true;
  11. int wonInRow = 0;
  12. bool goldenPowder = false;
  13.  
  14. void slowPrint(unsigned long speed, const char *s) {
  15.  
  16.     int i = 0;
  17.     while(s[i]!=0) {
  18.         cout << s[i++];
  19.         cout.flush();
  20.         usleep(speed);
  21.     }
  22. }
  23. int generateRand(){
  24.     int a, b, c, lolrand;
  25.     a = rand();
  26.     lolrand = rand() %10 + 1;
  27.     c = lolrand;
  28.     return c;
  29.  
  30.  
  31. }
  32. int damageRand(){
  33.     int a, b, c, lolrand;
  34.     a = rand();
  35.     lolrand = rand() %20 + 1;
  36.     c = lolrand;
  37.     return c;
  38.  
  39.  
  40. }
  41. int goldenRand(){
  42.     int a, b, c, lolrand;
  43.     a = rand();
  44.     lolrand = rand() %10 + 5;
  45.     c = lolrand;
  46.     return c;
  47.  
  48.  
  49. }
  50. int testWon(){
  51.     if (ohealth <1){
  52.         system("clear");
  53.         slowPrint(50000,"Congratulations! You have beat the game!\nI hope you enjoyed it!\nYour final health was: ");
  54.         cout << health << "\n";
  55.         slowPrint(50000,"You fought a good game, congratulations.\n");
  56.         cout << "Press ENTER\n";
  57.         cin.get();
  58.         return 0;
  59.     }
  60. }
  61. int testLose(){
  62.     if (health <1){
  63.         system("clear");
  64.         slowPrint(50000,"You were shot down!\nYou must now restart :(\nYour enemy's final health was: ");
  65.         cout << ohealth << "\n";
  66.         slowPrint(50000,"See ya later, soldier\n");
  67.         cout << "Press ENTER\n";
  68.         cin.get();
  69.         return 0;
  70.     }
  71. }
  72. void q6(){
  73. }
  74. void q5(){
  75.     testWon();
  76.     testLose();
  77.     system("clear");
  78.     cout << "Health: " << health << endl;
  79.     cout << "Enemy's health: " << ohealth << endl;
  80.     if (wonInRow > 2){
  81.         goldenPowder = true;
  82.         system("clear");
  83.         slowPrint(50000,"You got golden powder for your minnieball musket!\nYou attacks will now become 50% stronger!");
  84.         cin.get();
  85.         system("clear");
  86.     }
  87.     if (wonInRow <=2){
  88.         goldenPowder = false;
  89.     }
  90.     cout << "Who were white southern democrats who wanted to regain power?" <<endl;
  91.     cout << "1)Redeemers" <<endl;
  92.     cout << "2)Red Shirts" <<endl;
  93.     cout << "3)Scalawags" <<endl;
  94.     cin >> ans;
  95.     switch (ans){
  96.         case 2:
  97.         system("clear");
  98.         slowPrint(50000,"You have taken damage!\n");
  99.         dmgTakenn = damageRand();
  100.         health = health - dmgTakenn;
  101.         cout << "Damage taken: " << dmgTakenn << endl;
  102.         wonInRow = 0;
  103.         cin.get();
  104.         cin.get();
  105.         q5();
  106.         break;
  107.         case 3:
  108.         system("clear");
  109.         slowPrint(50000,"You have taken damage!\n");
  110.         dmgTaken = damageRand();
  111.         health = health - dmgTaken;
  112.         cout << "Damage taken: " << dmgTaken << endl;
  113.         wonInRow = 0;
  114.         cin.get();
  115.         cin.get();
  116.         q5();
  117.         break;
  118.         case 1:
  119.         system("clear");
  120.         slowPrint(50000,"You have succeeded!\n");
  121.         wonInRow++;
  122.         if (goldenPowder == true){
  123.             int dmg = goldenRand();
  124.             ohealth = ohealth - dmg;
  125.             if (dmg > 7){
  126.             cout << "Critical hit!\n" << endl;
  127.             }
  128.         }
  129.         if (goldenPowder == false){
  130.             int dmg = generateRand();
  131.             ohealth = ohealth - dmg;
  132.             if (dmg > 7){
  133.             cout << "Critical hit!\n" << endl;
  134.             }
  135.         }
  136.         cout << "Health: " << health << endl;
  137.         cout << "Enemy's health: " << ohealth << endl;
  138.         cout << "\n\nPress ENTER to continue to the next question...\n" << endl;
  139.         cin.get();
  140.         cin.get();
  141.         q6();
  142.         break;
  143.  
  144.  
  145.  
  146.     }
  147.  
  148.  
  149. }
  150. void q4(){
  151.     testWon();
  152.     testLose();
  153.     system("clear");
  154.     cout << "Health: " << health << endl;
  155.     cout << "Enemy's health: " << ohealth << endl;
  156.     if (wonInRow > 2){
  157.         goldenPowder = true;
  158.         system("clear");
  159.         slowPrint(50000,"You got golden powder for your minnieball musket!\nYou attacks will now become 50% stronger!");
  160.         cin.get();
  161.         system("clear");
  162.     }
  163.     if (wonInRow <=2){
  164.         goldenPowder = false;
  165.     }
  166.     cout << "Who were white southern democrats who wanted to regain power?" <<endl;
  167.     cout << "1)Redeemers" <<endl;
  168.     cout << "2)Red Shirts" <<endl;
  169.     cout << "3)Scalawags" <<endl;
  170.     cin >> ans;
  171.     switch (ans){
  172.         case 2:
  173.         system("clear");
  174.         slowPrint(50000,"You have taken damage!\n");
  175.         dmgTakenn = damageRand();
  176.         health = health - dmgTakenn;
  177.         cout << "Damage taken: " << dmgTakenn << endl;
  178.         wonInRow = 0;
  179.         cin.get();
  180.         cin.get();
  181.         q4();
  182.         break;
  183.         case 3:
  184.         system("clear");
  185.         slowPrint(50000,"You have taken damage!\n");
  186.         dmgTaken = damageRand();
  187.         health = health - dmgTaken;
  188.         cout << "Damage taken: " << dmgTaken << endl;
  189.         wonInRow = 0;
  190.         cin.get();
  191.         cin.get();
  192.         q4();
  193.         break;
  194.         case 1:
  195.         system("clear");
  196.         slowPrint(50000,"You have succeeded!\n");
  197.         wonInRow++;
  198.         if (goldenPowder == true){
  199.             int dmg = goldenRand();
  200.             ohealth = ohealth - dmg;
  201.             if (dmg > 7){
  202.             cout << "Critical hit!\n" << endl;
  203.             }
  204.         }
  205.         if (goldenPowder == false){
  206.             int dmg = generateRand();
  207.             ohealth = ohealth - dmg;
  208.             if (dmg > 7){
  209.             cout << "Critical hit!\n" << endl;
  210.             }
  211.         }
  212.         cout << "Health: " << health << endl;
  213.         cout << "Enemy's health: " << ohealth << endl;
  214.         cout << "\n\nPress ENTER to continue to the next question...\n" << endl;
  215.         cin.get();
  216.         cin.get();
  217.         q5();
  218.         break;
  219.  
  220.  
  221.  
  222.     }
  223.  
  224.  
  225. }
  226. void q3(){
  227.     testWon();
  228.     testLose();
  229.     system("clear");
  230.     cout << "Health: " << health << endl;
  231.     cout << "Enemy's health: " << ohealth << endl;
  232.     if (wonInRow > 2){
  233.         goldenPowder = true;
  234.         system("clear");
  235.         slowPrint(50000,"You got golden powder for your minnieball musket!\nYou attacks will now become 50% stronger!");
  236.         cin.get();
  237.         system("clear");
  238.     }
  239.     if (wonInRow <=2){
  240.         goldenPowder = false;
  241.     }
  242.     cout << "What amendment provided \"equality of the law\"?" <<endl;
  243.     cout << "1)13th Amendment" <<endl;
  244.     cout << "2)14th Amendment" <<endl;
  245.     cout << "3)15th Amendment" <<endl;
  246.     cin >> ans;
  247.     switch (ans){
  248.         case 1:
  249.         system("clear");
  250.         slowPrint(50000,"You have taken damage!\n");
  251.         dmgTakenn = damageRand();
  252.         health = health - dmgTakenn;
  253.         cout << "Damage taken: " << dmgTakenn << endl;
  254.         wonInRow = 0;
  255.         cin.get();
  256.         cin.get();
  257.         q3();
  258.         break;
  259.         case 3:
  260.         system("clear");
  261.         slowPrint(50000,"You have taken damage!\n");
  262.         dmgTaken = damageRand();
  263.         health = health - dmgTaken;
  264.         cout << "Damage taken: " << dmgTaken << endl;
  265.         wonInRow = 0;
  266.         cin.get();
  267.         cin.get();
  268.         q3();
  269.         break;
  270.         case 2:
  271.         system("clear");
  272.         slowPrint(50000,"You have succeeded!\n");
  273.         wonInRow++;
  274.         if (goldenPowder == true){
  275.             int dmg = goldenRand();
  276.             ohealth = ohealth - dmg;
  277.             if (dmg > 7){
  278.             cout << "Critical hit!\n" << endl;
  279.             }
  280.         }
  281.         if (goldenPowder == false){
  282.             int dmg = generateRand();
  283.             ohealth = ohealth - dmg;
  284.             if (dmg > 7){
  285.             cout << "Critical hit!\n" << endl;
  286.             }
  287.         }
  288.         cout << "Health: " << health << endl;
  289.         cout << "Enemy's health: " << ohealth << endl;
  290.         cout << "\n\nPress ENTER to continue to the next question...\n" << endl;
  291.         cin.get();
  292.         cin.get();
  293.         q4();
  294.         break;
  295.  
  296.  
  297.  
  298.     }
  299.  
  300.  
  301. }
  302. void q2(){
  303.     testWon();
  304.     testLose();
  305.     system("clear");
  306.     cout << "Health: " << health << endl;
  307.     cout << "Enemy's health: " << ohealth << endl;
  308.     if (wonInRow > 2){
  309.         goldenPowder = true;
  310.         system("clear");
  311.         slowPrint(50000,"You got golden powder for your minnieball musket!\nYou attacks will now become 50% stronger!");
  312.         cin.get();
  313.         system("clear");
  314.     }
  315.     if (wonInRow <=2){
  316.         goldenPowder = false;
  317.     }
  318.     cout << "Who was elected that ended reconstruction?" <<endl;
  319.     cout << "1)Daniel Chamberlain" <<endl;
  320.     cout << "2)Rutherford B. Hayes" <<endl;
  321.     cout << "3)Wade Hampton" <<endl;
  322.     cin >> ans;
  323.     switch (ans){
  324.         case 1:
  325.         system("clear");
  326.         slowPrint(50000,"You have taken damage!\n");
  327.         dmgTakenn = damageRand();
  328.         health = health - dmgTakenn;
  329.         cout << "Damage taken: " << dmgTakenn << endl;
  330.         wonInRow = 0;
  331.         cin.get();
  332.         cin.get();
  333.         q2();
  334.         break;
  335.         case 3:
  336.         system("clear");
  337.         slowPrint(50000,"You have taken damage!\n");
  338.         dmgTaken = damageRand();
  339.         health = health - dmgTaken;
  340.         cout << "Damage taken: " << dmgTaken << endl;
  341.         wonInRow = 0;
  342.         cin.get();
  343.         cin.get();
  344.         q2();
  345.         break;
  346.         case 2:
  347.         system("clear");
  348.         slowPrint(50000,"You have succeeded!\n");
  349.         wonInRow++;
  350.         if (goldenPowder == true){
  351.             int dmg = goldenRand();
  352.             ohealth = ohealth - dmg;
  353.             if (dmg > 7){
  354.             cout << "Critical hit!\n" << endl;
  355.             }
  356.         }
  357.         if (goldenPowder == false){
  358.             int dmg = generateRand();
  359.             ohealth = ohealth - dmg;
  360.             if (dmg > 7){
  361.             cout << "Critical hit!\n" << endl;
  362.             }
  363.         }
  364.         cout << "Health: " << health << endl;
  365.         cout << "Enemy's health: " << ohealth << endl;
  366.         cout << "\n\nPress ENTER to continue to the next question...\n" << endl;
  367.         cin.get();
  368.         cin.get();
  369.         q3();
  370.         break;
  371.  
  372.  
  373.  
  374.     }
  375.  
  376.  
  377. }
  378. void q1(){
  379.     testWon();
  380.     testLose();
  381.     system("clear");
  382.     cout << "Health: " << health << endl;
  383.     cout << "Enemy's health: " << ohealth << endl;
  384.     if (wonInRow > 2){
  385.         goldenPowder = true;
  386.         system("clear");
  387.         slowPrint(50000,"You got golden powder for your minnieball musket!\nYou attacks will now become 50% stronger!");
  388.         cin.get();
  389.         system("clear");
  390.     }
  391.     if (wonInRow <=2){
  392.         goldenPowder = false;
  393.     }
  394.     cout << "What is corruption?" <<endl;
  395.     cout << "1)Breaking the law" <<endl;
  396.     cout << "2)Radical Republicans" <<endl;
  397.     cout << "3)Dishonest practices" <<endl;
  398.     cin >> ans;
  399.     switch (ans){
  400.         case 1:
  401.         system("clear");
  402.         slowPrint(50000,"You have taken damage!\n");
  403.         dmgTakenn = damageRand();
  404.         health = health - dmgTakenn;
  405.         cout << "Damage taken: " << dmgTakenn << endl;
  406.         wonInRow = 0;
  407.         cin.get();
  408.         cin.get();
  409.         q1();
  410.         break;
  411.         case 2:
  412.         system("clear");
  413.         slowPrint(50000,"You have taken damage!\n");
  414.         dmgTaken = damageRand();
  415.         health = health - dmgTaken;
  416.         cout << "Damage taken: " << dmgTaken << endl;
  417.         wonInRow = 0;
  418.         cin.get();
  419.         cin.get();
  420.         q1();
  421.         break;
  422.         case 3:
  423.         system("clear");
  424.         slowPrint(50000,"You have succeeded!\n");
  425.         wonInRow++;
  426.         if (goldenPowder == true){
  427.             int dmg = goldenRand();
  428.             ohealth = ohealth - dmg;
  429.             if (dmg > 7){
  430.             cout << "Critical hit!\n" << endl;
  431.             }
  432.         }
  433.         if (goldenPowder == false){
  434.             int dmg = generateRand();
  435.             ohealth = ohealth - dmg;
  436.             if (dmg > 7){
  437.             cout << "Critical hit!\n" << endl;
  438.             }
  439.         }
  440.         cout << "Health: " << health << endl;
  441.         cout << "Enemy's health: " << ohealth << endl;
  442.         cout << "\n\nPress ENTER to continue to the next question...\n" << endl;
  443.         cin.get();
  444.         cin.get();
  445.         q2();
  446.         break;
  447.  
  448.  
  449.  
  450.     }
  451.  
  452.  
  453. }
  454. void play(){
  455.     system("clear");
  456.  
  457.     /*
  458.     Here comes the questions. :D
  459.     */
  460.     q1();
  461.  
  462. }
  463. void menu(){
  464.     system("clear");
  465.     cout << "****Crazy*Boss*RPG****\n";
  466.     cout << "**1)*Play*************\n";
  467.     cout << "**2)*About************\n";
  468.     cout << "**3)*Quit*************\n";
  469.     cout << "**********************\n";
  470.     int ch;
  471.     cin >> ch;
  472.     switch (ch){
  473.         case 1:
  474.         play();
  475.         break;
  476.         case 2:
  477.         system("clear");
  478.         slowPrint(50000,"\n\nCreated by Julian Rachele, started Febuary 19, 2012 for a SS project.\nIt uses C++ and the standard library.\nTook me a while to make, even if it is an ASCII based game.\n");
  479.         cin.get();
  480.         cin.get();
  481.         menu();
  482.         break;
  483.         case 3:
  484.         break;
  485.         default:
  486.         cout << "Please type in a correct value, thanks." << endl;
  487.         break;
  488.     }
  489.  
  490.  
  491. }
  492. int main() {
  493.     system("clear");
  494.     srand(time(0));
  495.     slowPrint(50000,"Julian Rachele Presents...\n");
  496.     slowPrint(50000,"A fun game that will (hopefully) keep you playing\n");
  497.     slowPrint(50000,"The Crazy Boss Social Studies RPG! (v1.0)\n");
  498.     slowPrint(50000,"Press [Enter].");
  499.     cin.get();
  500.     system("clear");
  501.     menu();
  502.     return 0;
  503. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement