Advertisement
Guest User

Dino Arena (Unfinished)

a guest
Jan 13th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 26.28 KB | None | 0 0
  1. //Main.cpp
  2.  
  3. #include <iostream>
  4. #include <fstream>
  5. #include <string>
  6. #include <vector>
  7. #include <cstdlib>
  8. #include <ctime>
  9. #include <sstream>
  10.  
  11. #include "player.h"
  12. #include "Dinosaur.h"
  13. #include "Prototypes.h"
  14.  
  15. using namespace std;
  16.  
  17. Player::Player(unsigned int PLAYERHEALTH, unsigned int PISTOLAMMO,
  18.                unsigned int SHOTGUNAMMO, unsigned int RIFLEAMMO,
  19.                unsigned int SCORE, unsigned int MONEY,
  20.                unsigned int HEALTHPACKS, int TURNS, std::vector<int> ITEMS): playerHealth(PLAYERHEALTH),
  21.                                                                              pistolAmmo(PISTOLAMMO),
  22.                                                                              shotgunAmmo(SHOTGUNAMMO),
  23.                                                                              rifleAmmo(RIFLEAMMO),
  24.                                                                              score(SCORE),
  25.                                                                              money(MONEY),
  26.                                                                              healthPacks(HEALTHPACKS),
  27.                                                                              turns(TURNS)
  28. {
  29.  
  30. }
  31.  
  32.  
  33. Dinosaur::Dinosaur(int DINOSAURHEALTH, int ATTACKS, time_t CREATETIME): dinosaurHealth(DINOSAURHEALTH),
  34.                                                                         attacks(ATTACKS),
  35.                                                                         createTime(CREATETIME)
  36. {
  37.  
  38. }
  39.  
  40.  
  41. /*
  42. ==================|
  43. Main Menu function|
  44. ==================|
  45. */
  46.  
  47. int Menu(Player &player, Dinosaur &dinosaur)
  48. {
  49.     int intChoice;
  50.     string strChoice;
  51.  
  52.     cout << "Build 1.2.0" << endl;
  53.     cout << "\n";
  54.     cout << "DINOSAUR ARENA\n" << endl;
  55.  
  56.     cout << "What do you want to do?\n" << endl;
  57.     cout << "1) Load Game" << endl;
  58.     cout << "2) New Game" << endl;
  59.     cout << "3) Game Info" << endl;
  60.     cout << "4) Quit Game" << endl;
  61.  
  62.     do
  63.     {
  64.         stringstream ss; //Why does this need to be in the loop for the stringstream to work?
  65.                          //Without it, the program will not convert the string to int.
  66.         getline(cin, strChoice);
  67.  
  68.         ss << strChoice;
  69.         ss >> intChoice;
  70.  
  71.         //Debug
  72.         cout << "strChoice: " << strChoice << endl;
  73.         cout << "intChoice: " << intChoice << endl;
  74.         //End Debug
  75.  
  76.         switch(intChoice)
  77.         {
  78.             case 1:
  79.                 load(player, dinosaur);
  80.             break;
  81.  
  82.             case 2:
  83.                 MainGame(player, dinosaur);
  84.             break;
  85.  
  86.             case 3:
  87.                 gameInfo();
  88.             break;
  89.  
  90.             case 4:
  91.                 return 0;
  92.             break;
  93.  
  94.             default:
  95.                 cout << "Error" << endl;
  96.             break;
  97.         }
  98.     }
  99.     while(intChoice != -1);
  100. }
  101.  
  102.  
  103. /*
  104. =============|
  105. Save function|
  106. =============|
  107. */
  108.  
  109. void save(Player &player, Dinosaur &dinosaur)
  110. {
  111.     ofstream fileOut;
  112.  
  113.     fileOut.open("DASave.txt");
  114.  
  115.     fileOut << player.playerHealth << endl;
  116.     fileOut << player.pistolAmmo << endl;
  117.     fileOut << player.shotgunAmmo << endl;
  118.     fileOut << player.rifleAmmo << endl;
  119.     fileOut << player.score << endl;
  120.     fileOut << player.money << endl;
  121.     fileOut << player.healthPacks << endl;
  122.  
  123.     MainGame(player, dinosaur);
  124. }
  125.  
  126.  
  127. /*
  128. =============|
  129. Load function|
  130. =============|
  131. */
  132.  
  133. void load(Player &player, Dinosaur &dinosaur)
  134. {
  135.     //TODO
  136.     //Add error checking for loading function
  137.  
  138.     ifstream fileIn;
  139.  
  140.     fileIn.open("DASave.txt");
  141.  
  142.     fileIn >> player.playerHealth;
  143.     fileIn >> player.pistolAmmo;
  144.     fileIn >> player.shotgunAmmo;
  145.     fileIn >> player.rifleAmmo;
  146.     fileIn >> player.score;
  147.     fileIn >> player.money;
  148.     fileIn >> player.healthPacks;
  149.  
  150.     cout << "Health: " << player.playerHealth << endl;
  151.     cout << "Pistol Ammo: " << player.pistolAmmo << endl;
  152.     cout << "Shotgun Ammo: " << player.shotgunAmmo << endl;
  153.     cout << "Rifle Ammo: " << player.rifleAmmo << endl;
  154.     cout << "Score: " << player.score << endl;
  155.     cout << "player.money: " << player.money << endl;
  156.     cout << "Health Packs: " << player.healthPacks << endl;
  157.     cout << "\n";
  158.  
  159.     MainGame(player, dinosaur);
  160. }
  161.  
  162.  
  163. /*
  164. =============|
  165. Shop function|
  166. =============|
  167. */
  168.  
  169. void shop(Player &player, Dinosaur &dinosaur)
  170. {
  171.     unsigned int menuChoice;
  172.     int amountChoice = 0;
  173.     unsigned int itemPrice;
  174.     unsigned int itemQuantity = 0;
  175.     unsigned int confirmPurchase;
  176.     string itemName;
  177.     string itemType;
  178.  
  179.     while((amountChoice != -1) || (menuChoice != -1))
  180.     {
  181.         cout << "\n";
  182.         cout << "GENERAL STORE\n" << endl;
  183.  
  184.         cout << "Type in -1 to quit" << endl;
  185.         cout << "1) Health Pack - $5" << endl;
  186.         cout << "2) Pistol Ammo - $2" << endl;
  187.         cout << "3) Shotgun Ammo - $5" << endl;
  188.         cout << "4) Rifle Ammo - $18" << endl;
  189.  
  190.         cin >> menuChoice;
  191.  
  192.         if((amountChoice == -1) || (menuChoice == -1))
  193.         {
  194.             cout << "Thank you for shopping at the store\n" << endl;
  195.             MainGame(player, dinosaur);
  196.             break;
  197.         }
  198.         else
  199.         {
  200.             switch(menuChoice)
  201.             {
  202.                 case 1:
  203.                     {
  204.                         cout << "You get 1 Health Pack per purchase" << endl;
  205.                         itemName = "Health Pack(s)";
  206.                         itemType = "Unit(s)";
  207.                         itemPrice = 5;
  208.                         itemQuantity = 1;
  209.                     }break;
  210.                 case 2:
  211.                     {
  212.                         cout << "You get 17 rounds of Pistol Ammo per purchase" << endl;
  213.                         itemName = "Pistol Ammo";
  214.                         itemType = "Round(s)";
  215.                         itemPrice = 2;
  216.                         itemQuantity = 17;
  217.                     }break;
  218.                 case 3:
  219.                     {
  220.                         cout << "You get 8 rounds of Shotgun Ammo per purchase" << endl;
  221.                         itemName = "Shotgun Ammo";
  222.                         itemType = "Round(s)";
  223.                         itemPrice = 5;
  224.                         itemQuantity = 8;
  225.                     }break;
  226.                 case 4:
  227.                     {
  228.                         cout << "You get 14 rounds of Rifle Ammo per purchase" << endl;
  229.                         itemName = "Rifle Ammo";
  230.                         itemType = "Round(s)";
  231.                         itemPrice = 18;
  232.                         itemQuantity = 14;
  233.                     }break;
  234.                 default:
  235.                     cout << "Invalid answer" << endl;
  236.             }
  237.  
  238.                     cout << "How many do you want to buy?" << endl;
  239.  
  240.                     while(amountChoice != -1)
  241.                     {
  242.                         cin >> amountChoice;
  243.  
  244.                         if(player.money >= amountChoice * itemPrice)
  245.                         {
  246.                             cout << "Are you sure you want to buy " << amountChoice * itemQuantity << " " << itemType << " of " << itemName << endl;
  247.                             cout << "This will cost $" << amountChoice * itemPrice << endl;
  248.                             cout << "Type in 1 for YES and 2 for NO" << endl;
  249.  
  250.                             cin >> confirmPurchase;
  251.  
  252.                             if(confirmPurchase == 1)
  253.                             {
  254.                                 player.money -= amountChoice * itemPrice;
  255.  
  256.                                 cout << "Thank you for your purchase: -$" << amountChoice * itemPrice << endl;
  257.                                 cout << "You recieved +" << amountChoice * itemQuantity << " " << itemName << endl;
  258.  
  259.                                 //Add items to inventory
  260.                                 switch(menuChoice)
  261.                                 {
  262.                                     case 1:{player.healthPacks += amountChoice * itemQuantity;}break;
  263.                                     case 2:{player.pistolAmmo += amountChoice * itemQuantity;}break;
  264.                                     case 3:{player.shotgunAmmo += amountChoice * itemQuantity;}break;
  265.                                     case 4:{player.rifleAmmo += amountChoice * itemQuantity;}break;
  266.                                     default: cout << "Error" << endl;
  267.                                 }
  268.  
  269.                                 cout << "Your current money is $" << player.money << endl;
  270.                                 cout << "Current " << itemName << " is: ";
  271.  
  272.                                 //show how many of chosen item the player has in backpack
  273.                                 switch(menuChoice)
  274.                                 {
  275.                                     case 1:{cout << player.healthPacks << endl;}break;
  276.                                     case 2:{cout << player.pistolAmmo << endl;}break;
  277.                                     case 3:{cout << player.shotgunAmmo << endl;}break;
  278.                                     case 4:{cout << player.rifleAmmo << endl;}break;
  279.                                     default: cout << "Error" << endl;
  280.                                 }
  281.  
  282.                                 cout << "\n";
  283.  
  284.                                 menuChoice = 0;
  285.                                 amountChoice = 0;
  286.                                 confirmPurchase = 0;
  287.  
  288.                                 save(player, dinosaur);
  289.                                 shop(player, dinosaur);
  290.                             }
  291.                             if(confirmPurchase == 2)
  292.                             {
  293.                                 cout << "Ok what else would you like?\n" << endl;
  294.                                 menuChoice = 0;
  295.                                 amountChoice = 0;
  296.                                 confirmPurchase = 0;
  297.                                 break;
  298.                             }
  299.                         }break;
  300.                     }
  301.         }
  302.     }//End of while loop
  303. }
  304.  
  305.  
  306. /*
  307. =================|
  308. Backpack function|
  309. =================|
  310. */
  311.  
  312. void backpack(Player &player, Dinosaur &dinosaur)
  313. {
  314.     cout << "ITEMS\n" << endl;
  315.  
  316.     cout << "money $" << player.money << endl;
  317.     cout << "Health Packs: " << player.healthPacks << endl;
  318.     cout << "Pistol Ammo: " << player.pistolAmmo << endl;
  319.     cout << "Shotgun Ammo: " << player.shotgunAmmo << endl;
  320.     cout << "Rifle Ammo: " << player.rifleAmmo << endl;
  321.  
  322.     cout << "\n";
  323.  
  324.     cout << "WEAPONS\n" << endl;
  325.  
  326.     cout << "Pistol - Does 3 points of damage against enemies" << endl;
  327.     cout << "Shotgun - Does 9 points of damage against enemies" << endl;
  328.     cout << "Rifle - Does 13 points of damage against enemies" << endl;
  329. }
  330.  
  331.  
  332. /*
  333. =====================|
  334. Player Stats function|
  335. =====================|
  336. */
  337.  
  338. void stats(Player &player, Dinosaur &dinosaur)
  339. {
  340.     cout << "STATS\n" << endl;
  341.  
  342.  
  343. }
  344.  
  345. void gameInfo()
  346. {
  347.     cout << "GAME INFO\n" << endl;
  348.  
  349.     cout << "Lines of Code: 931" << endl;
  350. }
  351.  
  352.  
  353. /*
  354. ==================|
  355. Main Game function|
  356. ==================|
  357. */
  358.  
  359. void MainGame(Player &player, Dinosaur &dinosaur)
  360. {
  361.     string strChoice;
  362.     int intChoice;
  363.  
  364.     cout << "1) Start Battle" << endl;
  365.     cout << "2) View Stats" << endl;
  366.     cout << "3) General Store" << endl;
  367.     cout << "4) View Backpack" << endl;
  368.     cout << "5) Save Game" << endl;
  369.  
  370.     do
  371.     {
  372.         stringstream ss;
  373.  
  374.         getline(cin, strChoice);
  375.  
  376.         ss << strChoice;
  377.         ss >> intChoice;
  378.  
  379.         if(intChoice == 1)
  380.         {
  381.             dinoSelect(player, dinosaur);
  382.         }
  383.         else if(intChoice == 2)
  384.         {
  385.             stats(player, dinosaur);
  386.         }
  387.         else if(intChoice == 3)
  388.         {
  389.             shop(player, dinosaur);
  390.         }
  391.         else if(intChoice == 4)
  392.         {
  393.             backpack(player, dinosaur);
  394.         }
  395.         else if(intChoice == 5)
  396.         {
  397.             save(player, dinosaur);
  398.         }
  399.     }
  400.     while(intChoice != -1);
  401. }
  402.  
  403.  
  404. /*
  405. ========================|
  406. Dinosaur select function|
  407. ========================|
  408. */
  409.  
  410. void dinoSelect(Player &player, Dinosaur &dinosaur)
  411. {
  412.     switch(dinosaur.createTime)
  413.     {
  414.         case 0:
  415.             {
  416.                 cout << "Your opponent is the T-Rex!!\n" << endl;
  417.                 while(player.playerHealth >= 1);
  418.                 {
  419.                     arena(player, dinosaur);
  420.                     trex(player, dinosaur);
  421.                 }
  422.             }break;
  423.     }
  424. }
  425.  
  426.  
  427. /*
  428. ==============|
  429. Arena function|
  430. ==============|
  431. */
  432.  
  433. void arena(Player &player, Dinosaur &dinosaur)
  434. {
  435.     int choice;
  436.     int miss;
  437.     int useHealth;
  438.     time_t T;
  439.     time(&T);
  440.     srand(T);
  441.  
  442.     for(int i = 0; i < 5; i++)
  443.     {
  444.         miss = rand() % 5;
  445.     }
  446.  
  447.     flags(player, dinosaur);
  448.  
  449.     cout << "==========================" << endl;
  450.     cout << "----------TURN " << player.turns << "----------"<< endl;
  451.     cout << "==========================\n" << endl;
  452.  
  453.     player.turns++;
  454.  
  455.     cout << "Make your move\n" << endl;
  456.  
  457.     cout << "Your health " << player.playerHealth << endl;
  458.     cout << "Dinosaur health " << dinosaur.dinosaurHealth << endl;
  459.     cout << "\n";
  460.     cout << "ITEMS\n";
  461.     cout << "Pistol Ammo " << player.pistolAmmo << endl;
  462.     cout << "Shotgun Ammo " << player.shotgunAmmo << endl;
  463.     cout << "Rifle Ammo " << player.rifleAmmo << endl;
  464.     cout << "\n";
  465.  
  466.     cout << "What do you want to use?" << endl;
  467.     cout << "1) Pistol" << endl;
  468.     cout << "\t Damage: 3" << endl;
  469.     cout << "\t\t Ammo used: 17 rounds" << endl;
  470.  
  471.     cout << "2) Shotgun" << endl;
  472.     cout << "\t Damage: 9" << endl;
  473.     cout << "\t\t Ammo used: 8 rounds" << endl;
  474.  
  475.     cout << "3) Rifle" << endl;
  476.     cout << "\t Damage: 13" << endl;
  477.     cout << "\t\t Ammo used: 32 rounds" << endl;
  478.  
  479.     cout << "4) Use Health Pack - +50 health" << endl;
  480.     cin >> choice;
  481.  
  482.     cout << "\n";
  483.  
  484.     switch(choice)
  485.     {
  486.         case 1://Pistol Choice
  487.             {
  488.                 if(miss == 0)
  489.                 {
  490.                     cout << "Your attack missed!!\n" << endl;
  491.                     dinosaur.dinosaurHealth -= 0;
  492.                     player.pistolAmmo -= 0;
  493.                 }
  494.                 if(miss == 4)
  495.                 {
  496.                     cout << "Double Damage Bonus!!\n" << endl;
  497.                     if(player.pistolAmmo >= 17)
  498.                     {
  499.                         cout << "Enough ammo" << endl;
  500.                         player.pistolAmmo -= 17;
  501.                         dinosaur.dinosaurHealth -= 6;
  502.                     }
  503.                     if((player.pistolAmmo < 17) && (player.pistolAmmo >= 1))
  504.                     {
  505.                         cout << "But you dont have enough Ammo, you only did regular damage!" << endl;
  506.                         cout << "Used " << player.pistolAmmo << " Pistol rounds" << endl;
  507.                         player.pistolAmmo -= player.pistolAmmo;
  508.                         dinosaur.dinosaurHealth -= 3;
  509.                     }
  510.                     if(player.pistolAmmo == 0)
  511.                     {
  512.                         cout << "No ammo left for the Pistol!!" << endl;
  513.                         player.pistolAmmo -= 0;
  514.                         dinosaur.dinosaurHealth -= 0;
  515.                     }
  516.  
  517.                 else if((miss != 0) &&(miss != 4))//If none of the above applies then execute this else statement
  518.                     {
  519.                         cout << "You hit the enemy\n" << endl;
  520.                         if(player.pistolAmmo >= 17)
  521.                         {
  522.                             cout << "Enough ammo" << endl;
  523.                             player.pistolAmmo -= 17;
  524.                             dinosaur.dinosaurHealth -= 3;
  525.                         }
  526.                         if((player.pistolAmmo < 17) && (player.pistolAmmo >= 1))
  527.                         {
  528.                             cout << "Not enough Ammo" << endl;
  529.                             cout << "Used " << player.pistolAmmo << " Pistol rounds" << endl;
  530.                             player.pistolAmmo -= player.pistolAmmo;
  531.                             dinosaur.dinosaurHealth -= 2;
  532.                         }
  533.                         if(player.pistolAmmo == 0)
  534.                         {
  535.                             cout << "No ammo left for the Pistol!!" << endl;
  536.                             player.pistolAmmo -= 0;
  537.                             dinosaur.dinosaurHealth -= 0;
  538.                         }
  539.                     }//End of else statement
  540.                 }//end of else if
  541.  
  542.             }break;//End of Case 1
  543.  
  544.  
  545.         case 2://Shotgun Choice
  546.             {
  547.                 if(miss == 0)
  548.                 {
  549.                     cout << "Your attack missed!!\n" << endl;
  550.                     dinosaur.dinosaurHealth -= 0;
  551.                     player.shotgunAmmo -= 0;
  552.                 }
  553.                 if(miss == 4)
  554.                 {
  555.                     cout << "Double Damage Bonus!!\n" << endl;
  556.                     if(player.shotgunAmmo >= 9)
  557.                     {
  558.                         cout << "Enough ammo" << endl;
  559.                         player.shotgunAmmo -= 17;
  560.                         dinosaur.dinosaurHealth -= 6;
  561.                     }
  562.                     if((player.shotgunAmmo < 9) && (player.shotgunAmmo >= 1))
  563.                     {
  564.                         cout << "But you dont have enough Ammo, you only did regular damage!" << endl;
  565.                         cout << "Used " << player.shotgunAmmo << " Shotgun rounds" << endl;
  566.                         player.shotgunAmmo -= player.shotgunAmmo;
  567.                         dinosaur.dinosaurHealth -= 3;
  568.                     }
  569.                     if(player.shotgunAmmo == 0)
  570.                     {
  571.                         cout << "No ammo left for the Shotgun!!" << endl;
  572.                         player.shotgunAmmo -= 0;
  573.                         dinosaur.dinosaurHealth -= 0;
  574.                     }
  575.  
  576.                 else if((miss != 0) &&(miss != 4))//If none of the above applies then execute this else statement
  577.                     {
  578.                         cout << "You hit the enemy\n" << endl;
  579.                         if(player.shotgunAmmo >= 9)
  580.                         {
  581.                             cout << "Enough ammo" << endl;
  582.                             player.shotgunAmmo -= 17;
  583.                             dinosaur.dinosaurHealth -= 3;
  584.                         }
  585.                         if((player.shotgunAmmo < 9) && (player.shotgunAmmo >= 1))
  586.                         {
  587.                             cout << "Not enough Ammo" << endl;
  588.                             cout << "You used " << player.shotgunAmmo << " Shotgun rounds" << endl;
  589.                             player.shotgunAmmo -= player.shotgunAmmo;
  590.                             dinosaur.dinosaurHealth -= 2;
  591.                         }
  592.                         if(player.shotgunAmmo == 0)
  593.                         {
  594.                             cout << "No ammo left for the Shotgun!!" << endl;
  595.                             player.shotgunAmmo -= 0;
  596.                             dinosaur.dinosaurHealth -= 0;
  597.                         }
  598.                     }//End of else statement
  599.                 }//end of else if
  600.  
  601.             }break;//End of Case 2
  602.  
  603.  
  604.         case 3://Rifle Choice
  605.             {
  606.                 if(miss == 0)
  607.                 {
  608.                     cout << "Your attack missed!!\n" << endl;
  609.                     dinosaur.dinosaurHealth -= 0;
  610.                     player.rifleAmmo -= 0;
  611.                 }
  612.                 if(miss == 4)
  613.                 {
  614.                     cout << "Double Damage Bonus!!\n" << endl;
  615.                     if(player.rifleAmmo >= 17)
  616.                     {
  617.                         cout << "Enough ammo" << endl;
  618.                         player.rifleAmmo -= 17;
  619.                         dinosaur.dinosaurHealth -= 6;
  620.                     }
  621.                     if((player.rifleAmmo < 17) && (player.rifleAmmo >= 1))
  622.                     {
  623.                         cout << "But you dont have enough Ammo, you only did regular damage!" << endl;
  624.                         cout << "Used " << player.rifleAmmo << " Rifle rounds" << endl;
  625.                         player.rifleAmmo -= player.rifleAmmo;
  626.                         dinosaur.dinosaurHealth -= 3;
  627.                     }
  628.                     if(player.rifleAmmo == 0)
  629.                     {
  630.                         cout << "No ammo left for the Rifle!!" << endl;
  631.                         player.rifleAmmo -= 0;
  632.                         dinosaur.dinosaurHealth -= 0;
  633.                     }
  634.  
  635.                 else if((miss != 0) &&(miss != 4))//If none of the above applies then execute this else statement
  636.                     {
  637.                         cout << "You hit the enemy\n" << endl;
  638.                         if(player.rifleAmmo >= 17)
  639.                         {
  640.                             cout << "Enough ammo" << endl;
  641.                             player.rifleAmmo -= 17;
  642.                             dinosaur.dinosaurHealth -= 3;
  643.                         }
  644.                         if((player.rifleAmmo < 17) && (player.rifleAmmo >= 1))
  645.                         {
  646.                             cout << "Not enough Ammo" << endl;
  647.                             cout << "Used " << player.rifleAmmo << " Rifle rounds" << endl;
  648.                             player.rifleAmmo -= player.rifleAmmo;
  649.                             dinosaur.dinosaurHealth -= 2;
  650.                         }
  651.                         if(player.rifleAmmo == 0)
  652.                         {
  653.                             cout << "No ammo left for the Rifle!!" << endl;
  654.                             player.rifleAmmo -= 0;
  655.                             dinosaur.dinosaurHealth -= 0;
  656.                         }
  657.                     }//End of else statement
  658.                 }//end of else if
  659.             }break;
  660.  
  661.  
  662.         case 4://Health pack choice
  663.             {
  664.                 cout << "Use health pack?" << endl;
  665.                 cout << "1) Use" << endl;
  666.                 cout << "2) Don't Use" << endl;
  667.                 cin >> useHealth;
  668.  
  669.                 if(useHealth == 1)
  670.                 {
  671.                     cout << "\n";
  672.                     cout << "Health pack used +50 health restored\n" << endl;
  673.                     player.playerHealth += 50;
  674.                     player.healthPacks -= 1;
  675.                 }
  676.                 if(useHealth == 2)
  677.                 {
  678.                     cout << "Did not use a health pack" << endl;
  679.                 }
  680.             }break;
  681.     }
  682. }
  683.  
  684.  
  685. /*
  686. ==============|
  687. T-Rex function|
  688. ==============|
  689. */
  690.  
  691. void trex(Player &player, Dinosaur &dinosaur)
  692. {
  693.     switch(dinosaur.createTime)
  694.     {
  695.         case 0:
  696.             {
  697.                 cout << "T-Rex used Bite!!\n" << endl;
  698.                 player.playerHealth -= 5;
  699.             }break;
  700.         case 1:
  701.             {
  702.                 cout << "T-Rex used Stomp!!\n" << endl;
  703.                 player.playerHealth -= 9;
  704.             }break;
  705.         case 2:
  706.             {
  707.                 cout << "T-Rex used Crunch\n" << endl;
  708.                 player.playerHealth -= 13;
  709.             }break;
  710.         case 3:
  711.             {
  712.                 cout << "T-Rex used Slam\n" << endl;
  713.                 player.playerHealth -= 19;
  714.             }break;
  715.         case 4:
  716.             {
  717.                 cout << "T-Rex used Pulverize\n" << endl;
  718.                 player.playerHealth -= 23;
  719.             }break;
  720.         default:
  721.             {
  722.                 cout << "T-Rex attack missed!!\n" << endl;
  723.                 player.playerHealth -= 0;
  724.             }
  725.     }
  726. }
  727.  
  728.  
  729. /*
  730. ==========================|
  731. Conditional flags function|
  732. ==========================|
  733. */
  734.  
  735. void flags(Player &player, Dinosaur &dinosaur)
  736. {
  737.     if(player.playerHealth <= 0)
  738.     {
  739.         cout << "\n";
  740.         cout << "->You died game over<-\n" << endl;
  741.         MainGame(player, dinosaur);
  742.     }
  743.  
  744.     else if((player.playerHealth >= 1) && (dinosaur.dinosaurHealth <= 0))
  745.     {
  746.         player.money += 250;
  747.         player.score++;
  748.  
  749.         cout << "\n";
  750.         cout << "->You have won!!!<-\n" << endl;
  751.         cout << "Score " << player.score << endl;
  752.         cout << "player.money+ $" << player.money << endl;
  753.         cout << "\n";
  754.         MainGame(player, dinosaur);
  755.     }
  756. }
  757.  
  758.  
  759. /*
  760. ====|
  761. Main|
  762. ====|
  763. */
  764.  
  765. int main()
  766. {
  767.     vector<int> tItems;
  768.     tItems.push_back(5);
  769.  
  770.     time_t T;
  771.     unsigned int Time;
  772.     time(&T);
  773.     srand(T);
  774.  
  775.     for(int i = 0; i < 5; i++)
  776.     {
  777.         Time = rand() % 5;
  778.     }
  779.  
  780.     Player player(100,
  781.            0,
  782.            0,
  783.            0,
  784.            0,
  785.            500,
  786.            0,
  787.            0,
  788.            tItems);
  789.  
  790.     Dinosaur dinosaur(100, 5, Time);
  791.  
  792.     Menu(player, dinosaur);
  793.     //dinoSelect(player, dinosaur);
  794. }
  795.  
  796.  
  797. //Player.h
  798.  
  799. #ifndef PLAYER_H
  800. #define PLAYER_H
  801.  
  802. #include <vector>
  803.  
  804. /*
  805. ============|
  806. Player Class|
  807. ============|
  808. */
  809.  
  810. class Player
  811. {
  812.     public:
  813.         Player(unsigned int PLAYERHEALTH, unsigned int PISTOLAMMO,
  814.                unsigned int SHOTGUNAMMO, unsigned int RIFLEAMMO,
  815.                unsigned int SCORE, unsigned int MONEY,
  816.                unsigned int HEALTHPACKS, int TURNS, std::vector<int> ITEMS);
  817.  
  818.     private:
  819.         unsigned int playerHealth;
  820.         unsigned int pistolAmmo;
  821.         unsigned int shotgunAmmo;
  822.         unsigned int rifleAmmo;
  823.         unsigned int score;
  824.         unsigned int money;
  825.         unsigned int healthPacks;
  826.         unsigned int turns;
  827.         std::vector<int> items;
  828. };
  829.  
  830. #endif // PLAYER_H
  831.  
  832.  
  833. //Prototypes.h
  834.  
  835. #ifndef PROTOTYPES_H_INCLUDED
  836. #define PROTOTYPES_H_INCLUDED
  837.  
  838. #include <string>
  839.  
  840. void save(Player &player, Dinosaur &dinosaur);
  841. void load(Player &player, Dinosaur &dinosaur);
  842. void shop(Player &player, Dinosaur &dinosaur);
  843. void arena(Player &player, Dinosaur &dinosaur);
  844. void backpack(Player &player, Dinosaur &dinosaur);
  845. void flags(Player &player, Dinosaur &dinosaur);
  846. void dinoSelect(Player &player, Dinosaur &dinosaur);
  847. void stats(Player &player, Dinosaur &dinosaur);
  848. void trex(Player &player, Dinosaur &dinosaur);
  849. void velociraptor(Player &player, Dinosaur &dinosaur);
  850. int Menu(Player &player, Dinosaur &dinosaur);
  851. void MainGame(Player &player, Dinosaur &dinosaur);
  852. int IntegerProcessing(Player &player, Dinosaur &dinosaur, int, int, std::string, std::string);
  853. std::string StringProcessing(Player &player, Dinosaur &dinosaur);
  854. void gameInfo();
  855.  
  856. #endif // PROTOTYPES_H_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement