mirror of
http://forgejo-oa09toasww4dgii9cj3gpzda.187.127.164.61.sslip.io/iamcoolvivek007/bharath.git
synced 2026-06-11 00:06:51 +00:00
- Multi-language support (English, Hindi, Tamil, Telugu) with icon-based UI - Voice input (Web Speech API) for low-literacy users - Driver tools: Ledger, Trip Planner, Return Load, Safety, Maintenance, FASTag - Marketplace: WhatsApp share, Rate Intelligence, Classifieds, Fleet - Engagement: Gamification (XP/Levels), Challenges, Leaderboard, Referrals, Feed - Business: Invoice (GST+UPI), Reports+CSV, Notifications, Documents, Bank - Games: Rate Guesser, Route Quiz - SEO: Sitemap, public load share pages with OG tags - India utilities: vehicle validation, UPI links, toll/fuel calculator - 29 routes, 54 templates, 4 languages, 3 migration files
46 lines
2.7 KiB
JavaScript
46 lines
2.7 KiB
JavaScript
// Gamification Engine: XP, Levels, Achievements, Badges, Streaks
|
|
|
|
const XP_REWARDS = {
|
|
signup: 50, add_phone: 30, select_role: 25, add_vehicle: 40, complete_onboarding: 100,
|
|
first_login_today: 10, post_load: 30, place_bid: 20, win_bid: 50, complete_trip: 40,
|
|
add_ledger_entry: 15, settle_payment: 25, share_load_whatsapp: 15,
|
|
invite_friend: 40, friend_joined: 60, receive_rating: 20, give_rating: 10,
|
|
safety_checkin: 5, log_toll: 5, add_reminder: 10,
|
|
first_load_posted: 75, first_bid_placed: 75, first_bid_won: 100, first_trip_completed: 100,
|
|
login_streak_3: 50, login_streak_7: 150, login_streak_30: 500,
|
|
};
|
|
|
|
const LEVELS = [
|
|
{ level: 1, xp: 0, title: 'Beginner', title_hi: 'शुरुआत', icon: '🌱' },
|
|
{ level: 2, xp: 100, title: 'Starter', title_hi: 'नया', icon: '🌿' },
|
|
{ level: 3, xp: 300, title: 'Active', title_hi: 'सक्रिय', icon: '🌳' },
|
|
{ level: 4, xp: 600, title: 'Regular', title_hi: 'नियमित', icon: '⭐' },
|
|
{ level: 5, xp: 1000, title: 'Pro', title_hi: 'प्रो', icon: '🌟' },
|
|
{ level: 6, xp: 1500, title: 'Expert', title_hi: 'विशेषज्ञ', icon: '💫' },
|
|
{ level: 7, xp: 2500, title: 'Master', title_hi: 'मास्टर', icon: '🏆' },
|
|
{ level: 8, xp: 4000, title: 'Legend', title_hi: 'लीजेंड', icon: '👑' },
|
|
];
|
|
|
|
const ACHIEVEMENTS = [
|
|
{ id: 'first_load', title: 'First Load', icon: '📦', xp: 75, condition: 'post_load >= 1' },
|
|
{ id: 'first_bid', title: 'First Bid', icon: '🏷️', xp: 75, condition: 'place_bid >= 1' },
|
|
{ id: 'first_trip', title: 'First Trip', icon: '🚛', xp: 100, condition: 'complete_trip >= 1' },
|
|
{ id: 'five_trips', title: '5 Trips', icon: '🎯', xp: 150, condition: 'complete_trip >= 5' },
|
|
{ id: 'ten_trips', title: '10 Trips', icon: '🔥', xp: 250, condition: 'complete_trip >= 10' },
|
|
{ id: 'social_butterfly', title: 'Social', icon: '🦋', xp: 100, condition: 'share_load_whatsapp >= 5' },
|
|
{ id: 'safe_driver', title: 'Safe Driver', icon: '🛡️', xp: 100, condition: 'safety_checkin >= 7' },
|
|
{ id: 'streak_week', title: '7 Day Streak', icon: '🔥', xp: 150, condition: 'login_streak >= 7' },
|
|
{ id: 'referrer', title: 'Referrer', icon: '🤝', xp: 200, condition: 'invite_friend >= 3' },
|
|
];
|
|
|
|
function getLevelForXP(xp) {
|
|
let current = LEVELS[0];
|
|
for (const l of LEVELS) { if (xp >= l.xp) current = l; else break; }
|
|
const next = LEVELS[current.level] || null;
|
|
const progress = next ? Math.round(((xp - current.xp) / (next.xp - current.xp)) * 100) : 100;
|
|
return { ...current, xp_current: xp, xp_next: next ? next.xp : current.xp, progress };
|
|
}
|
|
|
|
function getXPReward(action) { return XP_REWARDS[action] || 0; }
|
|
|
|
module.exports = { XP_REWARDS, LEVELS, ACHIEVEMENTS, getLevelForXP, getXPReward };
|