It's really simple- you select a class, and that class affects how much damage you do to the one monster.
This is all procedural programming- would it have been a better idea to use objects? Could I have made better use of procedural functions? Should I have used a function? I'm seeking any sort of advice.
#include <iostream>
#include <cstdlib>
usingnamespace std;
int main()
{
int x;
int stats [2];
int monsterhealth = 6 + rand() % (4 - 6);
short chance = 3 + rand() % (1 - 3);
cout << "Welcome to my RPG! Have fun!\n";
cout << "Select whether you want to be a fighter, a rogue, or a wizard.\n";
cout << "1. Fighter \n2. Rogue \n3. Wizard\n";
cin >> x;
if (x = 1)
{
stats[0]=3;stats[1]=2;stats[2]=1;
}
elseif (x = 2)
{
stats[0]=1;stats[1]=3;stats[2]=2;
}
elseif (x = 3)
{
stats[0]=1;stats[1]=2;stats[2]=3;
}
cout << "A Monster has appeared!\nWhat do you do?\n\n";
while (monsterhealth > 0)
{
cout << "\n1. Hit it with your blade!\n2. Shoot it with your bow!\n3. Cast a spell at it!\n";
cin >> x;
if (x = 1)
{
monsterhealth = monsterhealth - (stats[0] + chance);
}
elseif (x = 2)
{
monsterhealth = monsterhealth - (stats[1] + chance);
}
elseif (x = 3)
{
monsterhealth = monsterhealth - (stats[2] + chance);
}
cout << "Monster's health:" << monsterhealth << "\n";
if (monsterhealth > 0)
{cout << "It's not dead yet! Have another go at it!\n";}
}
cout << "The monster has been defeated! Yeah!\nYou saved the princess. Hooray!\n";
return 0;
}