Package net.royalur.rules
Interface TimeProvider
- All Known Implementing Classes:
Game
,TimeProvider.Timed
,TimeProvider.Untimed
public interface TimeProvider
Provides timing information for recording the history of a game.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
static class
-
Method Summary
Modifier and TypeMethodDescriptionstatic TimeProvider
createStartingAtEpochMs
(long epochMs) Creates a new time provider where the game starts at the given time.static TimeProvider
Creates a new time provider where the game starts now.static TimeProvider
Creates a new time provider where the game is not timed.static TimeProvider
fromMetadata
(GameMetadata metadata) Creates a new time provider that takes the game start time from the given metadata.long
Gets the start time of the game in milliseconds since the epoch.default ZonedDateTime
Gets the start time of the game, ornull
if the start time is not recorded.long
Gets the number of milliseconds elapsed since the start of the game.boolean
isTimed()
Checks whether this time provider produces values other than zero.
-
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
Gets the start time of the game, ornull
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
Creates a new time provider where the game starts now.- Returns:
- A new time provider where the game starts now.
-
createStartingAtEpochMs
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
Creates a new time provider where the game is not timed.- Returns:
- A new time provider where the game is not timed.
-
fromMetadata
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
.
-