Problem Dealing Damage

///////////////////////////////////////////////////////////////
// Program: un-named-game.cpp
// Description: this program will send out a creature
// and battle your opponents creature. The code currently works
// but more is being added to it.
//
// All code is mine unless otherwise stated
///////////////////////////////////////////////////////////////

//LIBRARYS
#include <iostream>
#include <ctime>
#include <string>
#include <sstream>
#include <cstdlib>


//NAMESPACE
using namespace std;
//MY VARIABLES
string PlayerAge;
string PlayerName;
string PlayerGender;
string CharacterDetails;
string OpponentCharacterDetails;
string Continue;
string PlayAgain;
long Earnings = 10;
long Money = 0;
long AmountExp = 10;
long TotalExp = 0;
long NewLevel = 0;
long LevelUp = 10;
long SkillPoints = 3;
long TotalSkillPoints = 0;
long Attack = 8;
long Defence = 1;
long Health = 40;
long Damage;
long ODamage;
long OAttack = 8;
long ODefence = 1;
long OHealth = 40;
int TypeOfCharacter;
int Armor;
//CALLS MY FUNCTIONS
void Age();//asks for the players age
void Name();//asks the players name
void Gender();//asks for the players gender
void PlayerCard();//shows the user the thier I'D card
void Program();//introduces them to the program
void CharacterDetail();//decides the character they chose
void Rules();//tells the rules
void YourMonster1();//your-fire-type
void YourMonster2();//your-water-type
void YourMonster3();//your-nature-type
void OpponentMonster1();//opponent-fire-type
void OpponentMonster2();//opponent-water-type
void OpponentMonster3();//opponent-nature-type
void OponentType();//chooses the oponents creature
void Battlephase();//begins the battlephase
void Earned();//states what you earned from combat
void Level();//if you leveled up, what level you are, and exp gained
void pause(int dur);//pauses the program for a set number of seconds

//EXECUTES THE PROGRAM
int main()
{
Name();
Age();
Gender();
PlayerCard();
replay:
Program();
CharacterDetail();
Rules();
OponentType();
Battlephase();
Earned();
Level();
cout << "Would you like to play again? y o n"<< endl;
if(PlayAgain == "y")
{
goto replay;
}


system("PAUSE");
return 0;
}
//FUNCTION DECLARATIONS

void Program()
{
cout << "Please note this program will only work if you press ENTER after each responce."<< endl;
pause (5);

system("CLS");
}
void CharacterDetail()
{
cout << "What character do you want?" << endl << endl;
cout << "There is a fire type who specializes with fire attacks. (fire)" << endl;
cout << "There is a water type who specializes with water attacks. (water)" << endl;
cout << "There is a nature type who specializes with nature attacks. (nature)" << endl << endl;
cout << "Please enter the type of the monster you would like:";
cin >> CharacterDetails;
system("CLS");
if(CharacterDetails == "fire")
{
YourMonster1();
}
else if(CharacterDetails == "water")
{
YourMonster2();
}
else{
CharacterDetails = "nature";
YourMonster3();
}
pause(10);

system("CLS");
}
void Rules()
{
cout << "Each of your characters battle." << endl;
cout << "You each alternate by taking turns. " << endl;
cout << "Since you are a beginner you will go first." << endl << endl;
pause(5);
system("CLS");
}
void OponentType()
{
/* rand example: guess the number */
#include <stdio.h>

/* initialize random seed: */
srand ( time(NULL) );

/* generate secret number: */
TypeOfCharacter = rand() % 3 + 1;

if (TypeOfCharacter == 1)
{
OpponentMonster1();
}
else if (TypeOfCharacter == 2)
{
OpponentMonster2();
}
else
{
OpponentMonster3();
}
}
void Battlephase()
{
cout <<"Let the battle begin!"<<endl;
pause(5);
YouAttack:
system("CLS");
{
if(Health > 0)
{
{
Damage = Attack - ODefence;
if(Damage <=1)
{
Damage = 1;
}
cout << "You attacked and dealt " << Damage <<" Damage" <<endl;
OHealth = OHealth - Damage;
cout << "Your opponents health is " << OHealth <<endl <<endl;
}
if(OHealth <= 0)
{
cout <<"You Win!"<<endl<<endl;
}
pause(5);
if (OHealth > 0)goto OpponentAttack;
}
}
OpponentAttack:
system("CLS");
{
if(OHealth > 0)
{
{
ODamage = OAttack - Defence;
if(ODamage <=1)
{
ODamage = 1;
}
cout << "Your opponent attacked and dealt " << ODamage <<" Damage" <<endl;
Health = Health - ODamage;
cout << "Your health is " << Health <<endl <<endl;
}
if(Health <= 0)
{
cout <<"You Lose :("<<endl<<endl;
}
pause(5);
if (Health > 0)goto YouAttack;
}
}

system("CLS");
}

