MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / SaveCalendar

Function SaveCalendar

internal/gametime/admin.go:33–62  ·  view source on GitHub ↗

SaveCalendar upserts a named calendar into the in-memory store, applies the derived constants, and persists the full gametime.yaml to disk.

(name string, cfg CalendarConfig)

Source from the content-addressed store, hash-verified

31// SaveCalendar upserts a named calendar into the in-memory store, applies the
32// derived constants, and persists the full gametime.yaml to disk.
33func SaveCalendar(name string, cfg CalendarConfig) error {
34 if name == "" {
35 return fmt.Errorf("calendar name is required")
36 }
37 if cfg.RoundsPerDay < 24 {
38 return fmt.Errorf("rounds_per_day must be at least 24")
39 }
40 if cfg.DaysPerYear < 1 {
41 return fmt.Errorf("days_per_year must be at least 1")
42 }
43 if cfg.DaysPerWeek < 1 {
44 return fmt.Errorf("days_per_week must be at least 1")
45 }
46 if len(cfg.Months) == 0 {
47 return fmt.Errorf("months list cannot be empty")
48 }
49 if len(cfg.Zodiac) == 0 {
50 return fmt.Errorf("zodiac list cannot be empty")
51 }
52
53 gameTimeData.Calendars[name] = cfg
54 applyCalendarConfig(name, cfg)
55
56 if err := saveGameTimeFile(); err != nil {
57 return err
58 }
59
60 mudlog.Info("gametime.SaveCalendar", "calendar", name)
61 return nil
62}
63
64// DeleteCalendar removes a named calendar from the in-memory store and
65// persists the change to disk. The "default" calendar cannot be deleted.

Callers 2

Calls 3

InfoFunction · 0.92
applyCalendarConfigFunction · 0.85
saveGameTimeFileFunction · 0.85

Tested by

no test coverage detected