"""Christine's Choice. Python 3."""

SCENES = {
    "start": "Christine has Tony's notebook.",
    "clue": (
        "Two plans disagree. Which one came from Tony?"
    ),
    "ally": "Leonard remembers an old service door.",
    "retry": (
        "The evidence is not reliable yet. Try again."
    ),
    "rescue": "The team has a checked route to Tony.",
    "ending": (
        "Tony is home. Your story can begin again."
    ),
}

ROUTES = {
    "start": {"notebook": "clue", "ask": "ally"},
    "clue": (
        {"compare": "rescue", "guess": "retry"}
    ),
    "ally": {"check": "rescue", "rush": "retry"},
    "retry": (
        {"again": "start"}
    ),
    "rescue": {"finish": "ending"},
}


def destination(section, choice):
    choices = ROUTES.get(section, {})
    return choices.get(choice, section)


def play():
    print("CHRISTINE'S CHOICE")
    print("Type a listed choice, or q to quit.")
    section = "start"

    while section != "ending":
        print("\n" + SCENES[section])
        choices = ROUTES[section]
        print("Choices:", ", ".join(choices))
        choice = input("> ").strip().lower()
        if choice == "q":
            print("Come back whenever you're ready.")
            return
        next_section = destination(section, choice)
        if next_section == section:
            print("Choose one of the listed words.")
        section = next_section

    print(SCENES[section])


if __name__ == "__main__":
    play()
