feat: show special note shares and clarify average event rankings

This commit is contained in:
2026-09-04 10:41:52 +09:00
parent cda25fdcb1
commit e1925f4f0f
9 changed files with 126 additions and 8 deletions
+16 -1
View File
@@ -1,7 +1,7 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { events } from '../data/events.ts';
import { activeEventAt, eventBonusBreakdown, eventChallengeSongScoreBonusPercent, eventOptimizationCardEligible, eventPointIndex } from './event-optimization.ts';
import { activeEventAt, compareEventRankings, eventBonusBreakdown, eventChallengeSongScoreBonusPercent, eventOptimizationCardEligible, eventPointIndex } from './event-optimization.ts';
const currentEvent = events[0];
@@ -46,3 +46,18 @@ test('과제곡에 대응하는 신규 카드가 있을 때만 스코어 보너
test('예상 점수에 이벤트 획득 배율을 적용해 비교 지수를 만든다', () => {
assert.equal(eventPointIndex(1_000_000, 128), 2_280_000);
});
test('이벤트 순위는 최고점보다 평균 점수를 우선한다', () => {
const highMaximum = { result: { expectedScore: 100, theoreticalMaxScore: 300 } };
const highAverage = { result: { expectedScore: 120, theoreticalMaxScore: 200 } };
assert.deepEqual([highMaximum, highAverage].sort(compareEventRankings), [highAverage, highMaximum]);
});
test('평균 이벤트 Pt에는 획득 보너스를 반영하고 동률은 평균 점수로 정렬한다', () => {
const bonus = { result: { expectedScore: 100 }, eventBonusPercent: 100 };
const score = { result: { expectedScore: 150 }, eventBonusPercent: 0 };
assert.ok(compareEventRankings(bonus, score) < 0);
assert.ok(compareEventRankings(bonus, { result: { expectedScore: 200 } }) > 0);
const sameAverage = { ...bonus, result: { expectedScore: 100, theoreticalMaxScore: 999 } };
assert.equal(compareEventRankings(bonus, sameAverage), 0);
});
+9
View File
@@ -71,3 +71,12 @@ export function eventChallengeSongScoreBonusPercent(
export function eventPointIndex(score: number, eventBonusPercent: number): number {
return Math.round(score * (1 + eventBonusPercent / 100));
}
export function compareEventRankings(
left: { result: { expectedScore: number }; eventBonusPercent?: number },
right: { result: { expectedScore: number }; eventBonusPercent?: number }
): number {
return eventPointIndex(right.result.expectedScore, right.eventBonusPercent ?? 0)
- eventPointIndex(left.result.expectedScore, left.eventBonusPercent ?? 0)
|| right.result.expectedScore - left.result.expectedScore;
}
@@ -0,0 +1,23 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { summarizeSpecialNotes } from './special-note-summary.ts';
const note = (timeSeconds: number, baselineScore: number) => ({ timeSeconds, baselineScore, combo: 0, expectedScore: baselineScore * 2, theoreticalMaxScore: baselineScore * 3 });
const window = (cardId: string, startSeconds: number, endSeconds: number) => ({ cardId, startSeconds, endSeconds, scoreUpPercent: 100 });
test('스페셜 시작 노트는 포함하고 종료 노트는 제외하며 동시 노트를 각각 합산한다', () => {
const [summary] = summarizeSpecialNotes([note(0, 100), note(1, 100), note(1, 10), note(2, 100)], [window('a', 1, 2)]);
assert.equal(summary.noteCount, 2);
assert.equal(summary.notePercent, 50);
assert.equal(summary.baselineScore, 110);
assert.equal(summary.baselinePercent, 110 / 310 * 100);
});
test('겹친 스페셜 구간은 각 멤버 기준으로 계산하고 빈 채보는 0으로 표시한다', () => {
const summaries = summarizeSpecialNotes([note(1, 10)], [window('a', 0, 2), window('b', 1, 3)]);
assert.deepEqual(summaries.map((summary) => summary.noteCount), [1, 1]);
const [empty] = summarizeSpecialNotes([], [window('a', 0, 2)]);
assert.equal(empty.notePercent, 0);
assert.equal(empty.baselinePercent, 0);
assert.deepEqual(summarizeSpecialNotes([note(1, 10)], []), []);
});
+16
View File
@@ -0,0 +1,16 @@
import type { NoteScorePoint, SkillWindow } from './types.ts';
export function summarizeSpecialNotes(notes: readonly NoteScorePoint[], windows: readonly SkillWindow[]) {
const totalScore = notes.reduce((sum, note) => sum + note.baselineScore, 0);
return windows.map((window) => {
const selected = notes.filter((note) => window.startSeconds <= note.timeSeconds && note.timeSeconds < window.endSeconds);
const baselineScore = selected.reduce((sum, note) => sum + note.baselineScore, 0);
return {
...window,
noteCount: selected.length,
notePercent: notes.length > 0 ? selected.length / notes.length * 100 : 0,
baselineScore,
baselinePercent: totalScore > 0 ? baselineScore / totalScore * 100 : 0
};
});
}