adding player profiles
All checks were successful
Build Images and Deploy / Update-PROD-Stack (push) Successful in 28s

This commit is contained in:
2026-02-28 00:51:43 -05:00
parent 30f0c98102
commit 79ee7064a8
11 changed files with 256 additions and 31 deletions

View File

@@ -1,6 +1,6 @@
const express = require('express');
const router = express.Router();
const { Hunts, Packages, Scans } = require('../models');
const { Hunts, Packages, Scans, Users } = require('../models');
// ─── Hunt profile ─────────────────────────────────────────
router.get('/hunt/:shortName', (req, res) => {
@@ -59,6 +59,29 @@ router.get('/hunt/:shortName/:cardNumber', (req, res) => {
});
});
// ─── User profile ─────────────────────────────────────────
router.get('/player/:username', (req, res) => {
const user = Users.findByUsername(req.params.username);
if (!user) {
return res.status(404).render('error', { title: 'Not Found', message: 'Player not found.' });
}
const profile = Users.getProfile(user.id);
const recentScans = Users.getRecentScans(user.id);
const huntBreakdown = Users.getHuntBreakdown(user.id);
const rank = Users.getRank(user.id);
const totalPlayers = Users.getTotalPlayerCount();
res.render('player/profile', {
title: `${user.username}'s Profile`,
profile,
recentScans,
huntBreakdown,
rank,
totalPlayers
});
});
// ─── Browse all hunts ─────────────────────────────────────
router.get('/hunts', (req, res) => {
const hunts = Hunts.getAll();