fixes to make quest tracking work better, also quest rejection in via the converation with the NPC

This commit is contained in:
2025-11-29 17:51:53 -06:00
parent df26abd207
commit 72cf92021e
11 changed files with 885 additions and 22 deletions

View File

@@ -9,6 +9,8 @@ Expected context:
- player_line: What the player just said
- dialogue: NPC's current response
- session_id: For any follow-up actions
- quest_offer: Optional quest offer data {quest_id, quest_name, quest_description, rewards, npc_id}
- npc_id: NPC identifier for quest accept/decline
#}
{# Only show CURRENT exchange (removed conversation_history loop) #}
@@ -23,6 +25,50 @@ Expected context:
</div>
</div>
{# Quest Offer Card - appears inline after NPC dialogue when quest is offered #}
{% if quest_offer %}
<div class="quest-offer-card" id="quest-offer-{{ quest_offer.quest_id }}">
<div class="quest-offer-header">
<span class="quest-offer-icon">&#128220;</span>
<span class="quest-offer-label">Quest Offered</span>
</div>
<div class="quest-offer-content">
<h4 class="quest-offer-title">{{ quest_offer.quest_name }}</h4>
<p class="quest-offer-description">{{ quest_offer.quest_description }}</p>
{% if quest_offer.rewards %}
<div class="quest-offer-rewards">
<span class="rewards-label">Rewards:</span>
{% if quest_offer.rewards.gold %}
<span class="reward-item reward-gold">{{ quest_offer.rewards.gold }} gold</span>
{% endif %}
{% if quest_offer.rewards.experience %}
<span class="reward-item reward-xp">{{ quest_offer.rewards.experience }} XP</span>
{% endif %}
</div>
{% endif %}
</div>
<div class="quest-offer-actions">
<button class="quest-btn quest-btn--accept"
hx-post="{{ url_for('game.accept_quest', session_id=session_id) }}"
hx-vals='{"quest_id": "{{ quest_offer.quest_id }}", "npc_id": "{{ quest_offer.npc_id }}", "npc_name": "{{ npc_name }}"}'
hx-target="#quest-offer-{{ quest_offer.quest_id }}"
hx-swap="outerHTML">
Accept Quest
</button>
<button class="quest-btn quest-btn--decline"
hx-post="{{ url_for('game.decline_quest', session_id=session_id) }}"
hx-vals='{"quest_id": "{{ quest_offer.quest_id }}", "npc_id": "{{ quest_offer.npc_id }}", "npc_name": "{{ npc_name }}"}'
hx-target="#quest-offer-{{ quest_offer.quest_id }}"
hx-swap="outerHTML">
Decline
</button>
</div>
</div>
{% endif %}
{# Trigger history refresh after new message #}
<div hx-trigger="load"
_="on load trigger newMessage on body"

View File

@@ -0,0 +1,64 @@
{#
Quest Action Response - Replaces quest offer card after accept/decline.
Shows confirmation message and triggers toast notification + sidebar refresh.
Expected context:
- action: 'accept', 'decline', or 'error'
- quest_name: Name of the quest (for accept message)
- npc_name: Name of the NPC offering the quest
- error_message: Error details (for error action)
- session_id: For sidebar refresh
#}
{% if action == 'error' %}
{# Error state - display error message #}
<div class="quest-action-result quest-action-result--error">
<div class="quest-action-icon">&#9888;</div>
<div class="quest-action-message">
<strong>Error</strong>
<p>{{ error_message | default('Something went wrong') }}</p>
</div>
</div>
{% elif action == 'accept' %}
{# Quest accepted - show success message #}
<div class="quest-action-result quest-action-result--accept">
<div class="quest-action-icon">&#10004;</div>
<div class="quest-action-message">
<strong>Quest Accepted!</strong>
<p>{{ npc_name }} nods approvingly. Check your quest log for details.</p>
</div>
</div>
{# Trigger toast notification #}
<script>
if (typeof showToast === 'function') {
showToast('Quest "{{ quest_name }}" accepted!', 'success');
}
</script>
{# Refresh quests accordion to show newly accepted quest #}
<div hx-get="{{ url_for('game.quests_accordion', session_id=session_id) }}"
hx-trigger="load"
hx-target="#accordion-quests"
hx-swap="innerHTML"
style="display: none;"></div>
{% elif action == 'decline' %}
{# Quest declined - show confirmation message #}
<div class="quest-action-result quest-action-result--decline">
<div class="quest-action-icon">&#10006;</div>
<div class="quest-action-message">
<strong>Quest Declined</strong>
<p>{{ npc_name }} understands. Perhaps another time.</p>
</div>
</div>
{# Trigger toast notification #}
<script>
if (typeof showToast === 'function') {
showToast('Quest declined', 'info');
}
</script>
{% endif %}