configs

package
v0.9.3-unreachable-code.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PVPEnabled  = `enabled`
	PVPDisabled = `disabled`
	PVPOff      = `off`
	PVPLimited  = `limited`
)

Variables

View Source
var (
	ErrInvalidConfigName = errors.New("invalid config name")
	ErrLockedConfig      = errors.New("config name is locked")
)

Functions

func AddOverlayOverrides

func AddOverlayOverrides(dotMap map[string]any) error

func FindFullPath

func FindFullPath(inputKey string) (properKey string, typeName string)

func Flatten

func Flatten(input map[string]any) map[string]any

flatten recursively flattens a map[string]any. It supports both map[string]any and map[any]any values, which is useful when unmarshaling YAML.

func GetOverrides

func GetOverrides() map[string]any

func GetSecret

func GetSecret(v ConfigSecret) string

Usage: configs.GetSecret(c.DiscordWebhookUrl)

func ReloadConfig

func ReloadConfig() error

func SetVal

func SetVal(propertyPath string, newVal string) error

Types

type Config

type Config struct {
	// Start config subsections
	Server       Server       `yaml:"Server"`
	Memory       Memory       `yaml:"Memory"`
	LootGoblin   LootGoblin   `yaml:"LootGoblin"`
	Timing       Timing       `yaml:"Timing"`
	FilePaths    FilePaths    `yaml:"FilePaths"`
	GamePlay     GamePlay     `yaml:"GamePlay"`
	Integrations Integrations `yaml:"Integrations"`
	TextFormats  TextFormats  `yaml:"TextFormats"`
	Translation  Translation  `yaml:"Translation"`
	Network      Network      `yaml:"Network"`
	Scripting    Scripting    `yaml:"Scripting"`
	SpecialRooms SpecialRooms `yaml:"SpecialRooms"`
	Validation   Validation   `yaml:"Validation"`
	Roles        Roles        `yaml:"Roles"`
	// Plugins is a special case
	Modules Modules `yaml:"Modules"`
	// contains filtered or unexported fields
}

func GetConfig

func GetConfig() Config

func (Config) AllConfigData

func (c Config) AllConfigData(excludeStrings ...string) map[string]any

func (*Config) DotPaths

func (c *Config) DotPaths() map[string]any

func (Config) IsBannedName

func (c Config) IsBannedName(name string) (string, bool)

func (*Config) OverlayOverrides

func (c *Config) OverlayOverrides(dotMap map[string]any) error

OverlayDotMap overlays values from a dot-syntax map onto the Config.

func (Config) SeedInt

func (c Config) SeedInt() int64

func (*Config) SetOverrides

func (c *Config) SetOverrides(newOverrides map[string]any) error

func (*Config) Validate

func (c *Config) Validate()

Ensures certain ranges and defaults are observed

type ConfigBool

type ConfigBool bool

func (*ConfigBool) Set

func (c *ConfigBool) Set(value string) error

func (ConfigBool) String

func (c ConfigBool) String() string

type ConfigFloat

type ConfigFloat float64

func (*ConfigFloat) Set

func (c *ConfigFloat) Set(value string) error

func (ConfigFloat) String

func (c ConfigFloat) String() string

type ConfigInt

type ConfigInt int

func (*ConfigInt) Set

func (c *ConfigInt) Set(value string) error

func (ConfigInt) String

func (c ConfigInt) String() string

type ConfigSecret

type ConfigSecret string // special case string

func (*ConfigSecret) Set

func (c *ConfigSecret) Set(value string) error

func (ConfigSecret) String

func (c ConfigSecret) String() string

type ConfigSliceString

type ConfigSliceString []string

func (*ConfigSliceString) Set

func (c *ConfigSliceString) Set(value string) error

func (ConfigSliceString) String

func (c ConfigSliceString) String() string

type ConfigString

type ConfigString string

func (*ConfigString) Set

func (c *ConfigString) Set(value string) error

func (ConfigString) String

func (c ConfigString) String() string

type ConfigUInt64

type ConfigUInt64 uint64

func (*ConfigUInt64) Set

func (c *ConfigUInt64) Set(value string) error

func (ConfigUInt64) String

func (c ConfigUInt64) String() string

type ConfigValue

type ConfigValue interface {
	String() string
	Set(string) error
}

func StringToConfigValue

