This a part of a battle simulation of my game. Why does this loop never ends? How do I fix it? I already placed a break after every return statement but it would just start over from 50 HP. Thanks for any kind of help.
Code:
int snakeBattle(int bonus)
{
int you=50, snake=50, punch=0, kick=0, bite=0;
char attack[20];
do
{
printf("Your HP: %d Snake's HP: %d\n\n", you, snake);
printf("Skills:\nkick\npunch\n\n");
printf("Enter skill: ");
scanf("%s", attack);
if(strcmp("kick", attack)==0)
{
kickDamage(kick);
kick=kickDamage(kick);
biteDamage(bite);
bite=biteDamage(bite);
printf("You kicked the snake for %d damage!\n", kick);
printf("Snake bit you for %d damage!\n", bite);
snake=snake-kick;
you=you-bite;
if(you<0 && snake>you)
{
printf("You lost the battle!\n");
bonus=-1;
return bonus;
break;
}
if(snake<0 && you>snake)
{
printf("You won the battle!\n");
bonus=1;
return bonus;
break;
}
}
else if(strcmp("punch", attack)==0)
{
punchDamage(punch);
punch=punchDamage(punch);
biteDamage(bite);
bite=biteDamage(bite);
printf("You punched the snake for %d damage!\n", punch);
printf("Snake bit you for %d damage!\n", bite);
snake=snake-punch;
you=you-bite;
if(you<0 && snake>you)
{
printf("You lost the battle!\n");
bonus=-1;
return bonus;
break;
}
if(snake<0 && you>snake)
{
printf("You won the battle!\n");
bonus=1;
return bonus;
break;
}
}
else
{
printf("Skill not learned!\n\n");
}
} while(bonus!=1 || bonus!=-1);
}