Referencing something from a Unique Pointer
Dec 25, 2013 at 1:40pm UTC
I'm fairly new to coding c++ and am trying to make a Text based RPG. I've been working at it for awhile, and i'm not sure what to do. I'm trying to make it so that when in battle a characters stats are outputted, e.g Attack, Health etc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
#include <iostream>
#include "mage.h"
#include "Warrior.h"
#include "Rogue.h"
#include "CharacterType.h"
#include <memory>
#include <string>
#include "MainGame.h"
#include "Inventory.h"
using namespace std;
int GameStart()
{
std::unique_ptr<blankCharacter> myCharacter;
std::unique_ptr<Inventory> myInventory;
string name;
int choice;
cout << " Please enter player name." << endl << endl;
cin >> name;
system("cls" );
cout << "Please select fighting class." << endl << endl;
cout <<" 1 - Mage" << endl;
cout <<" 2 - Warrior" << endl;
cout <<" 3 - Rogue" << endl;
cin >> choice;
switch (choice)
{
case 1: //Mage
myCharacter = std::unique_ptr<blankCharacter>(new Mage(70,100,150,60));
myInventory = std::unique_ptr<Inventory>(new Inventory(10, 30));
break ;
case 2: //Warrior
myCharacter = std::unique_ptr<blankCharacter>(new Warrior(100,160,50,60));
myInventory = std::unique_ptr<Inventory>(new Inventory(10, 30));
break ;
case 3: //Rogue
myCharacter = std::unique_ptr<blankCharacter>(new Rogue(90,160,70,100));
myInventory = std::unique_ptr<Inventory>(new Inventory(10, 30));
break ;
default :
cout << "Please select a relivant value 1 to 3" << endl << endl;
break ;
}
system("cls" );
cout << name << endl << endl;
return 0;
}
Topic archived. No new replies allowed.