15 lines
610 B
TypeScript
15 lines
610 B
TypeScript
/** 队列只控制未来普通局;STOP 不回滚已经提交的当前局。 / The queue controls future paid rounds; stopping never rolls back the committed spin. */
|
|
export class AutoSpinQueue {
|
|
active = false;
|
|
remaining = 0;
|
|
start(count: number): void {
|
|
if (![10, 25, 50, 100].includes(count) || this.active) throw new Error('Invalid automatic spin request');
|
|
this.remaining = count; this.active = true;
|
|
}
|
|
consume(): void {
|
|
if (!this.active || this.remaining <= 0) throw new Error('No automatic spin remains');
|
|
this.remaining--;
|
|
}
|
|
stop(): void { this.active = false; this.remaining = 0; }
|
|
}
|