All files / app-play/src/services play-options.ts

99.27% Statements 137/138
96.72% Branches 59/61
100% Functions 10/10
100% Lines 133/133

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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500                                                                                                                                                                                                                                                                        9x                                                                                                                                                                                                                                                       9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x   9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x                             11x 11x               13x 13x 11x 11x                                                           13x 374x 11x 11x 11x         19x         19x       128x         290x               27x 565x 27x       4x                                                                        
import type { BeMusicReplay } from '@be-music/player-engine/replay';
import type { RulesetId } from '@be-music/player-engine/ruleset';
// The play options the player hands to every screen and play: the full `PlayOptions`, kept here rather than read back
// from the select screen. The Options dialog holds some of them itself (auto play, gauge, lane options, assists, sort and
// filters, hi-speed, covers, BGA and the score graph); the rest (the 2P gauge) are only
// changed on a select screen, and live here between screens, so a select screen made again (another skin system or
// theme) starts from them.
 
import { resolvePlayOptions, type PlayOptions } from '@be-music/player-scene-model';
import type { PlayerGUIState } from '../types.ts';
 
/** The play options the Options dialog holds itself, under its own names (`gauge` is `gauge1P`). */
export type GUIPlayOptions = Pick<
  PlayerGUIState,
  | 'autoPlay'
  | 'gauge'
  | 'hRandomThresholdBPM'
  | 'randomSeed1P'
  | 'randomSeed2P'
  | 'randomFixedLane1P'
  | 'randomFixedLane2P'
  | 'lr2RandomScratch1P'
  | 'lr2RandomScratch2P'
  | 'random1P'
  | 'random2P'
  | 'dpFlip'
  | 'bpmGuide'
  | 'bpmChangeWarning'
  | 'guideSE'
  | 'windowHold'
  | 'judgeCounts'
  | 'judgeDetailSplit'
  | 'judgeDetail'
  | 'scoreTargetRate'
  | 'judgePosition'
  | 'judgeDisplay'
  | 'laneBrightness'
  | 'scoreTarget'
  | 'markProcessedNotes'
  | 'showJudgeArea'
  | 'lr2AddMines'
  | 'lr2AddLongNotes'
  | 'lr2Loudness'
  | 'lr2AddNotes'
  | 'lr2Gambol'
  | 'lr2SideJump'
  | 'lr2SpiralEffect'
  | 'lr2Wave'
  | 'lr2SinCurve'
  | 'lr2Nabeatsu'
  | 'lr2Heartbeat'
  | 'lr2Char'
  | 'lr2SuperLoop'
  | 'lr2Tornado'
  | 'lr2Earthquake'
  | 'lr2Acceleration'
  | 'autoScratchNotes'
  | 'judgeTimingAutoAdjust'
  | 'visualConstant'
  | 'lift1P'
  | 'lift2P'
  | 'liftOn1P'
  | 'liftOn2P'
  | 'noteDurationMs'
  | 'constantFadeMs'
  | 'judgeTimingMs'
  | 'normalHiSpeedLevel'
  | 'classicHiSpeed'
  | 'floatingHiSpeed'
  | 'fixedDisplayArea'
  | 'judgeAlgorithm'
  | 'scrollSection'
  | 'scrollRate'
  | 'scrollModifier'
  | 'mineModifier'
  | 'crazyJudge'
  | 'crazyHellJudge'
  | 'crazyAddMine'
  | 'crazyNotes'
  | 'gaugeAutoShift'
  | 'bmsonTotalMode'
  | 'bottomShiftableGauge'
  | 'longNoteModifier'
  | 'longNoteRate'
  | 'sevenToNinePattern'
  | 'sevenToNineType'
  | 'battleMode'
  | 'dBattleScratch'
  | 'gauge2P'
  | 'mRan1P'
  | 'mRan2P'
  | 'longNoteMode'
  | 'customJudge'
  | 'practice'
  | 'practiceGauge'
  | 'practiceGaugeCategory'
  | 'practiceStartGauge'
  | 'practiceJudgeRank'
  | 'practiceTotal'
  | 'practiceRestBefore'
  | 'practiceRestAfter'
  | 'practiceCarriedLongNotes'
  | 'customJudgeKeyPerfectGreat'
  | 'customJudgeKeyGreat'
  | 'customJudgeKeyGood'
  | 'customJudgeScratchPerfectGreat'
  | 'customJudgeScratchGreat'
  | 'customJudgeScratchGood'
  | 'customJudgeLongNoteMargin'
  | 'lr2ExtraMode'
  | 'lr2ExtraLevel'
  | 'extraNoteDepth'
  | 'extraNoteScratch'
  | 'autoScratch1P'
  | 'autoScratch2P'
  | 'sort'
  | 'keysFilter'
  | 'difficultyFilter'
  | 'hiSpeed'
  | 'hsFix'
  | 'displayAreaInfo'
  | 'bga'
  | 'bgaSize'
  | 'scoreGraph'
  | 'hiddenSudden1P'
  | 'hiddenSudden2P'
  | 'laneCover'
  | 'shutter'
