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

@@ -464,9 +464,12 @@ async def combat_action(
new_progress[obj['target']] = current_count + 1
progres_changed = True
if progres_changed:
# Check completion
all_done = True
progress_str = ""
for obj in objectives:
target = obj['target']
req_count = obj['count']
@@ -476,8 +479,10 @@ async def combat_action(
if obj['type'] == 'kill_count':
if curr < req_count:
all_done = False
# Capture progress string for the notification (if this was the target updated)
if target == combat['npc_id']:
progress_str = f" ({curr}/{req_count})"
elif obj['type'] == 'item_delivery':
# For mixed quests, we can't complete purely on kills.
pass
await db.update_quest_progress(player['id'], q_record['quest_id'], new_progress, 'active')
@@ -486,7 +491,7 @@ async def combat_action(
messages.append(create_combat_message(
"quest_update",
origin="system",
message=f"Quest updated: {get_locale_string(q_def['title'], locale)}"
message=f"{get_locale_string(q_def['title'], locale)}{progress_str}"
))
quest_updated = True
@@ -501,62 +506,6 @@ async def combat_action(
except Exception as e:
logger.error(f"Failed to update quest progress: {e}")
# -----------------------------
for q_record in active_quests:
if q_record['status'] != 'active':
continue
q_def = all_quests_def.get(q_record['quest_id'])
if not q_def: continue
objectives = q_def.get('objectives', [])
current_progress = q_record.get('progress') or {}
new_progress = current_progress.copy()
progres_changed = False
for obj in objectives:
if obj['type'] == 'kill_count' and obj['target'] == combat['npc_id']:
current_count = current_progress.get(obj['target'], 0)
if current_count < obj['count']:
new_progress[obj['target']] = current_count + 1
progres_changed = True
if progres_changed:
# Check completion
all_done = True
for obj in objectives:
target = obj['target']
req_count = obj['count']
curr = new_progress.get(target, 0)
# Simple check for now (ignoring items for kill quests)
if obj['type'] == 'kill_count':
if curr < req_count:
all_done = False
elif obj['type'] == 'item_delivery':
# Items are checked at hand-in usually
# But we need to know if we should mark as completed "ready to turn in" or just "objectives met"
# For mixed quests, we can't complete purely on kills.
# Let's just update progress.
pass
# We generally don't auto-complete quests, user has to hand in.
# But we can update the progress in DB.
new_status = 'active'
# If we wanted to support auto-complete, we'd do it here. Use 'active'.
await db.update_quest_progress(player['id'], q_record['quest_id'], new_progress, new_status)
# Notify user
messages.append(create_combat_message(
"quest_update",
origin="system",
message=f"Quest updated: {get_locale_string(q_def['title'], locale)}"
))
quest_updated = True
except Exception as e:
logger.error(f"Failed to update quest progress: {e}")
# -----------------------------