You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
576 B
C++
29 lines
576 B
C++
#include "rng.hpp"
|
|
#include <cstdlib>
|
|
#include <ctime>
|
|
|
|
namespace Misc
|
|
{
|
|
|
|
void Rng::init()
|
|
{
|
|
std::srand(static_cast<unsigned int>(std::time(NULL)));
|
|
}
|
|
|
|
float Rng::rollProbability()
|
|
{
|
|
return static_cast<float>(std::rand() / (static_cast<double>(RAND_MAX)+1.0));
|
|
}
|
|
|
|
float Rng::rollClosedProbability()
|
|
{
|
|
return static_cast<float>(std::rand() / static_cast<double>(RAND_MAX));
|
|
}
|
|
|
|
int Rng::rollDice(int max)
|
|
{
|
|
return static_cast<int>((std::rand() / (static_cast<double>(RAND_MAX)+1.0)) * (max));
|
|
}
|
|
|
|
}
|