>;
 
/** The Options dialog's play options as `PlayOptions` fields. */
export function playOptionsFromGUI(state: Readonly<GUIPlayOptions>): Partial<PlayOptions> {
  return {
    autoPlay: state.autoPlay,
    gauge1P: state.gauge,
    random1P: state.random1P,
    hRandomThresholdBPM: state.hRandomThresholdBPM,
    randomSeed1P: state.randomSeed1P,
    randomSeed2P: state.randomSeed2P,
    randomFixedLane1P: state.randomFixedLane1P,
    randomFixedLane2P: state.randomFixedLane2P,
    lr2RandomScratch1P: state.lr2RandomScratch1P,
    lr2RandomScratch2P: state.lr2RandomScratch2P,
    random2P: state.random2P,
    dpFlip: state.dpFlip,
    bpmGuide: state.bpmGuide,
    bpmChangeWarning: state.bpmChangeWarning,
    guideSE: state.guideSE,
    windowHold: state.windowHold,
    judgeCounts: state.judgeCounts,
    judgeDetailSplit: state.judgeDetailSplit,
    judgeDetail: state.judgeDetail,
    scoreTargetRate: state.scoreTargetRate,
    judgePosition: state.judgePosition,
    judgeDisplay: state.judgeDisplay,
    laneBrightness: state.laneBrightness,
    scoreTarget: state.scoreTarget,
    markProcessedNotes: state.markProcessedNotes,
    showJudgeArea: state.showJudgeArea,
    lr2AddMines: state.lr2AddMines,
    lr2AddLongNotes: state.lr2AddLongNotes,
    lr2Loudness: state.lr2Loudness,
    lr2AddNotes: state.lr2AddNotes,
    lr2Gambol: state.lr2Gambol,
    lr2SideJump: state.lr2SideJump,
    lr2SpiralEffect: state.lr2SpiralEffect,
    lr2Wave: state.lr2Wave,
    lr2SinCurve: state.lr2SinCurve,
    lr2Nabeatsu: state.lr2Nabeatsu,
    lr2Heartbeat: state.lr2Heartbeat,
    lr2Char: state.lr2Char,
    lr2SuperLoop: state.lr2SuperLoop,
    lr2Tornado: state.lr2Tornado,
    lr2Earthquake: state.lr2Earthquake,
    lr2Acceleration: state.lr2Acceleration,
    autoScratchNotes: state.autoScratchNotes,
    judgeTimingAutoAdjust: state.judgeTimingAutoAdjust,
    visualConstant: state.visualConstant,
    noteDurationMs: state.noteDurationMs,
    lift1P: state.lift1P,
    lift2P: state.lift2P,
    liftOn1P: state.liftOn1P,
    liftOn2P: state.liftOn2P,
 
    constantFadeMs: state.constantFadeMs,
    judgeTimingMs: state.judgeTimingMs,
    normalHiSpeedLevel: state.normalHiSpeedLevel,
    classicHiSpeed: state.classicHiSpeed,
    floatingHiSpeed: state.floatingHiSpeed,
    fixedDisplayArea: state.fixedDisplayArea,
    judgeAlgorithm: state.judgeAlgorithm,
    longNoteModifier: state.longNoteModifier,
    longNoteRate: state.longNoteRate,
    sevenToNinePattern: state.sevenToNinePattern,
    sevenToNineType: state.sevenToNineType,
    battleMode: state.battleMode,
    dBattleScratch: state.dBattleScratch,
    gauge2P: state.gauge2P,
    mRan1P: state.mRan1P,
    mRan2P: state.mRan2P,
    longNoteMode: state.longNoteMode,
    customJudge: state.customJudge,
    practice: state.practice,
    practiceGauge: state.practiceGauge,
    practiceGaugeCategory: state.practiceGaugeCategory,
    practiceStartGauge: state.practiceStartGauge,
    practiceJudgeRank: state.practiceJudgeRank,
    practiceTotal: state.practiceTotal,
    practiceRestBefore: state.practiceRestBefore,
    practiceRestAfter: state.practiceRestAfter,
    practiceCarriedLongNotes: state.practiceCarriedLongNotes,
    customJudgeKeyPerfectGreat: state.customJudgeKeyPerfectGreat,
    customJudgeKeyGreat: state.customJudgeKeyGreat,
    customJudgeKeyGood: state.customJudgeKeyGood,
    customJudgeScratchPerfectGreat: state.customJudgeScratchPerfectGreat,
    customJudgeScratchGreat: state.customJudgeScratchGreat,
    customJudgeScratchGood: state.customJudgeScratchGood,
    customJudgeLongNoteMargin: state.customJudgeLongNoteMargin,
    lr2ExtraMode: state.lr2ExtraMode,
    lr2ExtraLevel: state.lr2ExtraLevel,
    extraNoteDepth: state.extraNoteDepth,
    extraNoteScratch: state.extraNoteScratch,
    mineModifier: state.mineModifier,
    crazyJudge: state.crazyJudge,
    crazyHellJudge: state.crazyHellJudge,
    crazyAddMine: state.crazyAddMine,
    crazyNotes: state.crazyNotes,
    scrollModifier: state.scrollModifier,
    scrollSection: state.scrollSection,
    scrollRate: state.scrollRate,
    gaugeAutoShift: state.gaugeAutoShift,
    bmsonTotalMode: state.bmsonTotalMode,
    bottomShiftableGauge: state.bottomShiftableGauge,
    autoScratch1P: state.autoScratch1P,
    autoScratch2P: state.autoScratch2P,
    sort: state.sort,
    keysFilter: state.keysFilter,
    difficultyFilter: state.difficultyFilter,
    hiSpeed: state.hiSpeed,
    hsFix: state.hsFix,
    displayAreaInfo: state.displayAreaInfo,
    bga: state.bga,
    bgaSize: state.bgaSize,
    scoreGraph: state.scoreGraph,
    hiddenSudden1P: state.hiddenSudden1P,
    hiddenSudden2P: state.hiddenSudden2P,
    laneCover: state.laneCover,
    shutter: state.shutter,
  };
}
 
