All files / player-browser/src/skins/synesthesia burst-budget.ts

100% Statements 10/10
100% Branches 4/4
100% Functions 2/2
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57                26x                         5x   1x   1x   3x         26x           26x                           18x 18x 18x    
import type { BeMusicSkinChoiceSetting, BeMusicSkinSettingValues } from '@be-music/player-skin-sdk';
 
/**
 * Spark budget for Synesthesia bombs. A lone hit throws its full burst; when many hits overlap, the frame's total grain
 * count is capped and shared between them, so a dense chord or a chart's busiest passage costs about as much to draw
 * as a few hits — the overlapping additive light reads just as full either way.
 */
 
export const JUDGMENT_PARTICLES_SETTING = {
  kind: 'choice',
  id: 'judgmentParticles',
  label: 'Judgment particles',
  options: [
    { value: 'normal', label: '通常' },
    { value: 'more', label: 'マシ' },
    { value: 'most', label: 'マシマシ' },
  ],
  default: 'normal',
} satisfies BeMusicSkinChoiceSetting;
 
export function judgmentParticleMultiplier(settings: BeMusicSkinSettingValues | undefined): number {
  switch (settings?.[JUDGMENT_PARTICLES_SETTING.id]) {
    case 'more':
      return 5;
    case 'most':
      return 10;
    default:
      return 2;
  }
}
 
/** Most spark grains drawn across every live bomb in one frame. */
export const BURST_FRAME_BUDGET = 960;
 
/**
 * Most skirt grains (the low powder that spreads along the judgement line under each burst) drawn across every live
 * bomb in one frame; budgeted apart from the sparks so the skirt never thins the fountain.
 */
export const BURST_SKIRT_FRAME_BUDGET = 720;
 
/**
 * Grains one bomb draws: its tier-scaled burst (`base + perTier × tier`, scaled by the effects `amount`), capped by an
 * even share of `budget` (the frame's grain budget, {@link BURST_FRAME_BUDGET} by default) among `liveBombs`.
 */
export function burstGrainCount(
  base: number,
  perTier: number,
  tier: number,
  amount: number,
  liveBombs: number,
  budget: number = BURST_FRAME_BUDGET,
): number {
  const wanted = Math.max(0, Math.round((base + perTier * tier) * amount));
  const share = Math.floor(budget / Math.max(1, liveBombs));
  return Math.min(wanted, share);
}