events dissappear after 10s

This commit is contained in:
evanpelle
2024-09-20 20:01:18 -07:00
parent df99457867
commit a77831f4c8
5 changed files with 18 additions and 7 deletions
+2 -1
View File
@@ -128,8 +128,9 @@
* comfirm alliance DONE 9/20/2024 * comfirm alliance DONE 9/20/2024
* create event box DONE 9/20/2024 * create event box DONE 9/20/2024
* BUG: left click lost after right click 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 * first place has crown
* make fake humans easier
* BUG: FakeHuman don't be enemy if don't share border * BUG: FakeHuman don't be enemy if don't share border
* BUG: when send boat only captures one pixel * BUG: when send boat only captures one pixel
* store cookies * store cookies
+1 -1
View File
@@ -167,7 +167,7 @@ export class ClientGame {
} }
this.isProcessingTurn = true this.isProcessingTurn = true
this.gs.addExecution(...this.executor.createExecs(this.turns[this.currTurn])) this.gs.addExecution(...this.executor.createExecs(this.turns[this.currTurn]))
this.gs.tick() this.gs.executeNextTick()
this.renderer.tick() this.renderer.tick()
this.currTurn++ this.currTurn++
this.isProcessingTurn = false this.isProcessingTurn = false
+13 -3
View File
@@ -19,6 +19,7 @@ interface Event {
action: () => void action: () => void
}[]; }[];
highlight?: boolean; highlight?: boolean;
createdAt: number
} }
export class EventsDisplay implements Layer { export class EventsDisplay implements Layer {
@@ -43,6 +44,14 @@ export class EventsDisplay implements Layer {
} }
tick() { 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() { private createTableContainer() {
@@ -87,7 +96,8 @@ export class EventsDisplay implements Layer {
action: () => this.eventBus.emit(new AllianceRequestReplyUIEvent(event.allianceRequest, false)), action: () => this.eventBus.emit(new AllianceRequestReplyUIEvent(event.allianceRequest, false)),
} }
], ],
highlight: true highlight: true,
createdAt: this.game.ticks()
}); });
this.renderTable() this.renderTable()
} }
@@ -101,10 +111,10 @@ export class EventsDisplay implements Layer {
if (event.allianceRequest.requestor() != myPlayer) { if (event.allianceRequest.requestor() != myPlayer) {
return return
} }
this.addEvent({ this.addEvent({
description: `${event.allianceRequest.recipient().name()} ${event.accepted ? "accepted" : "rejected"} your alliance request`, description: `${event.allianceRequest.recipient().name()} ${event.accepted ? "accepted" : "rejected"} your alliance request`,
highlight: true highlight: true,
createdAt: this.game.ticks(),
}); });
this.renderTable() this.renderTable()
} }
+1 -1
View File
@@ -176,7 +176,7 @@ export interface Game {
forEachTile(fn: (tile: Tile) => void): void forEachTile(fn: (tile: Tile) => void): void
executions(): ExecutionView[] executions(): ExecutionView[]
terraNullius(): TerraNullius terraNullius(): TerraNullius
tick(): void executeNextTick(): void
ticks(): number ticks(): number
inSpawnPhase(): boolean inSpawnPhase(): boolean
addExecution(...exec: Execution[]): void addExecution(...exec: Execution[]): void
+1 -1
View File
@@ -85,7 +85,7 @@ export class GameImpl implements MutableGame {
return this._ticks return this._ticks
} }
tick() { executeNextTick() {
this.execs.forEach(e => { this.execs.forEach(e => {
if (e.isActive() && (!this.inSpawnPhase() || e.activeDuringSpawnPhase())) { if (e.isActive() && (!this.inSpawnPhase() || e.activeDuringSpawnPhase())) {
e.tick(this._ticks) e.tick(this._ticks)