Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "Player.h"
- #include "Consumable.h"
- using namespace std;
- void displayStars(unsigned int n){
- for(unsigned int i=0; i<n; i++){
- cout << "*";
- }
- cout << endl;
- }
- int main()
- {
- // Intro
- displayStars(63);
- cout << "**** This is an example of a Fortnite player healing! ****\n";
- displayStars(63);
- cout << endl;
- // 1. Choosing character/skin
- cout << "First of all you have to choose your character/skin. You have 4 choices (press 1,2,3 or 4): " << endl;
- cout << "1. DJ Yonder\n2. Calamity\n3. Ice King\n4. Hybrid\n\n";
- int skinChoice;
- cin >> skinChoice;
- cout << endl;
- string skinChoosed;
- switch(skinChoice){
- case 1:
- skinChoosed = "DJ Yonder";
- break;
- case 2:
- skinChoosed = "Calamity";
- break;
- case 3:
- skinChoosed = "Ice King";
- break;
- case 4:
- skinChoosed = "Hybrid";
- break;
- default:
- skinChoosed = "DJ Yonder";
- }
- // 2. Choosing backpack
- cout << "It's time to choose your backpack. You have 4 choices (press 1,2,3 or 4): " << endl;
- cout << "1. Rufus\n2. Dusk Wings\n3. Fabled Cape\n4. Waveform\n\n";
- int backpackChoice;
- cin >> backpackChoice;
- cout << endl;
- string backpackChoosed;
- switch(backpackChoice){
- case 1:
- backpackChoosed = "Rufus";
- break;
- case 2:
- backpackChoosed = "Dusk Wings";
- break;
- case 3:
- backpackChoosed = "Fabled Cape";
- break;
- case 4:
- backpackChoosed = "Waveform";
- break;
- default:
- backpackChoosed = "Rufus";
- }
- // 3. Choosing health
- cout << "Now it is time to choose your player's health. Be careful, because the health cannot be over 100\n";
- cout << "neither below 1 (1 <= health <= 100)\n";
- unsigned int healthChoice;
- do{
- cin >> healthChoice;
- } while(healthChoice < 1 || healthChoice > 100);
- // 4. Choosing shield
- cout << "\nLast step is to choose your player's shield according to the same rules relating with the health as above\n";
- cout << "with the difference that your shield can be 0.\n";
- unsigned int shieldChoice;
- do{
- cin >> shieldChoice;
- } while(shieldChoice < 0 || shieldChoice > 100);
- cout << endl;
- // a) Create the player and show user's choices
- Player player = Player(skinChoosed, backpackChoosed, healthChoice, shieldChoice);
- player.show();
- // b1) Show the list of consumables
- cout << endl << endl;
- displayStars(30);
- MiniShield mini1 = MiniShield();
- mini1.show();
- BigShield big1 = BigShield();
- big1.show();
- Bandage ban1 = Bandage();
- ban1.show();
- MedKit med1 = MedKit();
- med1.show();
- Slurp slurp1 = Slurp();
- slurp1.show();
- ChugJug chug1 = ChugJug();
- chug1.show();
- displayStars(30);
- // b2) Healing
- cout << endl;
- displayStars(104);
- cout << "Nice, you chose to heal your character! Please select which one of the consumables you are going to use.\n";
- cout << "Press a number from 1 to 6:\n";
- cout << "1. MiniShield\n2. BigShield\n3. Bandage\n4. Med Kit\n5. Slurp Juice\n6. Chug Jug\n";
- int healChoice;
- cin >> healChoice;
- // Create all the variables and objects that will be used in "cases"
- int shieldUp;
- int healthUp;
- MiniShield mini = MiniShield();
- BigShield bigShield = BigShield();
- Bandage ban = Bandage();
- MedKit medKit = MedKit();
- Slurp slurp = Slurp();
- ChugJug chugJug = ChugJug();
- switch(healChoice){
- case 1:
- cout << "****Heal with MiniShield****\n";
- if(player.shield <= 25){
- shieldUp = mini.points;
- healthUp = 0;
- player.shield += shieldUp;
- // Show player's new health info
- //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
- cout << "Health: " << player.health << endl << "Shield: " << player.shield << " (+" << shieldUp << ")\n\n";
- displayStars(104);
- }
- else if(player.shield > 25 && player.shield < 50){
- int initialShield = player.shield;
- player.shield = 50;
- shieldUp = player.shield - initialShield;
- healthUp = 0;
- // Show player's new health info
- //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
- cout << "Health: " << player.health << endl << "Shield: " << player.shield << " (+" << shieldUp << ")\n\n";
- displayStars(104);
- }
- else{
- cout << "Can't use MiniShield!\n";
- shieldUp = 0;
- healthUp = 0;
- player.show();
- displayStars(104);
- }
- break;
- case 2:
- cout << "****Heal with BigShield****\n";
- if(player.shield <= 50){
- healthUp = 0;
- shieldUp = bigShield.points;
- player.shield += shieldUp;
- // Show player's new health info
- //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
- cout << "Health: " << player.health << endl << "Shield: " << player.shield << " (+" << shieldUp << ")\n\n";
- displayStars(104);
- }
- else{
- healthUp = 0;
- int initialShield = player.shield;
- shieldUp = 100 - initialShield;
- player.shield = 100;
- //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
- cout << "Health: " << player.health << endl << "Shield: " << player.shield << " (+" << shieldUp << ")\n\n";
- displayStars(104);
- }
- break;
- case 3:
- cout << "****Heal with Bandage****\n";
- if(player.health >= 75){
- shieldUp = 0;
- healthUp = 0;
- cout << "Can't heal with bandage (Bandage heal limit = 75).\n";
- }
- else if(player.health <= 60){
- shieldUp = 0;
- healthUp = ban.points;
- player.health += healthUp;
- // Show player's new health info
- //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
- cout << "Health: " << player.health << " (+" << healthUp << ")" << endl << "Shield: " << player.shield << "\n\n";
- displayStars(104);
- }
- else{
- int initialHealth = player.health;
- shieldUp = 0;
- healthUp = 75 - initialHealth;
- player.health = 75;
- // Show player's new health info
- //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
- cout << "Health: " << player.health << " (+" << healthUp << ")" << endl << "Shield: " << player.shield << "\n\n";
- displayStars(104);
- }
- break;
- case 4:
- cout << "****Heal with Med Kit****\n";
- if(player.health == medKit.points){
- cout << "Can't heal with Med Kit. Your life is full (health = 100).\n";
- }
- else{
- int initialHealth = player.health;
- healthUp = medKit.points - initialHealth;
- player.health = medKit.points;
- // Show player's new health info
- //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
- cout << "Health: " << player.health << " (+" << healthUp << ")" << endl << "Shield: " << player.shield << "\n\n";
- displayStars(104);
- }
- break;
- case 5:
- cout << "****Heal with Slurp Juice****\n";
- if(player.health + player.shield == 200){
- cout << "Can't heal with Chug Jug. Full health and shield (100 and 100).\n";
- }
- else if(player.health + player.shield >= 125){
- int initialHealth = player.health;
- int initialShield = player.shield;
- healthUp = 100 - initialHealth;
- shieldUp = 100 - initialShield;
- player.health = 100;
- player.shield = 100;
- // Show player's new health info
- //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
- cout << "Health: " << player.health << " (+" << healthUp << ")" << endl << "Shield: " << player.shield << "(+" << shieldUp << ")" << "\n\n";
- displayStars(104);
- }
- // If player.health + player.shield < 125
- else{
- if(player.health <= 25){
- shieldUp = 0;
- healthUp = slurp.points;
- player.health += healthUp;
- //Show player's new health info
- //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
- cout << "Health: " << player.health << " (+" << healthUp << ")" << endl << "Shield: " << player.shield << "\n\n";
- displayStars(104);
- }
- else{
- int initialHealth = player.health;
- healthUp = 100 - initialHealth;
- //int initialShield = player.shield;
- shieldUp = slurp.points - healthUp;
- player.health += healthUp;
- player.shield += shieldUp;
- //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
- cout << "Health: " << player.health << " (+" << healthUp << ")" << endl << "Shield: " << player.shield << "(+" << shieldUp << ")" << "\n\n";
- displayStars(104);
- }
- break;
- }
- case 6:
- cout << "****Heal with Chug Jug****\n";
- if(player.health == 100 && player.shield == 100){
- cout << "Can't heal with Chug Jug. Full health and shield (100 and 100).\n";
- }
- else{
- int initialHealth = player.health;
- int initialShield = player.shield;
- healthUp = 100 - initialHealth;
- shieldUp = 100 - initialShield;
- player.health = 100;
- player.shield = 100;
- // Show player's new health info
- //cout << "Skin: " << player.skin << endl << "BackPack: " << player.backpack << endl;
- cout << "Health: " << player.health << " (+" << healthUp << ")" << endl << "Shield: " << player.shield << "(+" << shieldUp << ")" << "\n\n";
- displayStars(104);
- }
- break;
- default:
- ;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement