feat: add combination search workflow
This commit is contained in:
@@ -26,6 +26,10 @@ export type BoardConnections = {
|
||||
placements: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
||||
cards: readonly BoardConnectionCard[];
|
||||
};
|
||||
export type BoardEffectOverrides = {
|
||||
generationBonusByCardId?: Readonly<Record<string, number>>;
|
||||
directSongScoreBonusPercent?: number;
|
||||
};
|
||||
export type BoardEffectsResult = {
|
||||
flatByCardId: Record<string, Record<UnitStat, number>>;
|
||||
rateByCardId: Record<string, Record<UnitStat, number>>;
|
||||
@@ -126,7 +130,8 @@ export function calculateBoardEffects(
|
||||
cards: readonly BoardEffectCard[],
|
||||
leaderCharacterId: string,
|
||||
song?: BoardEffectSong | null,
|
||||
connections?: BoardConnections | null
|
||||
connections?: BoardConnections | null,
|
||||
overrides?: BoardEffectOverrides | null
|
||||
): BoardEffectsResult {
|
||||
const flatByCardId = Object.fromEntries(cards.map((card) => [card.id, emptyStats()]));
|
||||
const rateByCardId = Object.fromEntries(cards.map((card) => [card.id, emptyStats()]));
|
||||
@@ -167,12 +172,20 @@ export function calculateBoardEffects(
|
||||
|
||||
const destination = effect.type.endsWith('_permil_up') ? rateByCardId : flatByCardId;
|
||||
const normalizedValue = effect.type.endsWith('_permil_up') ? value / 10 : value;
|
||||
for (const card of targets(effect, ownerId, cards)) {
|
||||
const effectTargets = targets(effect, ownerId, cards).filter((card) =>
|
||||
effect.type !== 'all_parameter_up_for_character_grouping' || overrides?.generationBonusByCardId?.[card.id] === undefined
|
||||
);
|
||||
for (const card of effectTargets) {
|
||||
for (const stat of affectedStats(effect.type)) destination[card.id][stat] += normalizedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const [cardId, value] of Object.entries(overrides?.generationBonusByCardId ?? {})) {
|
||||
if (!flatByCardId[cardId]) continue;
|
||||
for (const stat of stats) flatByCardId[cardId][stat] += value;
|
||||
}
|
||||
|
||||
// 쿨타임 감소는 현재 보드 상태가 아니라 최적화 변수다. 모든 멤버가 네 경우를 항상 탐색한다.
|
||||
const allowedCooldownReductionsByCardId = Object.fromEntries(cards.map((card) => [
|
||||
card.id,
|
||||
@@ -184,6 +197,6 @@ export function calculateBoardEffects(
|
||||
activationRateUpByCardId,
|
||||
allowedCooldownReductionsByCardId,
|
||||
scoreSupportPercent,
|
||||
directSongScoreBonusPercent: Math.min(10, directSongScoreBonusPercent)
|
||||
directSongScoreBonusPercent: overrides?.directSongScoreBonusPercent ?? Math.min(10, directSongScoreBonusPercent)
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user