import re, fileinput, sys import utilities as u import os import ast block_id = 0 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) return list_of_blocks def build_title_block(title,description,backstory,reputation): title_block_html = f"""

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

""" return title_block_html def build_image_block(sd_prompt, block_id): image_block_html = f"""
""" return image_block_html # Break each part of properties into segments, add to list, loop over possible multiple owners, servies, specialties, employees, and rumors 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): store_properties_base_html = f"""
""" store_owners = [] store_employees = [] def process_iterable_into_html(iterable_type, iterable, block_id): iterable_html = f"""""" for item in iterable: item_html = f"""""" iterable_html += item_html return iterable_html def process_rumors_into_html(rumors, block_id): rumors_html = f"""""" for rumor in rumors: rumor_html = f"""""" rumors_html += rumor_html return rumors_html 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
{iterable_type}
Store Rumors
Store Reputation
""" store_properties_block_html = f"""{store_properties_base_html} {store_iterables_html} {store_end_html}""" return store_properties_block_html def list_names_to_str(data): list_of_names = [] for i in data: list_of_names.append(i['name']) str_of_names = ', '.join(list_of_names) return str_of_names def list_to_str(list): str_of_list = ', '.join(list) return str_of_list def build_owners_section(owners_list): owner_s = 'Owner' if len(owners_list) > 1 : owner_s = 'Owners' owner_section_html = f"""

{owner_s}

""" # iterating through list of owners, each is a dictionary with descriptive qualities for owner in range(len(owners_list)) : secrets = '
'.join(owners_list[owner - 1]['secrets']) owner_section_html += f"""

{owners_list[owner - 1]['name']}

Species {owners_list[owner - 1]['species']}
Class {owners_list[owner - 1]['class']}
Description {owners_list[owner - 1]['description']}.
Personality {owners_list[owner - 1]['personality']}
Secrets {secrets}
""" return owner_section_html store_image_url = "" # Assigning strings to variables for replacing location of dependencies for the webpage to local static folders # Path is ../../ for the html files location in output/dated_folder/ def build_html_base(store_dict) : base_dir = os.path.dirname(os.path.abspath(__file__)) dependencies_path = os.path.relpath(os.path.join(base_dir, "dependencies"), os.path.join(base_dir, "output", "test")) # Template for the page html_file_as_text = f""" {store_dict['store_name']}

{store_dict['store_name']}

{store_dict['store_description']}

{store_dict['store_backstory']}

{store_dict['store_reputation']}

{store_dict['store_name']}

Size {store_dict['store_size']}
Town {store_dict['store_location']['town']}
District {store_dict['store_location']['district']}
Street {store_dict['store_location']['street']}
Type {store_dict['store_type']}
Owners {list_names_to_str(store_dict['store_owners'])}
Employees {list_names_to_str(store_dict['store_employees'])}
Store Hours {store_dict['store_hours']}
Services {list_names_to_str(store_dict['store_services'])}
Specialties {list_names_to_str(store_dict['store_specialties'])}
Reputation {store_dict['store_reputation']}
Rumors {list_to_str(store_dict['store_rumors'])}

{store_dict['store_owners'][0]['name']}

{build_owners_section(store_dict['store_owners'])}

 

 

Employees

Brega

Brega

Species Half-Orc
Class Assistant Butcher
Description A burly half-orc with a kind face and a perpetual smudge of blood on his cheek. Brega handles the heavy lifting and cutting of larger beasts.
Personality Soft-spoken and gentle despite his imposing appearance, Brega is loyal to Morgor and respects his cunning. He has a soft spot for stray animals.

Notable Customers

Lord Vittorio Blackthorn

An eccentric noble known for his extravagant feasts featuring rare and exotic meats.

Lord Blackthorn’s patronage lends an air of mystery and prestige to Morgor’s shop, attracting curious gourmands and shady characters alike.

Related Quests

The Basilisk Bounty

Morgor needs fresh basilisk meat and offers a handsome reward for those brave enough to hunt one.

500 gold coins and choice cuts of meat.

Services and Specialties

Services

Custom Slaughtering

Bring your own beasts, and Morgor will prepare the meat to your specifications. 50 gold coins per beast.

Specialties

Basilisk Cutlets

Tender and marbled with a unique flavor, perfect for those seeking a truly rare dining experience.

Subterranean Lizard Tail

A delicacy prized for its unique texture and earthy taste, enchanted to enhance its natural flavor.