/**
 * Mirrors a select screen's play options (an LR2 panel, a skin's buttons) into the Options dialog's state, so both surfaces
 * agree. The hi-speed is left to the caller, which also remembers it for the next visit.
 */
export function copyPlayOptionsToGUI(options: Readonly<PlayOptions>, state: GUIPlayOptions): void {
  state.hsFix = options.hsFix;
  state.displayAreaInfo = options.displayAreaInfo;
  state.bga = options.bga;
  state.bgaSize = options.bgaSize;
  state.scoreGraph = options.scoreGraph;
  state.hiddenSudden1P = options.hiddenSudden1P;
  state.hiddenSudden2P = options.hiddenSudden2P;
  state.laneCover = options.laneCover;
  state.shutter = options.shutter;
  state.autoPlay = options.autoPlay;
  state.gauge = options.gauge1P;
  state.random1P = options.random1P;
  state.hRandomThresholdBPM = options.hRandomThresholdBPM;
  state.randomSeed1P = options.randomSeed1P;
  state.randomSeed2P = options.randomSeed2P;
  state.randomFixedLane1P = options.randomFixedLane1P;
  state.randomFixedLane2P = options.randomFixedLane2P;
  state.lr2RandomScratch1P = options.lr2RandomScratch1P;
  state.lr2RandomScratch2P = options.lr2RandomScratch2P;
  state.random2P = options.random2P;
  state.dpFlip = options.dpFlip;
  state.bpmGuide = options.bpmGuide;
  state.bpmChangeWarning = options.bpmChangeWarning;
  state.guideSE = options.guideSE;
  state.windowHold = options.windowHold;
  state.judgeCounts = options.judgeCounts;
  state.judgeDetailSplit = options.judgeDetailSplit;
  state.judgeDetail = options.judgeDetail;
  state.scoreTargetRate = options.scoreTargetRate;
  state.judgePosition = options.judgePosition;
  state.judgeDisplay = options.judgeDisplay;
  state.laneBrightness = options.laneBrightness;
  state.scoreTarget = options.scoreTarget;
  state.markProcessedNotes = options.markProcessedNotes;
  state.showJudgeArea = options.showJudgeArea;
  state.lr2AddMines = options.lr2AddMines;
  state.lr2AddLongNotes = options.lr2AddLongNotes;
  state.lr2Loudness = options.lr2Loudness;
  state.lr2AddNotes = options.lr2AddNotes;
  state.lr2Gambol = options.lr2Gambol;
  state.lr2SideJump = options.lr2SideJump;
  state.lr2SpiralEffect = options.lr2SpiralEffect;
  state.lr2Wave = options.lr2Wave;
  state.lr2SinCurve = options.lr2SinCurve;
  state.lr2Nabeatsu = options.lr2Nabeatsu;
  state.lr2Heartbeat = options.lr2Heartbeat;
  state.lr2Char = options.lr2Char;
  state.lr2SuperLoop = options.lr2SuperLoop;
  state.lr2Tornado = options.lr2Tornado;
  state.lr2Earthquake = options.lr2Earthquake;
  state.lr2Acceleration = options.lr2Acceleration;
  state.autoScratchNotes = options.autoScratchNotes;
  state.judgeTimingAutoAdjust = options.judgeTimingAutoAdjust;
  state.visualConstant = options.visualConstant;
  state.noteDurationMs = options.noteDurationMs;
  state.lift1P = options.lift1P;
  state.lift2P = options.lift2P;
  state.liftOn1P = options.liftOn1P;
  state.liftOn2P = options.liftOn2P;
 
  state.constantFadeMs = options.constantFadeMs;
  state.judgeTimingMs = options.judgeTimingMs;
  state.normalHiSpeedLevel = options.normalHiSpeedLevel;
  state.classicHiSpeed = options.classicHiSpeed;
  state.floatingHiSpeed = options.floatingHiSpeed;
  state.fixedDisplayArea = options.fixedDisplayArea;
  state.judgeAlgorithm = options.judgeAlgorithm;
  state.longNoteModifier = options.longNoteModifier;
  state.longNoteRate = options.longNoteRate;
  state.sevenToNinePattern = options.sevenToNinePattern;
  state.sevenToNineType = options.sevenToNineType;
  state.battleMode = options.battleMode;
  state.dBattleScratch = options.dBattleScratch;
  state.gauge2P = options.gauge2P;
  state.mRan1P = options.mRan1P;
  state.mRan2P = options.mRan2P;
  state.longNoteMode = options.longNoteMode;
  state.customJudge = options.customJudge;
  state.practice = options.practice;
  state.practiceGauge = options.practiceGauge;
  state.practiceGaugeCategory = options.practiceGaugeCategory;
  state.practiceStartGauge = options.practiceStartGauge;
  state.practiceJudgeRank = options.practiceJudgeRank;
  state.practiceTotal = options.practiceTotal;
  state.practiceRestBefore = options.practiceRestBefore;
  state.practiceRestAfter = options.practiceRestAfter;
  state.practiceCarriedLongNotes = options.practiceCarriedLongNotes;
  state.customJudgeKeyPerfectGreat = options.customJudgeKeyPerfectGreat;
  state.customJudgeKeyGreat = options.customJudgeKeyGreat;
  state.customJudgeKeyGood = options.customJudgeKeyGood;
  state.customJudgeScratchPerfectGreat = options.customJudgeScratchPerfectGreat;
  state.customJudgeScratchGreat = options.customJudgeScratchGreat;
  state.customJudgeScratchGood = options.customJudgeScratchGood;
  state.customJudgeLongNoteMargin = options.customJudgeLongNoteMargin;
  state.lr2ExtraMode = options.lr2ExtraMode;
  state.lr2ExtraLevel = options.lr2ExtraLevel;
  state.extraNoteDepth = options.extraNoteDepth;
  state.extraNoteScratch = options.extraNoteScratch;
  state.mineModifier = options.mineModifier;
  state.crazyJudge = options.crazyJudge;
  state.crazyHellJudge = options.crazyHellJudge;
  state.crazyAddMine = options.crazyAddMine;
  state.crazyNotes = options.crazyNotes;
  state.scrollModifier = options.scrollModifier;
  state.scrollSection = options.scrollSection;
  state.scrollRate = options.scrollRate;
  state.gaugeAutoShift = options.gaugeAutoShift;
  state.bmsonTotalMode = options.bmsonTotalMode;
  state.bottomShiftableGauge = options.bottomShiftableGauge;
  state.autoScratch1P = options.autoScratch1P;
  state.autoScratch2P = options.autoScratch2P;
  state.sort = options.sort;
  state.keysFilter = options.keysFilter;
  state.difficultyFilter = options.difficultyFilter;
}
 
