diff --git a/README.md b/README.md index d3f4cec..667fc16 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,7 @@ html page (`index.html`) where you can: * See the damage, crowd control, boon uptime, resurrects, mechanic fails, downs and deaths of every player * See the health of the boss when you wiped * See the statistics over all days (kill rate and time per encounter, downs and deaths) on the Statistics tab +* Look at one boss in detail on the Boss tab (or with "Stats →" on a boss card): all tries of a day or of all days, boss health left per try, fastest kill, best wipe, and per player average/best DPS, mechanic fails, downs and deaths * Click on the try to go to the log (the html log of Elite Insights, or the dps.report page) This is done by parsing the Elite Insights json files and combining the information from the log files. diff --git a/raidTimeline.App/Commands/ParserCommands.cs b/raidTimeline.App/Commands/ParserCommands.cs index aa88afa..aad06e5 100644 --- a/raidTimeline.App/Commands/ParserCommands.cs +++ b/raidTimeline.App/Commands/ParserCommands.cs @@ -23,10 +23,14 @@ internal static CoconaApp RegisterParserCommands(this CoconaApp app) [Option('f', Description = "Only uses the logs that are in the list of boss ids (in the config.json file) for the timeline.")] - bool filter + bool filter, + [Option('H', Description = + "Only regenerates the html timeline from the existing json files, Elite Insights is not run.")] + bool htmlOnly ) => { - parserService.ParseLogsFromDisk(day, reverse, killOnly, filter, null!, context.CancellationToken); + parserService.ParseLogsFromDisk(day, reverse, killOnly, filter, null!, + context.CancellationToken, htmlOnly); }) .WithDescription("Parses local log files with Elite Insights."); diff --git a/raidTimeline.App/Services/Interfaces/IParserService.cs b/raidTimeline.App/Services/Interfaces/IParserService.cs index d742674..ccbf694 100644 --- a/raidTimeline.App/Services/Interfaces/IParserService.cs +++ b/raidTimeline.App/Services/Interfaces/IParserService.cs @@ -5,7 +5,7 @@ namespace raidTimeline.App.Services.Interfaces; internal interface IParserService { void ParseLogsFromDisk(string? day, bool reverse, bool killOnly, bool filter, - IEncounterService encounterService, CancellationToken cancellationToken); + IEncounterService encounterService, CancellationToken cancellationToken, bool htmlOnly = false); void ParseLogsFromDiskLive(bool reverse, bool killOnly, bool filter, CancellationToken cancellationToken); void ParseLogsFromDpsReport(string? day, bool reverse, bool killOnly, bool filter, diff --git a/raidTimeline.App/Services/ParserService.cs b/raidTimeline.App/Services/ParserService.cs index 810a6ab..eb655ba 100644 --- a/raidTimeline.App/Services/ParserService.cs +++ b/raidTimeline.App/Services/ParserService.cs @@ -23,39 +23,42 @@ public ParserService(ITimelineCreator timelineCreator, } public void ParseLogsFromDisk(string? day, bool reverse, bool killOnly, bool filter, - IEncounterService encounterService, CancellationToken cancellationToken) + IEncounterService encounterService, CancellationToken cancellationToken, bool htmlOnly = false) { - Spinner.Start($"Parsing logs for {day}", spinner => + Spinner.Start(htmlOnly ? "Regenerating the timeline" : $"Parsing logs for {day}", spinner => { day ??= $"{DateTime.Now:yyyyMMdd}"; - if (!_configurationHelper.Configuration.EliteInsightsOptionsReadable) - { - spinner.Fail("Elite Insights configuration could not be read."); - } - else if (!HasJsonOutput(spinner)) + if (!htmlOnly) { - return; - } + if (!_configurationHelper.Configuration.EliteInsightsOptionsReadable) + { + spinner.Fail("Elite Insights configuration could not be read."); + } + else if (!HasJsonOutput(spinner)) + { + return; + } - var files = Directory.GetFiles(_configurationHelper.Configuration.LogPath, - $"{day}*.zevtc", SearchOption.AllDirectories); + var files = Directory.GetFiles(_configurationHelper.Configuration.LogPath, + $"{day}*.zevtc", SearchOption.AllDirectories); - var failed = 0; - for (var i = 0; i < files.Length && !cancellationToken.IsCancellationRequested; i++) - { - spinner.Text = $"Parsing logs for {day}: {i + 1}/{files.Length}"; - if (!_eliteInsightsService.ParseEiFile(files[i], - _configurationHelper.Configuration.ConfigurationPath, - _configurationHelper.Configuration.EliteInsightsPath, cancellationToken)) + var failed = 0; + for (var i = 0; i < files.Length && !cancellationToken.IsCancellationRequested; i++) { - failed++; + spinner.Text = $"Parsing logs for {day}: {i + 1}/{files.Length}"; + if (!_eliteInsightsService.ParseEiFile(files[i], + _configurationHelper.Configuration.ConfigurationPath, + _configurationHelper.Configuration.EliteInsightsPath, cancellationToken)) + { + failed++; + } } - } - if (failed > 0 && !cancellationToken.IsCancellationRequested) - { - spinner.Warn($"Elite Insights failed for {failed} of {files.Length} logs (see the log file)."); + if (failed > 0 && !cancellationToken.IsCancellationRequested) + { + spinner.Warn($"Elite Insights failed for {failed} of {files.Length} logs (see the log file)."); + } } spinner.Text = $"Parsing json files"; diff --git a/raidTimeline.Logic/template.html b/raidTimeline.Logic/template.html index b248f13..7ee130d 100644 --- a/raidTimeline.Logic/template.html +++ b/raidTimeline.Logic/template.html @@ -231,6 +231,18 @@ .hp { margin:0 18px 12px; height:8px; border-radius:5px; position:relative; overflow:hidden; background:color-mix(in srgb,var(--ok) 35%,var(--surface-2)); } .hp i { position:absolute; inset:0 auto 0 0; width:var(--w); background:linear-gradient(90deg,var(--fail),color-mix(in srgb,var(--fail) 70%,#fff)); } + /* boss page */ + .pickers { display:flex; gap:10px; flex-wrap:wrap; margin-bottom:18px; } + .pickers select { background:var(--surface); color:var(--text); border:1px solid var(--line); border-radius:999px; padding:7px 14px; font:inherit; font-size:14px; max-width:100%; } + .pickers select:focus-visible { outline:2px solid var(--accent); } + .card .v.sm { font-size:24px; } + .trend { display:flex; align-items:flex-end; gap:3px; height:130px; padding:6px 8px 0; border-bottom:1px solid var(--line); overflow-x:auto; } + .tb { flex:1 0 14px; max-width:44px; height:var(--h); min-height:4px; border:0; padding:0; border-radius:5px 5px 0 0; cursor:default; + background:linear-gradient(180deg,color-mix(in srgb,var(--c) 95%,#fff),var(--c)); opacity:.85; } + .tb:hover { opacity:1; } + .tb.kill { --c:var(--ok); } .tb.wipe { --c:var(--fail); } .tb.unk { --c:var(--muted); } + .trend-cap { display:flex; justify-content:space-between; gap:10px; font-size:12px; color:var(--muted); padding:6px 10px 10px; } + .boss-link { margin-left:8px; } .bossname a { color:inherit; text-decoration:none; } .bossname a:hover { text-decoration:underline; } @@ -240,6 +252,7 @@
+
@@ -256,6 +269,7 @@
+
@@ -294,7 +308,7 @@ /* pulls are always shown in chronological order, the rail and the downtimes only make sense that way */ const enc = byDay[key].sort((a, b) => a.start < b.start ? -1 : 1).map(l => { const sec = Math.max(0, Math.round((new Date(l.end) - new Date(l.start)) / 1000)); - return { boss: l.name, kill: l.killed, start: l.start.slice(11), dur: mmss(sec), sec, log: l }; + return { boss: l.name, kill: l.killed, day: key, start: l.start.slice(11), dur: mmss(sec), sec, log: l }; }); enc.forEach(e => { e.s0 = toSec(e.start); e.s1 = e.s0 + e.sec; }); enc.forEach((e, i) => { e.gap = i ? Math.max(0, e.s0 - enc[i - 1].s1) : 0; }); @@ -413,7 +427,7 @@ const badge = last.kill ? (list.length > 1 ? `Kill after ${list.length - 1} wipe${list.length > 2 ? 's' : ''}` : 'Kill') : (kills ? 'Mixed' : 'Wipe'); return `
${bossIcon(boss, 'icon', last.log.icon)}

${esc(boss)}

${sub}
- ${badge}
+ ${badge}
${tries} ${list.map((e, i) => `
${attemptBody(e, list[i - 1])}
`).join('')} `; @@ -506,6 +520,84 @@ Object.values(acct).sort((a, b) => b.died - a.died || b.downed - a.downed || a.p.account.localeCompare(b.p.account)) .map(a => `${who(a.p)}${a.downed}${a.died}`).join(''))}`; +/* ---------- boss page: all tries of one boss ---------- */ +const bossNames = Object.keys(bossStats).sort((a, b) => bossStats[b].tries - bossStats[a].tries || a.localeCompare(b)); +const hp0 = e => e.log.hpLeft.length ? e.log.hpLeft[0] : null; +const dash = '–'; +function bossBody(name, dayKey) { + const tries = allEnc.filter(e => e.boss === name && (dayKey === 'all' || e.day === dayKey)); + const kills = tries.filter(e => e.kill), wipes = tries.filter(e => !e.kill); + const fastest = kills.length ? Math.min(...kills.map(e => e.sec)) : null; + const hps = wipes.map(hp0).filter(v => v !== null); + const bestWipe = hps.length ? Math.min(...hps) : null; + const avgDps = tries.reduce((s, e) => s + gdps(e), 0) / (tries.length || 1); + const cards = `
+
${tries.length}
Tries
+
${kills.length}
Kills · ${Math.round(kills.length / (tries.length || 1) * 100)}% kill rate
+
${fastest === null ? '–' : mmss(fastest)}
Fastest kill
+
${bestWipe === null ? '–' : bestWipe.toFixed(1) + '%'}
Best wipe (boss HP left)
+
${(avgDps / 1000).toFixed(1)}k
Average group DPS
`; + + const bars = tries.map((e, i) => { + const h = hp0(e), cls = e.kill ? 'kill' : h === null ? 'unk' : 'wipe'; + const height = e.kill ? 6 : h === null ? 10 : Math.max(h, 4); + const label = `#${i + 1} · ${e.kill ? 'Kill' : h === null ? 'Wipe' : 'Wipe, ' + h.toFixed(1) + '% left'} · ${e.dur}` + (dayKey === 'all' ? ` · ${e.day}` : '') + ` · ${clock(e.s0)}`; + return ``; + }).join(''); + const trend = `

Boss health left per try

${bars}
+
First tryLower is better, a kill is the small green barLast try
`; + + const showDay = dayKey === 'all'; + const rows = tries.map((e, i) => { + const h = hp0(e), deaths = e.log.players.reduce((s, p) => s + p.died, 0), downs = e.log.players.reduce((s, p) => s + p.downed, 0); + return `${i + 1}${showDay ? `${esc(e.day)}` : ''}${clock(e.s0)} + ${e.kill ? 'Kill' : 'Wipe'}${e.dur} + ${e.kill ? '–' : h === null ? '?' : h.toFixed(1) + '%'}${(gdps(e) / 1000).toFixed(1)}k + ${deaths}${downs} + Log ↗`; + }).join(''); + const triesTbl = `

All tries

${tbl(`#${showDay ? 'Day' : ''}StartResultTimeHP leftGroup DPSDeathsDowns`, rows)}
`; + + const pl = {}; + tries.forEach(e => e.log.players.filter(p => !p.isNpc).forEach(p => { + const a = pl[p.account] ??= { p, n: 0, dps: 0, best: 0, downed: 0, died: 0, mech: 0 }; + a.n++; a.dps += p.dps; a.best = Math.max(a.best, p.dps); a.downed += p.downed; a.died += p.died; + a.mech += e.log.columns.filter(c => c.rank).reduce((s, c) => s + (p.mechanics[c.key] ?? 0), 0); + a.p = p; + })); + const plRows = Object.values(pl).sort((a, b) => b.dps / b.n - a.dps / a.n).map(a => `${who(a.p)}${a.n} + ${fmt(a.dps / a.n)}${fmt(a.best)} + ${a.mech ? `${a.mech}` : dash} + ${a.downed || dash}${a.died || dash}`).join(''); + const players = `

Players

${tbl('PlayerTriesAvg DPSBest DPSMech failsDownedDied', plRows)}
`; + return cards + trend + triesTbl + players; +} +function renderBoss(i, dayKey) { + const name = bossNames[i]; + const dayKeys = [...new Set(allEnc.filter(e => e.boss === name).map(e => e.day))]; + if (dayKey !== 'all' && !dayKeys.includes(dayKey)) dayKey = 'all'; + $('#boss').innerHTML = `
+ +
+
${bossBody(name, dayKey)}
`; + $('#boss-pick').onchange = ev => renderBoss(+ev.target.value, 'all'); + $('#boss-day').onchange = ev => renderBoss(i, ev.target.value); +} +function openBoss(name, dayKey) { + const i = bossNames.indexOf(name); + if (i < 0) return; + renderBoss(i, dayKey || 'all'); + showPage('boss'); +} +if (!days.length) $('#boss').innerHTML = `

No logs found yet.

`; +else { + /* the boss with the most tries on the newest day: that is usually the one you are working on */ + const latest = days.reduce((m, d) => d.key > m.key ? d : m); + const counts = {}; latest.enc.forEach(e => counts[e.boss] = (counts[e.boss] ?? 0) + 1); + const top = Object.keys(counts).sort((a, b) => counts[b] - counts[a])[0]; + renderBoss(bossNames.indexOf(top), latest.key); +} + /* ---------- tooltip for the strip ---------- */ const tip = document.createElement('div'); tip.className = 'tip'; tip.hidden = true; document.body.appendChild(tip); @@ -553,11 +645,14 @@ $$('#views button').forEach(b => b.onclick = () => setView(b.dataset.v)); setView(store('rt-view') || 'dps'); -$$('#pages button').forEach(b => b.onclick = () => { - $$('.page').forEach(p => p.classList.toggle('on', p.id === b.dataset.page)); - $$('#pages button').forEach(x => x.setAttribute('aria-pressed', x === b)); - $('#views').style.display = b.dataset.page === 'timeline' ? '' : 'none'; -}); +function showPage(page) { + $$('.page').forEach(p => p.classList.toggle('on', p.id === page)); + $$('#pages button').forEach(x => x.setAttribute('aria-pressed', x.dataset.page === page)); + $('#views').style.display = page === 'timeline' ? '' : 'none'; + window.scrollTo(0, 0); +} +$$('#pages button').forEach(b => b.onclick = () => showPage(b.dataset.page)); +$$('.boss-link').forEach(b => b.onclick = () => openBoss(b.dataset.boss, b.dataset.day)); function showDay(i, focus) { $$('.daytab').forEach(t => { diff --git a/tests-js/page.js b/tests-js/page.js index 414c96a..9f9e887 100644 --- a/tests-js/page.js +++ b/tests-js/page.js @@ -27,6 +27,7 @@ function load(data, { hash = '', storage = {}, dark = true } = {}) { window.matchMedia = query => ({ matches: dark && query.includes('dark'), addEventListener() {}, removeEventListener() {} }); window.Element.prototype.scrollIntoView = function () { window.scrolled = this; }; window.Element.prototype.scrollBy = function () {}; + window.scrollTo = function () {}; for (const [key, value] of Object.entries(storage)) window.localStorage.setItem(key, value); window.addEventListener('error', e => errors.push(e.error || e.message)); }, diff --git a/tests-js/timeline.test.js b/tests-js/timeline.test.js index f507f9e..ea267d5 100644 --- a/tests-js/timeline.test.js +++ b/tests-js/timeline.test.js @@ -368,3 +368,66 @@ test('the data can contain a closing script tag without breaking the page', () = assert.equal(w.pwned, undefined); assert.equal(days(w).length, 1); }); + +/* ---------- boss page ---------- */ + +const tonight = () => ({ + newestFirst: false, + logs: [ + log('Gorseval', '2026-03-01T20:00:00', '2026-03-01T20:05:00'), + ...[60, 40, 15].map((hp, i) => log('Sabetha', `2026-03-02T20:${10 + i * 10}:00`, `2026-03-02T20:${14 + i * 10}:00`, + { killed: false, hpLeft: [hp], players: [player('A.1111', { dps: 2000 + i * 1000, died: i }), player('B.2222')] })), + log('Sabetha', '2026-03-02T20:50:00', '2026-03-02T20:53:00', { players: [player('A.1111', { dps: 6000 }), player('B.2222')] }), + ], +}); +const boss = w => w.document.querySelector('#boss'); +const bossCards = w => [...boss(w).querySelectorAll('.card')].map(c => text(c)); + +test('boss page: opens on the boss with the most tries of the newest day and lists every try', () => { + const w = load(tonight()); + assert.deepEqual(w.errors, []); + assert.equal(w.document.querySelector('#boss-pick').selectedOptions[0].textContent, 'Sabetha (4)'); + assert.equal(w.document.querySelector('#boss-day').value, '2026-03-02'); + assert.equal(boss(w).querySelectorAll('.panel tbody tr').length >= 4, true); + assert.equal(boss(w).querySelectorAll('.tb').length, 4); + assert.equal(boss(w).querySelectorAll('.tb.kill').length, 1); +}); + +test('boss page: summary cards show tries, kills, fastest kill and the best wipe', () => { + const w = load(tonight()); + const cards = bossCards(w); + assert.match(cards[0], /4 Tries/); + assert.match(cards[1], /1 Kills · 25% kill rate/); + assert.match(cards[2], /3:00 Fastest kill/); + assert.match(cards[3], /15\.0% Best wipe/); +}); + +test('boss page: players get their average and best dps over the tries', () => { + const w = load(tonight()); + const row = [...boss(w).querySelectorAll('tbody tr')].find(r => text(r).startsWith('A.1111')); + assert.match(text(row), /A\.1111 4 3,750 6,000 – – 3/); +}); + +test('boss page: picking another boss or all days changes the tries', () => { + const w = load(tonight()); + w.document.querySelector('#boss-day').value = 'all'; + w.document.querySelector('#boss-day').dispatchEvent(new w.Event('change')); + assert.equal(boss(w).querySelectorAll('.tb').length, 4); + const pick = w.document.querySelector('#boss-pick'); + pick.value = [...pick.options].findIndex(o => o.textContent.startsWith('Gorseval')); + pick.dispatchEvent(new w.Event('change')); + assert.match(bossCards(w)[0], /1 Tries/); +}); + +test('boss page: the stats button on a boss card opens it for that day', () => { + const w = load(tonight()); + click(w.document.querySelector('#day-0 .boss-link')); + assert.equal(w.document.querySelector('#boss').classList.contains('on'), true); + assert.equal(w.document.querySelector('#boss-pick').selectedOptions[0].textContent, 'Gorseval (1)'); + assert.equal(w.document.querySelector('#boss-day').value, '2026-03-01'); +}); + +test('boss page: no logs says so', () => { + const w = load({ newestFirst: false, logs: [] }); + assert.match(text(boss(w)), /No logs found yet/); +});