Spaces:
Sleeping
Sleeping
import random | |
from typing import Dict, List, Any, Optional | |
# ===== DATA BANKS ===== | |
RACES = ["Human", "Elf", "Dwarf", "Halfling", "Dragonborn", "Gnome", "Half-Elf", "Half-Orc", "Tiefling"] | |
CLASSES = ["Fighter", "Wizard", "Rogue", "Cleric", "Ranger", "Paladin", "Barbarian", "Bard", "Druid", "Monk", "Sorcerer", "Warlock"] | |
ALIGNMENTS = ["Lawful Good", "Neutral Good", "Chaotic Good", "Lawful Neutral", "True Neutral", "Chaotic Neutral", "Lawful Evil", "Neutral Evil", "Chaotic Evil"] | |
BACKGROUNDS = ["Acolyte", "Criminal", "Folk Hero", "Noble", "Sage", "Soldier", "Charlatan", "Entertainer", "Guild Artisan", "Hermit", "Outlander", "Sailor"] | |
PERSONALITY_TRAITS = [ | |
"I always have a plan for what to do when things go wrong", | |
"I am always calm, no matter what the situation", | |
"I would rather make a new friend than a new enemy", | |
"I have a strong sense of fair play and always try to find the most equitable solution", | |
"I'm confident in my own abilities and do what I can to instill confidence in others" | |
] | |
IDEALS = [ | |
"Respect. People deserve to be treated with dignity and respect", | |
"Fairness. No one should get preferential treatment before the law", | |
"Freedom. Chains are meant to be broken, as are those who would forge them", | |
"Might. The strongest are meant to rule", | |
"Sincerity. There's no good in pretending to be something I'm not" | |
] | |
BONDS = [ | |
"I would die to recover an ancient relic that was stolen from my temple", | |
"Someone I loved died because of a mistake I made", | |
"I owe my life to the priest who took me in when my parents died", | |
"Everything I do is for the common people", | |
"I will face any challenge to win the approval of my family" | |
] | |
FLAWS = [ | |
"I turn tail and run when things look bad", | |
"I have a 'tell' that reveals when I'm lying", | |
"I can't keep a secret to save my life", | |
"I'm too greedy for my own good", | |
"I can't resist a pretty face" | |
] | |
OCCUPATIONS = [ | |
"Merchant", "Guard", "Innkeeper", "Blacksmith", "Priest", "Noble", "Farmer", | |
"Scholar", "Thief", "Soldier", "Alchemist", "Baker", "Carpenter", "Hunter" | |
] | |
MOTIVATIONS = [ | |
"Seeking wealth and power", "Protecting their family", "Serving their god", "Pursuing knowledge", | |
"Seeking revenge", "Finding love", "Escaping their past", "Gaining recognition" | |
] | |
SECRETS = [ | |
"Is actually a spy for a rival faction", "Has a hidden magical talent", "Is fleeing from a dark past", | |
"Is secretly in love with someone inappropriate", "Has a gambling addiction", "Is being blackmailed" | |
] | |
ITEM_TYPES = { | |
"Weapon": ["Sword", "Axe", "Bow", "Dagger", "Mace", "Spear", "Crossbow", "Warhammer"], | |
"Armor": ["Chain Mail", "Plate Armor", "Leather Armor", "Scale Mail", "Hide Armor"], | |
"Shield": ["Round Shield", "Tower Shield", "Buckler", "Kite Shield"], | |
"Accessory": ["Ring", "Amulet", "Cloak", "Belt", "Bracers", "Crown", "Boots"], | |
"Consumable": ["Potion", "Scroll", "Oil", "Poison", "Bomb", "Elixir"], | |
"Tool": ["Lockpicks", "Rope", "Lantern", "Compass", "Spyglass", "Hammer"], | |
"Treasure": ["Gem", "Coins", "Art Object", "Jewelry", "Statue", "Book"] | |
} | |
MAGICAL_PROPERTIES = [ | |
"+1 to attack and damage rolls", "Resistance to fire damage", "Advantage on stealth checks", | |
"Cast a spell once per day", "Glows in the presence of evil", "Never breaks or dulls", | |
"Returns when thrown", "Speaks telepathically", "Changes color based on emotion" | |
] | |
LOCATION_TYPES = { | |
"City": ["Metropolis", "Trading Hub", "Capital", "Port City", "Fortress City"], | |
"Village": ["Farming Village", "Mining Town", "Fishing Village", "Trading Post"], | |
"Dungeon": ["Ancient Tomb", "Underground Lair", "Ruined Tower", "Cave System"], | |
"Castle": ["Royal Castle", "Fortress", "Ruined Keep", "Wizard's Tower"], | |
"Forest": ["Ancient Woods", "Dark Forest", "Enchanted Grove", "Sacred Grove"], | |
"Temple": ["Cathedral", "Shrine", "Monastery", "Sacred Site"], | |
"Tavern": ["Roadside Inn", "City Tavern", "Adventurer's Rest", "Noble's Club"] | |
} | |
FACTION_TYPES = { | |
"Guild": ["Merchant Guild", "Thieves Guild", "Artisan Guild", "Adventurer's Guild"], | |
"Religious Order": ["Temple", "Monastery", "Cult", "Holy Order"], | |
"Military": ["Army", "Guard", "Mercenaries", "Knights"], | |
"Criminal": ["Thieves", "Smugglers", "Assassins", "Pirates"], | |
"Political": ["Royal Court", "City Council", "Rebels", "Loyalists"], | |
"Academic": ["University", "Research Group", "Library", "School"] | |
} | |
DEITY_DOMAINS = { | |
"War": ["Battle", "Strategy", "Conquest", "Honor"], | |
"Knowledge": ["Wisdom", "Learning", "Magic", "Secrets"], | |
"Life": ["Healing", "Growth", "Birth", "Protection"], | |
"Death": ["Endings", "Judgment", "Undeath", "Graves"], | |
"Nature": ["Animals", "Plants", "Seasons", "Weather"], | |
"Light": ["Sun", "Dawn", "Hope", "Renewal"], | |
"Trickery": ["Deception", "Theft", "Luck", "Mischief"] | |
} | |
# ===== MAIN GENERATION FUNCTIONS ===== | |
def generate_character(name: str = "", race: str = "Random", char_class: str = "Random", | |
level: int = 5, alignment: str = "Random") -> Dict[str, Any]: | |
"""Generate a complete D&D character""" | |
if not name: | |
name = generate_fantasy_name() | |
if race == "Random": | |
race = random.choice(RACES) | |
if char_class == "Random": | |
char_class = random.choice(CLASSES) | |
if alignment == "Random": | |
alignment = random.choice(ALIGNMENTS) | |
background = random.choice(BACKGROUNDS) | |
personality = random.choice(PERSONALITY_TRAITS) | |
ideal = random.choice(IDEALS) | |
bond = random.choice(BONDS) | |
flaw = random.choice(FLAWS) | |
appearance = generate_appearance(race) | |
equipment = generate_class_equipment(char_class, level) | |
backstory = generate_backstory(name, race, char_class, background) | |
hooks = generate_adventure_hooks(name, background) | |
return { | |
"name": name, | |
"race": race, | |
"character_class": char_class, | |
"level": level, | |
"alignment": alignment, | |
"background": background, | |
"personality": personality, | |
"ideal": ideal, | |
"bond": bond, | |
"flaw": flaw, | |
"appearance": appearance, | |
"equipment": equipment, | |
"backstory": backstory, | |
"hooks": hooks | |
} | |
def generate_npc(name: str = "", race: str = "Random", occupation: str = "Random", | |
location: str = "", relationship: str = "Neutral") -> Dict[str, Any]: | |
"""Generate a detailed NPC""" | |
if not name: | |
name = generate_fantasy_name() | |
if race == "Random": | |
race = random.choice(RACES) | |
if occupation == "Random": | |
occupation = random.choice(OCCUPATIONS) | |
alignment = random.choice(ALIGNMENTS) | |
personality = random.choice(PERSONALITY_TRAITS) | |
appearance = generate_appearance(race) | |
motivation = random.choice(MOTIVATIONS) | |
secret = random.choice(SECRETS) | |
relationships = generate_relationships(name, occupation) | |
return { | |
"name": name, | |
"race": race, | |
"occupation": occupation, | |
"alignment": alignment, | |
"personality": personality, | |
"appearance": appearance, | |
"motivation": motivation, | |
"secret": secret, | |
"relationships": relationships, | |
"location": location or "Unknown", | |
"relationship_to_party": relationship | |
} | |
def generate_item(name: str = "", item_type: str = "Random", rarity: str = "Random", | |
magical: bool = True, cursed: bool = False) -> Dict[str, Any]: | |
"""Generate a magical or mundane item""" | |
if item_type == "Random": | |
item_type = random.choice(list(ITEM_TYPES.keys())) | |
if not name: | |
base_item = random.choice(ITEM_TYPES[item_type]) | |
name = generate_item_name(base_item, magical) | |
if rarity == "Random": | |
rarity = random.choice(["Common", "Uncommon", "Rare", "Very Rare", "Legendary"]) | |
description = generate_item_description(name, item_type, magical) | |
properties = [] | |
if magical: | |
num_properties = {"Common": 1, "Uncommon": 1, "Rare": 2, "Very Rare": 3, "Legendary": 4}.get(rarity, 1) | |
properties = random.sample(MAGICAL_PROPERTIES, min(num_properties, len(MAGICAL_PROPERTIES))) | |
if cursed: | |
properties.append(generate_curse()) | |
base_values = {"Common": 50, "Uncommon": 500, "Rare": 5000, "Very Rare": 50000, "Legendary": 500000} | |
value = f"{base_values.get(rarity, 50):,} gp" | |
requirements = "Attunement" if rarity in ["Rare", "Very Rare", "Legendary"] and magical else "None" | |
return { | |
"name": name, | |
"item_type": item_type, | |
"rarity": rarity, | |
"description": description, | |
"properties": properties, | |
"value": value, | |
"requirements": requirements, | |
"magical": magical, | |
"cursed": cursed | |
} | |
def generate_location(name: str = "", loc_type: str = "Random", size: str = "Medium", | |
danger_level: str = "Moderate", theme: str = "Standard Fantasy") -> Dict[str, Any]: | |
"""Generate a detailed location""" | |
if loc_type == "Random": | |
loc_type = random.choice(list(LOCATION_TYPES.keys())) | |
if not name: | |
subtype = random.choice(LOCATION_TYPES[loc_type]) | |
name = generate_location_name(subtype) | |
description = generate_location_description(name, loc_type, size, theme) | |
inhabitants = generate_inhabitants(loc_type, size) | |
features = generate_location_features(loc_type) | |
dangers = generate_location_dangers(danger_level) | |
treasures = generate_location_treasures(danger_level) | |
atmosphere = generate_atmosphere(loc_type, theme) | |
return { | |
"name": name, | |
"location_type": loc_type, | |
"size": size, | |
"danger_level": danger_level, | |
"theme": theme, | |
"description": description, | |
"inhabitants": inhabitants, | |
"features": features, | |
"dangers": dangers, | |
"treasures": treasures, | |
"atmosphere": atmosphere | |
} | |
def generate_faction(name: str = "", faction_type: str = "Random", alignment: str = "Random", | |
size: str = "Medium", influence: str = "Regional") -> Dict[str, Any]: | |
"""Generate a detailed faction""" | |
if faction_type == "Random": | |
faction_type = random.choice(list(FACTION_TYPES.keys())) | |
if not name: | |
subtype = random.choice(FACTION_TYPES[faction_type]) | |
name = generate_faction_name(subtype) | |
if alignment == "Random": | |
alignment = random.choice(ALIGNMENTS) | |
goals = generate_faction_goals(faction_type) | |
methods = generate_faction_methods(alignment) | |
resources = generate_faction_resources(size) | |
enemies = generate_faction_enemies(faction_type) | |
allies = generate_faction_allies(faction_type) | |
headquarters = generate_faction_headquarters(faction_type) | |
return { | |
"name": name, | |
"faction_type": faction_type, | |
"alignment": alignment, | |
"size": size, | |
"influence": influence, | |
"goals": goals, | |
"methods": methods, | |
"resources": resources, | |
"enemies": enemies, | |
"allies": allies, | |
"headquarters": headquarters | |
} | |
def generate_deity(name: str = "", domain: str = "Random", alignment: str = "Random", | |
pantheon: str = "Generic Fantasy", power_level: str = "Intermediate") -> Dict[str, Any]: | |
"""Generate a detailed deity""" | |
if domain == "Random": | |
domain = random.choice(list(DEITY_DOMAINS.keys())) | |
if not name: | |
name = generate_deity_name(domain, pantheon) | |
if alignment == "Random": | |
alignment = random.choice(ALIGNMENTS) | |
appearance = generate_deity_appearance(domain, alignment) | |
personality = generate_deity_personality(domain) | |
portfolio = random.sample(DEITY_DOMAINS[domain], min(3, len(DEITY_DOMAINS[domain]))) | |
worshippers = generate_deity_worshippers(domain) | |
temples = generate_deity_temples(power_level) | |
holy_symbol = generate_holy_symbol(domain) | |
return { | |
"name": name, | |
"domain": domain, | |
"alignment": alignment, | |
"pantheon": pantheon, | |
"power_level": power_level, | |
"appearance": appearance, | |
"personality": personality, | |
"portfolio": portfolio, | |
"worshippers": worshippers, | |
"temples": temples, | |
"holy_symbol": holy_symbol | |
} | |
def generate_scenario(title: str = "", scenario_type: str = "Random", level: str = "Medium", | |
duration: str = "Medium (2-3 hours)", setting: str = "Mixed") -> Dict[str, Any]: | |
"""Generate a detailed scenario/adventure""" | |
scenario_types = ["Combat Encounter", "Social Encounter", "Exploration", "Mystery", | |
"Heist", "Rescue", "Dungeon Crawl", "Political Intrigue"] | |
if scenario_type == "Random": | |
scenario_type = random.choice(scenario_types) | |
if not title: | |
title = generate_scenario_title(scenario_type) | |
description = generate_scenario_description(title, scenario_type, setting) | |
objective = generate_scenario_objective(scenario_type) | |
complications = generate_scenario_complications(level) | |
npcs_involved = generate_scenario_npcs(scenario_type) | |
locations = generate_scenario_locations(setting) | |
rewards = generate_scenario_rewards(level) | |
hooks = generate_scenario_hooks(scenario_type, title) | |
return { | |
"title": title, | |
"scenario_type": scenario_type, | |
"difficulty_level": level, | |
"duration": duration, | |
"setting": setting, | |
"description": description, | |
"objective": objective, | |
"complications": complications, | |
"npcs_involved": npcs_involved, | |
"locations": locations, | |
"rewards": rewards, | |
"hooks": hooks | |
} | |
# ===== HELPER FUNCTIONS ===== | |
def generate_fantasy_name() -> str: | |
"""Generate a random fantasy name""" | |
prefixes = ["Ar", "El", "Gal", "Mor", "Sil", "Tha", "Val", "Zar"] | |
middles = ["and", "eth", "dor", "wen", "ion", "las", "mir", "nal"] | |
suffixes = ["iel", "wen", "dil", "las", "mir", "nal", "oth", "ril"] | |
return random.choice(prefixes) + random.choice(middles) + random.choice(suffixes) | |
def generate_appearance(race: str) -> str: | |
"""Generate physical appearance based on race""" | |
appearances = { | |
"Human": "tall and sturdy with kind eyes", | |
"Elf": "tall and graceful with ethereal beauty", | |
"Dwarf": "short and stocky with a braided beard", | |
"Halfling": "small and cheerful with curly hair", | |
"Dragonborn": "scaled skin with draconic features", | |
"Tiefling": "demonic horns with exotic features" | |
} | |
return appearances.get(race, "distinctive appearance") | |
def generate_class_equipment(char_class: str, level: int) -> List[str]: | |
"""Generate equipment based on class""" | |
base_equipment = { | |
"Fighter": ["Sword", "Shield", "Armor"], | |
"Wizard": ["Spellbook", "Staff", "Robes"], | |
"Rogue": ["Daggers", "Thieves' Tools", "Leather Armor"], | |
"Cleric": ["Mace", "Shield", "Holy Symbol"], | |
"Ranger": ["Bow", "Arrows", "Survival Gear"] | |
} | |
equipment = base_equipment.get(char_class, ["Basic Gear"]) | |
if level > 5: | |
equipment.append("Magic Item") | |
return equipment | |
def generate_backstory(name: str, race: str, char_class: str, background: str) -> str: | |
"""Generate character backstory""" | |
return f"{name} grew up as a {background.lower()} among the {race.lower()} people, drawn to the path of the {char_class.lower()}." | |
def generate_adventure_hooks(name: str, background: str) -> List[str]: | |
"""Generate adventure hooks""" | |
return [ | |
f"{name}'s {background.lower()} background connects to this adventure", | |
f"An old contact needs {name}'s help", | |
f"The character's past comes back to haunt them" | |
] | |
def generate_item_name(base_item: str, magical: bool) -> str: | |
"""Generate item names""" | |
if not magical: | |
return base_item | |
prefixes = ["Enchanted", "Mystic", "Ancient", "Blessed", "Legendary"] | |
return f"{random.choice(prefixes)} {base_item}" | |
def generate_curse() -> str: | |
"""Generate item curse""" | |
curses = [ | |
"Compels the wielder to attack allies", | |
"Drains health slowly", | |
"Causes the wielder to speak in riddles", | |
"Makes the wielder tell the truth" | |
] | |
return random.choice(curses) | |
def generate_item_description(name: str, item_type: str, magical: bool) -> str: | |
"""Generate item descriptions""" | |
base = f"A well-crafted {item_type.lower()}" | |
if magical: | |
return f"{base} emanating with magical energy" | |
return f"{base} of excellent quality" | |
def generate_location_name(subtype: str) -> str: | |
"""Generate location names""" | |
prefixes = ["Ancient", "Lost", "Hidden", "Sacred", "Golden"] | |
return f"{random.choice(prefixes)} {subtype}" | |
def generate_location_description(name: str, loc_type: str, size: str, theme: str) -> str: | |
"""Generate location descriptions""" | |
return f"A {size.lower()} {loc_type.lower()} with {theme.lower()} characteristics" | |
def generate_inhabitants(loc_type: str, size: str) -> List[str]: | |
"""Generate location inhabitants""" | |
base_inhabitants = { | |
"City": ["Merchants", "Guards", "Nobles"], | |
"Village": ["Farmers", "Blacksmith", "Elder"], | |
"Dungeon": ["Monsters", "Undead", "Bandits"] | |
} | |
return base_inhabitants.get(loc_type, ["Various Creatures"]) | |
def generate_location_features(loc_type: str) -> List[str]: | |
"""Generate location features""" | |
return ["Notable landmark", "Gathering place", "Hidden area"] | |
def generate_location_dangers(danger_level: str) -> List[str]: | |
"""Generate location dangers""" | |
dangers = { | |
"Safe": ["Pickpockets", "Overpriced goods"], | |
"Low": ["Wild animals", "Natural hazards"], | |
"Moderate": ["Monsters", "Traps"], | |
"High": ["Deadly creatures", "Curses"], | |
"Extreme": ["Ancient evils", "Reality distortions"] | |
} | |
return dangers.get(danger_level, ["Unknown threats"]) | |
def generate_location_treasures(danger_level: str) -> List[str]: | |
"""Generate location treasures""" | |
treasures = { | |
"Safe": ["Copper coins", "Common items"], | |
"Moderate": ["Gold coins", "Rare items"], | |
"Extreme": ["Legendary items", "Artifacts"] | |
} | |
return treasures.get(danger_level, ["Hidden treasures"]) | |
def generate_atmosphere(loc_type: str, theme: str) -> str: | |
"""Generate atmospheric description""" | |
return f"The air is thick with {random.choice(['mystery', 'tension', 'magic'])}" | |
def generate_relationships(name: str, occupation: str) -> List[str]: | |
"""Generate NPC relationships""" | |
return [ | |
f"Knows the local {random.choice(['merchant', 'guard', 'priest'])}", | |
f"Has connections to {random.choice(['traders', 'criminals', 'officials'])}", | |
f"Family ties to nearby communities" | |
] | |
# Faction functions | |
def generate_faction_name(subtype: str) -> str: | |
"""Generate faction names""" | |
prefixes = ["Order of the", "Brotherhood of", "Guild of"] | |
themes = ["Silver Dawn", "Golden Eagle", "Iron Fist"] | |
return f"{random.choice(prefixes)} {random.choice(themes)}" | |
def generate_faction_goals(faction_type: str) -> List[str]: | |
"""Generate faction goals""" | |
goals = { | |
"Guild": ["Increase profits", "Expand influence"], | |
"Military": ["Defend territory", "Maintain order"], | |
"Criminal": ["Control trade", "Eliminate rivals"] | |
} | |
return goals.get(faction_type, ["Gain power", "Protect interests"]) | |
def generate_faction_methods(alignment: str) -> List[str]: | |
"""Generate faction methods""" | |
if "Good" in alignment: | |
return ["Diplomacy", "Charity", "Cooperation"] | |
elif "Evil" in alignment: | |
return ["Intimidation", "Corruption", "Violence"] | |
else: | |
return ["Politics", "Economics", "Information"] | |
def generate_faction_resources(size: str) -> List[str]: | |
"""Generate faction resources""" | |
resources = { | |
"Small": ["Limited funds", "Few contacts"], | |
"Medium": ["Moderate wealth", "Local connections"], | |
"Large": ["Significant wealth", "Regional network"], | |
"Massive": ["Vast fortune", "International contacts"] | |
} | |
return resources.get(size, ["Basic resources"]) | |
def generate_faction_enemies(faction_type: str) -> List[str]: | |
"""Generate faction enemies""" | |
return [f"Rival {faction_type.lower()} groups", "Government opposition", "Ancient enemies"] | |
def generate_faction_allies(faction_type: str) -> List[str]: | |
"""Generate faction allies""" | |
return [f"Friendly {faction_type.lower()} groups", "Sympathetic nobles", "Mercenary companies"] | |
def generate_faction_headquarters(faction_type: str) -> str: | |
"""Generate faction headquarters""" | |
headquarters = { | |
"Guild": "Guild Hall", | |
"Military": "Fortress", | |
"Criminal": "Hidden Safehouse", | |
"Religious Order": "Temple" | |
} | |
return headquarters.get(faction_type, "Secure Location") | |
# Deity functions | |
def generate_deity_name(domain: str, pantheon: str) -> str: | |
"""Generate deity names""" | |
names = { | |
"War": ["Valorian", "Marticus", "Bellona"], | |
"Knowledge": ["Athenis", "Scholaris", "Wisdomia"], | |
"Life": ["Vitalis", "Celestine", "Healara"] | |
} | |
return random.choice(names.get(domain, ["Divinus", "Godara", "Sanctus"])) | |
def generate_deity_appearance(domain: str, alignment: str) -> str: | |
"""Generate deity appearance""" | |
appearances = { | |
"War": "battle-scarred warrior in ornate armor", | |
"Knowledge": "wise figure surrounded by floating books", | |
"Life": "radiant being with healing aura" | |
} | |
return appearances.get(domain, "divine otherworldly presence") | |
def generate_deity_personality(domain: str) -> str: | |
"""Generate deity personality""" | |
personalities = { | |
"War": "Strategic and honorable, values courage", | |
"Knowledge": "Wise and patient, values learning", | |
"Life": "Nurturing and protective, values growth" | |
} | |
return personalities.get(domain, "Mysterious and powerful") | |
def generate_deity_worshippers(domain: str) -> List[str]: | |
"""Generate deity worshippers""" | |
worshippers = { | |
"War": ["Soldiers", "Warriors", "Generals"], | |
"Knowledge": ["Scholars", "Wizards", "Students"], | |
"Life": ["Healers", "Farmers", "Clerics"] | |
} | |
return worshippers.get(domain, ["Various followers"]) | |
def generate_deity_temples(power_level: str) -> str: | |
"""Generate deity temples""" | |
temples = { | |
"Lesser": "Small local shrines", | |
"Intermediate": "Regional temples with clergy", | |
"Greater": "Grand cathedrals and pilgrimage sites" | |
} | |
return temples.get(power_level, "Modest temples") | |
def generate_holy_symbol(domain: str) -> str: | |
"""Generate holy symbols""" | |
symbols = { | |
"War": "Crossed swords", | |
"Knowledge": "Open book with eye", | |
"Life": "Tree of life" | |
} | |
return symbols.get(domain, "Sacred emblem") | |
# Scenario functions | |
def generate_scenario_title(scenario_type: str) -> str: | |
"""Generate scenario titles""" | |
titles = { | |
"Combat Encounter": ["The Bandit Ambush", "Goblin Raid", "Dragon's Lair"], | |
"Social Encounter": ["The Noble's Feast", "Tavern Negotiations", "Court Intrigue"], | |
"Mystery": ["The Missing Merchant", "Murder at the Inn", "The Cursed Artifact"] | |
} | |
return random.choice(titles.get(scenario_type, ["The Unknown Adventure"])) | |
def generate_scenario_description(title: str, scenario_type: str, setting: str) -> str: | |
"""Generate scenario descriptions""" | |
return f"In this {scenario_type.lower()}, the party must deal with {title.lower()} in a {setting.lower()} environment" | |
def generate_scenario_objective(scenario_type: str) -> str: | |
"""Generate scenario objectives""" | |
objectives = { | |
"Combat Encounter": "Defeat the hostile creatures", | |
"Social Encounter": "Navigate complex social dynamics", | |
"Mystery": "Solve the central mystery" | |
} | |
return objectives.get(scenario_type, "Complete the adventure successfully") | |
def generate_scenario_complications(level: str) -> List[str]: | |
"""Generate scenario complications""" | |
complications = { | |
"Easy": ["Minor obstacles", "Simple challenges"], | |
"Medium": ["Competing factions", "Hidden enemies"], | |
"Hard": ["Powerful adversaries", "Complex puzzles"], | |
"Deadly": ["Overwhelming odds", "Reality-threatening consequences"] | |
} | |
return complications.get(level, ["Unexpected challenges"]) | |
def generate_scenario_npcs(scenario_type: str) -> List[str]: | |
"""Generate scenario NPCs""" | |
npcs = { | |
"Combat Encounter": ["Enemy Leader", "Local Guard"], | |
"Social Encounter": ["Influential Noble", "Wise Elder"], | |
"Mystery": ["Prime Suspect", "Key Witness"] | |
} | |
return npcs.get(scenario_type, ["Important NPC"]) | |
def generate_scenario_locations(setting: str) -> List[str]: | |
"""Generate scenario locations""" | |
locations = { | |
"Urban": ["City Square", "Noble District", "Marketplace"], | |
"Wilderness": ["Forest Clearing", "Mountain Pass", "Cave"], | |
"Mixed": ["Village Center", "Roadside Inn", "Ancient Shrine"] | |
} | |
return locations.get(setting, ["Notable Location"]) | |
def generate_scenario_rewards(level: str) -> List[str]: | |
"""Generate scenario rewards""" | |
rewards = { | |
"Easy": ["50-100 gold", "Common magic item"], | |
"Medium": ["200-500 gold", "Uncommon magic item"], | |
"Hard": ["1000+ gold", "Rare magic item"], | |
"Deadly": ["5000+ gold", "Very rare magic item"] | |
} | |
return rewards.get(level, ["Appropriate treasure"]) | |
def generate_scenario_hooks(scenario_type: str, title: str) -> List[str]: | |
"""Generate scenario hooks""" | |
return [ | |
f"A messenger arrives seeking help with {title.lower()}", | |
f"The party overhears rumors about {title.lower()}", | |
f"An old contact asks for help investigating {title.lower()}" | |
] |