diff --git "a/index.html" "b/index.html" --- "a/index.html" +++ "b/index.html" @@ -1,3 +1,110 @@ + + +
+ + +An interactive text adventure game powered by Gradio-lite
+Can you defeat the Evil Power Master and save the land?
+No content for this page.
") + + # Build options + options = [] + if "options" in page_data: + for opt in page_data["options"]: + # Basic check if opt is a dict with 'text' + if isinstance(opt, dict) and "text" in opt: + options.append(opt["text"]) + if not options: # Fallback if no options defined + options = ["Restart"] + content += "There are no actions defined here.
" + + # Update game statistics display + stats = generate_stats_display(game_state) + + # Initialize inventory display + inventory = generate_inventory_display(game_state) + + # Set story path + story_path = "You are at the beginning of your adventure." + + return svg_content, content, gr.Dropdown(choices=options, label="What will you do?", value=None), game_state.to_json(), stats, inventory, story_path + except Exception as e: + print(f"Error during initialization: {e}") + traceback.print_exc() # Print detailed traceback + # Provide a fallback state in case of error during init + error_state = GameState() + return ("Error
", f"An error occurred during game initialization: {e}
{traceback.format_exc()}", gr.Dropdown(choices=["Restart"], value=None), + error_state.to_json(), generate_stats_display(error_state), generate_inventory_display(error_state), "Error") + + def update_game(choice, game_state_json): """Update game based on player choice""" try: # Wrap major logic in try-except @@ -6,8 +113,12 @@ def update_game(choice, game_state_json): return gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update() # Parse game state from JSON - game_state_dict = json.loads(game_state_json) - game_state = GameState.from_dict(game_state_dict) + try: + game_state_dict = json.loads(game_state_json) + game_state = GameState.from_dict(game_state_dict) + except json.JSONDecodeError: + print("Error decoding game state JSON. Resetting.") + return initialize_game() # Reset if state is corrupted # Get current page data current_page = game_state.current_page @@ -15,6 +126,7 @@ def update_game(choice, game_state_json): if current_page_str not in game_data: # Handle invalid page number + print(f"Error: Reached invalid page number {current_page}. Resetting.") error_content = f"
Error: Reached invalid page number {current_page}. Resetting game.
" svg_error = create_svg_illustration("default") new_game_state = GameState() @@ -35,23 +147,24 @@ def update_game(choice, game_state_json): # Check alternative option if it was displayed and chosen alt_opt_data = page_data.get("alternativeOption") if not selected_option and isinstance(alt_opt_data, dict) and alt_opt_data.get("text") == choice: + current_inventory = game_state.inventory # Cache inventory for checks # Check if the alternative option should have been available - # This logic needs refinement: check if primary options were filtered out *and* alt condition met alt_show_if = alt_opt_data.get("showIf") - current_inventory = game_state.inventory primary_options_available = False if current_options_list: for opt in current_options_list: is_available = True - req_item = opt.get("requireItem") - if req_item and req_item not in current_inventory: - is_available = False - req_any = opt.get("requireAnyItem") - if is_available and req_any and not any(i in current_inventory for i in req_any): - is_available = False - if is_available: - primary_options_available = True - break # Found at least one available primary option + if isinstance(opt, dict): # Check opt is dict + req_item = opt.get("requireItem") + if req_item and req_item not in current_inventory: + is_available = False + req_any = opt.get("requireAnyItem") + if is_available and req_any and not any(i in current_inventory for i in req_any): + is_available = False + if is_available: + primary_options_available = True + break # Found at least one available primary option + # else: ignore malformed primary option # Select alternative only if no primary options were available AND showIf condition is met if not primary_options_available and (not alt_show_if or any(item in current_inventory for item in alt_show_if)): @@ -64,81 +177,92 @@ def update_game(choice, game_state_json): return initialize_game() else: # Stay on the same page if the choice wasn't found - options = [opt.get("text", "Invalid Option") for opt in current_options_list] - if alt_opt_data and alt_opt_data.get("text"): # Add alternative option text if it exists - # Check showIf condition for alternative option display + current_inventory = game_state.inventory # Cache inventory for checks + options_texts = [] + # Populate with available primary options + if current_options_list: + for opt in current_options_list: + if isinstance(opt, dict): + is_available = True + req_item = opt.get("requireItem") + if req_item and req_item not in current_inventory: is_available = False + req_any = opt.get("requireAnyItem") + if is_available and req_any and not any(i in current_inventory for i in req_any): is_available = False + if is_available and opt.get("text"): + options_texts.append(opt["text"]) + + primary_options_shown = bool(options_texts) # Were any primary options shown? + + # Check if alt option should be added + if isinstance(alt_opt_data, dict) and alt_opt_data.get("text") and not primary_options_shown: alt_show_if = alt_opt_data.get("showIf") - current_inventory = game_state.inventory if not alt_show_if or any(item in current_inventory for item in alt_show_if): - # Check if primary options were filtered out - primary_options_available = False - if current_options_list: - # Re-check primary options availability - for opt in current_options_list: - is_available = True - req_item = opt.get("requireItem") - if req_item and req_item not in current_inventory: is_available = False - req_any = opt.get("requireAnyItem") - if is_available and req_any and not any(i in current_inventory for i in req_any): is_available = False - if is_available: - primary_options_available = True - break - if not primary_options_available: - options.append(alt_opt_data["text"]) - - if not options: options = ["Restart"] + options_texts.append(alt_opt_data["text"]) + + if not options_texts: options_texts = ["Restart"] svg_content = create_svg_illustration(page_data.get("illustration", "default")) - content = f"Debug: Choice '{choice}' not matched to any available option.
" + content = f"Invalid choice or state. Please select from the available options. (Selected: '{choice}')
" stats_display = generate_stats_display(game_state) inventory_display = generate_inventory_display(game_state) story_path_display = f"You remain on page {current_page}: {page_data.get('title', 'Error')}" - return svg_content, content, gr.Dropdown(choices=options, value=None), game_state.to_json(), stats_display, inventory_display, story_path_display + # Use set to remove potential duplicates if logic error occurred + return svg_content, content, gr.Dropdown(choices=list(set(options_texts)), value=None), game_state.to_json(), stats_display, inventory_display, story_path_display # --- Option requirement checks --- item_required = selected_option.get("requireItem") any_item_required = selected_option.get("requireAnyItem") current_inventory = game_state.inventory # Cache inventory - # Check specific item requirement + # Check specific item requirement (This logic seems redundant as unavailable options shouldn't be selectable, but keep as safeguard) if item_required and item_required not in current_inventory: content = f"You need the {item_required} for this option, but you don't have it.
" - options_texts = [opt.get("text") for opt in page_data.get("options", []) if opt.get("text")] - # Check if alt option should be added back - if alt_opt_data and alt_opt_data.get("text"): - alt_show_if = alt_opt_data.get("showIf") - if not alt_show_if or any(item in current_inventory for item in alt_show_if): - primary_available_check = any( - opt.get("text") and (not opt.get("requireItem") or opt.get("requireItem") in current_inventory) and \ - (not opt.get("requireAnyItem") or any(i in current_inventory for i in opt.get("requireAnyItem"))) - for opt in page_data.get("options", []) - ) - if not primary_available_check: options_texts.append(alt_opt_data["text"]) + content += f"Requirement Error: You need {item_required}, but don't have it.
" + # Rebuild options based on current state + options_texts = [] + if current_options_list: + for opt in current_options_list: + if isinstance(opt,dict): + is_available = True + req_item_check = opt.get("requireItem") + if req_item_check and req_item_check not in current_inventory: is_available = False + req_any_check = opt.get("requireAnyItem") + if is_available and req_any_check and not any(i in current_inventory for i in req_any_check): is_available = False + if is_available and opt.get("text"): options_texts.append(opt["text"]) + + primary_options_shown = bool(options_texts) + if isinstance(alt_opt_data, dict) and alt_opt_data.get("text") and not primary_options_shown: + alt_show_if = alt_opt_data.get("showIf") + if not alt_show_if or any(item in current_inventory for item in alt_show_if): options_texts.append(alt_opt_data["text"]) if not options_texts: options_texts = ["Restart"] svg_content = create_svg_illustration(page_data.get("illustration", "default")) stats_display = generate_stats_display(game_state) inventory_display = generate_inventory_display(game_state) story_path_display = f"You remain on page {current_page}: {page_data['title']}" - return svg_content, content, gr.Dropdown(choices=list(set(options_texts)), value=None), game_state.to_json(), stats_display, inventory_display, story_path_display # Use set to remove duplicates + return svg_content, content, gr.Dropdown(choices=list(set(options_texts)), value=None), game_state.to_json(), stats_display, inventory_display, story_path_display - # Check 'any item' requirement + # Check 'any item' requirement (Similar safeguard) if any_item_required and not any(item in current_inventory for item in any_item_required): item_list = ", ".join(f"'{item}'" for item in any_item_required) content = f"You need one of the following items for this option: {item_list}, but you don't have any.
" - options_texts = [opt.get("text") for opt in page_data.get("options", []) if opt.get("text")] - # Check if alt option should be added back (similar logic as above) - if alt_opt_data and alt_opt_data.get("text"): - alt_show_if = alt_opt_data.get("showIf") - if not alt_show_if or any(item in current_inventory for item in alt_show_if): - primary_available_check = any( - opt.get("text") and (not opt.get("requireItem") or opt.get("requireItem") in current_inventory) and \ - (not opt.get("requireAnyItem") or any(i in current_inventory for i in opt.get("requireAnyItem"))) - for opt in page_data.get("options", []) - ) - if not primary_available_check: options_texts.append(alt_opt_data["text"]) + content += f"Requirement Error: You need one of: {item_list}.
" + # Rebuild options + options_texts = [] + if current_options_list: + for opt in current_options_list: + if isinstance(opt,dict): + is_available = True + req_item_check = opt.get("requireItem") + if req_item_check and req_item_check not in current_inventory: is_available = False + req_any_check = opt.get("requireAnyItem") + if is_available and req_any_check and not any(i in current_inventory for i in req_any_check): is_available = False + if is_available and opt.get("text"): options_texts.append(opt["text"]) + + primary_options_shown = bool(options_texts) + if isinstance(alt_opt_data, dict) and alt_opt_data.get("text") and not primary_options_shown: + alt_show_if = alt_opt_data.get("showIf") + if not alt_show_if or any(item in current_inventory for item in alt_show_if): options_texts.append(alt_opt_data["text"]) if not options_texts: options_texts = ["Restart"] svg_content = create_svg_illustration(page_data.get("illustration", "default")) @@ -147,7 +271,6 @@ def update_game(choice, game_state_json): story_path_display = f"You remain on page {current_page}: {page_data['title']}" return svg_content, content, gr.Dropdown(choices=list(set(options_texts)), value=None), game_state.to_json(), stats_display, inventory_display, story_path_display - # --- Process valid choice --- item_to_add = selected_option.get("addItem") if item_to_add and item_to_add not in game_state.inventory: @@ -155,29 +278,36 @@ def update_game(choice, game_state_json): item_data = items_data.get(item_to_add, {}) if item_data.get("type") == "consumable" and item_data.get("useOnAdd"): if "hpRestore" in item_data: - hp_before = game_state.current_hp game_state.current_hp = min(game_state.max_hp, game_state.current_hp + item_data["hpRestore"]) - # Maybe add feedback about using the item? Add later if needed. - game_state.inventory.remove(item_to_add) # Remove consumable after use + if item_to_add in game_state.inventory: # Remove if added + game_state.inventory.remove(item_to_add) - # Move to the next page (initial move before battle/challenge checks) - next_page = selected_option["next"] - next_page_str = str(next_page) + # Get the target page number + next_page = selected_option.get("next") + if next_page is None: # Handle options without a 'next' page (e.g., info) + print(f"Warning: Option '{choice}' on page {current_page_str} has no 'next' page defined.") + # Stay on the current page, rebuild options + next_page = current_page # Explicitly stay + next_page_str = current_page_str + page_data = game_data[next_page_str] # Reload current page data + else: + next_page_str = str(next_page) if next_page_str not in game_data: + print(f"Error: Option leads to invalid page number {next_page}. Resetting.") error_content = f"Error: Option leads to invalid page number {next_page}. Resetting game.
" svg_error = create_svg_illustration("default") new_game_state = GameState() return (svg_error, error_content, gr.Dropdown(choices=["Restart"], label="Error", value=None), new_game_state.to_json(), generate_stats_display(new_game_state), generate_inventory_display(new_game_state), "Error - Resetting") - # --- Battle Check --- + # --- Battle Check (Based on the page *before* the move) --- battle_occurred = False battle_message = "" battle_result = True + page_data_before_move = game_data[current_page_str] # Use data of the page the choice was made on - # Check random battle flag on the *current* page data (page_data before challenge potentially changes it) - if page_data.get("randomBattle", False) and random.random() < 0.2: + if page_data_before_move.get("randomBattle", False) and random.random() < 0.2: battle_result, battle_log = simulate_battle(game_state) battle_occurred = True if not battle_result: @@ -188,7 +318,7 @@ def update_game(choice, game_state_json): else: battle_message = f"Error: Challenge outcome leads to invalid page {next_page}. Resetting.
" + print(f"Error: Challenge outcome leads to invalid page {next_page_challenge}. Resetting.") + error_content = f"Error: Challenge outcome leads to invalid page {next_page_challenge}. Resetting.
" svg_error = create_svg_illustration("default") new_game_state = GameState() return (svg_error, error_content, gr.Dropdown(choices=["Restart"], label="Error", value=None), new_game_state.to_json(), generate_stats_display(new_game_state), generate_inventory_display(new_game_state), "Error - Resetting") - if next_page not in game_state.visited_pages: - game_state.visited_pages.append(next_page) + if next_page_challenge not in game_state.visited_pages: + game_state.visited_pages.append(next_page_challenge) # Load the *final* destination page data after challenge resolution page_data = game_data[next_page_str] - + next_page = next_page_challenge # Update next_page variable as well # --- Prepare Final Output --- final_page_title = page_data.get('title', 'Untitled') @@ -295,6 +428,8 @@ def update_game(choice, game_state_json): options_texts = [] current_inventory = game_state.inventory # Cache inventory again final_page_options = page_data.get("options", []) + final_alt_opt_data = page_data.get("alternativeOption") + if final_page_options: for opt in final_page_options: option_available = True @@ -310,12 +445,13 @@ def update_game(choice, game_state_json): options_texts.append(opt["text"]) # else: skip invalid option format - # Handle alternative option if necessary (only if no primary options were available/visible) - alt_opt_data = page_data.get("alternativeOption") - if isinstance(alt_opt_data, dict) and alt_opt_data.get("text") and not options_texts: # Check if text exists and no primary options shown - alt_show_if = alt_opt_data.get("showIf") + primary_options_shown = bool(options_texts) # Were any primary options available? + + # Handle alternative option if necessary + if isinstance(final_alt_opt_data, dict) and final_alt_opt_data.get("text") and not primary_options_shown: + alt_show_if = final_alt_opt_data.get("showIf") if not alt_show_if or any(item in current_inventory for item in alt_show_if): - options_texts.append(alt_opt_data["text"]) + options_texts.append(final_alt_opt_data["text"]) if not options_texts: # If still no options (dead end?) @@ -332,18 +468,1066 @@ def update_game(choice, game_state_json): stats_display = generate_stats_display(game_state) inventory_display = generate_inventory_display(game_state) - # Return final state + # Return final state using set to avoid duplicates in choices just in case return (svg_content, content, gr.Dropdown(choices=list(set(options_texts)), label="What will you do?", value=None), game_state.to_json(), stats_display, inventory_display, story_path) except Exception as e: # Generic error handling for the entire update function print(f"Error during update_game: {e}") - import traceback - traceback.print_exc() # Print detailed traceback to console (if possible in Gradio Lite) - error_content = f"A critical error occurred: {e}. Resetting game state.
" + traceback.print_exc() # Print detailed traceback + error_content = f"A critical error occurred: {e}. Resetting game state.
{traceback.format_exc()}" svg_error = create_svg_illustration("default") new_game_state = GameState() # Reset state return (svg_error, error_content, gr.Dropdown(choices=["Restart"], label="Critical Error", value=None), new_game_state.to_json(), generate_stats_display(new_game_state), generate_inventory_display(new_game_state), "Critical Error - Reset") - \ No newline at end of file + + +def generate_stats_display(game_state): + """Generate HTML for displaying player stats""" + # Calculate HP percentage for the progress bar + hp_percent = (game_state.current_hp / game_state.max_hp) * 100 if game_state.max_hp > 0 else 0 + hp_color = "#4CAF50" # Green + if hp_percent < 30: + hp_color = "#F44336" # Red + elif hp_percent < 70: + hp_color = "#FFC107" # Yellow + + stats_html = f""" +
No enemies defined for battle!
" # Avoid error if no enemies exist + enemy_type = random.choice(enemy_types) + enemy = enemies_data[enemy_type].copy() # Copy data to modify HP + + battle_log += f"A wild {enemy_type} appears!
" + + # Simple battle simulation + player_hp = game_state.current_hp + enemy_hp = enemy.get("hp", 10) # Default HP if missing + + player_base_attack = game_state.stats.get("strength", 1) + player_base_defense = 1 # Base defense + + player_attack = player_base_attack + player_defense = player_base_defense + + # Add weapon/armor bonuses if the player has relevant items + attack_bonuses = [] + defense_bonuses = [] + for item in game_state.inventory: + item_data = items_data.get(item, {}) + if "attackBonus" in item_data: + bonus = item_data["attackBonus"] + player_attack += bonus + attack_bonuses.append(f"{item} (+{bonus})") + if "defenseBonus" in item_data: + bonus = item_data["defenseBonus"] + player_defense += bonus + defense_bonuses.append(f"{item} (+{bonus})") + + if attack_bonuses: battle_log += f"Your attack ({player_base_attack}) is boosted by: {', '.join(attack_bonuses)} = {player_attack} total.
" + if defense_bonuses: battle_log += f"Your defense ({player_base_defense}) is boosted by: {', '.join(defense_bonuses)} = {player_defense} total.
" + + enemy_attack = enemy.get("attack", 3) # Default attack + enemy_defense = enemy.get("defense", 1) # Default defense + + battle_log += f"Player HP: {player_hp}, Enemy HP: {enemy_hp}
Turn {turn}:
" + # Player attacks + damage_to_enemy = max(1, player_attack - enemy_defense) + enemy_hp -= damage_to_enemy + battle_log += f" You attack the {enemy_type} for {damage_to_enemy} damage. (Enemy HP: {max(0, enemy_hp)})You defeated the {enemy_type}!
" + game_state.enemies_defeated += 1 # Increment defeated count + break + + # Enemy attacks + damage_to_player = max(1, enemy_attack - player_defense) + player_hp -= damage_to_player + battle_log += f" The {enemy_type} attacks you for {damage_to_player} damage. (Your HP: {max(0, player_hp)})" + + if player_hp <= 0: + battle_log += f"The {enemy_type} defeated you!
" + break + + battle_log += "The battle drags on too long and ends inconclusively. The enemy retreats!
" + + # Update player HP after battle + game_state.current_hp = max(0, player_hp) # Ensure HP doesn't go below 0 + + # Return True if player won (or survived), False if player lost + player_won = game_state.current_hp > 0 + battle_log += "The Evil Power Master has been terrorizing the land for years. With his dark magic, he has enslaved villages, summoned terrible monsters, and threatens to plunge the world into eternal darkness.
+You, a skilled adventurer, have been called upon to stop him. You stand at the entrance to the last free city, Silverhold, ready to begin your quest.
+The fate of the world rests on your shoulders. How will you prepare for your journey?
""", + "options": [ + { "text": "Visit the local weaponsmith for equipment", "next": 2 }, + { "text": "Seek wisdom at the ancient temple", "next": 3 }, + { "text": "Meet with the resistance leader for information", "next": 4 } + ], + "illustration": "city-gates" + }, + + "2": { + "title": "The Weaponsmith", + "content": """The city's renowned weaponsmith, Gorn, welcomes you to his forge. Weapons of all kinds line the walls, from simple daggers to exotic blades that pulse with magic.
+"I've been expecting you," Gorn says. "The Evil Power Master's fortress is treacherous. You'll need more than common steel to face what lies ahead."
+He presents you with three weapons, each crafted with special materials and enchantments.
""", + "options": [ + { "text": "Take the Flaming Sword, powerful but dangerous", "next": 5, "addItem": "Flaming Sword" }, + { "text": "Choose the Whispering Bow, silent and precise", "next": 5, "addItem": "Whispering Bow" }, + { "text": "Select the Guardian Shield, defensive and protective", "next": 5, "addItem": "Guardian Shield" } + ], + "illustration": "weaponsmith" + }, + + "3": { + "title": "The Ancient Temple", + "content": """The Temple of Eternal Light stands at the heart of Silverhold. Inside, the air is thick with incense, and soft chanting echoes through the chambers.
+High Priestess Alara greets you with concern in her eyes. "The Evil Power Master grows stronger each day. Before you face him, you should prepare your mind and spirit."
+She offers to teach you one of the temple's secret arts to aid your quest.
""", + "options": [ + { "text": "Learn the Healing Light technique", "next": 5, "addItem": "Healing Light Spell" }, + { "text": "Master the Shield of Faith protection", "next": 5, "addItem": "Shield of Faith Spell" }, + { "text": "Study the ancient Binding Runes", "next": 5, "addItem": "Binding Runes Scroll" } + ], + "illustration": "temple" + }, + + "4": { + "title": "The Resistance Leader", + "content": """In a secluded tavern, you meet Lyra, leader of the resistance against the Evil Power Master. Battle-scarred but determined, she unfurls a map across the table.
+"His fortress has three possible entry points," she explains, pointing to marked locations. "Each has its dangers and advantages. You must choose your path carefully."
+She also offers you a special item from the resistance's limited supplies.
""", + "options": [ + { "text": "Take the map showing the secret tunnel entrance", "next": 5, "addItem": "Secret Tunnel Map" }, + { "text": "Accept the poison-tipped daggers for stealth", "next": 5, "addItem": "Poison Daggers" }, + { "text": "Choose the master key that unlocks ancient doors", "next": 5, "addItem": "Master Key" } + ], + "illustration": "resistance-meeting" + }, + + "5": { + "title": "The Journey Begins", + "content": """Prepared as best you can be, you leave Silverhold behind. The path to the Evil Power Master's fortress takes you through the Shadowwood Forest, a place once beautiful but now corrupted by dark magic.
+Strange sounds echo among the twisted trees, and the feeling of being watched raises the hair on your neck. The main road is the fastest route, but there are alternatives.
""", + "options": [ + { "text": "Take the main road through the forest", "next": 6 }, + { "text": "Follow the winding river path", "next": 7 }, + { "text": "Brave the ancient ruins shortcut", "next": 8 } + ], + "randomBattle": True, + "illustration": "shadowwood-forest" + }, + + "6": { + "title": "Ambush on the Road", + "content": """The main road through Shadowwood is overgrown but still visible. As you make your way forward, the trees suddenly rustle with movement.
+A group of the Evil Power Master's scouts emerges from hiding! They've been patrolling the road, looking for those who might oppose their master.
+"Surrender now," their leader snarls, "or face the consequences!"
""", + "challenge": { + "title": "Escape the Ambush", + "description": "You need to either fight your way through or find an escape route.", + "stat": "courage", + "difficulty": 5, + "success": 9, + "failure": 10 + }, + "illustration": "road-ambush" + }, + + "7": { + "title": "The Mist-Shrouded River", + "content": """The river path is longer but less traveled. Thick mist clings to the water's surface, reducing visibility but potentially hiding you from enemies.
+As you follow the winding shore, you notice strange glowing lights beneath the water's surface. Suddenly, the mist parts to reveal a mysterious figure standing on the water itself.
+"Few choose this path," the figure says in a melodic voice. "To proceed, you must answer my riddle."
""", + "challenge": { + "title": "The River Spirit's Riddle", + "description": "Answer correctly to gain passage and a blessing. Answer wrongly and face the river's peril.", + "stat": "wisdom", + "difficulty": 6, + "success": 11, + "failure": 12 + }, + "illustration": "river-spirit" + }, + + "8": { + "title": "The Forgotten Ruins", + "content": """The ancient ruins rise from the forest floor like the bones of a forgotten civilization. Moss-covered stones and crumbling arches create a labyrinth of passages and dead ends.
+This path is the shortest route to the fortress, but the ruins are said to be haunted by the spirits of those who built this place long ago.
+As you enter the heart of the ruins, the temperature drops dramatically, and whispers echo through the stone corridors.
""", + "challenge": { + "title": "Navigate the Haunted Ruins", + "description": "Find the correct path through the ruins while avoiding the malevolent spirits.", + "stat": "wisdom", + "difficulty": 5, + "success": 13, + "failure": 14 + }, + "illustration": "ancient-ruins" + }, + + "9": { + "title": "Breaking Through", + "content": """With courage and quick thinking, you manage to fight your way through the ambush. Several scouts fall to your attacks, and the rest scatter into the forest.
+Though you've escaped, the commotion may have alerted other enemies in the area. You need to move quickly before reinforcements arrive.
+Ahead, the forest begins to thin, revealing the barren lands that surround the Evil Power Master's fortress.
""", + "options": [ + { "text": "Rush across the open ground to the fortress", "next": 15 }, + { "text": "Wait for nightfall before crossing", "next": 16 }, + { "text": "Search for underground passages", "next": 17 } + ], + "randomBattle": True, + "illustration": "forest-edge" + }, + + "10": { + "title": "Captured!", + "content": """Despite your best efforts, the scouts overwhelm you. Disarmed and bound, you're dragged through the forest to a small outpost.
+"The Master will be pleased," the leader laughs. "He always enjoys interrogating those who think they can stand against him."
+As night falls, you're locked in a crude cell. All seems lost, but one guard looks at you with sympathy when the others aren't watching.
""", + "options": [ + { "text": "Try to escape during the night", "next": 18 }, + { "text": "Appeal to the sympathetic guard", "next": 19 }, + { "text": "Wait for transport to the fortress", "next": 20 } + ], + "hpLoss": 5, + "illustration": "prisoner-cell" + }, + + "11": { + "title": "The Spirit's Blessing", + "content": """"Wisdom flows in you like the river itself," the spirit says, impressed by your answer. The mist swirls around you, and you feel a surge of energy.
+"Take my blessing. The waters will aid you against the darkness." The spirit touches your forehead, and a cool sensation spreads through your body.
+The mist parts, revealing a clear path forward and the distant silhouette of the Evil Power Master's fortress.
""", + "options": [ + { "text": "Continue to the barren plains", "next": 15 }, + { "text": "Ask the spirit for more information", "next": 16 }, + { "text": "Follow the underwater passage the spirit reveals", "next": 17 } + ], + "addItem": "Water Spirit's Blessing", + "statIncrease": { "stat": "wisdom", "amount": 2 }, + "illustration": "spirit-blessing" + }, + + "12": { + "title": "The Spirit's Wrath", + "content": """"Incorrect," the spirit hisses, its melodic voice turning harsh. "The river does not suffer fools!"
+The mist thickens around you, and the calm water suddenly churns. A powerful current grabs your legs, pulling you into the depths.
+You struggle against the supernatural force, barely managing to break free and scramble onto the shore, soaked and battered.
""", + "options": [ + { "text": "Continue along the riverbank", "next": 15 }, + { "text": "Find another path through the forest", "next": 16 }, + { "text": "Rest and recover before moving on", "next": 17 } + ], + "hpLoss": 8, + "illustration": "river-danger" + }, + + "13": { + "title": "Ancient Allies", + "content": """Your wisdom guides you through the ruins' labyrinth. As you navigate the crumbling corridors, the whispers change from threatening to curious.
+In the central chamber, transparent figures materialize - the ancient spirits of this place. They were not malevolent but protective, testing those who pass through.
+"You have shown respect and intelligence," their leader says. "We too oppose the darkness that has corrupted our land."
""", + "options": [ + { "text": "Accept their offer of a magical artifact", "next": 15, "addItem": "Ancient Amulet" }, + { "text": "Ask for knowledge about the fortress", "next": 16 }, + { "text": "Request they guide you through secret paths", "next": 17 } + ], + "statIncrease": { "stat": "wisdom", "amount": 1 }, + "illustration": "ancient-spirits" + }, + + "14": { + "title": "Lost in Time", + "content": """The ruins become an impossible maze. Each turn leads to unfamiliar passages, and the whispers grow louder, disorienting you further.
+Hours pass as you wander, and malevolent spirits tug at your life force. By the time you finally stumble out of the ruins, you're exhausted and drained.
+Worse, you've emerged far from your intended path, and valuable time has been lost.
""", + "options": [ + { "text": "Rest to recover your strength", "next": 15 }, + { "text": "Push on despite your exhaustion", "next": 16 }, + { "text": "Find a local guide in a nearby village", "next": 17 } + ], + "hpLoss": 10, + "statIncrease": { "stat": "luck", "amount": -1 }, + "illustration": "lost-ruins" + }, + + "15": { + "title": "The Looming Fortress", + "content": """The Evil Power Master's fortress dominates the landscape - a massive structure of black stone with towers that seem to pierce the clouds.
+Lightning crackles around its highest spires, and dark shapes patrol the battlements. The main gate is heavily guarded, but there must be other ways in.
+As you survey the imposing structure, you consider your options for infiltration.
""", + "options": [ + { "text": "Approach the main gate (needs disguise)", "next": 21, "requireItem": "Guard Disguise" }, + { "text": "Scale the outer wall under cover of darkness", "next": 22 }, + { "text": "Look for the secret tunnel (requires Secret Tunnel Map)", "next": 24, "requireItem": "Secret Tunnel Map" } + ], + "alternativeOption": { "text": "Search for another entrance (risky)", "next": 21, "showIf": ["Guard Disguise", "Secret Tunnel Map"] }, + "illustration": "evil-fortress" + }, + + "16": { + "title": "Strategic Approach", + "content": """You take time to observe the fortress from a distance. Patrols move in predictable patterns, and supply wagons come and go at regular intervals.
+As night falls, different sections of the fortress light up, revealing potential weaknesses in security. Your careful observation provides valuable insights.
+You identify several possible entry points, each with its own risks and advantages.
""", + "options": [ + { "text": "Infiltrate with an incoming supply wagon", "next": 21 }, + { "text": "Use magic to create a distraction (requires any spell)", "next": 22, "requireAnyItem": ["Healing Light Spell", "Shield of Faith Spell", "Binding Runes Scroll", "Water Spirit's Blessing"] }, + { "text": "Bribe a guard to let you in (requires special item)", "next": 23, "requireAnyItem": ["Ancient Amulet", "Master Key"] } + ], + "alternativeOption": { + "text": "Attempt to sneak in using shadows", + "next": 21, + "showIf": ["Healing Light Spell", "Shield of Faith Spell", "Binding Runes Scroll", "Water Spirit's Blessing", "Ancient Amulet", "Master Key"] + }, + "statIncrease": { "stat": "wisdom", "amount": 1 }, + "illustration": "fortress-observation" + }, + + "17": { + "title": "The Hidden Way", + "content": """Your search reveals an unexpected approach to the fortress - an ancient maintenance tunnel that runs beneath the barren plains, likely forgotten by the Evil Power Master.
+The tunnel is old and could be unstable, but it would allow you to bypass most of the outer defenses entirely.
+As you consider this option, you hear patrol horns in the distance - they're sweeping the area for intruders.
""", + "options": [ + { "text": "Enter the tunnel immediately", "next": 24 }, + { "text": "Hide and wait for the patrol to pass", "next": 21 }, + { "text": "Set a trap for the patrol", "next": 22 } + ], + "illustration": "hidden-tunnel" + }, + + "18": { + "title": "Night Escape", + "content": """You wait until the dead of night, when most guards are dozing at their posts. Using a loose stone you discovered in your cell, you work on the rusted lock.
+With a satisfying click, the cell door unlocks. Moving silently through the shadows, you retrieve your confiscated equipment from a nearby storeroom.
+Now you must leave the outpost without raising the alarm.
""", + "challenge": { + "title": "Stealthy Escape", + "description": "Slip past the sleeping guards without alerting them.", + "stat": "wisdom", + "difficulty": 6, + "success": 16, + "failure": 10 + }, + "illustration": "night-escape" + }, + + "19": { + "title": "Unexpected Ally", + "content": """When the guard passes your cell alone, you whisper, asking why they seemed sympathetic. The guard looks around nervously before responding.
+"My village was enslaved by the Evil Power Master. My family serves him under threat of death, but many of us secretly hope for his downfall."
+The guard offers to help you escape, but warns there will be a price for this betrayal if discovered.
""", + "options": [ + { "text": "Accept the guard's help (gain disguise, proceed)", "next": 16, "addItem": "Guard Disguise"}, + { "text": "Decline - you don't want to put them at risk", "next": 18 }, + { "text": "Convince them to join your cause", "next": 20 } + ], + "illustration": "guard-ally" + }, + + "20": { + "title": "Journey to the Fortress", + "content": """At dawn, you're bound and loaded onto a prison wagon with other captured travelers. The journey to the fortress is uncomfortable, but you use the time to observe and plan.
+The other prisoners share what they know about the fortress. One mentions rumors of a resistance operating within the Evil Power Master's ranks.
+As the wagon approaches the massive gates, you begin to formulate a plan.
""", + "options": [ + { "text": "Look for an opportunity to escape during transfer", "next": 22 }, + { "text": "Remain captive to get inside, then escape", "next": 21 }, + { "text": "Try to contact the internal resistance (needs clue/item)", "next": 23, "requireAnyItem": ["Guard Disguise", "Ancient Amulet"]} + ], + "alternativeOption": { "text": "Remain captive with no plan (leads to capture)", "next": 28, "showIf": ["Guard Disguise", "Ancient Amulet"] }, + "illustration": "prison-wagon" + }, + + "21": { + "title": "Infiltration", + "content": """Using your skills and preparation, you manage to infiltrate the outer perimeter of the fortress. The black stone walls loom overhead, even more intimidating up close.
+Guards patrol in pairs, and magical wards pulse with dark energy. You'll need to be extremely careful as you navigate deeper into enemy territory.
+The sound of a bell signals a shift change, providing a momentary distraction.
""", + "options": [ + { "text": "Head towards the central tower", "next": 25 }, + { "text": "Search for the dungeons", "next": 26 }, + { "text": "Follow a group of mages", "next": 27 } + ], + "randomBattle": True, + "illustration": "fortress-interior" + }, + + "22": { + "title": "Discovered!", + "content": """As you make your way through the fortress, an alarm suddenly sounds! Your presence has been detected, and you hear the heavy footsteps of guards approaching.
+"Intruder in the south corridor!" a voice shouts. "Seal all exits!"
+You have moments to react before you're surrounded.
""", + "challenge": { + "title": "Escape Detection", + "description": "You need to escape from the approaching guards before they trap you.", + "stat": "courage", + "difficulty": 7, + "success": 25, + "failure": 28 + }, + "illustration": "fortress-alarm" + }, + + "23": { + "title": "Secret Resistance", + "content": """Through luck or skill (or maybe a bribe or disguise), you make contact with members of the secret resistance operating within the fortress. They're skeptical of you at first, but your actions have convinced them of your intentions.
+"We've been working to undermine the Evil Power Master for years," their leader whispers. "Now with your help, we might finally have a chance to end his reign."
+They share crucial information about the fortress layout and the Evil Power Master's weaknesses.
""", + "options": [ + { "text": "Join their planned uprising", "next": 29 }, + { "text": "Ask them to help you reach the Power Master directly", "next": 30 }, + { "text": "Share your knowledge with them", "next": 31 } + ], + "illustration": "secret-meeting" + }, + + "24": { + "title": "Underground Passage", + "content": """The ancient tunnel is damp and narrow, forcing you to crouch as you make your way forward. Roots hang from the ceiling, and the air feels thick with age.
+After what seems like hours of careful navigation, you notice light ahead. The tunnel opens into what appears to be a forgotten storeroom beneath the fortress.
+Dust covers everything, but you can hear movement in the rooms above.
""", + "options": [ + { "text": "Explore the storeroom for useful items", "next": 32 }, + { "text": "Find a way up to the main fortress", "next": 33 }, + { "text": "Listen carefully to determine what's happening above", "next": 34 } + ], + "illustration": "underground-passage" + }, + + "25": { + "title": "The Central Tower", + "content": """The central tower rises from the heart of the fortress like a black spear. As you get closer, you can feel powerful magic emanating from its peak.
+Guards are more numerous here, and you spot several dark mages performing rituals in alcoves along the walls. Whatever the Evil Power Master is planning, it seems to be approaching its climax.
+A massive door blocks the entrance to the tower, engraved with strange symbols.
""", + "options": [ + { "text": "Try to decipher the symbols (needs wisdom)", "next": 35 }, + { "text": "Look for another entrance", "next": 36 }, + { "text": "Use magic/key to open the door", "next": 37, "requireAnyItem": ["Healing Light Spell", "Shield of Faith Spell", "Binding Runes Scroll", "Water Spirit's Blessing", "Master Key", "Ancient Amulet"] } + ], + "alternativeOption": { "text": "Wait and observe the mages", "next": 36, "showIf": ["Healing Light Spell", "Shield of Faith Spell", "Binding Runes Scroll", "Water Spirit's Blessing", "Master Key", "Ancient Amulet"] }, + "illustration": "central-tower" + }, + + "26": { + "title": "The Dungeons", + "content": """The dungeons are a maze of dark, damp corridors lined with cells. Moans and whispers echo off the stone walls, creating an eerie atmosphere of despair.
+Many of the cells contain prisoners - ordinary people from villages conquered by the Evil Power Master, resistance fighters, and even a few magical creatures.
+At the end of one corridor, you spot a heavily guarded cell that seems more important than the others.
""", + "options": [ + { "text": "Try to free prisoners (needs Master Key)", "next": 38, "requireItem": "Master Key"}, # Made freeing need key + { "text": "Investigate the heavily guarded cell", "next": 39 }, + { "text": "Look for a passage leading upward", "next": 40 } + ], + "alternativeOption": { "text": "Avoid the dungeons, look upward", "next": 40, "showIf": ["Master Key"] }, + "illustration": "dungeon-corridors" + }, + + "27": { + "title": "The Ritual Chamber", + "content": """Following the group of mages leads you to a large circular chamber. Hidden in the shadows, you observe as they prepare for what appears to be an important ritual.
+In the center of the room hovers a dark crystal, pulsing with malevolent energy. The mages arrange themselves around it, beginning a chant in an ancient language.
+"Soon the master's power will be unstoppable," one of them mutters. "The alignment is nearly perfect."
""", + "options": [ + { "text": "Disrupt the ritual", "next": 41 }, + { "text": "Quietly observe to learn more", "next": 42 }, + { "text": "Steal the crystal when they're distracted", "next": 43 } + ], + "illustration": "ritual-chamber" + }, + + "28": { + "title": "Captured Again", + "content": """The guards overwhelm you, and this time, there's no easy escape. You're brought before a high-ranking officer, who smiles coldly.
+"The Master will be most pleased," he says. "He so rarely gets to meet those foolish enough to challenge him directly."
+You're escorted under heavy guard toward the central tower, where the Evil Power Master awaits.
""", + "options": [ + { "text": "Look for another chance to escape (low odds)", "next": 44 }, + { "text": "Prepare yourself mentally to face the Power Master", "next": 45 }, + { "text": "Try to gather information from the guards", "next": 46 } + ], + "illustration": "prisoner-escort" + }, + + "29": { + "title": "The Uprising", + "content": """The resistance has planned carefully. When the signal is given, chaos erupts throughout the fortress. Guards find themselves fighting servants, and magical wards fail as saboteurs destroy key components.
+In the confusion, you and a small team of resistance fighters make your way toward the central tower where the Evil Power Master resides.
+"This is our only chance," the resistance leader whispers. "We must reach him before he realizes what's happening."
""", + "options": [ + { "text": "Lead the charge directly", "next": 47 }, + { "text": "Split up to create more distractions", "next": 48 }, + { "text": "Sneak ahead while the others draw attention", "next": 49 } + ], + "illustration": "fortress-uprising" + }, + + "30": { + "title": "The Final Approach", + "content": """With the resistance's help, you navigate through secret passages unknown to most of the fortress inhabitants. These narrow corridors, built during the fortress's construction, lead directly to the upper levels.
+"The Power Master's chambers are at the top of the central tower," your guide explains. "He rarely leaves them these days, too focused on some grand ritual. This may be our only chance to stop him."
+The passage ends at a hidden door, beyond which lies the base of the central tower.
""", + "options": [ + { "text": "Enter the tower cautiously", "next": 50 }, + { "text": "Ask about the ritual the Power Master is performing", "next": 51 }, + { "text": "Request additional help for the final confrontation", "next": 52 } + ], + "illustration": "secret-passage" + }, + + "31": { + "title": "Knowledge Exchange", + "content": """You share everything you've learned on your journey - about the river spirit, the ancient ruins, and any magical artifacts you've collected. In return, the resistance provides crucial information.
+"The Evil Power Master draws his power from an ancient crystal," their sage explains. "It amplifies his natural abilities tenfold, but it's also a weakness. Destroy the crystal, and his power will be greatly diminished."
+They also reveal that the Power Master is preparing for a cosmic alignment that will make him virtually unstoppable.
""", + "options": [ + { "text": "Ask how to locate the crystal", "next": 53 }, + { "text": "Find out when the alignment will occur", "next": 54 }, + { "text": "Learn if there are any weapons that can harm the crystal", "next": 55 } + ], + "statIncrease": { "stat": "wisdom", "amount": 1 }, + "illustration": "knowledge-sharing" + }, + + # --- Placeholder Pages --- + "32": { "title": "Storeroom Search", "content": "You search the dusty storeroom. Mostly old crates and broken tools, but you find a forgotten Healing Potion tucked away!
", "options": [{ "text": "Drink Potion and find way up", "next": 33, "addItem": "Healing Potion" }], "illustration": "underground-passage" }, + "33": { "title": "Ascending", "content": "You find a loose grate leading to the fortress kitchens. Smells marginally better than the tunnel. You emerge cautiously.
", "options": [{ "text": "Sneak through the kitchens", "next": 21 }], "illustration": "fortress-interior" }, + "34": { "title": "Listening", "content": "You hear the rhythmic marching of guards above, and the distant clang of metal from the armory. Sounds like standard patrols, nothing immediately alarming.
", "options": [{ "text": "Explore the storeroom", "next": 32 }, { "text": "Try to find a way up", "next": 33 }], "illustration": "underground-passage" }, + "35": { "title": "Deciphering Symbols", "content": "The symbols pulse with dark energy. Your wisdom tells you they form a powerful ward, possibly tied to the Master's life force. It requires a specific magical resonance or immense force to bypass.
", "options": [{ "text": "Look for another entrance", "next": 36 }, { "text": "Use magic/key (if you have it)", "next": 37, "requireAnyItem": ["Healing Light Spell", "Shield of Faith Spell", "Binding Runes Scroll", "Water Spirit's Blessing", "Master Key", "Ancient Amulet"] }], "statIncrease": {"stat":"wisdom", "amount":1}, "illustration": "central-tower" }, + "36": { "title": "Searching for Entry", "content": "You circle the base of the tower. High up, you spot a less guarded balcony. Scaling the sheer, dark stone might be possible for someone with exceptional strength or courage, but it's extremely dangerous.
", "options": [{ "text": "Attempt to climb (Strength/Courage Challenge)", "next": 22 }, {"text": "Return to the main door", "next": 25}], "illustration": "central-tower" }, + "37": { "title": "Magical Entry", "content": "You focus your magical item (or the Master Key). The symbols flare violently, then fade as the massive door groans open! You step into the oppressive darkness of the tower base.
", "options": [{ "text": "Ascend the tower", "next": 48 }], "illustration": "final-confrontation" }, + "38": { "title": "Causing Distraction", "content": "Using your Master Key, you manage to unlock a few cells. The freed prisoners, though weak, immediately cause a commotion, shouting and banging, drawing several guards away from their posts.
", "options": [{ "text": "Investigate the guarded cell", "next": 39 }, {"text": "Look for an exit upwards", "next": 40}], "illustration": "dungeon-corridors" }, # Removed requireItem from option as it's implied by reaching this page + "39": { "title": "Guarded Cell", "content": "Inside the heavily barred cell is a frail figure clad in mage robes – likely a captured resistance member or someone who defied the Master. They look up weakly as you approach the bars.
", "options": [{ "text": "Attempt to free the mage (needs Master Key/Runes)", "next": 30, "requireAnyItem": ["Master Key", "Binding Runes Scroll"] }, {"text": "Leave them for now", "next": 40}], "illustration": "dungeon-corridors" }, + "40": { "title": "Finding Passage", "content": "Behind a loose tapestry depicting the Master's grim visage, you find a hidden spiral staircase leading up, likely towards the main fortress levels above the dungeons.
", "options": [{ "text": "Take the stairs", "next": 21 }], "illustration": "fortress-interior" }, + "41": { "title": "Disrupting the Ritual", "content": "You burst into the chamber! The mages are startled, their chant faltering. You launch an attack, disrupting their concentration entirely. The central crystal flares erratically, and raw magic arcs through the room.
", "options": [{ "text": "Fight the enraged mages!", "next": 22 }], "illustration": "ritual-chamber" }, + "42": { "title": "Observing the Ritual", "content": "You watch intently as the mages chant in unison. The crystal seems to be drawing power from ley lines deep within the fortress, focusing it towards the tower's peak for the Master's final empowerment during the alignment.
", "options": [{ "text": "Try to disrupt it now", "next": 41 }, {"text": "Try to steal the crystal (very risky)", "next": 43}, {"text": "Leave and head to the tower", "next": 25}], "statIncrease": {"stat": "wisdom", "amount": 1}, "illustration": "ritual-chamber" }, + "43": { "title": "Stealing the Crystal", "content": "As the mages are deep in their chant, you attempt to swiftly snatch the pulsing crystal. It burns with raw, cold energy! They immediately sense the disturbance and react with fury, turning to attack you.
", "options": [{ "text": "Fight back!", "next": 22 }], "illustration": "ritual-chamber" }, + "44": { "title": "Escape Attempt", "content": "You scan your surroundings, looking for any weakness, any chance. But the guards are professionals, their grip like iron, their eyes vigilant. No escape seems possible right now.
", "options": [{ "text": "Focus and prepare mentally", "next": 45 }, {"text": "Try to glean info from guards", "next": 46}], "illustration": "prisoner-escort" }, + "45": { "title": "Mental Preparation", "content": "You close your eyes briefly, focusing your mind. You recall your training, your purpose, the faces of those suffering under the Master's rule. You are ready. Let him come.
", "options": [{ "text": "Continue to the Master's chamber", "next": 48 }], "statIncrease": {"stat": "courage", "amount": 1}, "illustration": "final-confrontation" }, + "46": { "title": "Gathering Information", "content": "You try to subtly listen to the guards' chatter. They mutter about the Master being 'nearly ready' and the 'alignment is minutes away'. One nervously mentions the crystal is 'unstable' at peak power. Time is critically short.
", "options": [{ "text": "Focus and prepare mentally", "next": 45 }, {"text": "Look desperately for escape again", "next": 44}], "statIncrease": {"stat": "wisdom", "amount": 1}, "illustration": "prisoner-escort" }, + "47": { "title": "Leading the Charge", "content": "With a battle cry, you lead the resistance fighters forward, cutting through the surprised ranks of the Master's personal guard. Steel clashes against steel as you push relentlessly towards the main tower entrance.
", "options": [{ "text": "Breach the tower door", "next": 25 }], "illustration": "fortress-uprising" }, + "48": { # Final Confrontation - ensure this exists and leads to battle/crystal options + "title": "The Final Confrontation", + "content": """At last, you stand before the Evil Power Master in his chamber at the top of the central tower. Dark energy crackles around him as he turns to face you, his eyes gleaming with malice.
+"So, you're the one who's caused so much trouble," he says, his voice echoing with unnatural power. "I must admit, I'm impressed you made it this far. But your journey ends here."
+The dark crystal hovers behind him, pulsing with energy. This is the moment all your choices have led to.
""", + "options": [ + { "text": "Attack the Evil Power Master directly", "next": 56 }, + { "text": "Try to destroy the crystal", "next": 57 }, + { "text": "Attempt to reason with him", "next": 58 } + ], + "illustration": "final-confrontation" + }, + "49": { "title": "Sneaking Ahead", "content": "While the main uprising creates chaos as a diversion, you slip through the shadows, bypassing the main battle. You find a less-guarded servant's entrance to the central tower.
", "options": [{ "text": "Enter the tower stealthily", "next": 50 }], "illustration": "secret-passage" }, + "50": { "title": "Cautious Entry", "content": "You ease open the hidden door and step into the base of the central tower. A grand staircase spirals upwards into oppressive darkness. The very air hums with palpable dark energy.
", "options": [{ "text": "Ascend the tower carefully", "next": 48 }], "illustration": "final-confrontation" }, + "51": { "title": "Ritual Information", "content": "Your resistance guide explains the Master is performing a ritual tied to a rare cosmic alignment to achieve immense power, possibly immortality. The dark crystal in his chamber is the focal point.
", "options": [{ "text": "Enter the tower now", "next": 50 }, {"text": "Ask for additional backup", "next": 52}], "illustration": "secret-passage" }, + "52": { "title": "Requesting Help", "content": "The resistance leader nods grimly. 'Take Kaelen,' she says, gesturing to a scarred warrior armed with a blessed axe. 'May their strength aid yours.' Kaelen gives a curt nod.
", "options": [{ "text": "Accept Kaelen's help and enter", "next": 48 }], "addItem": "Resistance Ally", "illustration": "secret-passage" }, + "53": { "title": "Crystal Location", "content": "The resistance sage confirms the crystal is kept in the Master's main audience chamber, at the very top of the central tower. It reputedly floats above his throne, radiating immense power.
", "options": [{ "text": "Prepare and head to the tower", "next": 48 }], "illustration": "knowledge-sharing" }, + "54": { "title": "Alignment Timing", "content": "'The alignment is upon us!' the sage gasps, pointing to strange lights in the sky visible even through the fortress windows. 'It may already be too late! You must hurry!'
", "options": [{ "text": "Race to the tower immediately!", "next": 48 }], "illustration": "knowledge-sharing" }, + "55": { "title": "Crystal Weakness", "content": "They mention ancient texts hinting that the crystal, forged in darkness, is vulnerable to sources of pure light or concentrated holy energy. Perhaps your Healing Light spell, if focused, or the Shield of Faith could disrupt it?
", "options": [{ "text": "Remember this and head to the tower", "next": 48 }], "illustration": "knowledge-sharing" }, + + "56": { + "title": "Direct Confrontation", + "content": """You charge at the Evil Power Master, drawing on all your courage and strength. He meets your attack with blasts of dark magic, the air between you crackling and distorting with raw energy.
+The battle is fierce, pushing you to your absolute limits. Each blow you land seems partially absorbed by the dark energy surrounding him, while his counter-attacks grow increasingly powerful and difficult to evade.
+As the fight rages, you realize that as long as the dark crystal pulses behind him, this might be an unwinnable war of attrition.
""", + "challenge": { + "title": "Battle with the Evil Power Master", + "description": "You must overcome his dark magic through sheer determination, skill, and perhaps exploiting a weakness.", + "stat": "strength", + "difficulty": 9, + "success": 59, + "failure": 60 + }, + "illustration": "power-battle" + }, + "57": { + "title": "Crystal Destruction", + "content": """Recognizing the crystal as the true source of his overwhelming power, you feint an attack and then lunge towards the malevolently pulsing gem floating above the throne. The Evil Power Master shouts in alarm and fury, desperately trying to intercept you.
+"No! Stay away from that, you insignificant fool! You have no conception of the forces you're tampering with!"
+As you get closer, the crystal's energy intensifies dramatically, throwing up a shimmering barrier of pure dark magic that you must break through to reach it.
""", + "challenge": { + "title": "Breaking the Crystal Barrier", + "description": "You must overcome the crystal's protective magic using wit, willpower, or perhaps a specific counter-energy.", + "stat": "wisdom", + "difficulty": 8, + "success": 61, + "failure": 62 + }, + "illustration": "crystal-barrier" + }, + "58": { + "title": "Attempt to Reason", + "content": """You hold up a hand, trying to speak to the Evil Power Master, appealing to any possible reason or shred of humanity that might remain within the darkness. He pauses, then throws back his head and laughs – a chilling, hollow sound.
+"Humanity? Reason? Such fleeting, petty concerns! Power is the only truth, the only reason! And soon, I shall have ultimate power!" he snarls, launching a devastating bolt of dark energy directly at you.
+Clearly, negotiation was never an option.
""", + "options": [ + { "text": "Attack the Evil Power Master directly", "next": 56 }, + { "text": "Try to destroy the crystal", "next": 57 } + ], + "illustration": "final-confrontation" + }, + "59": { + "title": "A Hero's Victory", + "content": """Through sheer determination, skill, and perhaps exploiting a momentary weakness, you manage to overcome the Evil Power Master's formidable defenses. As he staggers backwards from your decisive blow, his concentration wavers, and his connection to the crystal weakens for a critical instant.
+Seizing the opportunity, you strike the dark crystal with all your remaining might (or perhaps channel pure energy into it). It cracks visibly, then shatters in a blinding flash of light and concussive energy that throws you back.
+The Evil Power Master screams a final, agonized cry as his borrowed power dissipates like smoke. "Impossible! I was... so close... to ultimate power!"
+As the blinding light fades, you stand victorious amidst the crumbling chamber. The dark magic recedes from the land, and the people are free once more.
""", + "gameOver": True, + "ending": "You have defeated the Evil Power Master and destroyed the source of his terrible power. Songs will be sung of your bravery and skill for generations to come. The land slowly begins to heal from his corruption, and you are hailed as the Hero of Silverhold throughout the recovering realm.", + "illustration": "hero-victory" + }, + "60": { + "title": "Darkness Prevails", + "content": """Despite your bravery and best efforts, the Evil Power Master's command over dark magic, amplified by the crystal, is simply too great. His relentless attacks overwhelm your defenses, shattering your weapon or shield, and bringing you crashing to your knees.
+"Valiant, perhaps, but ultimately futile," he says, looking down at you with cold contempt. "You could have served me, you know. Gained power beyond your imagining. Now... you will simply serve as a warning." He raises a hand, dark energy coalescing.
+As your vision fades into darkness, you see the crystal's evil glow intensifying, the alignment reaching its peak. You have failed. Darkness will cover the land, and the Master's reign is absolute.
""", + "gameOver": True, + "ending": "The Evil Power Master proved too powerful, and your heroic quest ends in tragic defeat. Darkness spreads unchallenged across the land as he completes his ritual and ascends to even greater, terrifying power. Hope fades, but perhaps, someday, another hero will rise to challenge his eternal reign.", + "illustration": "dark-victory" + }, + "61": { + "title": "The Crystal Shatters", + "content": """Drawing on all your wisdom and inner willpower (or perhaps using a specific magical counter), you manage to push through the crystal's defensive barrier. Reaching out, you touch its vibrating surface, which burns with an unnatural cold against your skin.
+The Evil Power Master shrieks in mingled fury and desperation, "Stop! Stop, you fool! You'll doom us all!"
+With a final, concentrated effort, you channel your own life force or focused energy into the dark gem. Cracks spiderweb across its obsidian surface, spreading rapidly until it detonates with a deafening implosion of light and sound, sucking the dark energy from the room.
+When your vision clears, the Evil Power Master lies broken and powerless on the floor, his power utterly broken along with the crystal. The oppressive atmosphere lifts, and peace can finally begin to return to the land.
""", + "gameOver": True, + "ending": "By cleverly targeting and destroying the source of the Evil Power Master's augmented strength, you have saved the realm from his tyranny. The fortress itself begins to shake and crumble as its dark magic foundations unravel. You escape just in time, leaving the ruin behind. Your name becomes a legend associated with wisdom and decisive action.", + "illustration": "crystal-destroyed" + }, + "62": { + "title": "A Desperate Gambit", + "content": """The crystal's protective barrier proves too strong, violently repelling your attempts to break through. As you struggle against its crushing force, the Evil Power Master regains his composure and approaches, a cruel smile playing on his lips.
+"Did you truly think it would be that easy?" he mocks, preparing a final, devastating spell. "This crystal has endured for millennia. It cannot be destroyed by a pathetic mortal like you."
+Seeing no other option, in a final, desperate move, you gather all your remaining strength and hurl your most powerful weapon or focus your strongest spell directly at the unstable crystal.
+To your surprise and the Evil Power Master's horror, this doesn't break the barrier but instead creates a catastrophic resonance effect within the overloaded gem. The crystal begins to vibrate violently, its contained energy spiraling wildly out of control.
+"What have you done?!" the Master cries in terror as the crystal's energy erupts outwards, engulfing both of you, the chamber, and the entire tower top in blinding, destructive light.
""", + "gameOver": True, + "ending": "Your desperate, final attack destabilized the dark crystal, causing a catastrophic release of uncontrolled energy that utterly annihilated the Evil Power Master, his chamber, and tragically, yourself. Though you did not survive, your ultimate sacrifice shattered his power and saved the realm from imminent darkness. Bards will forever sing of your selfless heroism.", + "illustration": "heroic-sacrifice" + } +} + +# --- Item Data --- +items_data = { + "Flaming Sword": {"type": "weapon", "description": "A sword wreathed in magical fire. Looks dangerous to friend and foe. +3 Attack.", "attackBonus": 3}, + "Whispering Bow": {"type": "weapon", "description": "A finely crafted bow enchanted for silence. Favored by assassins. +2 Attack.", "attackBonus": 2}, + "Guardian Shield": {"type": "armor", "description": "A sturdy shield blessed with protective magic. Glows faintly. +2 Defense.", "defenseBonus": 2}, + "Healing Light Spell": {"type": "spell", "description": "A basic clerical spell that can mend minor wounds."}, + "Shield of Faith Spell": {"type": "spell", "description": "A protective spell that creates a temporary shimmering barrier."}, + "Binding Runes Scroll": {"type": "spell", "description": "A scroll containing complex runes to temporarily immobilize an enemy."}, + "Secret Tunnel Map": {"type": "quest", "description": "A crudely drawn map marking a hidden tunnel entrance near the fortress's north wall."}, + "Poison Daggers": {"type": "weapon", "description": "A pair of wicked-looking daggers coated with a fast-acting paralytic poison. +1 Attack.", "attackBonus": 1}, + "Master Key": {"type": "quest", "description": "A heavy iron key with intricate wards. Said to unlock any non-magical lock."}, + "Water Spirit's Blessing": {"type": "spell", "description": "A lingering blessing from the river spirit, enhancing clarity and insight."}, + "Ancient Amulet": {"type": "quest", "description": "A heavy stone amulet radiating ancient protective magic. Seems to resist dark energy. +1 Defense.", "defenseBonus": 1}, + "Guard Disguise": {"type": "quest", "description": "A slightly ill-fitting uniform worn by the fortress guards."}, + "Healing Potion": {"type": "consumable", "description": "A vial containing a sparkling red liquid. Restores 10 HP.", "hpRestore": 10, "useOnAdd": True}, + "Resistance Ally": {"type": "quest", "description": "Kaelen, a grim resistance fighter armed with a blessed axe, fights alongside you."}, +} + +# --- Enemy Data --- +enemies_data = { + "Scout": {"hp": 15, "attack": 4, "defense": 1}, + "Dark Mage": {"hp": 20, "attack": 6, "defense": 2}, + "Fortress Guard": {"hp": 25, "attack": 5, "defense": 3}, + "Shadow Hound": {"hp": 18, "attack": 5, "defense": 2}, + "Animated Armor": {"hp": 30, "attack": 4, "defense": 4}, +} +