rendered paste bodyvoid cmd_roll()
{
// Find the two numbers on either side of "d".
if (prompt_arguments.size() <= 1)
{
cout << endl <<"Please enter the dice to roll... ex: 1d4";
prompt();
}
else
{
string die1;
string die2;
int result = 0;
stringstream convert;
int maxscore = 0;
string full = prompt_arguments[1];
int dpos = full.find("d");
full.replace(dpos, 1, " ");
int spacepos = full.find(" ");
die1 = full[0];
die2 = full[2];
convert.clear();
convert << die2;
convert >> maxscore
// Begin Dice Rolling
// Seed random number generator with time.
result += (rand() % maxscore) + 1;
cout << endl << "Rolled " << die1 << "d" << die2 << ": " << result;
}
}