Simplify
This commit is contained in:
parent
c318aca51a
commit
c8f040f3e4
5
actor.ts
5
actor.ts
|
@ -71,7 +71,6 @@ export class Turn {
|
|||
readonly actor: Actor;
|
||||
readonly queues: Map<Actor, LocalAction[]> = new Map();
|
||||
readonly localActions: Array<LocalAction> = [];
|
||||
completed = false;
|
||||
|
||||
static for(actor: Actor, f: (t: Turn) => void): void {
|
||||
const t = new Turn(actor);
|
||||
|
@ -137,9 +136,7 @@ export class Turn {
|
|||
this.queues.get(actor)?.push(a) ?? this.queues.set(actor, [a]);
|
||||
}
|
||||
|
||||
complete(): void {
|
||||
if (this.completed) throw new Error("Reuse of completed Turn!");
|
||||
this.completed = true;
|
||||
private complete(): void {
|
||||
this.queues.forEach((q, a) => a.execute(() => q.forEach(f => Turn.for(a, f))));
|
||||
if (this.localActions.length > 0) {
|
||||
queueMicrotask(() => this.localActions.forEach(f => Turn.for(this.actor, f)));
|
||||
|
|
Loading…
Reference in New Issue