from jinja2 import Template import random # Define our template template_string = """ # {{ title }} ## Chapter 1: A Furry Detective's Morning In the quaint town of {{ setting }}, {{ cat_name }} the {{ cat_color }} cat stretched lazily in the morning sun. With {{ cat_trait }} and {{ cat_skill }}, {{ cat_name }} was no ordinary feline. {{ owner_name }}, {{ cat_name }}'s human companion and local {{ owner_occupation }}, busied {{ owner_pronoun }}self with {{ morning_activity }}. Little did they know, their day was about to take an unexpected turn. ## Chapter 2: The Mysterious Occurrence As {{ cat_name }} {{ cat_action }}, a {{ sudden_event }} caught {{ cat_pronoun }} attention. {{ cat_name }}'s whiskers twitched with curiosity. Something was amiss at the {{ crime_location }}. {{ owner_name }} noticed {{ cat_name }}'s unusual behavior and asked, "What's wrong, {{ cat_name }}?" {{ dialogue_response }} ## Chapter 3: Investigation Begins {{ cat_name }} led {{ owner_name }} to the {{ crime_location }}. There, they discovered {{ crime_discovery }}. {{ owner_name }} gasped, "Oh no! We need to solve this mystery!" With determination gleaming in {{ cat_pronoun }} eyes, {{ cat_name }} began to investigate. {{ cat_pronoun | capitalize }} {{ investigation_method }}, looking for clues. ## Chapter 4: Suspects and Clues Their investigation led them to question: 1. {{ suspect_1 }}, who {{ suspect_1_alibi }} 2. {{ suspect_2 }}, known for {{ suspect_2_trait }} 3. {{ suspect_3 }}, who was seen {{ suspect_3_action }} {{ cat_name }} found a crucial clue: {{ important_clue }}. But what did it mean? ## Chapter 5: The Chase As {{ cat_name }} and {{ owner_name }} pieced together the clues, they realized the culprit was {{ culprit }}. But just as they made this discovery, {{ chase_event }}! {{ cat_name }} sprang into action, {{ cat_action_chase }}. {{ owner_name }} followed close behind, {{ owner_action_chase }}. ## Chapter 6: Mystery Solved In a final confrontation at {{ confrontation_location }}, {{ cat_name }} cleverly {{ resolution_action }}. The mystery was solved! {{ culprit }} confessed, explaining {{ motive }}. ## Epilogue As things settled back to normal in {{ setting }}, {{ cat_name }} enjoyed a well-deserved {{ reward }}. {{ owner_name }} smiled, knowing their feline detective would always be ready for the next mystery. The end... or is it just the beginning of {{ cat_name }}'s next adventure? """ # Create the template template = Template(template_string) # Function to get user input or use a random choice def get_input(prompt, choices=None): user_input = input(prompt) if user_input: return user_input elif choices: return random.choice(choices) return "" # Get inputs from the user (or use random choices) story_inputs = { "title": get_input("Enter a title for your mystery: ", ["The Case of the Missing Tuna", "Whiskers and Shadows", "Paws of Deception"]), "setting": get_input("Enter the story's setting: ", ["Purrington", "Catsbury", "Whisker Grove"]), "cat_name": get_input("Enter the cat detective's name: ", ["Sherlock Paws", "Miss Marple Whiskers", "Inspector Furlock"]), "cat_color": get_input("Enter the cat's color: ", ["tabby", "black", "calico", "ginger"]), "cat_trait": get_input("Enter a unique trait of the cat: ", ["an uncanny sense of smell", "the ability to understand human speech", "a photographic memory"]), "cat_skill": get_input("Enter a special skill of the cat: ", ["stealthy paw-steps", "acrobatic leaps", "hypnotic purrs"]), "owner_name": get_input("Enter the owner's name: ", ["Emily", "John", "Sarah"]), "owner_occupation": get_input("Enter the owner's occupation: ", ["librarian", "baker", "retired detective"]), "owner_pronoun": get_input("Enter 'him' or 'her' for the owner: ", ["him", "her"]), "morning_activity": get_input("Enter a morning activity: ", ["preparing breakfast", "reading the newspaper", "watering the plants"]), "cat_action": get_input("Enter what the cat was doing: ", ["groomed its whiskers", "perched on the windowsill", "napped in a sunbeam"]), "sudden_event": get_input("Enter a sudden event: ", ["loud crash", "strange smell", "mysterious shadow"]), "cat_pronoun": get_input("Enter 'his' or 'her' for the cat: ", ["his", "her"]), "crime_location": get_input("Enter the location of the crime: ", ["local fish market", "neighbor's garden", "town square"]), "dialogue_response": get_input("Enter the cat's response (in cat language): ", ["'Meow meow!' (Something's not right!)", "'Purr... hiss!' (Follow me, quickly!)", "'Mrow?' (You won't believe what I found!)"]), "crime_discovery": get_input("Enter what they discovered: ", ["all the fish had vanished", "prized roses were destroyed", "the town's beloved statue was missing"]), "investigation_method": get_input("Enter how the cat investigates: ", ["sniffed around for clues", "pawed at suspicious objects", "meowed at potential witnesses"]), "suspect_1": get_input("Enter the first suspect: ", ["the new dog in town", "the grumpy old cat lady", "the mysterious stranger"]), "suspect_1_alibi": get_input("Enter the first suspect's alibi: ", ["claimed to be chasing squirrels", "said she was napping all day", "insisted on being out of town"]), "suspect_2": get_input("Enter the second suspect: ", ["the local fishmonger", "the mischievous raccoon", "the mayor's sneaky cat"]), "suspect_2_trait": get_input("Enter a trait of the second suspect: ", ["always smelling of fish", "having sticky paws", "being overly ambitious"]), "suspect_3": get_input("Enter the third suspect: ", ["the quiet bookshop owner", "the eccentric bird watcher", "the new construction worker"]), "suspect_3_action": get_input("Enter what the third suspect was seen doing: ", ["lurking around the crime scene", "acting suspiciously nervous", "suddenly having unexplained wealth"]), "important_clue": get_input("Enter an important clue: ", ["a distinctive paw print", "a piece of torn fabric", "a dropped treat wrapper"]), "culprit": get_input("Enter the culprit: ", ["the seemingly innocent kitten", "the trusted town mascot", "the least suspected individual"]), "chase_event": get_input("Enter a chase event: ", ["the culprit made a dash for it", "a sudden distraction caused chaos", "an unexpected accomplice appeared"]), "cat_action_chase": get_input("Enter the cat's action during the chase: ", ["leaped from rooftop to rooftop", "darted through secret alleyways", "used feline agility to corner the suspect"]), "owner_action_chase": get_input("Enter the owner's action during the chase: ", ["called for backup", "set up a clever trap", "provided a timely distraction"]), "confrontation_location": get_input("Enter the confrontation location: ", ["the old clock tower", "the abandoned fish cannery", "the maze-like hedge garden"]), "resolution_action": get_input("Enter how the cat resolves the situation: ", ["tricked the culprit into a confession", "presented irrefutable evidence", "orchestrated a dramatic reveal"]), "motive": get_input("Enter the culprit's motive: ", ["jealousy over another pet's popularity", "a misguided attempt to impress someone", "a complicated misunderstanding"]), "reward": get_input("Enter the cat's reward: ", ["gourmet salmon dinner", "new catnip toys", "a cozy new bed by the fireplace"]) } # Generate the story story = template.render(story_inputs) # Print the story print(story)