void battlePhase(Player1 &player, Boar1 &boar, bool printLvlMsg=true)
{
//...
battlePhase(player,boar,false); // message won't be printed in these calls
//...
if(printLvlMsg)
{
cout<<"You are level "<<player.level<<" at the moment."<<endl;
system ("pause");
}
}
}
EDIT:
Maybe a better way is to move all the following into the if boar.health==0 branch before return since it makes sense to show it when the enemy dies.
1 2 3 4 5 6 7 8 9
if(player.exp>=0 && player.exp<99) player.level=1;
if(player.exp>=100 && player.exp<199) player.level=2;
if(player.exp>=200 && player.exp<299) player.level=3;
if(player.exp>=300 && player.exp<399) player.level=4;
if(player.exp>=400 && player.exp<499) player.level=5;
if(player.exp>=500 && player.exp<999) player.level=6;
if(player.exp>=1000 && player.exp<1999) player.level=7;
cout<<"You are level "<<player.level<<" at the moment."<<endl;
system ("pause");
The call to battlePhase() within itself should be moved to after you check player health since no point calling battlePhase() if player is dead. I think the way you do it means player never dies.
If you move the level system into boar.health ==0 part you don't need the other change with the printLvlMsg flag. Make sure the call in battlePhase to battlePhase doesn't have the false argument.