Advertisement
makispaiktis

Main

Mar 23rd, 2019 (edited)
1,738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 10.70 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #include "Player.h"
  4. #include "Consumable.h"
  5.  
  6. using namespace std;
  7.  
  8. void displayStars(unsigned int n){
  9.     for(unsigned int i=0; i<n; i++){
  10.         cout << "*";
  11.     }
  12.     cout << endl;
  13. }
  14.  
  15. int main()
  16. {
  17.     // Intro
  18.     displayStars(63);
  19.     cout << "****   This is an example of a Fortnite player healing!    ****\n";
  20.     displayStars(63);
  21.     cout << endl;
  22.  
  23.     // 1. Choosing character/skin
  24.     cout << "First of all you have to choose your character/skin. You have 4 choices (press 1,2,3 or 4): " << endl;
  25.     cout << "1. DJ Yonder\n2. Calamity\n3. Ice King\n4. Hybrid\n\n";
  26.  
  27.     int skinChoice;
  28.     cin >> skinChoice;
  29.     cout << endl;
  30.     string skinChoosed;
  31.     switch(skinChoice){
  32.         case 1:
  33.             skinChoosed = "DJ Yonder";
  34.             break;
  35.  
  36.         case 2:
  37.             skinChoosed = "Calamity";
  38.             break;
  39.  
  40.         case 3:
  41.             skinChoosed = "Ice King";
  42.             break;
  43.  
  44.         case 4:
  45.             skinChoosed = "Hybrid";
  46.             break;
  47.  
  48.         default:
  49.             skinChoosed = "DJ Yonder";
  50.     }
  51.  
  52.     // 2. Choosing backpack
  53.     cout << "It's time to choose your backpack. You have 4 choices (press 1,2,3 or 4): " << endl;
  54.     cout << "1. Rufus\n2. Dusk Wings\n3. Fabled Cape\n4. Waveform\n\n";
  55.  
  56.     int backpackChoice;
  57.     cin >> backpackChoice;
  58.     cout << endl;
  59.     string backpackChoosed;
  60.     switch(backpackChoice){
  61.         case 1:
  62.             backpackChoosed = "Rufus";
  63.             break;
  64.  
  65.         case 2:
  66.             backpackChoosed = "Dusk Wings";
  67.             break;
  68.  
  69.         case 3:
  70.             backpackChoosed = "Fabled Cape";
  71.             break;
  72.  
  73.         case 4:
  74.             backpackChoosed = "Waveform";
  75.             break;
  76.  
  77.         default:
  78.             backpackChoosed = "Rufus";
  79.     }
  80.  
  81.     // 3. Choosing health
  82.     cout << "Now it is time to choose your player's health. Be careful, because the health cannot be over 100\n";
  83.     cout << "neither below 1 (1 <= health <= 100)\n";
  84.  
  85.     unsigned int healthChoice;
  86.     do{
  87.         cin >> healthChoice;
  88.     } while(healthChoice < 1 || healthChoice > 100);
  89.  
  90.     // 4. Choosing shield
  91.     cout << "\nLast step is to choose your player's shield according to the same rules relating with the health as above\n";
  92.     cout << "with the difference that your shield can be 0.\n";
  93.     unsigned int shieldChoice;
  94.     do{
  95.         cin >> shieldChoice;
  96.     } while(shieldChoice < 0 || shieldChoice > 100);
  97.     cout << endl;
  98.  
  99.     // a) Create the player and show user's choices
  100.     Player player = Player(skinChoosed, backpackChoosed, healthChoice, shieldChoice);
  101.     player.show();
  102.     // b1) Show the list of consumables
  103.     cout << endl << endl;
  104.     displayStars(30);
  105.     MiniShield mini1 = MiniShield();
  106.     mini1.show();
  107.     BigShield big1 = BigShield();
  108.     big1.show();
  109.     Bandage ban1 = Bandage();
  110.     ban1.show();
  111.     MedKit med1 = MedKit();
  112.     med1.show();
  113.     Slurp slurp1 = Slurp();
  114.     slurp1.show();
  115.     ChugJug chug1 = ChugJug();
  116.     chug1.show();
  117.     displayStars(30);
  118.  
  119.     // b2) Healing
  120.     cout << endl;
  121.     displayStars(104);
  122.     cout << "Nice, you chose to heal your character! Please select which one of the consumables you are going to use.\n";
  123.     cout << "Press a number from 1 to 6:\n";
  124.     cout << "1. MiniShield\n2. BigShield\n3. Bandage\n4. Med Kit\n5. Slurp Juice\n6. Chug Jug\n";
  125.  
  126.     int healChoice;
  127.     cin >> healChoice;
  128.     // Create all the variables and objects that will be used in "cases"
  129.     int shieldUp;
  130.     int healthUp;
  131.     MiniShield mini = MiniShield();
  132.     BigShield bigShield = BigShield();
  133.     Bandage ban = Bandage();
  134.     MedKit medKit = MedKit();
  135.     Slurp slurp = Slurp();
  136.     ChugJug chugJug = ChugJug();
  137.  
  138.     switch(healChoice){
  139.  
  140.     case 1:
  141.         cout << "****Heal with MiniShield****\n";
  142.         if(player.shield <= 25){
  143.             shieldUp = mini.points;
  144.             healthUp = 0;
  145.             player.shield += shieldUp;
  146.             // Show player's new health info
  147.             //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
  148.             cout << "Health: " << player.health << endl << "Shield: " << player.shield << " (+" << shieldUp << ")\n\n";
  149.             displayStars(104);
  150.         }
  151.         else if(player.shield > 25 && player.shield < 50){
  152.             int initialShield = player.shield;
  153.             player.shield = 50;
  154.             shieldUp = player.shield - initialShield;
  155.             healthUp = 0;
  156.             // Show player's new health info
  157.             //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
  158.             cout << "Health: " << player.health << endl << "Shield: " << player.shield << " (+" << shieldUp << ")\n\n";
  159.             displayStars(104);
  160.         }
  161.         else{
  162.             cout << "Can't use MiniShield!\n";
  163.             shieldUp = 0;
  164.             healthUp = 0;
  165.             player.show();
  166.             displayStars(104);
  167.         }
  168.         break;
  169.  
  170.  
  171.     case 2:
  172.         cout << "****Heal with BigShield****\n";
  173.         if(player.shield <= 50){
  174.             healthUp = 0;
  175.             shieldUp = bigShield.points;
  176.             player.shield += shieldUp;
  177.             // Show player's new health info
  178.             //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
  179.             cout << "Health: " << player.health << endl << "Shield: " << player.shield << " (+" << shieldUp << ")\n\n";
  180.             displayStars(104);
  181.            }
  182.         else{
  183.             healthUp = 0;
  184.             int initialShield = player.shield;
  185.             shieldUp = 100 - initialShield;
  186.             player.shield = 100;
  187.             //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
  188.             cout << "Health: " << player.health << endl << "Shield: " << player.shield << " (+" << shieldUp << ")\n\n";
  189.             displayStars(104);
  190.            }
  191.            break;
  192.  
  193.     case 3:
  194.         cout << "****Heal with Bandage****\n";
  195.         if(player.health >= 75){
  196.             shieldUp = 0;
  197.             healthUp = 0;
  198.             cout << "Can't heal with bandage (Bandage heal limit = 75).\n";
  199.         }
  200.         else if(player.health <= 60){
  201.             shieldUp = 0;
  202.             healthUp = ban.points;
  203.             player.health += healthUp;
  204.             // Show player's new health info
  205.             //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
  206.             cout << "Health: " << player.health << " (+" << healthUp << ")" << endl << "Shield: " << player.shield  << "\n\n";
  207.             displayStars(104);
  208.         }
  209.         else{
  210.             int initialHealth = player.health;
  211.             shieldUp = 0;
  212.             healthUp = 75 - initialHealth;
  213.             player.health = 75;
  214.             // Show player's new health info
  215.             //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
  216.             cout << "Health: " << player.health << " (+" << healthUp << ")" << endl << "Shield: " << player.shield  << "\n\n";
  217.             displayStars(104);
  218.  
  219.         }
  220.         break;
  221.  
  222.     case 4:
  223.         cout << "****Heal with Med Kit****\n";
  224.         if(player.health == medKit.points){
  225.             cout << "Can't heal with Med Kit. Your life is full (health = 100).\n";
  226.         }
  227.         else{
  228.             int initialHealth = player.health;
  229.             healthUp = medKit.points - initialHealth;
  230.             player.health = medKit.points;
  231.             // Show player's new health info
  232.             //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
  233.             cout << "Health: " << player.health << " (+" << healthUp << ")" << endl << "Shield: " << player.shield  << "\n\n";
  234.             displayStars(104);
  235.         }
  236.         break;
  237.  
  238.     case 5:
  239.         cout << "****Heal with Slurp Juice****\n";
  240.         if(player.health + player.shield == 200){
  241.             cout << "Can't heal with Chug Jug. Full health and shield (100 and 100).\n";
  242.         }
  243.  
  244.         else if(player.health + player.shield >= 125){
  245.             int initialHealth = player.health;
  246.             int initialShield = player.shield;
  247.             healthUp = 100 - initialHealth;
  248.             shieldUp = 100 - initialShield;
  249.             player.health = 100;
  250.             player.shield = 100;
  251.             // Show player's new health info
  252.             //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
  253.             cout << "Health: " << player.health << " (+" << healthUp << ")" << endl << "Shield: " << player.shield  << "(+" << shieldUp << ")" << "\n\n";
  254.             displayStars(104);
  255.         }
  256.  
  257.         // If player.health + player.shield < 125
  258.         else{
  259.             if(player.health <= 25){
  260.                 shieldUp = 0;
  261.                 healthUp = slurp.points;
  262.                 player.health += healthUp;
  263.                 //Show player's new health info
  264.                 //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
  265.                 cout << "Health: " << player.health << " (+" << healthUp << ")" << endl << "Shield: " << player.shield  << "\n\n";
  266.                 displayStars(104);
  267.             }
  268.  
  269.             else{
  270.                 int initialHealth = player.health;
  271.                 healthUp = 100 - initialHealth;
  272.                 //int initialShield = player.shield;
  273.                 shieldUp = slurp.points - healthUp;
  274.                 player.health += healthUp;
  275.                 player.shield += shieldUp;
  276.                 //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
  277.                 cout << "Health: " << player.health << " (+" << healthUp << ")" << endl << "Shield: " << player.shield << "(+" << shieldUp << ")" << "\n\n";
  278.                 displayStars(104);
  279.  
  280.             }
  281.  
  282.             break;
  283.         }
  284.  
  285.     case 6:
  286.         cout << "****Heal with Chug Jug****\n";
  287.         if(player.health == 100 && player.shield == 100){
  288.             cout << "Can't heal with Chug Jug. Full health and shield (100 and 100).\n";
  289.         }
  290.  
  291.         else{
  292.             int initialHealth = player.health;
  293.             int initialShield = player.shield;
  294.             healthUp = 100 - initialHealth;
  295.             shieldUp = 100 - initialShield;
  296.             player.health = 100;
  297.             player.shield = 100;
  298.             // Show player's new health info
  299.             //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
  300.             cout << "Health: " << player.health << " (+" << healthUp << ")" << endl << "Shield: " << player.shield  << "(+" << shieldUp << ")" << "\n\n";
  301.             displayStars(104);
  302.         }
  303.         break;
  304.  
  305.     default:
  306.         ;
  307.     }
  308.  
  309.  
  310.     return 0;
  311. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement