OK @bcrivera have a look at this file: tools/roll_a_story.py at master · PlutoniumProphet/tools · GitHub
I created a Story class as that is the object you are actually creating, not a player. The story has its own methods for generating the genre, character, plot and setting.
I’ve reused your calculating function as it’s fun. But it sits outside the Story class along with the roll_a_story function (basically the program flow) and a roll_again function to shortcut the process for subsequent tries.
I think this is in a similar direction to what you were aiming for?
This revision is still pretty poor. I’ve started ‘modelling’ the idea of a story and things a story may need. But you’ll notice the class functions still have a lot of data in lists. (By the way I opted for lists as a dictionary wasn’t needed with random.choice() builtin method use.) You could easily have lots more genres or characters, and certainly many, many more plots and settings.
If you remove the unnecessary print statements I added in the main roll_a_story function for fun, you’ll see the script is quite short now, and more maintainable. But there is lots more you could do to simplify it.
Why not look into how you could separate the data from the class methods? Perhaps in one lists of lists? Or if you prefer, a list of dictionaries? Perhaps in another file completely? Could you return all story elements at once in one method?
Or bin it completely. But the idea was so show how you can create multiple objects (story class) for each story creation and reuse the function calls. And more importantly, that you are modelling an object and its behaviours to use as a blueprint in instances, not writing a script to just procedurally execute from top to bottom.
If you’re tool got much bigger, you might just have the roll_a_story function in the main file. Your Story class might be in its own module with many more methods, like change character, or something… food for thought.
Hope that helps!
Edit: it’s also pointless in initialising the story instance with name. The use of the name variable is managed outside of the class so it’s never used in the class methods. I forgot to remove it!