feat: major cleanup + death alerts + idle detection + Discord webhooks
Cleanup: - Removed 109 stale asset files from static/assets/ (was 122, now 13) - Removed static/v2/ entirely (was duplicate of root assets) - Removed dead dashboard code: DashboardView, Layout, GlobalStats, CharacterCard, CharacterGrid, VitalBar, TabContainer, CombatTab, RaresTab, MapTab, InventoryTab, global.css, MapTransformContext - Removed recharts dependency (425KB chunk eliminated) - CSS reduced from 17KB to 10KB - Added deploy-frontend.sh script for one-command build+deploy - Updated CLAUDE.md with combat_stats, share_*, dungeon_map events and React frontend architecture Death alerts (frontend + backend): - Frontend: DeathNotification component with red banner + sawtooth sound when vitae goes from 0 to >0 - Backend: detects vitae transition in vitals handler, sends Discord webhook to #aclog with "☠️ CHARACTER died! (vitae: X%)" - Rate-limited: max 1 Discord alert per character per 5 minutes Idle detection (backend): - Background task runs every 60 seconds - Detects: vt_state "default"/"idle" OR kph=0 while in combat/hunt - Sends Discord webhook: "⚠️ CHARACTER appears idle (state: X, KPH: 0)" - Auto-clears alert when character becomes active again - No duplicate alerts for same idle period Discord integration: - DISCORD_ACLOG_WEBHOOK env var for webhook URL - Used by both death alerts and idle detection - Graceful fallback when not configured Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d2c30b610b
commit
adb9d5feab
163 changed files with 2756 additions and 2910 deletions
|
|
@ -1,91 +0,0 @@
|
|||
import React, { useState } from 'react';
|
||||
import { VitalBar } from './VitalBar';
|
||||
import type { CharacterState } from '../types';
|
||||
|
||||
interface Props {
|
||||
character: CharacterState;
|
||||
}
|
||||
|
||||
const vtankBadge = (state: string) => {
|
||||
const s = (state || 'idle').toLowerCase();
|
||||
if (s === 'combat' || s === 'hunt') return { label: s === 'combat' ? 'Combat' : 'Hunt', cls: 'badge-combat' };
|
||||
if (s === 'nav' || s === 'navigation') return { label: 'Nav', cls: 'badge-other' };
|
||||
if (s === 'default' || s === 'idle' || s === '') return { label: 'Idle', cls: 'badge-idle' };
|
||||
// Show the actual state name for anything else (e.g. turn_in_quests)
|
||||
return { label: state, cls: 'badge-other' };
|
||||
};
|
||||
|
||||
export const CharacterCard: React.FC<Props> = React.memo(({ character }) => {
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
const { telemetry: t, vitals: v, combat: c } = character;
|
||||
const badge = vtankBadge(t?.vt_state ?? '');
|
||||
|
||||
return (
|
||||
<div className="char-card" onClick={() => setExpanded(!expanded)}>
|
||||
<div className="char-header">
|
||||
<span className="char-name">{character.name}</span>
|
||||
<span className={`char-badge ${badge.cls}`}>{badge.label}</span>
|
||||
</div>
|
||||
|
||||
{v ? (
|
||||
<div className="char-vitals">
|
||||
<VitalBar label="HP" current={v.health_current} max={v.health_max}
|
||||
color="linear-gradient(90deg, #ff4444, #ff6666)" bgColor="#330000" />
|
||||
<VitalBar label="ST" current={v.stamina_current} max={v.stamina_max}
|
||||
color="linear-gradient(90deg, #ffaa00, #ffcc44)" bgColor="#331a00" />
|
||||
<VitalBar label="MN" current={v.mana_current} max={v.mana_max}
|
||||
color="linear-gradient(90deg, #4488ff, #66aaff)" bgColor="#001433" />
|
||||
</div>
|
||||
) : (
|
||||
<div className="char-vitals-placeholder">Awaiting vitals...</div>
|
||||
)}
|
||||
|
||||
<div className="char-stats-row">
|
||||
<div className="stat">
|
||||
<span className="stat-value">{t?.kills_per_hour ?? '--'}</span>
|
||||
<span className="stat-label">kills/hr</span>
|
||||
</div>
|
||||
<div className="stat">
|
||||
<span className="stat-value">{t?.kills?.toLocaleString() ?? '--'}</span>
|
||||
<span className="stat-label">kills</span>
|
||||
</div>
|
||||
<div className="stat">
|
||||
<span className="stat-value">{t?.deaths ?? '0'}</span>
|
||||
<span className="stat-label">deaths</span>
|
||||
</div>
|
||||
<div className="stat">
|
||||
<span className="stat-value">{t?.onlinetime?.replace(/^00\./, '') ?? '--'}</span>
|
||||
<span className="stat-label">uptime</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{t && (
|
||||
<div className="char-location">
|
||||
{t.ns?.toFixed(1)}N, {t.ew?.toFixed(1)}E
|
||||
</div>
|
||||
)}
|
||||
|
||||
{expanded && (
|
||||
<div className="char-expanded">
|
||||
{v?.vitae ? <div className="vitae-warn">Vitae: {v.vitae}%</div> : null}
|
||||
<div className="expanded-row">
|
||||
<span>Prismatics: {t?.prismatic_taper_count ?? '--'}</span>
|
||||
<span>Total Deaths: {t?.total_deaths ?? '--'}</span>
|
||||
</div>
|
||||
{c?.session && (
|
||||
<div className="expanded-row">
|
||||
<span>Session Dmg: {c.session.total_damage_given?.toLocaleString()}</span>
|
||||
<span>Session Kills: {c.session.total_kills}</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="expanded-row">
|
||||
<span>RAM: {t?.mem_mb ? (t.mem_mb / 1048576).toFixed(0) + ' MB' : '--'}</span>
|
||||
<span>CPU: {t?.cpu_pct?.toFixed(1) ?? '--'}%</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
CharacterCard.displayName = 'CharacterCard';
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
import React, { useMemo } from 'react';
|
||||
import { CharacterCard } from './CharacterCard';
|
||||
import type { CharacterState } from '../types';
|
||||
|
||||
interface Props {
|
||||
characters: Map<string, CharacterState>;
|
||||
}
|
||||
|
||||
export const CharacterGrid: React.FC<Props> = ({ characters }) => {
|
||||
const sorted = useMemo(() => {
|
||||
return Array.from(characters.values()).sort((a, b) =>
|
||||
a.name.localeCompare(b.name)
|
||||
);
|
||||
}, [characters]);
|
||||
|
||||
if (sorted.length === 0) {
|
||||
return <div className="grid-empty">No active characters</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="char-grid">
|
||||
{sorted.map(ch => (
|
||||
<CharacterCard key={ch.name} character={ch} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
import React from 'react';
|
||||
import type { ServerHealth } from '../types';
|
||||
|
||||
interface Props {
|
||||
activeChars: number;
|
||||
totalKills: number;
|
||||
totalRares: number;
|
||||
serverHealth: ServerHealth | null;
|
||||
}
|
||||
|
||||
export const GlobalStats: React.FC<Props> = ({ activeChars, totalKills, totalRares, serverHealth }) => {
|
||||
const serverStatus = serverHealth?.status?.toLowerCase() ?? 'unknown';
|
||||
const isOnline = serverStatus === 'online' || serverStatus === 'up';
|
||||
|
||||
return (
|
||||
<div className="global-stats">
|
||||
<div className="global-stat">
|
||||
<span className="global-value">{activeChars}</span>
|
||||
<span className="global-label">Active Characters</span>
|
||||
</div>
|
||||
<div className="global-stat">
|
||||
<span className="global-value">{totalKills.toLocaleString()}</span>
|
||||
<span className="global-label">Total Kills</span>
|
||||
</div>
|
||||
<div className="global-stat">
|
||||
<span className="global-value">{totalRares}</span>
|
||||
<span className="global-label">Total Rares</span>
|
||||
</div>
|
||||
<div className="global-stat">
|
||||
<span className={`server-dot ${isOnline ? 'online' : 'offline'}`} />
|
||||
<span className="global-value">{serverHealth?.latency_ms ?? '--'}ms</span>
|
||||
<span className="global-label">Coldeve</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
import React from 'react';
|
||||
|
||||
interface Props {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export const Layout: React.FC<Props> = ({ children }) => {
|
||||
return (
|
||||
<div className="dashboard">
|
||||
<header className="dashboard-header">
|
||||
<h1 className="dashboard-title">Mosswart Overlord</h1>
|
||||
</header>
|
||||
<main className="dashboard-main">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
import React from 'react';
|
||||
|
||||
interface Props {
|
||||
label: string;
|
||||
current: number;
|
||||
max: number;
|
||||
color: string;
|
||||
bgColor: string;
|
||||
}
|
||||
|
||||
export const VitalBar: React.FC<Props> = React.memo(({ label, current, max, color, bgColor }) => {
|
||||
const pct = max > 0 ? Math.min(100, Math.max(0, (current / max) * 100)) : 0;
|
||||
return (
|
||||
<div className="vital-bar">
|
||||
<span className="vital-label">{label}</span>
|
||||
<div className="vital-track" style={{ backgroundColor: bgColor }}>
|
||||
<div className="vital-fill" style={{ width: `${pct}%`, background: color }} />
|
||||
</div>
|
||||
<span className="vital-text">{current}/{max}</span>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
VitalBar.displayName = 'VitalBar';
|
||||
71
frontend/src/components/effects/DeathNotification.tsx
Normal file
71
frontend/src/components/effects/DeathNotification.tsx
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
import React, { useEffect, useState, useRef } from 'react';
|
||||
|
||||
interface DeathAlert {
|
||||
character_name: string;
|
||||
vitae: number;
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
deathAlerts: DeathAlert[];
|
||||
}
|
||||
|
||||
interface ActiveNotification {
|
||||
key: number;
|
||||
alert: DeathAlert;
|
||||
exiting: boolean;
|
||||
}
|
||||
|
||||
let deathKey = 0;
|
||||
|
||||
export const DeathNotification: React.FC<Props> = ({ deathAlerts }) => {
|
||||
const [active, setActive] = useState<ActiveNotification[]>([]);
|
||||
const lastCount = useRef(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (deathAlerts.length > lastCount.current && lastCount.current > 0) {
|
||||
const newAlerts = deathAlerts.slice(lastCount.current);
|
||||
for (const alert of newAlerts) {
|
||||
const key = ++deathKey;
|
||||
setActive(prev => [...prev, { key, alert, exiting: false }]);
|
||||
// Sound
|
||||
try {
|
||||
const ctx = new AudioContext();
|
||||
const osc = ctx.createOscillator();
|
||||
const gain = ctx.createGain();
|
||||
osc.connect(gain); gain.connect(ctx.destination);
|
||||
osc.frequency.value = 440; osc.type = 'sawtooth'; gain.gain.value = 0.2;
|
||||
osc.start();
|
||||
gain.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + 0.8);
|
||||
osc.stop(ctx.currentTime + 0.8);
|
||||
} catch {}
|
||||
// Auto-dismiss after 8s
|
||||
setTimeout(() => {
|
||||
setActive(prev => prev.map(n => n.key === key ? { ...n, exiting: true } : n));
|
||||
setTimeout(() => setActive(prev => prev.filter(n => n.key !== key)), 500);
|
||||
}, 8000);
|
||||
}
|
||||
}
|
||||
lastCount.current = deathAlerts.length;
|
||||
}, [deathAlerts.length]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
if (active.length === 0) return null;
|
||||
|
||||
return (
|
||||
<div style={{ position: 'fixed', top: 70, left: '50%', transform: 'translateX(-50%)', zIndex: 99999, display: 'flex', flexDirection: 'column', gap: 6, pointerEvents: 'none' }}>
|
||||
{active.map(n => (
|
||||
<div key={n.key} style={{
|
||||
background: 'linear-gradient(135deg, #2a0a0a, #1a0000)',
|
||||
border: '2px solid #cc4444',
|
||||
borderRadius: 8, padding: '12px 24px', textAlign: 'center',
|
||||
boxShadow: '0 0 30px rgba(204, 68, 68, 0.3)',
|
||||
animation: n.exiting ? 'ml-notif-out 0.5s ease-in forwards' : 'ml-notif-in 0.5s ease-out',
|
||||
}}>
|
||||
<div style={{ fontSize: '1.2rem', fontWeight: 800, color: '#ff4444' }}>☠️ CHARACTER DIED ☠️</div>
|
||||
<div style={{ fontSize: '1rem', fontWeight: 600, color: '#fff', marginTop: 2 }}>{n.alert.character_name}</div>
|
||||
<div style={{ fontSize: '0.8rem', color: '#c88', marginTop: 2 }}>Vitae: {n.alert.vitae}%</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -5,6 +5,7 @@ import { MapView } from './MapView';
|
|||
import { Sidebar } from './Sidebar';
|
||||
import { WindowRenderer } from '../windows/WindowRenderer';
|
||||
import { RareNotification } from '../effects/RareNotification';
|
||||
import { DeathNotification } from '../effects/DeathNotification';
|
||||
import { usePlayerColors } from '../../hooks/usePlayerColors';
|
||||
import type { DashboardState } from '../../hooks/useLiveData';
|
||||
|
||||
|
|
@ -69,6 +70,7 @@ export const MapLayout: React.FC<Props> = ({ data }) => {
|
|||
equipmentCantrips={data.equipmentCantrips} characterStats={data.characterStats}
|
||||
socket={data.socketRef.current} />
|
||||
<RareNotification recentRares={data.recentRares} />
|
||||
<DeathNotification deathAlerts={data.deathAlerts} />
|
||||
</div>
|
||||
</WindowManagerProvider>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,142 +0,0 @@
|
|||
import React, { useMemo } from 'react';
|
||||
import {
|
||||
BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer,
|
||||
PieChart, Pie, Cell, Legend,
|
||||
} from 'recharts';
|
||||
import type { CharacterState } from '../../types';
|
||||
|
||||
interface Props {
|
||||
characters: Map<string, CharacterState>;
|
||||
}
|
||||
|
||||
const ELEMENT_COLORS: Record<string, string> = {
|
||||
Slash: '#cc4444',
|
||||
Pierce: '#44cc44',
|
||||
Bludgeon: '#888888',
|
||||
Fire: '#ff6622',
|
||||
Cold: '#4488ff',
|
||||
Acid: '#44cc44',
|
||||
Electric: '#ffcc00',
|
||||
Typeless: '#aa66cc',
|
||||
};
|
||||
|
||||
export const CombatTab: React.FC<Props> = ({ characters }) => {
|
||||
// Kill rate per character
|
||||
const killData = useMemo(() => {
|
||||
return Array.from(characters.values())
|
||||
.filter(c => c.telemetry)
|
||||
.map(c => ({
|
||||
name: c.name.length > 18 ? c.name.slice(0, 16) + '..' : c.name,
|
||||
fullName: c.name,
|
||||
killsPerHour: parseInt(c.telemetry!.kills_per_hour) || 0,
|
||||
totalKills: c.telemetry!.kills || 0,
|
||||
}))
|
||||
.sort((a, b) => b.killsPerHour - a.killsPerHour)
|
||||
.slice(0, 30);
|
||||
}, [characters]);
|
||||
|
||||
// Damage given per character (from combat stats)
|
||||
const damageData = useMemo(() => {
|
||||
return Array.from(characters.values())
|
||||
.filter(c => c.combat?.session)
|
||||
.map(c => ({
|
||||
name: c.name.length > 18 ? c.name.slice(0, 16) + '..' : c.name,
|
||||
fullName: c.name,
|
||||
damage: c.combat!.session!.total_damage_given,
|
||||
}))
|
||||
.sort((a, b) => b.damage - a.damage)
|
||||
.slice(0, 30);
|
||||
}, [characters]);
|
||||
|
||||
// Aggregate element breakdown across all characters
|
||||
const elementData = useMemo(() => {
|
||||
const totals: Record<string, number> = {};
|
||||
for (const ch of characters.values()) {
|
||||
const session = ch.combat?.session;
|
||||
if (!session?.monsters) continue;
|
||||
for (const mon of Object.values(session.monsters)) {
|
||||
if (!mon.offense) continue;
|
||||
for (const byEl of Object.values(mon.offense)) {
|
||||
for (const [el, stats] of Object.entries(byEl)) {
|
||||
if (el === 'None' || el === 'Unknown') continue;
|
||||
totals[el] = (totals[el] || 0) + (stats.damage || 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Object.entries(totals)
|
||||
.map(([name, value]) => ({ name, value }))
|
||||
.filter(d => d.value > 0)
|
||||
.sort((a, b) => b.value - a.value);
|
||||
}, [characters]);
|
||||
|
||||
return (
|
||||
<div className="combat-tab">
|
||||
<div className="chart-section">
|
||||
<h3 className="chart-title">Kills per Hour</h3>
|
||||
<ResponsiveContainer width="100%" height={Math.max(200, killData.length * 28)}>
|
||||
<BarChart data={killData} layout="vertical" margin={{ left: 10, right: 20, top: 5, bottom: 5 }}>
|
||||
<CartesianGrid strokeDasharray="3 3" stroke="#333" />
|
||||
<XAxis type="number" stroke="#888" fontSize={11} />
|
||||
<YAxis type="category" dataKey="name" width={130} stroke="#888" fontSize={11} />
|
||||
<Tooltip
|
||||
contentStyle={{ background: '#1a1a1a', border: '1px solid #444', fontSize: 12 }}
|
||||
formatter={(v: number) => [v.toLocaleString(), 'Kills/hr']}
|
||||
labelFormatter={(l, payload) => payload?.[0]?.payload?.fullName || l}
|
||||
/>
|
||||
<Bar dataKey="killsPerHour" fill="#44cc44" radius={[0, 3, 3, 0]} />
|
||||
</BarChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
|
||||
{damageData.length > 0 && (
|
||||
<div className="chart-section">
|
||||
<h3 className="chart-title">Total Damage (Session)</h3>
|
||||
<ResponsiveContainer width="100%" height={Math.max(200, damageData.length * 28)}>
|
||||
<BarChart data={damageData} layout="vertical" margin={{ left: 10, right: 20, top: 5, bottom: 5 }}>
|
||||
<CartesianGrid strokeDasharray="3 3" stroke="#333" />
|
||||
<XAxis type="number" stroke="#888" fontSize={11} />
|
||||
<YAxis type="category" dataKey="name" width={130} stroke="#888" fontSize={11} />
|
||||
<Tooltip
|
||||
contentStyle={{ background: '#1a1a1a', border: '1px solid #444', fontSize: 12 }}
|
||||
formatter={(v: number) => [v.toLocaleString(), 'Damage']}
|
||||
labelFormatter={(l, payload) => payload?.[0]?.payload?.fullName || l}
|
||||
/>
|
||||
<Bar dataKey="damage" fill="#ff6644" radius={[0, 3, 3, 0]} />
|
||||
</BarChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{elementData.length > 0 && (
|
||||
<div className="chart-section">
|
||||
<h3 className="chart-title">Damage by Element (All Characters)</h3>
|
||||
<ResponsiveContainer width="100%" height={300}>
|
||||
<PieChart>
|
||||
<Pie
|
||||
data={elementData}
|
||||
dataKey="value"
|
||||
nameKey="name"
|
||||
cx="50%"
|
||||
cy="50%"
|
||||
outerRadius={100}
|
||||
label={({ name, percent }) => `${name} ${(percent * 100).toFixed(0)}%`}
|
||||
labelLine={true}
|
||||
fontSize={12}
|
||||
>
|
||||
{elementData.map((d) => (
|
||||
<Cell key={d.name} fill={ELEMENT_COLORS[d.name] || '#888'} />
|
||||
))}
|
||||
</Pie>
|
||||
<Tooltip
|
||||
contentStyle={{ background: '#1a1a1a', border: '1px solid #444', fontSize: 12 }}
|
||||
formatter={(v: number) => v.toLocaleString()}
|
||||
/>
|
||||
<Legend wrapperStyle={{ fontSize: 12, color: '#aaa' }} />
|
||||
</PieChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
import React, { useState, useCallback, useRef } from 'react';
|
||||
import { apiFetch } from '../../api/client';
|
||||
|
||||
interface SearchResult {
|
||||
character_name: string;
|
||||
item_name: string;
|
||||
type?: string;
|
||||
arcanelore?: string;
|
||||
material?: string;
|
||||
set_name?: string;
|
||||
workmanship?: number;
|
||||
value?: number;
|
||||
}
|
||||
|
||||
interface SearchResponse {
|
||||
results: SearchResult[];
|
||||
total: number;
|
||||
query: string;
|
||||
}
|
||||
|
||||
export const InventoryTab: React.FC = () => {
|
||||
const [query, setQuery] = useState('');
|
||||
const [results, setResults] = useState<SearchResult[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const debounceRef = useRef<number>(0);
|
||||
|
||||
const doSearch = useCallback(async (q: string) => {
|
||||
if (q.length < 2) { setResults([]); setTotal(0); return; }
|
||||
setLoading(true);
|
||||
try {
|
||||
const data = await apiFetch<SearchResponse>(`/search/items?q=${encodeURIComponent(q)}&limit=100`);
|
||||
setResults(data.results ?? []);
|
||||
setTotal(data.total ?? 0);
|
||||
} catch {
|
||||
setResults([]);
|
||||
}
|
||||
setLoading(false);
|
||||
}, []);
|
||||
|
||||
const handleInput = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const val = e.target.value;
|
||||
setQuery(val);
|
||||
clearTimeout(debounceRef.current);
|
||||
debounceRef.current = window.setTimeout(() => doSearch(val), 400);
|
||||
}, [doSearch]);
|
||||
|
||||
return (
|
||||
<div className="inventory-tab">
|
||||
<div className="search-bar">
|
||||
<input
|
||||
type="text"
|
||||
value={query}
|
||||
onChange={handleInput}
|
||||
placeholder="Search items across all characters..."
|
||||
className="search-input"
|
||||
/>
|
||||
{loading && <span className="search-spinner">Searching...</span>}
|
||||
</div>
|
||||
|
||||
{total > 0 && (
|
||||
<div className="search-count">{total.toLocaleString()} results</div>
|
||||
)}
|
||||
|
||||
<div className="search-results">
|
||||
{results.length === 0 && query.length >= 2 && !loading && (
|
||||
<div className="search-empty">No items found</div>
|
||||
)}
|
||||
<table className="results-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Character</th>
|
||||
<th>Item</th>
|
||||
<th>Type</th>
|
||||
<th>Material</th>
|
||||
<th>Set</th>
|
||||
<th>Work</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{results.map((r, i) => (
|
||||
<tr key={i}>
|
||||
<td>{r.character_name}</td>
|
||||
<td className="item-name">{r.item_name}</td>
|
||||
<td>{r.type || ''}</td>
|
||||
<td>{r.material || ''}</td>
|
||||
<td>{r.set_name || ''}</td>
|
||||
<td>{r.workmanship || ''}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
import React, { useMemo, useRef, useState, useCallback } from 'react';
|
||||
import type { CharacterState } from '../../types';
|
||||
|
||||
interface Props {
|
||||
characters: Map<string, CharacterState>;
|
||||
}
|
||||
|
||||
// UtilityBelt's coordinate bounds (matches v1 script.js)
|
||||
const MAP_BOUNDS = { west: -102.1, east: 102.1, north: 102.1, south: -102.1 };
|
||||
const MAP_SIZE = 800; // render size in CSS px
|
||||
|
||||
function coordToPixel(ew: number, ns: number): { x: number; y: number } {
|
||||
const x = ((ew - MAP_BOUNDS.west) / (MAP_BOUNDS.east - MAP_BOUNDS.west)) * MAP_SIZE;
|
||||
const y = ((MAP_BOUNDS.north - ns) / (MAP_BOUNDS.north - MAP_BOUNDS.south)) * MAP_SIZE;
|
||||
return { x, y };
|
||||
}
|
||||
|
||||
export const MapTab: React.FC<Props> = ({ characters }) => {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const [hovered, setHovered] = useState<string | null>(null);
|
||||
|
||||
const dots = useMemo(() => {
|
||||
return Array.from(characters.values())
|
||||
.filter(c => c.telemetry && c.telemetry.ew !== undefined)
|
||||
.map(c => {
|
||||
const t = c.telemetry!;
|
||||
const { x, y } = coordToPixel(t.ew, t.ns);
|
||||
const isHunting = (t.vt_state || '').toLowerCase() === 'combat' ||
|
||||
(t.vt_state || '').toLowerCase() === 'hunt';
|
||||
return { name: c.name, x, y, isHunting, ns: t.ns, ew: t.ew };
|
||||
});
|
||||
}, [characters]);
|
||||
|
||||
const handleDotHover = useCallback((name: string | null) => setHovered(name), []);
|
||||
|
||||
return (
|
||||
<div className="map-tab">
|
||||
<div className="map-container" ref={containerRef}>
|
||||
<img
|
||||
src="/dereth_highres.png"
|
||||
alt="Dereth Map"
|
||||
className="map-image"
|
||||
draggable={false}
|
||||
/>
|
||||
<svg className="map-overlay" viewBox={`0 0 ${MAP_SIZE} ${MAP_SIZE}`}>
|
||||
{dots.map(d => (
|
||||
<g key={d.name}>
|
||||
<circle
|
||||
cx={d.x}
|
||||
cy={d.y}
|
||||
r={hovered === d.name ? 6 : 4}
|
||||
fill={d.isHunting ? '#44cc44' : '#ffaa00'}
|
||||
stroke="#000"
|
||||
strokeWidth={1}
|
||||
opacity={0.9}
|
||||
onMouseEnter={() => handleDotHover(d.name)}
|
||||
onMouseLeave={() => handleDotHover(null)}
|
||||
style={{ cursor: 'pointer' }}
|
||||
/>
|
||||
{hovered === d.name && (
|
||||
<text
|
||||
x={d.x + 8}
|
||||
y={d.y + 4}
|
||||
fill="#fff"
|
||||
fontSize={11}
|
||||
stroke="#000"
|
||||
strokeWidth={0.3}
|
||||
paintOrder="stroke"
|
||||
>
|
||||
{d.name} ({d.ns?.toFixed(1)}N, {d.ew?.toFixed(1)}E)
|
||||
</text>
|
||||
)}
|
||||
</g>
|
||||
))}
|
||||
</svg>
|
||||
</div>
|
||||
<div className="map-legend">
|
||||
<span><span className="legend-dot hunting" /> Hunting/Combat</span>
|
||||
<span><span className="legend-dot other" /> Other state</span>
|
||||
<span className="map-count">{dots.length} characters on map</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
import React, { useMemo } from 'react';
|
||||
import {
|
||||
BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer,
|
||||
} from 'recharts';
|
||||
import type { CharacterState, RareMessage } from '../../types';
|
||||
|
||||
interface Props {
|
||||
characters: Map<string, CharacterState>;
|
||||
totalRares: number;
|
||||
totalKills: number;
|
||||
recentRares: RareMessage[];
|
||||
}
|
||||
|
||||
export const RaresTab: React.FC<Props> = ({ characters, totalRares, totalKills, recentRares }) => {
|
||||
// Rares per character from telemetry
|
||||
const raresData = useMemo(() => {
|
||||
return Array.from(characters.values())
|
||||
.filter(c => c.telemetry && (c.telemetry.total_rares ?? 0) > 0)
|
||||
.map(c => ({
|
||||
name: c.name.length > 18 ? c.name.slice(0, 16) + '..' : c.name,
|
||||
fullName: c.name,
|
||||
rares: c.telemetry!.total_rares ?? 0,
|
||||
}))
|
||||
.sort((a, b) => b.rares - a.rares);
|
||||
}, [characters]);
|
||||
|
||||
const killsPerRare = totalRares > 0 ? Math.round(totalKills / totalRares) : 0;
|
||||
|
||||
return (
|
||||
<div className="rares-tab">
|
||||
{/* Summary stats */}
|
||||
<div className="rares-summary">
|
||||
<div className="rare-stat-card">
|
||||
<span className="rare-stat-value">{totalRares}</span>
|
||||
<span className="rare-stat-label">Total Rares Found</span>
|
||||
</div>
|
||||
<div className="rare-stat-card">
|
||||
<span className="rare-stat-value">{totalKills.toLocaleString()}</span>
|
||||
<span className="rare-stat-label">Total Kills</span>
|
||||
</div>
|
||||
<div className="rare-stat-card">
|
||||
<span className="rare-stat-value">{killsPerRare > 0 ? `1 in ${killsPerRare.toLocaleString()}` : '--'}</span>
|
||||
<span className="rare-stat-label">Drop Rate</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Recent rare drops */}
|
||||
{recentRares.length > 0 && (
|
||||
<div className="chart-section">
|
||||
<h3 className="chart-title">Recent Rare Drops (This Session)</h3>
|
||||
<div className="rare-timeline">
|
||||
{recentRares.map((r, i) => (
|
||||
<div key={i} className="rare-event">
|
||||
<span className="rare-time">{new Date(r.timestamp).toLocaleTimeString()}</span>
|
||||
<span className="rare-char">{r.character_name}</span>
|
||||
<span className="rare-name">{r.name}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Rares per character */}
|
||||
{raresData.length > 0 && (
|
||||
<div className="chart-section">
|
||||
<h3 className="chart-title">Rares per Character (Lifetime)</h3>
|
||||
<ResponsiveContainer width="100%" height={Math.max(200, raresData.length * 28)}>
|
||||
<BarChart data={raresData} layout="vertical" margin={{ left: 10, right: 20, top: 5, bottom: 5 }}>
|
||||
<CartesianGrid strokeDasharray="3 3" stroke="#333" />
|
||||
<XAxis type="number" stroke="#888" fontSize={11} />
|
||||
<YAxis type="category" dataKey="name" width={130} stroke="#888" fontSize={11} />
|
||||
<Tooltip
|
||||
contentStyle={{ background: '#1a1a1a', border: '1px solid #444', fontSize: 12 }}
|
||||
formatter={(v: number) => [v, 'Rares']}
|
||||
labelFormatter={(l, payload) => payload?.[0]?.payload?.fullName || l}
|
||||
/>
|
||||
<Bar dataKey="rares" fill="#ffcc00" radius={[0, 3, 3, 0]} />
|
||||
</BarChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
import React, { useState } from 'react';
|
||||
|
||||
interface Tab {
|
||||
id: string;
|
||||
label: string;
|
||||
content: React.ReactNode;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
tabs: Tab[];
|
||||
}
|
||||
|
||||
export const TabContainer: React.FC<Props> = ({ tabs }) => {
|
||||
const [activeTab, setActiveTab] = useState(tabs[0]?.id ?? '');
|
||||
|
||||
return (
|
||||
<div className="tab-container">
|
||||
<div className="tab-bar">
|
||||
{tabs.map(tab => (
|
||||
<button
|
||||
key={tab.id}
|
||||
className={`tab-btn ${activeTab === tab.id ? 'active' : ''}`}
|
||||
onClick={() => setActiveTab(tab.id)}
|
||||
>
|
||||
{tab.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="tab-content">
|
||||
{tabs.find(t => t.id === activeTab)?.content}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue