I am having a hard time wrapping my head around this concept. I apologize for the vague subject line. I'm in the mists of creating a text base RPG and am stuck on the battle sequence. I have some variables that are effected, but the strength aspect is whats confusing.
this is the rule of what happens with strength:
Strength increases or decreases by 5 depending if win or lose.
I'm looking to have a 50/50 chance of winning or losing, but always at least a 5% chance of losing to make the game fair. Strength is an added bonus to the probability of winning as well.
My question:
How can I use strength to benefit the random number generated to win or lose?
It will run and will be 50/50 but once strength gets to be around 25-30 it wins 100% of the time making it unfair.I need the results to be 50/50 with the bonus of strength to be applied.
I know probably super simple but I can't figure it out. Please let me know if I need to explain better. This is kind of a lot to jump into for a learning project, I appreciate any and all assistance.
My code below is the snippet of the calculation. I know it might be confusing or totally wrong but even a slight nudge in the right direction would be huge. Thanks everyone!
randomNum = 1 + rand() % (100 - 1 + 1);
randomNum = player->strength + randomNum;
if (randomNum >= 51){//changed to be based off rand() + strength
player->money += 50;
if (player->strength < 95){//made it to not go above 95
player->strength += 5;
}
printf("\n You won $50 and 5 strength points!\n\n ");
else{
if (randomNum <= 50){//changed if less than 50 you lose
{
player->strength -= 5;
}
printf("\n You lost a life and 5 strength points!\n\n ");