i stopped it from looping by moving the while to the top. I also, for debugging purposes, made the taking in of abbrev and amount two sep lines. I took the liberty of shortenting your calculations:
Code:
variable = variable - another_variable
to
variable -= another_variable
I hope it helps, feel free to pm me if u need.
Code:
/* RPG 2 Copyright 2003 */
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
/**PLAYER STATISTICS STRUCTURE**/
struct stats
{
int stathpm;
int stathpc;
int statmpm;
int statmpc;
};
/**ENEMY STATISTICS STRUCTURE**/
struct enemies
{
int enemyhpm;
int enemyhpc;
int enemytype;
};
////////Functions!
void fight(int stathpm,int stathpc,int statmpm,int statmpc);
int main()
{
// Structure Variables
stats player;
enemies mob;
// Structure Variables Initial Values
player.stathpm=21;
player.stathpc=21;
player.statmpm=7;
player.statmpc=7;
// Other Variables + initial values
char name[15], pointchoi[2];
int points=7,points2=0,loop=1;
cout<<" RPG2 (working title) \n\n";
cout<<"Enter your name: ";
cin.getline(name, 15, '\n');
system("cls");
cout<<"Welcome "<<name<<" to the character creation."<<endl<<endl;
cout<<"Your character starts off with a preset number of statistics.\n";
cout<<"However, initially you are granted an additional 10 points\nto add to the statistic of your choosing."<<endl;
cout<<"Each time you level up will also grant you 5 more points to add to\nyour preferred statistic(s)."<<endl;
system("pause");
system("cls");
//AA: Loop
cout<<"\nYour current statistics are:";
cout<<"\nHealth Points (HP): "<<player.stathpm;
cout<<"\nMagic Points (MP): "<<player.statmpm;
cout<<"\nFree Points: "<<points;
cout<<"\n\nTo add points to a statistic, type its abbreviation and press enter\n";
points2=0;
cin.getline(pointchoi, 3);
cout<<"Enter amount";
cin>>points2;
while(points>0)
{
if( strcmp( pointchoi, "HP" ) == 1 || strcmp( pointchoi, "hp" )== 1 ) /// AA = Character creation
{
if(points2>points)
{
cout<<"\nPlease do not attempt to cheat. (fined 2 points)\n\n";
points -= 2;
points2 = 0;
}
else if(points2<points)
{
player.stathpm += points2;
points -= points2;
}
}
if( strcmp( pointchoi, "MP" ) == 1 || strcmp( pointchoi, "mp" )== 1 ) /// AA:
{
if(points2>points)
{
cout<<"\nPlease do not attempt to cheat. (fined 2 points)\n\n";
points -= 2;
points2 = 0;
}
else if(points2<points)
{
player.statmpm += points2;
points -= points2;
}
}
else /// AA:
{
cout<<"\nEnter valid input."<<endl;
}
}
/// AA END ///
system("pause");
return 0;
}
/** Fight function
Given: Statistical variables
Task: To calculate the end result of a battle based of player and enemy statistics
Return: Nothing
To be done...that's not the actual function...it was a test :)
**/
void fight(int stathpm,int stathpc,int statmpm,int statmpc)
{
if(stathpm<11)
{
cout<<"Gay ";
}
else
{
cout<<"Non-Gay. ";
}
}