Session 42: Player Intelligence System — archetypes, stat strips, player profile, enhanced cards (2011 tests)
Built from the Claude Design "VYNDR Player Intelligence" bundle (10 sections). - Archetypes: src/services/archetypeService.js — 41 archetypes (15 NBA / 5 WNBA-unique / 15 MLB / 6 soccer), classify -> primary+secondary+blend. Frontend visual map web/src/lib/archetypes.js (colors verified == backend). ArchetypeBadge (full/ghost/tint + glyphs) + ArchetypeBlend (DNA bar). - StatStrip (compact/expanded): player name once, horizontal mono stats, inline GradeBadge props, onPlayerClick -> profile. - Stats API: extended src/routes/stats.js with /player/:name, /leaders, /game/:id (rate-limited). Aggregation in playerIntelService.js (sanitizes name param; grades cache; graceful on cold cache). Next proxies added. - Player Profile /player/[name]: all 9 design sections, graceful empty states. - Enhanced GameCard (MLB pitchers + player-grouped StatStrips) + GradeResultCard (archetype strip + stat context + VYNDR intelligence, optional/self-hiding via gradeAdapter.buildIntelFields). Player-name links wired everywhere. - Settings page replaces the S41 redirect (account/subscription/notifications/ display/responsible-play/danger-zone with DELETE-gated delete). LINKS to the real /settings/security MFA page — does not replace it. + BookChip. - Bonus: Stats Explorer /explore (real /api/stats/leaders leaderboard); added Explore + Settings to Nav MORE. Deferred (need data pipelines, Session 43): Team Hub, Offseason Intel, Slate redesign, Stats Explorer sub-panels. Backend 1940 -> 2011 tests (+71), 157 suites. Web build clean (exit 0). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
// Session 42 — Phase 4: grade-adapter intel fields + enhanced game card.
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const WEB = path.join(__dirname, '..', '..', 'web', 'src');
|
||||
const read = (rel) => fs.readFileSync(path.join(WEB, rel), 'utf8');
|
||||
const { mapScanToGradeResult, buildIntelFields } = require('../../web/src/lib/gradeAdapter');
|
||||
|
||||
describe('gradeAdapter — Player Intelligence fields', () => {
|
||||
it('omits all new sections when the engine supplies nothing (self-hide)', () => {
|
||||
const r = mapScanToGradeResult({ player: 'X', stat: 'points', line: 26.5, grade: 'A' });
|
||||
expect(r.archetypeBlend).toBeUndefined();
|
||||
expect(r.statContext).toBeUndefined();
|
||||
expect(r.vyndrIntel).toBeUndefined();
|
||||
expect(r.propDNA).toBeUndefined();
|
||||
});
|
||||
|
||||
it('lifts a single archetype name into a one-segment blend', () => {
|
||||
const f = buildIntelFields({ archetype: 'VOLUME SCORER' });
|
||||
expect(f.archetypeBlend).toEqual([{ archetype: 'VOLUME SCORER', weight: 1 }]);
|
||||
});
|
||||
|
||||
it('passes through a full blend + propDNA + statContext + vyndrIntel', () => {
|
||||
const r = mapScanToGradeResult({
|
||||
player: 'Wemby', stat: 'points', line: 26.5, grade: 'A',
|
||||
archetype_blend: [{ archetype: 'TWO-WAY ANCHOR', weight: 0.6 }, { archetype: 'STRETCH BIG', weight: 0.4 }],
|
||||
prop_dna: { reliable: ['points'], volatile: ['rebounds'] },
|
||||
season_avg: 26.9, last10_avg: 28.4, vs_opp_avg: 30.1,
|
||||
form: 92, usage: '31.2%', matchup_grade: 'A', rest: '+2.4%',
|
||||
});
|
||||
expect(r.archetypeBlend).toHaveLength(2);
|
||||
expect(r.propDNA.reliable).toContain('points');
|
||||
expect(r.statContext).toEqual({ season: '26.9', last10: '28.4', vsOpp: '30.1' });
|
||||
expect(r.vyndrIntel).toEqual({ form: 92, usage: '31.2%', matchup: 'A', rest: '+2.4%' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('GradeResultCard — new sections', () => {
|
||||
const src = read('components/vyndr/GradeResultCard.tsx');
|
||||
it('renders the archetype strip + STAT CONTEXT + VYNDR INTELLIGENCE', () => {
|
||||
expect(src).toContain('ARCHETYPE STRIP');
|
||||
expect(src).toContain('STAT CONTEXT');
|
||||
expect(src).toContain('VYNDR INTELLIGENCE');
|
||||
expect(src).toContain('ArchetypeBlend');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Enhanced GameCard (Session 42)', () => {
|
||||
const src = read('components/vyndr/GameCard.tsx');
|
||||
it('renders MLB starting pitchers when provided', () => {
|
||||
expect(src).toContain('g.pitchers');
|
||||
expect(src).toContain('STARTING');
|
||||
expect(src).toContain('ERA');
|
||||
});
|
||||
it('prefers the player-grouped StatStrip (name once) over per-prop rows', () => {
|
||||
expect(src).toContain('g.playerStrips');
|
||||
expect(src).toContain('StatStrip');
|
||||
expect(src).toContain('variant="compact"');
|
||||
});
|
||||
it('links player names to their profile', () => {
|
||||
expect(src).toContain('playerHref');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user