Interface TimeProvider

All Known Implementing Classes:
Game, TimeProvider.Timed, TimeProvider.Untimed

public interface TimeProvider
Provides timing information for recording the history of a game.
  • Method Details

    • isTimed

      boolean isTimed()
      Checks whether this time provider produces values other than zero.
      Returns:
      Whether this time provider produces values other than zero.
    • getGameStartEpochMs

      long getGameStartEpochMs()
      Gets the start time of the game in milliseconds since the epoch. If this provider is untimed, 0 will be returned instead.
      Returns:
      The start time of the game in milliseconds since the epoch.
    • getGameStartTime

      @Nullable default ZonedDateTime getGameStartTime()
      Gets the start time of the game, or null if the start time is not recorded. If this provider is untimed, 0 will be returned instead.
      Returns:
      The start time of the game, or else null.
    • getTimeSinceGameStartMs

      long getTimeSinceGameStartMs()
      Gets the number of milliseconds elapsed since the start of the game.
      Returns:
      The number of milliseconds elapsed since the start of the game.
    • createStartingNow

      static TimeProvider createStartingNow()
      Creates a new time provider where the game starts now.
      Returns:
      A new time provider where the game starts now.
    • createStartingAtEpochMs

      static TimeProvider createStartingAtEpochMs(long epochMs)
      Creates a new time provider where the game starts at the given time.
      Returns:
      A new time provider where the game starts at the given time.
    • createUntimed

      static TimeProvider createUntimed()
      Creates a new time provider where the game is not timed.
      Returns:
      A new time provider where the game is not timed.
    • fromMetadata

      static TimeProvider fromMetadata(GameMetadata metadata)
      Creates a new time provider that takes the game start time from the given metadata.
      Parameters:
      metadata - The metadata to source the game start time from.
      Returns:
      A new time provider that takes the game start time from metadata.