Good day, Everyone!
For those who may have seen my posts last month: I'm still in the midst of my D&D Character Generator.
While I'm still fiddling with functions separately, and the whole thing is a bit messy, I'm starting to better understand the syntax.
Now currently, the stat roller is very random. The whole thing is based on this:
1 2
|
srand((unsigned) time(0));
for (int index = 0; index < 1; index++) {
| |
While I have had naysayers on my use of srand, the consistent psuedo-randomness suits the program just fine. More often than not, my numbers are set differently enough per each roll.
However, I have an issue: The numbers are too random sometimes.
In addition to stats, I've also added rolls for Races (including Subraces) and classes.
About a third of the time, I'll get a pretty well optimized build like a strong Orc Barbarian, or an intelligent Elf Wizard. Another third of the time, I'll get something a bit more average and less specialized. In the last third, I'll get something that would be very difficult to play like a very un-charismatic bard or glass-like-fighter.
Now, that's not at all an issue. I've heard, watched, and read documentation about the entertainment that can come from playing a weak or un-optimized character.
So my dilemma is how to give the user of my program a choice.
Before I can add in separate sets of code for adding racial modifiers and allowing the player to choose their race and class (thus only rolling for stats), I need to be able to split the code using an input; yes or no, true or false, etc.
I've determined that I'd likely need to set this up between the int main() and the srand, and somehow, using the input from the cin, skip over the random rolls of race, class, and stats, to another future block of code allowing for more refined choices and results.
Here's the code up to the for (int index...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <random>
using namespace std;
int main() {
int che; //Choice for whether the user wants totally random or optimized results
cout << "Would you like your character randomized?" << endl;
cin >> che;
if (che >> true)
else if (che >> false)
cout << "This is placeholder text" << endl;
srand((unsigned) time(0));
int rcrl; //Race Roll
for (int index = 0; index < 1; index++) {
| |
After that it's just the possible results from the race roll (rcrl), the definition of the value for and use of the class roll, and then the rolls for the stats and their displays.
This post was an adventure in itself. I'd be happy to read any feedback and assistance rendered. Ahead of time, thank you for any thereof!
Have fun and stay safe!