void pause(int dur)
{
int temp = time(NULL) + dur;

while(temp > time(NULL));
}

void Name()
{
cout << "Welcome to the game! Since you are starting on your journey," << endl;
cout << "let me know a little bit about you.";

cout << " What is your full name?" << endl << endl;
getline(cin,PlayerName);
cout << "Nice to meet you " << PlayerName << "." << endl;
pause(5);
system("CLS");
}
void Age()
{
cout << "How old are you?" << endl;
getline(cin,PlayerAge);
cout << "Wow your, " << PlayerAge << "!! My guess was way off. " << endl;
pause(5);
system("CLS");
}
void Gender()
{
cout << "Are you Male, Female, or Alien?" << endl;
getline(cin,PlayerGender);
pause(5);
system("CLS");
}
void PlayerCard()
{
cout << "Here " << PlayerName << " This is your I'D card I have created for you." << endl;
cout << "-----------------------------" <<endl;
cout << "| ID CARD | |" <<endl;
cout << "-----------------------------" <<endl;
cout << "| NAME: " << PlayerName << endl;
cout << "| AGE: " << PlayerAge << endl;
cout << "| GENDER: " << PlayerGender << endl;
cout << "=============================" << endl<<endl<<endl;
pause(8);
}
void Earned()
{
Money += Earnings;
cout << "You earned $" << Earnings << " and " << AmountExp << " exp." << endl;
TotalExp += AmountExp;
pause(3);
cout << "You now have $" << Money << " and " << TotalExp << " exp." << endl;
pause(5);
system("CLS");
}
void Level()
{
if(TotalExp >= LevelUp)
{
LevelUp:
NewLevel += + 1;
LevelUp = LevelUp * 2 + 10;
TotalSkillPoints += + SkillPoints;
cout << "You leveled up to level " << NewLevel << " and gained " << SkillPoints << " skill points." << endl;
pause(5);
cout << "You now have " << TotalSkillPoints << " unused skill points." << endl;

pause(5);
}
if(TotalExp >= LevelUp)
{
cout << "..." << endl;
pause(1);
goto LevelUp;
}
pause(5);
system("CLS");
}

void YourMonster1()
{
cout << "You chose the fire type." << endl << "It does twice as much damage on nature types and half as much damage on water types."<< endl << endl;
pause(5);
cout << "Your fire type has the following stats" << endl << endl;
pause(5);
cout << "Attack:" << Attack << endl;
cout << "Defense:" << Defence << endl;
cout << "Health:" << Health << endl;
cout << "Advantage:Nature" << endl;
cout << "Disadvantage:Water" << endl;
pause(5);
//Fire vs Fire
if(OpponentCharacterDetails == "Fire")
{
Attack = Attack + 0;
}
//Fire vs Water
if(OpponentCharacterDetails == "Water")
{
Attack = Attack / 2;
}
//Fire vs Nature
if (OpponentCharacterDetails == "Nature")
{
Attack = Attack * 2;
}
system("CLS");
}


