Im trying to make a function to determine whether an attack succeeds in a little game im making. The function is shown below
There is no fancy code where the function is used at the minute, so there's no point posting that too.Code:bool attack(Character human, Character orc, int turn) { int temp; bool outcome; switch (turn) { case 0: temp = ((rand() % 30) + 1); if (human.GetAgility() >= temp) outcome = true; else outcome = false; break; case 1: outcome = false; break; } return outcome; }
Turn is set to 0, hence why there is only one case at the moment as i tested it and it keeps returning true, and i have no idea why! There are no compile errors, just the incorrect return!
human.GetAgility() simply returns the agility of the human character class
Any ideas as to why this keeps happening would be greatly appreciated, as i've been looking at it and pulling my hair out for a couple of evenings over this.