/**
 * The full play options in force, over `DEFAULT_PLAY_OPTIONS`. It takes every change from both surfaces: the select
 * screen's own (`on.playOptions`, its whole set) and the Options dialog's (one option at a time). Each change is checked
 * as the select screen checks it (`resolvePlayOptions`), so the two never drift apart.
 */
export class PlayOptionsService {
  private options: PlayOptions;
  private previousArrangement: { chartId: string; replay: Pick<BeMusicReplay, 'chart' | 'play'> } | undefined;
  private fixedArrangement: { chartId: string; replay: Pick<BeMusicReplay, 'chart' | 'play'> } | undefined;
 
  /** Retain the previous play's exact arrangement, including source control-flow draws, under any judge rules. */
  public rememberArrangement(chartId: string, replay: BeMusicReplay | undefined): void {
    Iif (replay === undefined) return;
    this.previousArrangement = { chartId, replay: structuredClone({ chart: replay.chart, play: replay.play }) };
  }
 
  /**
   * Pin the previous layout for a fresh play on the same chart; no recorded inputs are replayed. Only a play under the
   * same judge rules (`ruleset`) is reused: its options were chosen for them.
   */
  public reusePreviousArrangement(ruleset: RulesetId): Partial<PlayOptions> | undefined {
    const previous = this.previousArrangement;
    if (!previous || (previous.replay.play.judgeRuleset ?? 'lr2') !== ruleset) return undefined;
    const play = previous.replay.play;
    const source = resolvePlayOptions({
      ...play.options,
      random1P: play.randomLane?.p1 ?? play.options?.random1P,
      random2P: play.randomLane?.p2 ?? play.options?.random2P,
      dpFlip: play.dpFlip ?? play.options?.dpFlip,
      longNoteModifier: play.longNoteModifier ?? play.options?.longNoteModifier,
      longNoteRate: play.longNoteRate ?? play.options?.longNoteRate,
      sevenToNinePattern: play.sevenToNinePattern ?? 0,
      sevenToNineType: play.sevenToNineType ?? 0,
      hRandomThresholdBPM: play.sevenToNineThresholdBPM ?? play.options?.hRandomThresholdBPM,
      battleMode: play.battleMode ?? 'OFF',
      dBattleScratch: play.dBattleScratch ?? false,
      lr2AddNotes: play.lr2Mania?.addNotes ?? 0,
      lr2Loudness: play.lr2Mania?.loudness ?? 0,
      lr2AddLongNotes: play.lr2Mania?.addLongNotes ?? 0,
      lr2AddMines: play.lr2Mania?.addMines ?? 0,
      lr2ExtraMode: play.lr2ExtraMode ?? false,
      lr2ExtraLevel: play.lr2ExtraLevel ?? 0,
      extraNoteDepth: play.extraNoteDepth ?? 0,
      extraNoteScratch: play.extraNoteScratch ?? false,
      // A play recorded with nanasigroove's ADDMINE (`NANASI_ADD`) restores it as its own option, beside the Mines choice.
      mineModifier:
        play.mineModifier === 'NANASI_ADD'
          ? play.options?.mineModifier
          : (play.mineModifier ?? play.options?.mineModifier),
      crazyAddMine: play.mineModifier === undefined ? play.options?.crazyAddMine : play.mineModifier === 'NANASI_ADD',
      scrollModifier: play.scrollModifier ?? play.options?.scrollModifier,
      scrollSection: play.scrollSection ?? play.options?.scrollSection,
      scrollRate: play.scrollRate ?? play.options?.scrollRate,
    });
    const changes: Partial<PlayOptions> = {};
    for (const key of ARRANGEMENT_OPTIONS) Object.assign(changes, { [key]: source[key] });
    this.update(changes);
    this.fixedArrangement = structuredClone(previous);
    return changes;
  }
 
