Mixed Messages: DnD alignment, race, class generator

I decided to write a random generator that would generate a random character and log it to the console. Attributes included were alignment, race, and class, along with a flavor text, e.g. “Yay! You’re a Neutral Human Wizard!”

Here’s a link to the git repository

The biggest challenge I had was getting remote repositories to work properly. I had to turn to a more experienced programmer for help, but he helped me through troubleshooting so that I could remotely push from my laptop onto GitHub.

The program is very simple. Four arrays with the flavor text, alignment, race, and class. A random number generator that takes the array as an argument and returns a random number, and a function that generates the random selections with the number generator and then logs the text to the console as a unified message.

I realized as I was writing this that I could make the program better by having the random number generator take the array as an argument and then return the selection, rather than just a random number. Maybe I’ll make that modification later. For now, it works.

What do you think?

Hi @kapuck, your code is very efficient! I didn’t think to create a random number generator function that can be used with multiple arrays as you did. For my project, I duplicated the code that generates a random number multiple times (you can see it here) so your approach is much better!

I also struggled a little bit with pushing a local repository to GitHub so I can relate to that.

I have been trying to use the command line/terminal for as many things as I can (opening a tab in my browser, looking at file contents etc.) so that I can become really comfortable with it. Perhaps that could be helpful for you to?

Happy coding and if you’re free on Thursdays at 1pm EST, feel free to join NYC’s weekly study sessions! :slight_smile:

I liked your approach mate I was trying to think of how to pass the array as an argument in mine but ended up going a slightly different way. Your code helped me figure out how I could have acheived the method I initially thought of though so thanks for sharing!

Hi @jasbneal I also try to use the command line a lot, both in VS code and just generally. I’ve set up a couple more repositories since then, and I think the problem was that I didn’t know the proper commands to set up the remote repository.

Github only shows you the commands if you don’t opt to make a readme.md file. So I just haven’t done that as part of the repository setup and it works. I will figure out how to just start the repositories on the computer directly at some point, but I know I can at least get them started and working one way!

Thanks for the invite to the NYC study sessions. I will see if I can make one. There aren’t any groups in St. Louis, which is the closest big city to me, though I haven’t checked for a few weeks.

Thanks @danjpixel, I’m glad I could help.

Would you care to share your code? I’d love to see your solution.

Sure here’s my post in the forum with a link to the git Mixed Messages OSRS Style!