Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include <iostream>
#include "Character.h"
#include "Fight.h"
#include "Items.h"
#include "Minigame.h"
int main()
{
cout << " Welcome to Dead Man's Reality " << endl << "To begin, enter your name:";
string Username; cin >> Username;
string _name;
int hp, at, sp, def;
cout << Username << ", it's time to choose your class." << endl << endl;;
cout << "Warrior(Improved attack and defence <1>" << endl << endl;
cout << "Mage (Improved health and defence) <2>" << endl << endl;
cout << "Assassin (Improved attack and speed) <3>" << endl << endl;
cout << "Which would you choose? ";
int answer; cin >> answer;
system("CLS");
if(answer==1)
{
_name = "Warrior";
hp = 150;
def = 30;
at = 20;
sp = 20;
}
if (answer == 2)
{
_name = "Mage";
hp = 200;
def = 10;
at = 40;
sp = 20;
}
if (answer == 3)
{
_name = "Assassin";
hp = 130;
def = 25;
at = 20;
sp = 30;
}
if ((answer != 1 && answer != 2) && answer != 3)
{
throw std::runtime_error("Invalid choice!");
}
Character Player(_name, hp, at, def, sp);
cout << "Your choice is " << Player << endl;
Player.Stats();
Character* pointerPlayer = &Player;
Character Zombie("Zombie", 150, 20, 20, 15);
Character Skeleton("Skeleton", 100, 30, 10, 40);
Character Golem("Golem", 200, 40, 50, 10);
std::vector<Character> characterList;
characterList.push_back(Zombie);
characterList.push_back(Skeleton);
characterList.push_back(Golem);
int i;
/* std::cout << "Enter your stage progress:" << std::endl;
std::cin >> i;*/
i = 0;
cout << "You enter into a dungeon. " << endl;
while (i < characterList.size())
{
int number = characterList.size() - i;
cout << number << " enemies alive."<<endl;
std::cout << "You encounter an enemy: " << characterList[i] << std::endl;
characterList[i].Stats();
std::cout << "Choose your action:" << std::endl;
if (i != characterList.size() - 1)
{
std::cout << "Fight[1] Run[2]" << std::endl;
}
if (i == characterList.size() - 1)
{
std::cout << "This is the last fight" << std::endl;
std::cout << "Fight[1]" << std::endl;
}
int action;
std::cin >> action;
system("CLS");
if (action == 1)
{
std::cout << "You entered into a battle. Choose your action: " << std::endl;
//fight the monster
Character* pointerEnemy = &characterList[i];
Fight(pointerPlayer, pointerEnemy);
Player.heal();
//kill him, deconstruct the object of the class
//change the value of i to i+1
if (Player.dead == true)
{
break;
}
characterList[i].~Character();
if (i == 0&&Player.name=="Warrior")
{
Item Sword("Sword", 80, 20, 0, 0);
Item* pSword = &Sword;
Equip(pointerPlayer, pSword);
}
if (i == 0&&Player.name=="Mage")
{
Item Staff("Staff", 80, 20, 0, 0);
Item* pStaff= &Staff;
Equip(pointerPlayer, pStaff);
}
if (i == 0&&Player.name=="Assassin")
{
Item Dagger("Dagger", 80, 20, 0, 0);
Item* pDagger = &Dagger;
Equip(pointerPlayer, pDagger);
}
if (i == 1&&Player.name=="Warrior")
{
Item Shield("Shield", 50, 5, 20, -5);
Item* pShield = &Shield;
Equip(pointerPlayer, pShield);
}
if (i == 1 && Player.name == "Mage")
{
Item Robe("Robe", 50, 5, 20, -5);
Item* pRobe = &Robe;
Equip(pointerPlayer, pRobe);
}
if (i == 1 && Player.name == "Assassin")
{
Item Cloak("Cloak", 50, 5, 20, -5);
Item* pCloak = &Cloak;
Equip(pointerPlayer, pCloak);
}
if (i == 2 && Player.name == "Warrior")
{
Item Armor("Armor", 70, 20, 30, 40);
Item* pArmor = &Armor;
Equip(pointerPlayer, pArmor);
}
if (i == 2 && Player.name == "Mage")
{
Item Spellbook("Spellbook", 70, 20, 30, 40);
Item* pSpellbook = &Spellbook;
Equip(pointerPlayer, pSpellbook);
}
if (i == 2 && Player.name == "Assassin")
{
Item Bow("Bow", 70, 20, 30, 40);
Item* pBow = &Bow;
Equip(pointerPlayer, pBow);
}
Player.get_inventory();
Player.Stats();
i++;
if (i == 2)
{
Minigame();
if(minigamePassed==true)
{
Item Special_item("Undead's Slayer", 70, 20, 30, 40);
Item* pSpecial = &Special_item;
Equip(pointerPlayer, pSpecial);
}
}
}
if (action == 2 && i != characterList.size() - 1)
{
//run from the enemy
std::cout << "You ran from the enemy!" << std::endl;
//change the value of the current enemy with the next one
Character aux;
aux = characterList[i];
characterList[i] = characterList[i + 1];
characterList[i + 1] = aux;
}
if (action != 1 && action != 2)
{
throw std::runtime_error("Invalid choice!");
}
}
if (Player.dead == false)
{
std::cout << "You destoryed all the enemies, the boss will appear soon." << std::endl;
cout << "The boss has been summoned." << endl;
}
Character Boss("Dead Man Master", 400, 50, 60, 20);
Character* pointerBoss = &Boss;
Fight(pointerPlayer, pointerBoss);
if(Player.dead==false)
{
Item Blade("Dad Man's Blade", 70, 100, 30, 40);
Item* pBlade = &Blade;
Equip(pointerPlayer, pBlade);
std::cout << "You finished the game! Good job." << std::endl;
}
}