func StringToConfigValue(strVal string, typeName string) ConfigValue

type FilePaths

type FilePaths struct {
	WebDomain        ConfigString `yaml:"WebDomain"`
	WebCDNLocation   ConfigString `yaml:"WebCDNLocation"`
	DataFiles        ConfigString `yaml:"DataFiles"`
	PublicHtml       ConfigString `yaml:"PublicHtml"`
	AdminHtml        ConfigString `yaml:"AdminHtml"`
	HttpsCertFile    ConfigString `yaml:"HttpsCertFile"`
	HttpsKeyFile     ConfigString `yaml:"HttpsKeyFile"`
	CarefulSaveFiles ConfigBool   `yaml:"CarefulSaveFiles"`
}

func GetFilePathsConfig

func GetFilePathsConfig() FilePaths

func (*FilePaths) Validate

func (f *FilePaths) Validate()

type GamePlay

type GamePlay struct {
	AllowItemBuffRemoval ConfigBool `yaml:"AllowItemBuffRemoval"`
	// Death related settings
	Death GameplayDeath `yaml:"Death"`

	LivesStart     ConfigInt `yaml:"LivesStart"`     // Starting permadeath lives
	LivesMax       ConfigInt `yaml:"LivesMax"`       // Maximum permadeath lives
	LivesOnLevelUp ConfigInt `yaml:"LivesOnLevelUp"` // # lives gained on level up
	PricePerLife   ConfigInt `yaml:"PricePerLife"`   // Price in gold to buy new lives
	// Shops/Conatiners
	ShopRestockRate  ConfigString `yaml:"ShopRestockRate"`  // Default time it takes to restock 1 quantity in shops
	ContainerSizeMax ConfigInt    `yaml:"ContainerSizeMax"` // How many objects containers can hold before overflowing
	// Alt chars
	MaxAltCharacters ConfigInt `yaml:"MaxAltCharacters"` // How many characters beyond the default character can they create?
	// Combat
	ConsistentAttackMessages ConfigBool `yaml:"ConsistentAttackMessages"` // Whether each weapon has consistent attack messages

	// PVP Restrictions
	PVP             ConfigString `yaml:"PVP"`
	PVPMinimumLevel ConfigInt    `yaml:"PVPMinimumLevel"`
	// XpScale (difficulty)
	XPScale           ConfigFloat `yaml:"XPScale"`
	MobConverseChance ConfigInt   `yaml:"MobConverseChance"` // Chance 1-100 of attempting to converse when idle
}

func GetGamePlayConfig

func GetGamePlayConfig() GamePlay

func (*GamePlay) Validate

func (g *GamePlay) Validate()

type GameplayDeath

type GameplayDeath struct {
	EquipmentDropChance ConfigFloat  `yaml:"EquipmentDropChance"` // Chance a player will drop a given piece of equipment on death
	AlwaysDropBackpack  ConfigBool   `yaml:"AlwaysDropBackpack"`  // If true, players will always drop their backpack items on death
	XPPenalty           ConfigString `yaml:"XPPenalty"`           // Possible values are: none, level, 10%, 25%, 50%, 75%, 90%, 100%
	ProtectionLevels    ConfigInt    `yaml:"ProtectionLevels"`    // How many levels is the user protected from death penalties for?
	PermaDeath          ConfigBool   `yaml:"PermaDeath"`          // Is permadeath enabled?
	CorpsesEnabled      ConfigBool   `yaml:"CorpsesEnabled"`      // Whether corpses are left behind after mob/player deaths
	CorpseDecayTime     ConfigString `yaml:"CorpseDecayTime"`     // How long until corpses decay to dust (go away)
}

type Integrations

type Integrations struct {
	Discord IntegrationsDiscord `yaml:"Discord"`
}

func GetIntegrationsConfig

func GetIntegrationsConfig() Integrations

func (*Integrations) Validate

func (i *Integrations) Validate()

type IntegrationsDiscord

type IntegrationsDiscord struct {
	WebhookUrl ConfigSecret `yaml:"WebhookUrl" env:"DISCORD_WEBHOOK_URL"` // Optional Discord URL to post updates to
}

type LootGoblin

