I've been writing my own 'choose your own adventure' game. This is an example of how I did the intro class:
from Text import introText as chapter
from clint.textui import prompt
class Introduction:
def __init__(self):
self.scene_start()
def scene_b(self):
print_part(chapter.part_B)
choice = prompt.options('Choose 1, 2 or 3', chapter.B_options)
if choice == '1':
self.scene_c()
elif choice == '2':
self.scene_d()
elif choice == '3':
self.scene_e()
def scene_c(self):
print_part(chapter.part_C)
choice = prompt.options('Choose 1 or 2', chapter.C_options)
if choice == '1':
self.scene_f()
elif choice == '2':
self.scene_g()
It works, but as a I finished the intro I realized I have 5 chapters, each over 8 'parts'. I don't want to add more classes and hard-code the scenes, ideas on how I would have 1 or 2 classes that would run the choices (maybe following a json) for the whole game?