I am working on textual RPG in Python, but I am stuck in NPC. I need something like a tree. For instance:
Bot: hello there.
1. Hi, what is your name?
2. Hi, Where do you live?
> 2
Player: Where do you live?
Bot: That a creepy question. Why do you ask?
1. I was just curious.
2. Never mind.
3. Hide yo kids, hide yo wife
> 1
Player: I was just curious.
Bot: Okay.
1. Do you like cheese?
2. Bye.
> 1
Player: Do you like cheese?
Bot: Yes! I love cheese.
Each choice you make will fall back on other options, AKA if the user answered β1β to the first question, the bot would answer βMy name is Bob. What's yours?β
My game is designed in such a way that the level editor will not be an impossible prospect (every place you can visit is stored as a key in the dictionary, and then a tuple containing everything in it [I have a store class, an enemy class, a portal class , and soon the NPC class]). So I would like it to be created in such a way that I can store all this in a variable that my NPC class has saved (not a bunch of if statements)
Just to clarify, I am NOT asking someone to write code for me, I'm just not sure how to approach the problem.
A short description of what I need:
A tree-like structure that starts with one line with the number of lines that are "disconnected" from it
Each of these lines has more branches.
The difference from this and tuples of tuples is that there should be a line in which they are disconnected, and not immediately.
source share