type LootGoblin struct {
	// Item/floor cleanup
	RoomId             ConfigInt  `yaml:"RoomId"`             // The room the loot goblin spawns in
	RoundCount         ConfigInt  `yaml:"RoundCount"`         // How often to spawn a loot goblin
	MinimumItems       ConfigInt  `yaml:"MinimumItems"`       // How many items on the ground to attract the loot goblin
	MinimumGold        ConfigInt  `yaml:"MinimumGold"`        // How much gold on the ground to attract the loot goblin
	IncludeRecentRooms ConfigBool `yaml:"IncludeRecentRooms"` // should the goblin include rooms that have been visited recently?

}

func GetLootGoblinConfig

func GetLootGoblinConfig() LootGoblin

func (*LootGoblin) Validate

func (l *LootGoblin) Validate()

type Memory

type Memory struct {
	// Mob/Room memory unload thresholds
	MaxMobBoredom       ConfigInt `yaml:"MaxMobBoredom"`
	MobUnloadThreshold  ConfigInt `yaml:"MobUnloadThreshold"`
	RoomUnloadRounds    ConfigInt `yaml:"RoomUnloadRounds"`
	RoomUnloadThreshold ConfigInt `yaml:"RoomUnloadThreshold"`
}

func GetMemoryConfig

func GetMemoryConfig() Memory

func (*Memory) Validate

func (m *Memory) Validate()

type Modules

type Modules map[string]any

func GetModulesConfig

func GetModulesConfig() Modules

func (*Modules) Validate

func (p *Modules) Validate()

type Network

type Network struct {
	MaxTelnetConnections ConfigInt         `yaml:"MaxTelnetConnections"` // Maximum number of telnet connections to accept
	TelnetPort           ConfigSliceString `yaml:"TelnetPort"`           // One or more Ports used to accept telnet connections
	LocalPort            ConfigInt         `yaml:"LocalPort"`            // Port used for admin connections, localhost only
	HttpPort             ConfigInt         `yaml:"HttpPort"`             // Port used for web requests
	HttpsPort            ConfigInt         `yaml:"HttpsPort"`            // Port used for web https requests
	HttpsRedirect        ConfigBool        `yaml:"HttpsRedirect"`        // If true, http traffic will be redirected to https
	AfkSeconds           ConfigInt         `yaml:"AfkSeconds"`           // How long until a player is marked as afk?
	MaxIdleSeconds       ConfigInt         `yaml:"MaxIdleSeconds"`       // How many seconds a player can go without a command in game before being kicked.
	TimeoutMods          ConfigBool        `yaml:"TimeoutMods"`          // Whether to kick admin/mods when idle too long.
	ZombieSeconds        ConfigInt         `yaml:"ZombieSeconds"`        // How many seconds a player will be a zombie allowing them to reconnect.
	LogoutRounds         ConfigInt         `yaml:"LogoutRounds"`         // How many rounds of uninterrupted meditation must be completed to log out.
}

func GetNetworkConfig

func GetNetworkConfig() Network

func (*Network) Validate

func (n *Network) Validate()

type Roles

type Roles map[string]ConfigSliceString

func GetRolesConfig

func GetRolesConfig() Roles

func (*Roles) Validate

func (m *Roles) Validate()

type Scripting

type Scripting struct {
	LoadTimeoutMs ConfigInt `yaml:"LoadTimeoutMs"` // How long to spend the first time a script is loaded into memory
	RoomTimeoutMs ConfigInt `yaml:"RoomTimeoutMs"` // How many milliseconds to allow a script to run before it is interrupted
}

func GetScriptingConfig

func GetScriptingConfig() Scripting

func (*Scripting) Validate

func (s *Scripting) Validate()

type Server

type Server struct {
	MudName         ConfigString      `yaml:"MudName"`         // Name of the MUD
	CurrentVersion  ConfigString      `yaml:"CurrentVersion"`  // Current version this mud has been updated to
	Seed            ConfigSecret      `yaml:"Seed"`            // Seed that may be used for generating content
	MaxCPUCores     ConfigInt         `yaml:"MaxCPUCores"`     // How many cores to allow for multi-core operations
	OnLoginCommands ConfigSliceString `yaml:"OnLoginCommands"` // Commands to run when a user logs in
	Motd            ConfigString      `yaml:"Motd"`            // Message of the day to display when a user logs in
	NextRoomId      ConfigInt         `yaml:"NextRoomId"`      // The next room id to use when creating a new room
	Locked          ConfigSliceString `yaml:"Locked"`          // List of locked config properties that cannot be changed without editing the file directly.
}