Security

Bewitched Meat Hooks

These enchanted meat hooks animate and attack intruders who try to take meat without paying. 200 gold coins per pound.

Attack: +5 to hit, 1d8+3 piercing damage.

Shadow Ward

A magical barrier that alerts Morgor if someone enters the shop after hours. 150 gold coins per pound.

Detection radius of 60 feet, triggers an audible alarm.

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”

 

""" # Open a file path that will receive the processed text store_file_path = f"output/test/{store_dict['store_name'].replace(' ', '_')}.html" with open(store_file_path, 'w') as clean_html: clean_html.write(html_file_as_text) clean_html.close() return store_file_path dict_template = { "store_name": "The Mirage Emporium", "store_description": "A peculiar shop filled with the odd and the useless, where each corner hides a laugh and a mystery.", "store_reputation": "Locally famous for its bizarre and delightful inventory, though not particularly useful.", "store_backstory": "The Mirage Emporium was founded by a retired jester known for his love of the whimsical and the curious. He traveled the world collecting oddball items that struck his fancy, and upon amassing a considerable collection, opened a shop to share his treasures with the world.", "store_sd_prompt": "A highly detailed fantasy illustration of a middle-aged full body male gnome in an eclectic shop. The gnome is wearing a colorful patchwork vest and a jaunty hat. The shop is filled with quirky items like broken clocks, mismatched shoes, and joke books. The gnome has distinct fantasy features, such as pointed ears and a small, sturdy build. The background is a vibrant mix of colors and textures, giving the impression of organized chaos.", "store_type": "Curiosity Shop", "store_size": "Small", "store_hours": "From dawn until the moonlight dances.", "store_location": { "town": "Bramblebrook", "district": "Harlequin Quarter", "street": "Twilight Alley" }, "store_owners": [ { "name": "Fizzwidget Funsquirrel", "species": "Gnome", "class": "Bard", "description": "A lively gnome with a perpetual twinkle in his eye and a knack for making people smile.", "personality": "Joyful, playful, and a tad mischievous.", "secrets": ["Fizzwidget once performed a jester act for the Queen of Faerun.", "He has a hidden collection of practical jokes for special customers."], "sd_prompt": "A highly detailed fantasy illustration of a cheerful full body male gnome in an eclectic shop. The gnome is wearing a colorful patchwork vest and a jaunty hat, with a playful expression and sparkling eyes. The shop is filled with quirky items and the background is a chaotic mix of vibrant colors and textures." } ], "store_employees": [ { "name": "Marigold Merryleaf", "role": "Shop Assistant", "species": "Halfling", "description": "A spry halfling with a knack for finding peculiar trinkets buried under heaps of clutter.", "personality": "Curious, quirky, and always up for a laugh.", "sd_prompt": "A highly detailed fantasy illustration of a spry full body female halfling in an eclectic shop. The halfling is wearing a colorful apron and has a curious expression. The shop is filled with quirky items, and the background is a chaotic mix of vibrant colors and textures." } ], "store_quests": [ { "name": "The Great Sock Hunt", "description": "Help Fizzwidget locate a rare pair of mismatched socks rumored to bring joy and luck, hidden somewhere in the town of Bramblebrook.", "reward": "A pair of enchanted socks that make the wearer extraordinarily lucky in games of chance." } ], "store_customers": [ { "name": "Lord Twiddleton", "description": "An eccentric noble who collects oddities and revels in the unusual.", "influence": "High, due to his noble status and wealth." } ], "store_rumors": [ "It's said that Fizzwidget once outwitted a dragon using only a rubber chicken and a whoopee cushion.", "Marigold can find lost items using her 'half-sense' for where things hide." ], "store_security": [ { "name": "Gizmo Gearshaft", "description": "An ingenious contraption that includes clockwork gears, springs, and enchanted runes.", "mechanics": "Gizmo Gearshaft patrols the shop, alert for intruders and mischief-makers, and can deploy harmless yet startling pranks to deter trouble." } ], "store_services": [ { "name": "Laughter Therapy", "description": "A session with Fizzwidget who tells jokes and performs tricks to brighten your day.", "price": "1 gold coin per session" } ], "store_specialties": [ { "name": "Mystery Mounds", "description": "A pile of assorted oddities bundled together; you never know what you'll get, but it'll always be a conversation starter!", "price": "5 silver per bundle" } ] }