void YourMonster2()
{
cout << "You chose the water type." << endl << "It does twice as much damage on fire types and half as much damage on nature types."<< endl << endl;
pause(5);
cout << "Your water type has the following stats" << endl << endl;
pause(5);
cout << "Attack:" << Attack << endl;
cout << "Defense:" << Defence << endl;
cout << "Health:" << Health << endl;
cout << "Advantage:Fire" << endl;
cout << "Disadvantage:Nature" << endl;
pause(5);
//Water vs Fire
if(OpponentCharacterDetails == "Fire")
{
Attack = Attack * 2;
}
//Water vs Water
if(OpponentCharacterDetails == "Water")
{
Attack = Attack + 0;
}
//Water vs Nature
if (OpponentCharacterDetails == "Nature")
{
Attack = Attack / 2;
}
system("CLS");
}

void YourMonster3()
{
cout << "You chose the nature type." << endl << "It does twice as much damage on water types and half as much damage on fire types."<< endl << endl;
pause(5);
cout << "Your nature type has the following stats"<< endl << endl;
pause(5);
cout << "Attack:" << Attack << endl;
cout << "Defense:" << Defence << endl;
cout << "Health:" << Health << endl;
cout << "Advantage:Water" << endl;
cout << "Disadvantage:Fire" << endl << endl;
pause(5);
//Nature vs Fire
if(OpponentCharacterDetails == "Fire")
{
Attack = Attack / 2;
}
//Nature vs Water
if(OpponentCharacterDetails == "Water")
{
Attack = Attack * 2;
}
//Nature vs Nature
if (OpponentCharacterDetails == "Nature")
{
Attack = Attack + 0;
}
system("CLS");
}

void OpponentMonster1()
{
OpponentCharacterDetails = "Fire";
cout << "Your opponent sent out a fire type."<<endl;
cout << "Its stats are"<<endl<<endl;
cout << "Attack:" << OAttack << endl;
cout << "Defense:" << ODefence << endl;
cout << "Health:" << OHealth << endl << endl;
cout << "Advantage:Nature" << endl;
cout << "Disadvantage:Water" << endl;
pause(5);
//fire vs fire
if(CharacterDetails == "Fire")
{
OAttack = OAttack + 0;
}
//fire vs water
if(CharacterDetails == "Water")
{
OAttack = OAttack / 2;
}
//fire vs nature
if (CharacterDetails == "Nature")
{
OAttack = OAttack * 2;
}
system("CLS");
}

void OpponentMonster2()
{
OpponentCharacterDetails = "Water";
cout << "Your opponent sent out a water type."<<endl;
cout << "Its stats are"<<endl<<endl;
cout << "Attack:" << OAttack << endl;
cout << "Defense:" << ODefence << endl;
cout << "Health:" << OHealth << endl << endl;
cout << "Advantage:Fire" << endl;
cout << "Disadvantage:Nature" << endl;
pause(5);
//water vs fire
if(CharacterDetails == "Fire")
{
OAttack = OAttack * 2;
}
//water vs water
if(CharacterDetails == "Water")
{
OAttack = OAttack + 0;
}
//water vs nature
if (CharacterDetails == "Nature")
{
OAttack = OAttack / 2;
}
}

void OpponentMonster3()
{
OpponentCharacterDetails = "Nature";
cout << "Your opponent sent out a nature type."<<endl;
cout << "Its stats are"<<endl<<endl;
cout << "Attack:" << OAttack << endl;
cout << "Defense:" << ODefence << endl;
cout << "Health:" << OHealth << endl << endl;
cout << "Advantage:Water" << endl;
cout << "Disadvantage:Fire" << endl;
pause(5);
//Nature vs Fire
if(CharacterDetails == "Fire")
{
OAttack = OAttack / 2;
}
//Nature vs Water
if(CharacterDetails == "Water")
{
OAttack = OAttack * 2;
}
//Nature vs Nature
if (CharacterDetails == "Nature")
{
OAttack = OAttack + 0;
}
}
Please use code tags - It would be alot easier to read
Are most of these functions really necessary? I rarely ever comment on the code I'm trying to fix, but there is so much wrong here.

1
2
3
void Age();//asks for the players age
void Name();//asks the players name
void Gender();//asks for the players gender 

These, as well as the amount of global variables, made me sick.
It seemed like it ran fine. Whats wrong?
Topic archived. No new replies allowed.