I am very new to C++ and have been spinning my wheels on a project. I am stuck at a few points.
1. I have to give the User a turn and the PC a turn, I am not really certain how to write a count statement to do this as either player can go unlimited times until their health = zero. I think I would put it in an if statement such as
int userturn = 0
if(userturn > 0, userturn<20, userturn++)
but I'm not sure where to put it to do the most good or even if I should.
2. The weapons the computer used on it's turn should display and it is only displaying the choice number
3. Not sure if random numbers are working because they are not displaying.
4. Userhealth and PChealth totals are not coming out right.
I've been staring at this for 8 hours and trying to go through my book. Can someone tell me what I'm doing wrong and where?
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
//Hold menu choice
int choice;
int pcchoice;
int damagedone = 0;
int Damageimpossed = 0;
//Constants for Health
int PChealth = 100,
Userhealth = 100;
//Constants for Weapon rounds
int Canon = 3,
Grenade = 4,
RifleR = 0;
//Constants for Menu Choices
const int Canon_CHOICE = 1,
Grenade_CHOICE = 2,
Rifle_CHOICE = 3;
//Declare varibale for damage via weapons
int CanonDamage,
GrenadeDamage,
RifleDamage,
RandomPCDamage;
//Randomization and top out at 100
srand ((unsigned)time(0));
CanonDamage = (rand() % 15) + 10; // OR CanonDamage -= (rand()%11)+5;
GrenadeDamage = (rand() % 12) + 7;
RifleDamage = (rand() % 8) + 3;
RandomPCDamage =(rand() & 15) +3;
//Welcome message
cout<<"Welcome to the Text Battle Game\n";
cout<<"Please choose your Weapon"<<endl;
//Loop for game
while ((PChealth >= 0) || (PChealth >= 0))
{
//Userhealth = Userhealth -= Damageimpossed;
cout<<"Your Health is: "<<Userhealth<<"\n";
PChealth = PChealth -= damagedone;
cout<<"PC Health is: "<<damagedone<<"\n"<<endl;
}
cout<<fixed<<showpoint<<setprecision(2);
if (PChealth == 0)
cout<<"You Win!!!";
else if (Userhealth == 0)
cout<<"You lose :(";