func GetServerConfig

func GetServerConfig() Server

func (*Server) Validate

func (s *Server) Validate()

type SpecialRooms

type SpecialRooms struct {
	StartRoom         ConfigInt         `yaml:"StartRoom"`         // Default starting room.
	DeathRecoveryRoom ConfigInt         `yaml:"DeathRecoveryRoom"` // Recovery room after dying.
	TutorialRooms     ConfigSliceString `yaml:"TutorialRooms"`     // List of all rooms that can be used to begin the tutorial process
}

func GetSpecialRoomsConfig

func GetSpecialRoomsConfig() SpecialRooms

func (*SpecialRooms) Validate

func (s *SpecialRooms) Validate()

type TextFormats

type TextFormats struct {
	Prompt                  ConfigString `yaml:"Prompt"`                  // The in-game status prompt style
	EnterRoomMessageWrapper ConfigString `yaml:"EnterRoomMessageWrapper"` // Special enter messages
	ExitRoomMessageWrapper  ConfigString `yaml:"ExitRoomMessageWrapper"`  // Special exit messages
	Time                    ConfigString `yaml:"Time"`                    // How to format time when displaying real time
	TimeShort               ConfigString `yaml:"TimeShort"`               // How to format time when displaying real time (shortform)
}

func GetTextFormatsConfig

func GetTextFormatsConfig() TextFormats

func (*TextFormats) Validate

func (m *TextFormats) Validate()

type Timing

type Timing struct {
	TurnMs            ConfigInt `yaml:"TurnMs"`
	RoundSeconds      ConfigInt `yaml:"RoundSeconds"`
	RoundsPerAutoSave ConfigInt `yaml:"RoundsPerAutoSave"`
	RoundsPerDay      ConfigInt `yaml:"RoundsPerDay"` // How many rounds are in a day
	NightHours        ConfigInt `yaml:"NightHours"`   // How many hours of night
	// contains filtered or unexported fields
}

func GetTimingConfig

func GetTimingConfig() Timing

func (Timing) MinutesToRounds

func (e Timing) MinutesToRounds(minutes int) int

func (Timing) MinutesToTurns

func (e Timing) MinutesToTurns(minutes int) int

func (Timing) RoundsToSeconds

func (e Timing) RoundsToSeconds(rounds int) int

func (Timing) SecondsToRounds

func (e Timing) SecondsToRounds(seconds int) int

func (Timing) SecondsToTurns

func (e Timing) SecondsToTurns(seconds int) int

func (Timing) TurnsPerAutoSave

func (e Timing) TurnsPerAutoSave() int

func (Timing) TurnsPerRound

func (e Timing) TurnsPerRound() int

func (Timing) TurnsPerSecond

func (e Timing) TurnsPerSecond() int

func (*Timing) Validate

func (e *Timing) Validate()

type Translation

type Translation struct {
	DefaultLanguage ConfigString      `yaml:"DefaultLanguage"` // Specify the default game language (fallback)
	Language        ConfigString      `yaml:"Language"`        // Specify the game language
	LanguagePaths   ConfigSliceString `yaml:"LanguagePaths"`   // Specify the game language file paths
}

func GetTranslationConfig

func GetTranslationConfig() Translation

func (*Translation) Validate

func (t *Translation) Validate()

type Validation

type Validation struct {
	NameSizeMin      ConfigInt         `yaml:"NameSizeMin"`
	NameSizeMax      ConfigInt         `yaml:"NameSizeMax"`
	PasswordSizeMin  ConfigInt         `yaml:"PasswordSizeMin"`
	PasswordSizeMax  ConfigInt         `yaml:"PasswordSizeMax"`
	NameRejectRegex  ConfigString      `yaml:"NameRejectRegex"`
	NameRejectReason ConfigString      `yaml:"NameRejectReason"`
	EmailOnJoin      ConfigString      `yaml:"EmailOnJoin"`
	BannedNames      ConfigSliceString `yaml:"BannedNames"` // List of names that are not allowed to be used
}

func GetValidationConfig

func GetValidationConfig() Validation

func (*Validation) Validate

func (v *Validation) Validate()

Jump to

Keyboard shortcuts

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