feat: improve combination search and offline build

This commit is contained in:
2026-08-18 20:59:20 +09:00
parent ee3498d146
commit d0f7654998
20 changed files with 552 additions and 99 deletions
+25 -1
View File
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { generateCombinationCandidates } from './index.ts';
import { generateCombinationCandidates, resolveCandidateAwakening } from './index.ts';
const cards = [
{ id: 'a-1', characterId: 'a', score: 10 },
@@ -20,3 +20,27 @@ test('빔 너비만큼 점수가 높은 조합을 남긴다', () => {
assert.equal(result.length, 2);
assert.deepEqual(result[0].map((card) => card.id).sort(), ['b-1', 'c-1']);
});
test('편성 점수로 카드 간 시너지를 선별할 수 있다', () => {
const synergyCards = [
{ id: 'a-1', characterId: 'a', score: 10, group: 'x' },
{ id: 'b-1', characterId: 'b', score: 9, group: 'x' },
{ id: 'c-1', characterId: 'c', score: 20, group: 'y' }
];
const result = generateCombinationCandidates(
[],
synergyCards,
2,
(card) => card.score,
2,
(selected) => selected.reduce((sum, card) => sum + card.score, 0) +
(selected.filter((card) => card.group === 'x').length >= 2 ? 100 : 0)
);
assert.deepEqual(result[0].map((card) => card.id).sort(), ['a-1', 'b-1']);
});
test('보유한 자동 후보는 설정값보다 실제 개화가 높으면 실제 개화를 사용한다', () => {
assert.equal(resolveCandidateAwakening(2, true, 4), 4);
assert.equal(resolveCandidateAwakening(4, true, 2), 4);
assert.equal(resolveCandidateAwakening(2, false, 5), 2);
});