diff --git a/TODO.txt b/TODO.txt index 1c8b2900f..4b849bd16 100644 --- a/TODO.txt +++ b/TODO.txt @@ -128,8 +128,9 @@ * comfirm alliance DONE 9/20/2024 * create event box DONE 9/20/2024 * BUG: left click lost after right click DONE 9/20/2024 -* make fake humans easier +* eventbox events dissapear after timeout DONE 9/20/2024 * first place has crown +* make fake humans easier * BUG: FakeHuman don't be enemy if don't share border * BUG: when send boat only captures one pixel * store cookies diff --git a/src/client/ClientGame.ts b/src/client/ClientGame.ts index b1c625cae..879d62502 100644 --- a/src/client/ClientGame.ts +++ b/src/client/ClientGame.ts @@ -167,7 +167,7 @@ export class ClientGame { } this.isProcessingTurn = true this.gs.addExecution(...this.executor.createExecs(this.turns[this.currTurn])) - this.gs.tick() + this.gs.executeNextTick() this.renderer.tick() this.currTurn++ this.isProcessingTurn = false diff --git a/src/client/graphics/layers/EventsDisplay.ts b/src/client/graphics/layers/EventsDisplay.ts index faa6ebd41..3543883f6 100644 --- a/src/client/graphics/layers/EventsDisplay.ts +++ b/src/client/graphics/layers/EventsDisplay.ts @@ -19,6 +19,7 @@ interface Event { action: () => void }[]; highlight?: boolean; + createdAt: number } export class EventsDisplay implements Layer { @@ -43,6 +44,14 @@ export class EventsDisplay implements Layer { } tick() { + const remainingEvent: Event[] = [] + for (const event of this.events) { + if (this.game.ticks() - event.createdAt < 100) { + remainingEvent.push(event) + } + } + this.events = remainingEvent + this.renderTable() } private createTableContainer() { @@ -87,7 +96,8 @@ export class EventsDisplay implements Layer { action: () => this.eventBus.emit(new AllianceRequestReplyUIEvent(event.allianceRequest, false)), } ], - highlight: true + highlight: true, + createdAt: this.game.ticks() }); this.renderTable() } @@ -101,10 +111,10 @@ export class EventsDisplay implements Layer { if (event.allianceRequest.requestor() != myPlayer) { return } - this.addEvent({ description: `${event.allianceRequest.recipient().name()} ${event.accepted ? "accepted" : "rejected"} your alliance request`, - highlight: true + highlight: true, + createdAt: this.game.ticks(), }); this.renderTable() } diff --git a/src/core/game/Game.ts b/src/core/game/Game.ts index 5a561a0fb..0627216d7 100644 --- a/src/core/game/Game.ts +++ b/src/core/game/Game.ts @@ -176,7 +176,7 @@ export interface Game { forEachTile(fn: (tile: Tile) => void): void executions(): ExecutionView[] terraNullius(): TerraNullius - tick(): void + executeNextTick(): void ticks(): number inSpawnPhase(): boolean addExecution(...exec: Execution[]): void diff --git a/src/core/game/GameImpl.ts b/src/core/game/GameImpl.ts index 74691f28a..7cb0a5565 100644 --- a/src/core/game/GameImpl.ts +++ b/src/core/game/GameImpl.ts @@ -85,7 +85,7 @@ export class GameImpl implements MutableGame { return this._ticks } - tick() { + executeNextTick() { this.execs.forEach(e => { if (e.isActive() && (!this.inSpawnPhase() || e.activeDuringSpawnPhase())) { e.tick(this._ticks)