mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-19 13:27:34 +00:00
visibleAt (#3497)
## Description: needs prereq of https://github.com/openfrontio/infra/pull/272 ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: w.o.n
This commit is contained in:
@@ -87,6 +87,8 @@ export class GameServer {
|
||||
|
||||
private lobbyInfoIntervalId: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
private visibleAt?: number;
|
||||
|
||||
constructor(
|
||||
public readonly id: string,
|
||||
readonly log_: Logger,
|
||||
@@ -98,6 +100,9 @@ export class GameServer {
|
||||
private publicGameType?: PublicGameType,
|
||||
) {
|
||||
this.log = log_.child({ gameID: id });
|
||||
if (startsAt !== undefined) {
|
||||
this.visibleAt = Date.now();
|
||||
}
|
||||
}
|
||||
|
||||
private get lobbyCreatorID(): ClientID | undefined {
|
||||
@@ -558,6 +563,8 @@ export class GameServer {
|
||||
|
||||
public setStartsAt(startsAt: number) {
|
||||
this.startsAt = startsAt;
|
||||
// Record when the lobby first became visible to players, used to measure lobby fill time.
|
||||
this.visibleAt ??= Date.now();
|
||||
}
|
||||
|
||||
public numClients(): number {
|
||||
@@ -656,6 +663,7 @@ export class GameServer {
|
||||
const result = GameStartInfoSchema.safeParse({
|
||||
gameID: this.id,
|
||||
lobbyCreatedAt: this.createdAt,
|
||||
visibleAt: this.visibleAt,
|
||||
config: this.gameConfig,
|
||||
players: this.activeClients.map((c) => ({
|
||||
username: c.username,
|
||||
@@ -1001,6 +1009,7 @@ export class GameServer {
|
||||
Date.now(),
|
||||
this.winner?.winner,
|
||||
this.createdAt,
|
||||
this.visibleAt,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user