utilities.cpp

#include "utilities.h"

bool GetRandomChance(const double percent)

{

const long MAX_NUM = 100; // the max number we will allow

bool in_range; // if the number is less than or equal to percent

double random; // the random number to be generated

random = rand() % (MAX_NUM + 1); // generate a random number [0-100]

random /= MAX_NUM; // modify the number to be a percent [0-1]

in_range = (random < percent); // determine if the percent is within bounds

return in_range; // return if the chance was a hit

}