TimeKeeper
in package
Configurable way to convert back and forth between real time and game time.
Table of Contents
- $adjustedEpoch : mixed
- $now : mixed
- $secondsPerDay : mixed
- $secondsPerGameDay : mixed
- $secondsPerGameHour : mixed
- $secondsPerGameMinute : mixed
- $secondsPerGameSecond : mixed
- $secondsPerGameYear : mixed
- $secondsPerHour : mixed
- $secondsPerMinute : mixed
- $theBeginning : mixed
- __construct() : mixed
- Construct a TimeKeeper with required configuration.
- convertFromGameTime() : DateTime
- Given a game time, convert it to a real time.
- convertToGameTime() : DateTime
- Given a real time, convert it to a game time.
- getGameTime() : DateTime
- Return the current game time.
- isNewDay() : bool
- Returns whether a user who is interating with the game now and last interacted at $lastInteractionTime should experience a New Day event.
- interval() : DateInterval
- Convenience method to generate a DateInterval from an exploded date.
Properties
$adjustedEpoch
private
mixed
$adjustedEpoch
$now
private
mixed
$now
$secondsPerDay
private
mixed
$secondsPerDay
= 60 * 60 * 24
$secondsPerGameDay
private
mixed
$secondsPerGameDay
$secondsPerGameHour
private
mixed
$secondsPerGameHour
$secondsPerGameMinute
private
mixed
$secondsPerGameMinute
$secondsPerGameSecond
private
mixed
$secondsPerGameSecond
$secondsPerGameYear
private
mixed
$secondsPerGameYear
$secondsPerHour
private
mixed
$secondsPerHour
= 60 * 60
$secondsPerMinute
private
mixed
$secondsPerMinute
= 60
$theBeginning
private
mixed
$theBeginning
Methods
__construct()
Construct a TimeKeeper with required configuration.
public
__construct(DateTime $gameEpoch, DateTime $now, int $gameOffsetSeconds, int $gameDaysPerDay) : mixed
Parameters
- $gameEpoch : DateTime
-
When in real time is game day 0.
- $now : DateTime
-
The current time.
- $gameOffsetSeconds : int
-
How many seconds from midnight on the epoch should the first game day start.
- $gameDaysPerDay : int
-
How many game days are in one real day.
Return values
mixed —convertFromGameTime()
Given a game time, convert it to a real time.
public
convertFromGameTime(DateTime $time) : DateTime
Parameters
- $time : DateTime
-
Game time to convert.
Return values
DateTime —Real time corresponding to game time $time.
convertToGameTime()
Given a real time, convert it to a game time.
public
convertToGameTime(DateTime $time) : DateTime
Parameters
- $time : DateTime
-
Real time to convert.
Return values
DateTime —Game time corresponding to real time $time.
getGameTime()
Return the current game time.
public
getGameTime() : DateTime
Return values
DateTime —isNewDay()
Returns whether a user who is interating with the game now and last interacted at $lastInteractionTime should experience a New Day event.
public
isNewDay(DateTime $lastInteractionTime) : bool
Parameters
- $lastInteractionTime : DateTime
Return values
bool —interval()
Convenience method to generate a DateInterval from an exploded date.
private
interval(int $years, int $days, int $hours, int $minutes, int $seconds) : DateInterval
Parameters
- $years : int
- $days : int
- $hours : int
- $minutes : int
- $seconds : int