# block_id is a global variable that is used to keep track of the current block id block_id = 0 # This function takes in the user input and block_id and returns a list of blocks built with textareas def build_blocks(user_input, block_id): list_of_blocks = [] title_block = build_title_block(user_input['store_name'], user_input['store_description'], user_input['store_backstory'], user_input['store_reputation']) block_id = block_id + 1 list_of_blocks.append(title_block) store_image_block = build_image_block(user_input['storefront_sd_prompt'], block_id) block_id = block_id + 1 list_of_blocks.append(store_image_block) store_properties_block = build_store_properties_block(store_type= user_input['store_type'], store_size= user_input['store_size'], store_hours= user_input['store_hours'], store_location= user_input['store_location'], store_owners= user_input['store_owners'], store_employees= user_input['store_employees'], store_services= user_input['store_services'], store_specialties= user_input['store_specialties'], store_reputation= user_input['store_reputation'], store_rumors= user_input['store_rumors'], block_id= block_id) block_id = block_id + 1 list_of_blocks.append(store_properties_block) owner_id = 1 # Employee and owner could be combined into a single function with a parameter for the type of block # Iterate over owners and generate owner image and details block owner_title = "Owner" if len(user_input['store_owners']) > 1: owner_title = "Owners" owner_title_block = f"""

{owner_title}

""" for owner in user_input['store_owners']: owner_image_block = build_image_block(owner['sd_prompt'], block_id) block_id = block_id + 1 list_of_blocks.append(owner_image_block) owner_block = build_owner_block(owner,owner_id, owner_title_block, block_id) block_id = block_id + 1 list_of_blocks.append(owner_block) owner_id += 1 employee_id = 1 # Iterate over employees and generate employee image and details block employee_title = "Employee" if len(user_input['store_employees']) > 1: employee_title = "Employees" employee_title_block = f"""

{employee_title}

""" for employee in user_input['store_employees']: employee_image_block = build_image_block(employee['sd_prompt'], block_id) block_id = block_id + 1 list_of_blocks.append(employee_image_block) employee_block = build_employee_block(employee, employee_id, employee_title_block, block_id) block_id = block_id + 1 list_of_blocks.append(employee_block) employee_id += 1 customer_id = 1 for customer in user_input['store_customers']: customers_block = build_section_entry_block('Customers',customer, customer_id, block_id) block_id = block_id + 1 customer_id += 1 list_of_blocks.append(customers_block) quest_id = 1 for quest in user_input['store_quests']: quests_block = build_section_entry_block('Store Quests', quest, quest_id, block_id) block_id = block_id + 1 quest_id += 1 list_of_blocks.append(quests_block) services_id = 1 for service in user_input['store_services']: services_block = build_section_entry_block('Services', service, services_id, block_id) block_id = block_id + 1 services_id += 1 list_of_blocks.append(services_block) specialties_id = 1 for specialty in user_input['store_specialties']: specialty_block = build_section_entry_block('Specialties', specialty, specialties_id, block_id) block_id = block_id + 1 specialties_id += 1 list_of_blocks.append(specialty_block) security_id = 1 for security in user_input['store_security']: security_block = build_section_entry_block('Security', security, security_id, block_id) block_id = block_id + 1 security_id += 1 list_of_blocks.append(security_block) inventory_block = build_inventory_block(user_input['inventory'], block_id) block_id = block_id + 1 list_of_blocks.append(inventory_block) return list_of_blocks # Take in a specific item type and item, and return the html for that item def process_into_html(item_type,item, block_id): item_html = f""" {item_type} """ return item_html # Take in a specific iterable type and iterable, and return the html for that iterable def process_iterable_into_html(iterable_type, iterable, block_id): iterable_html = f"""""" for item in iterable: item_html = f""" {iterable_type} """ iterable_html += item_html return iterable_html # Take in a list of rumors and return the html for that list of rumors def process_rumors_into_html(rumors, block_id): rumors_html = f"""""" for rumor in rumors: rumor_html = f""" Store Rumors """ rumors_html += rumor_html return rumors_html # Take in a list of secrets and return the html for that list of secrets def process_secrets_into_html(secrets, block_id): secrets_html = f"""""" for secret in secrets: secret_html = f""" Secrets """ secrets_html += secret_html return secrets_html # Block for title, description, backstory, and reputation def build_title_block(title,description,backstory,reputation): title_block_html = f"""

{f"{description} {backstory} {reputation}"}

