Documentation
¶
Index ¶
- func CopyoverContributor() copyover.Contributor
- func DeleteCalendar(name string) error
- func GetCalendars() []string
- func GetLastPeriod(periodName string, roundNumber uint64) uint64
- func GetZodiac(year int) string
- func IsNight() bool
- func LoadGameTimeConfigs()
- func MonthName(month int) string
- func SaveCalendar(name string, cfg CalendarConfig) error
- func SetTime(setToHour int, setToMinutes ...int)
- func SetToDay(roundAdjustment ...int)
- func SetToNight(roundAdjustment ...int)
- type CalendarConfig
- type CalendarOptions
- type GameDate
- type RoundTimer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyoverContributor ¶ added in v0.9.8
func CopyoverContributor() copyover.Contributor
CopyoverContributor returns the gametime contributor for registration.
func DeleteCalendar ¶ added in v0.9.8
DeleteCalendar removes a named calendar from the in-memory store and persists the change to disk. The "default" calendar cannot be deleted.
func GetCalendars ¶ added in v0.9.8
func GetCalendars() []string
GetCalendars returns a sorted slice of calendar names from the loaded data.
func GetLastPeriod ¶
func LoadGameTimeConfigs ¶ added in v0.9.8
func LoadGameTimeConfigs()
func SaveCalendar ¶ added in v0.9.8
func SaveCalendar(name string, cfg CalendarConfig) error
SaveCalendar upserts a named calendar into the in-memory store, applies the derived constants, and persists the full gametime.yaml to disk.
func SetToDay ¶
func SetToDay(roundAdjustment ...int)
Jumps the clock forward to the next day If a roundAdjustment is provided, it will be added to the offset This is useful to set to the round right before the rollover
func SetToNight ¶
func SetToNight(roundAdjustment ...int)
Jumps the clock foward to the next night If a roundAdjustment is provided, it will be added to the offset This is useful to set to the round right before the rollover
Types ¶
type CalendarConfig ¶ added in v0.9.8
type CalendarConfig struct {
RoundsPerDay int `yaml:"rounds_per_day" json:"rounds_per_day"`
NightHours int `yaml:"night_hours" json:"night_hours"`
DuskHours int `yaml:"dusk_hours" json:"dusk_hours"`
DaysPerYear int `yaml:"days_per_year" json:"days_per_year"`
DaysPerWeek int `yaml:"days_per_week" json:"days_per_week"`
SunCount int `yaml:"sun_count" json:"sun_count"` // 1-2
MoonCount int `yaml:"moon_count" json:"moon_count"` // 0-3
Months []string `yaml:"months" json:"months"`
Zodiac []string `yaml:"zodiac" json:"zodiac"`
}
CalendarConfig holds the configuration for a single named calendar system.
func GetCalendar ¶ added in v0.9.8
func GetCalendar(name string) (CalendarConfig, bool)
GetCalendar returns the CalendarConfig for the named calendar, plus a bool indicating whether it was found.
type CalendarOptions ¶ added in v0.9.8
type CalendarOptions struct {
Calendars map[string]CalendarConfig `yaml:"calendars"`
}
CalendarOptions is the top-level structure for gametime.yaml.
func (CalendarOptions) GetCalendarConfig ¶ added in v0.9.8
func (o CalendarOptions) GetCalendarConfig(name string) CalendarConfig
type GameDate ¶
type GameDate struct {
// which calendar this gamedate uses
Calendar string
// The round number this GameDate represents
RoundNumber uint64
RoundsPerDay int
NightHoursPerDay int
Year int
Month int
Week int
Day int
Hour int
Hour24 int
Minute int
MinuteFloat float64
AmPm string
Night bool
DayStart int
NightStart int
DuskHours int
SunCount int
MoonCount int
}
func (GameDate) AddPeriod ¶
Example: gd := gametime.GetDate() nextPeriodRound := gd.AddPeriod(`10 days`) Accepts: x years, x months, x weeks, x days, x hours, x rounds If `IRL` or `real` are in the mix, such as `x irl days` or `x days irl`, then it will use real world time
func (*GameDate) ReCalculate ¶
func (g *GameDate) ReCalculate()
type RoundTimer ¶
type RoundTimer struct {
RoundStart uint64 `yaml:"roundstart,omitempty"`
Period string `yaml:"period,omitempty"`
// contains filtered or unexported fields
}
func (*RoundTimer) Expired ¶
func (r *RoundTimer) Expired() bool