This commit is contained in:
Joan
2026-02-23 15:42:21 +01:00
parent a725ae5836
commit d38d4cc288
102 changed files with 4511 additions and 4454 deletions

View File

@@ -88,6 +88,26 @@ async def lifespan(app: FastAPI):
print(f"✅ Started {len(tasks)} background tasks in this worker")
else:
print("⏭️ Background tasks running in another worker")
# APPLY GLOBAL QUEST UNLOCKS
print("🔓 Applying global quest unlocks...")
try:
completed_quests = await db.get_completed_global_quests()
print(f" - Found {len(completed_quests)} completed global quests")
for quest_id in completed_quests:
# Unlock locations
for loc in LOCATIONS.values():
if loc.unlocked_by == quest_id:
loc.locked = False
print(f" - Unlocked location: {loc.id}")
# Unlock interactables
for inter in loc.interactables:
if inter.unlocked_by == quest_id:
inter.locked = False
print(f" - Unlocked interactable: {inter.id} in {loc.id}")
except Exception as e:
print(f"❌ Failed to apply global quest unlocks: {e}")
yield
@@ -150,6 +170,16 @@ try:
NPCS_DATA = n_data.get("static_npcs", {})
print(f"✅ Loaded {len(NPCS_DATA)} static NPCs")
# Load Enemies / Other NPCs
enemies_path = Path("./gamedata/npcs.json")
if enemies_path.exists():
with open(enemies_path, "r") as f:
e_data = json.load(f)
enemies = e_data.get("npcs", {})
# Merge into NPCS_DATA
NPCS_DATA.update(enemies)
print(f"✅ Loaded {len(enemies)} enemies/NPCs")
except Exception as e:
print(f"❌ Error loading game data: {e}")
@@ -161,7 +191,7 @@ crafting.init_router_dependencies(LOCATIONS, ITEMS_MANAGER, WORLD)
loot.init_router_dependencies(LOCATIONS, ITEMS_MANAGER, WORLD)
statistics.init_router_dependencies(LOCATIONS, ITEMS_MANAGER, WORLD)
admin.init_router_dependencies(LOCATIONS, ITEMS_MANAGER, WORLD, IMAGES_DIR)
quests.init_router_dependencies(ITEMS_MANAGER, QUESTS_DATA, NPCS_DATA)
quests.init_router_dependencies(ITEMS_MANAGER, QUESTS_DATA, NPCS_DATA, LOCATIONS)
trade.init_router_dependencies(ITEMS_MANAGER, NPCS_DATA)
npcs.init_router_dependencies()