gametime

package
v0.9.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

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

func DeleteCalendar(name string) error

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 GetLastPeriod(periodName string, roundNumber uint64) uint64

func GetZodiac

func GetZodiac(year int) string

func IsNight

func IsNight() bool

func LoadGameTimeConfigs added in v0.9.8

func LoadGameTimeConfigs()

func MonthName

func MonthName(month int) string

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 SetTime

func SetTime(setToHour int, setToMinutes ...int)

Jumps the clock forward a specific hour/minutes Between 0 and 23

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 GetDate

func GetDate(forceRound ...uint64) GameDate

Gets the details of the current date

func (GameDate) Add

func (g GameDate) Add(adjustHours int, adjustDays int, adjustYears int) GameDate

func (GameDate) AddPeriod

func (g GameDate) AddPeriod(periodStr string) uint64

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()

func (GameDate) String

func (gd GameDate) String(symbolOnly ...bool) string

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL