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

@@ -2662,3 +2662,273 @@
background: #ef4444;
color: white;
}
/* ===== QUEST OFFER CARD ===== */
/* Inline card that appears in NPC chat when quest is offered */
.quest-offer-card {
background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(59, 130, 246, 0.1));
border: 2px solid var(--action-premium);
border-radius: 8px;
margin-top: 1rem;
padding: 1rem;
animation: questCardAppear 0.4s ease;
}
@keyframes questCardAppear {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.quest-offer-header {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 0.75rem;
padding-bottom: 0.5rem;
border-bottom: 1px solid rgba(139, 92, 246, 0.3);
}
.quest-offer-icon {
font-size: 1.25rem;
}
.quest-offer-label {
font-size: var(--text-xs);
text-transform: uppercase;
letter-spacing: 1px;
color: var(--action-premium);
font-weight: 600;
}
.quest-offer-content {
margin-bottom: 1rem;
}
.quest-offer-title {
font-family: var(--font-heading);
font-size: var(--text-lg);
color: var(--accent-gold);
margin: 0 0 0.5rem 0;
}
.quest-offer-description {
font-size: var(--text-sm);
color: var(--text-secondary);
margin: 0 0 0.75rem 0;
line-height: 1.5;
}
.quest-offer-rewards {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
align-items: center;
}
.rewards-label {
font-size: var(--text-xs);
color: var(--text-muted);
text-transform: uppercase;
}
.reward-item {
font-size: var(--text-sm);
padding: 0.25rem 0.5rem;
border-radius: 4px;
background: rgba(0, 0, 0, 0.3);
}
.reward-gold {
color: var(--accent-gold);
}
.reward-xp {
color: #10b981;
}
.quest-offer-actions {
display: flex;
gap: 0.75rem;
}
.quest-btn {
flex: 1;
padding: 0.625rem 1rem;
font-size: var(--text-sm);
font-weight: 600;
border: none;
border-radius: 6px;
cursor: pointer;
transition: all 0.2s ease;
}
.quest-btn--accept {
background: #10b981;
color: white;
}
.quest-btn--accept:hover {
background: #059669;
transform: translateY(-1px);
}
.quest-btn--decline {
background: rgba(255, 255, 255, 0.1);
color: var(--text-secondary);
border: 1px solid var(--play-border);
}
.quest-btn--decline:hover {
background: rgba(255, 255, 255, 0.15);
color: var(--text-primary);
}
/* Quest action result (replaces card after action) */
.quest-action-result {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem 1rem;
border-radius: 6px;
margin-top: 1rem;
animation: questCardAppear 0.3s ease;
}
.quest-action-result--accept {
background: rgba(16, 185, 129, 0.15);
border: 1px solid #10b981;
}
.quest-action-result--decline {
background: rgba(107, 114, 128, 0.15);
border: 1px solid var(--play-border);
}
.quest-action-result--error {
background: rgba(239, 68, 68, 0.15);
border: 1px solid #ef4444;
}
.quest-action-icon {
font-size: 1.5rem;
}
.quest-action-message {
flex: 1;
}
.quest-action-message strong {
display: block;
color: var(--text-primary);
margin-bottom: 0.25rem;
}
.quest-action-message p {
margin: 0;
font-size: var(--text-sm);
color: var(--text-secondary);
}
/* ===== TOAST NOTIFICATIONS ===== */
/* Fixed position notifications for quick feedback */
.toast-container {
position: fixed;
top: 1rem;
right: 1rem;
z-index: 9999;
display: flex;
flex-direction: column;
gap: 0.5rem;
max-width: 350px;
pointer-events: none;
}
.toast {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.75rem 1rem;
border-radius: 6px;
font-size: var(--text-sm);
box-shadow: var(--shadow-lg);
opacity: 0;
transform: translateX(100%);
transition: all 0.3s ease;
pointer-events: auto;
}
.toast--visible {
opacity: 1;
transform: translateX(0);
}
.toast--dismissing {
opacity: 0;
transform: translateX(100%);
}
.toast--success {
background: rgba(16, 185, 129, 0.95);
color: white;
}
.toast--error {
background: rgba(239, 68, 68, 0.95);
color: white;
}
.toast--info {
background: rgba(59, 130, 246, 0.95);
color: white;
}
.toast-message {
flex: 1;
margin-right: 0.5rem;
}
.toast-close {
background: none;
border: none;
color: rgba(255, 255, 255, 0.8);
font-size: 1.25rem;
cursor: pointer;
padding: 0;
line-height: 1;
transition: color 0.2s ease;
}
.toast-close:hover {
color: white;
}
/* Mobile responsiveness for quest card */
@media (max-width: 768px) {
.quest-offer-card {
margin-top: 0.75rem;
padding: 0.75rem;
}
.quest-offer-actions {
flex-direction: column;
}
.quest-btn {
width: 100%;
}
.toast-container {
left: 1rem;
right: 1rem;
max-width: none;
}
}

View File

@@ -0,0 +1,82 @@
/**
* Toast Notification System
* Provides temporary notifications for game events (quest acceptance, errors, etc.)
*
* Usage:
* showToast('Quest accepted!', 'success');
* showToast('Failed to save', 'error');
* showToast('Item added to inventory', 'info');
*/
/**
* Show a toast notification
* @param {string} message - The message to display
* @param {string} type - Type of toast: 'success', 'error', or 'info'
* @param {number} duration - Duration in ms before auto-dismiss (default: 4000)
*/
function showToast(message, type = 'info', duration = 4000) {
// Create toast container if it doesn't exist
let container = document.getElementById('toast-container');
if (!container) {
container = document.createElement('div');
container.id = 'toast-container';
container.className = 'toast-container';
document.body.appendChild(container);
}
// Create toast element
const toast = document.createElement('div');
toast.className = `toast toast--${type}`;
toast.innerHTML = `
<span class="toast-message">${escapeHtml(message)}</span>
<button class="toast-close" onclick="dismissToast(this.parentElement)" aria-label="Close">&times;</button>
`;
// Add to container
container.appendChild(toast);
// Trigger animation (small delay for DOM to register element)
requestAnimationFrame(() => {
toast.classList.add('toast--visible');
});
// Auto-remove after duration
setTimeout(() => {
dismissToast(toast);
}, duration);
}
/**
* Dismiss a toast notification with animation
* @param {HTMLElement} toast - The toast element to dismiss
*/
function dismissToast(toast) {
if (!toast || toast.classList.contains('toast--dismissing')) {
return;
}
toast.classList.add('toast--dismissing');
toast.classList.remove('toast--visible');
// Remove from DOM after animation completes
setTimeout(() => {
if (toast.parentElement) {
toast.remove();
}
}, 300);
}
/**
* Escape HTML to prevent XSS
* @param {string} text - Text to escape
* @returns {string} Escaped text
*/
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
// Make functions globally available
window.showToast = showToast;
window.dismissToast = dismissToast;