datetime

package
v0.1.0-preview.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package datetime owns the Britannian calendar and calendar-derived presentation phases.

Index

Constants

View Source
const (
	DaysInMonth           = 28
	MonthsPerYear         = 13
	MinutesPerHour        = 60
	HoursPerDay           = 24
	MaximumAdvanceMinutes = MinutesPerHour * 9
)

Calendar dimensions and the maximum supported interval per advancement call.

Variables

This section is empty.

Functions

This section is empty.

Types

type BritannianDate

type BritannianDate struct {
	Year  uint16
	Month byte
	Day   byte
}

BritannianDate is an in-game calendar date without time-of-day or turn state.

func (BritannianDate) IsValid

func (d BritannianDate) IsValid() bool

IsValid reports whether the date is inside the Britannian calendar range.

type MoonPhase

type MoonPhase int

MoonPhase represents the 8 moon phases for moongate transportation Based on original Ultima V moon phase system (0-7)

const (
	MoonPhaseNew            MoonPhase = iota // 0
	MoonPhaseCrescentWaxing                  // 1
	MoonPhaseFirstQuarter                    // 2
	MoonPhaseGibbousWaxing                   // 3
	MoonPhaseFull                            // 4
	MoonPhaseGibbousWaning                   // 5
	MoonPhaseLastQuarter                     // 6
	MoonPhaseCrescentWaning                  // 7
)

Lunar phases in their original cyclic order.

func (MoonPhase) String

func (mp MoonPhase) String() string

String returns the string representation of the moon phase

func (MoonPhase) ToMoonstoneIndex

func (mp MoonPhase) ToMoonstoneIndex() int

ToMoonstoneIndex converts moon phase to moonstone index (0-7) Each moon phase corresponds to a specific moonstone for moongate travel

type TimeOfDay

type TimeOfDay int

TimeOfDay identifies a convenient calendar preset.

const (
	Morning TimeOfDay = iota
	Noon
	Evening
	Midnight
	Dusk
)

Calendar presets used by setup and debug controls.

type UltimaDate

type UltimaDate struct {
	Year   uint16
	Month  byte
	Day    byte
	Hour   byte
	Minute byte
	Turn   uint32
}

UltimaDate records the authoritative calendar and turn count.

func (*UltimaDate) Advance

func (d *UltimaDate) Advance(nMinutes int)

Advance applies one bounded calendar interval and increments the turn count.

func (UltimaDate) DateOnly

func (d UltimaDate) DateOnly() BritannianDate

DateOnly returns the Britannian calendar date represented by d.

func (*UltimaDate) GetAmbientTintDarkness

func (d *UltimaDate) GetAmbientTintDarkness() float32

GetAmbientTintDarkness returns the cosmetic night-tint strength from 0 to 1. REDUX DEVIATION: Original sight changes in steps during hours 5 (ref:LIGHT-0001) and 19. Redux fades only the ambient tint during 05:00-05:30 and 19:30-20:00 so dawn and dusk change smoothly without altering tile visibility.

func (*UltimaDate) GetCurrentMoonPhase

func (d *UltimaDate) GetCurrentMoonPhase() MoonPhase

GetCurrentMoonPhase returns Trammel's phase for compatibility with displays that represent one moon. Moongate routing uses GetMoongateMoonPhase.

func (*UltimaDate) GetDateAsString

func (d *UltimaDate) GetDateAsString() string

GetDateAsString formats the calendar as month-day-year.

func (*UltimaDate) GetFeluccaMoonPhase

func (d *UltimaDate) GetFeluccaMoonPhase() MoonPhase

GetFeluccaMoonPhase returns Felucca's phase for the current day; ref:MOON-0002.

func (*UltimaDate) GetMoongateMoonPhase

func (d *UltimaDate) GetMoongateMoonPhase() MoonPhase

GetMoongateMoonPhase selects Trammel before noon and Felucca from noon onward; ref:MOON-0003.

func (*UltimaDate) GetTimeAsString

func (d *UltimaDate) GetTimeAsString() string

GetTimeAsString formats the clock with an AM/PM suffix.

func (*UltimaDate) GetTotalDays

func (d *UltimaDate) GetTotalDays() int

GetTotalDays returns the total number of days since the start of the game. Ultima V uses Year 1, Month 1, Day 1 as the epoch.

func (*UltimaDate) GetTrammelMoonPhase

func (d *UltimaDate) GetTrammelMoonPhase() MoonPhase

GetTrammelMoonPhase returns Trammel's phase for the current day; ref:MOON-0002.

func (*UltimaDate) GetVisibilityFactorWithoutTorch

func (d *UltimaDate) GetVisibilityFactorWithoutTorch(baselineMin float32) float32

GetVisibilityFactorWithoutTorch returns a 0–1 visibility factor (despite the word “Percent” in the name).

func (*UltimaDate) IsDayLight

func (d *UltimaDate) IsDayLight() bool

IsDayLight reports the broad daytime window, including twilight.

func (*UltimaDate) IsFullDaylight

func (d *UltimaDate) IsFullDaylight() bool

IsFullDaylight returns true during full daylight hours (after dawn, before dusk). Ordinary original ambient sight reaches 50 only during hours 6-18 (ref:LIGHT-0001). Cosmetic dusk interpolation is independent of this lighthouse activation boundary.

func (*UltimaDate) IsNight

func (d *UltimaDate) IsNight() bool

IsNight reports whether the clock is outside the daytime window.

func (*UltimaDate) IsVisibilityDaylight

func (d *UltimaDate) IsVisibilityDaylight() bool

IsVisibilityDaylight preserves Redux's daylight visibility window separately from the original lighthouse sight threshold. Cosmetic dusk does not reduce LOS.

func (*UltimaDate) IsWithinFirstMonth

func (d *UltimaDate) IsWithinFirstMonth() bool

IsWithinFirstMonth returns true if the game is within the first in-game month. Used for "easy mode" where monster counts are reduced. Opening-campaign state reduces eligible encounter counts; ref:TIME-0007.

func (*UltimaDate) SetTimeOfDay

func (d *UltimaDate) SetTimeOfDay(timeOfDay TimeOfDay)

SetTimeOfDay selects a preset hour.

Jump to

Keyboard shortcuts

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