  /** Stop pinning the previous layout; explicit seed settings still apply. */
  public clearArrangement(): void {
    this.fixedArrangement = undefined;
  }
 
  /** A chart-specific copy prevents a reused layout from leaking to another chart. */
  public arrangementFor(chartId: string): Pick<BeMusicReplay, 'chart' | 'play'> | undefined {
    return this.fixedArrangement?.chartId === chartId ? structuredClone(this.fixedArrangement.replay) : undefined;
  }
 
  public constructor(initial: Readonly<Partial<PlayOptions>> = {}) {
    this.options = resolvePlayOptions(initial);
  }
 
  /** The play options in force, as a copy: what a select screen starts from, and what a decide screen and a play take. */
  public get current(): PlayOptions {
    return { ...this.options };
  }
 
  /**
   * Takes `changes` over the options in force. An option given a value it does not take goes back to its default, as
   * on the select screen.
   */
  public update(changes: Readonly<Partial<PlayOptions>>): void {
    const next = resolvePlayOptions({ ...this.options, ...changes });
    if (ARRANGEMENT_OPTIONS.some((key) => next[key] !== this.options[key])) this.clearArrangement();
    this.options = next;
  }
}
 
const ARRANGEMENT_OPTIONS = [
  'random1P',
  'random2P',
  'randomSeed1P',
  'randomSeed2P',
  'randomFixedLane1P',
  'randomFixedLane2P',
  'lr2RandomScratch1P',
  'lr2RandomScratch2P',
  'dpFlip',
  'hRandomThresholdBPM',
  'longNoteModifier',
  'longNoteRate',
  'sevenToNinePattern',
  'sevenToNineType',
  'battleMode',
  'dBattleScratch',
  'mRan1P',
  'mRan2P',
  'lr2ExtraMode',
  'lr2AddNotes',
  'lr2Loudness',
  'lr2AddLongNotes',
  'lr2AddMines',
  'lr2ExtraLevel',
  'extraNoteDepth',
  'extraNoteScratch',
  'mineModifier',
  'crazyJudge',
  'crazyHellJudge',
  'crazyAddMine',
  'crazyNotes',
  'scrollModifier',
  'scrollSection',
  'scrollRate',
] as const satisfies readonly (keyof PlayOptions)[];