""" return title_block_html # Block for image generation def build_image_block(sd_prompt, block_id): image_block_html = f"""
""" return image_block_html # Block for store properties def build_store_properties_block(store_type, store_size, store_hours, store_location, store_owners, store_employees, store_services, store_specialties, store_reputation, store_rumors, block_id): # This could be the iterable block function with additional flexibility store_properties_base_html = f"""
""" store_owners = [] store_employees = [] owners_html = process_iterable_into_html('Store Owners', store_owners, block_id) employees_html = process_iterable_into_html('Store Employees', store_employees, block_id) store_specialties_html = process_iterable_into_html('Store Specialties', store_specialties, block_id) store_services_html = process_iterable_into_html('Store Services', store_services, block_id) store_rumors_html = process_rumors_into_html(store_rumors, block_id) store_iterables_html = f""" {owners_html} {employees_html} {store_services_html} {store_specialties_html} {store_rumors_html} """ store_end_html = f"""
Size
Town
District
Street
Type
Store Hours
Store Reputation
""" store_properties_block_html = f"""{store_properties_base_html} {store_iterables_html} {store_end_html}""" return store_properties_block_html # Block of owner table def build_owner_block(owner, owner_id, owner_title_block, block_id): # Owner block with values : Name, Race, Class, Description, Personality, Secrets, sd-prompt # Process owner values into html owner_name_html = process_into_html('Owner', owner['name'], block_id) owner_race_html = process_into_html('Species', owner['species'], block_id) owner_class_html = process_into_html('Class', owner['class'], block_id) owner_description_html = process_into_html('Description', owner['description'], block_id) owner_personality_html = process_into_html('Personality', owner['personality'], block_id) owner_secrets_html = process_secrets_into_html(owner['secrets'], block_id) # Build owner block html # If owner_id is 1, add owner_title_block to owner_block_html owner_block_html = f"""""" owner_block_html += f"""
""" if owner_id == 1: owner_block_html+= owner_title_block owner_block_html += f"""

""" owner_block_html += f""" {owner_name_html} {owner_race_html} {owner_class_html} {owner_description_html} {owner_personality_html} {owner_secrets_html}
""" return owner_block_html # Block of employee table def build_employee_block(employee, employee_id, employee_title_block, block_id): # Employee block with name, role, species, description, personality, sd-prompt # Process employee values into html employee_name_html = process_into_html('Employee', employee['name'], block_id) employee_role_html = process_into_html('Role', employee['role'], block_id) employee_species_html = process_into_html('Species', employee['species'], block_id) employee_description_html = process_into_html('Description', employee['description'], block_id) employee_personality_html = process_into_html('Personality', employee['personality'], block_id) # Build employee block html employee_block_html = f"""""" employee_block_html += f"""
""" if employee_id == 1: employee_block_html += employee_title_block employee_block_html += f"""

{employee_name_html} {employee_role_html} {employee_species_html} {employee_description_html} {employee_personality_html}
""" return employee_block_html # Section to take in a section name, entry, entry_id, and block_id and return the html for that section def build_section_entry_block(section, entry, entry_id, block_id): section_block_html = f"""""" section_block_html += f"""
""" if entry_id == 1: section_block_html += f"""

{section}

""" entry_features_list = list(entry.keys()) for feature in entry_features_list: if feature == 'name': section_block_html += f"""

""" else: feature_name = feature[0].upper() + feature[1:] section_block_html += f"""

""" return section_block_html def build_inventory_block(inventory, block_id): inventory_block_html = f"""""" inventory_block_html += f"""
""" inventory_block_html += f"""
Inventory
""" # Create a list of the keys in the inventory, each key is the type of items list_of_type = list(inventory.keys()) # Iterate through keys and check if the value is greater than an empty list for type in list_of_type: inventory_type = inventory[type] if len(inventory_type) > 0 : # iterate through items in inventory type list, each item is a dictionary with prescribed values. # Need to check for list in properties. for item in inventory_type: item['properties'] = ', '.join(item['properties']) item_block_html = f"""""" inventory_block_html += item_block_html inventory_block_html += f"""
Name Type Cost Properties
""" return inventory_block_html """
Inventory
Name Type Cost Properties
Poultry Drumsticks Meat 1 gp per lbs
Ground Beef Meat 1 gp per lbs
Pork Chops Meat 1 gp per lbs
Bacon Strips Meat 1 gp per lbs
Sausage Links Meat 1 gp per lbs
Mystic Minotaur Steak Exotic Meat 25 gold per pound Grants temporary strength boost when consumed, Requires fine culinary skills to cook properly
Quantum Quail Exotic Poultry 15 gold each “Phases in and out of existence”, “Can enhance one’s agility”
Invisible Bacon Mystical Meat 10 gold per slice “Invisible to the naked eye”, “Tastes incredibly savory”, “Can only be seen with a special spell”
Hydra Sausage Mythical Meat 50 gold per link “Each bite regenerates after a while”, “Consuming too much may cause mild hallucinations”
Cursed Cleaver Kitchen Equipment 100 gold “Cuts through any meat effortlessly”, “Occasionally whispers in a long-forgotten language”, “Rumored to be haunted”
Vampire Spice Mix Cooking Ingredient 20 gold per pouch “Adds a distinct flavor”, “Enhances blood flow in the consumer”, “Leaves a lingering aftertaste of garlic”
Phoenix Feather Skewers Cooking Utensil 75 gold per set “Prevents meat from overcooking”, “Gives a slight warmth to cooked items”, “Reusable endlessly”
""" #Text Area Template """""" #Title Area Template """

<

"""