mapper

package
v0.9.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	SecretSymbol = '?'
	LockedSymbol = '⚷'
)

Variables

View Source
var (
	ErrOutOfBounds  = errors.New(`out of bounds`)
	ErrRoomNotFound = errors.New(`room not found`)
)
View Source
var (
	ErrPathNotFound  = errors.New(`path not found`)
	ErrPathDestMatch = errors.New(`path destination is same as source`)
)

Functions

func AddMapper

func AddMapper(m *mapper, lookupRoomId int)

func AdjustExitName

func AdjustExitName(exitName string) (newExitName, newExitDirection string, err error)

AdjustExitName splits an exit identifier into a base name and an optional direction. Supported formats:

"east"           → ("east", "east", nil)
"east-x2"        → ("east", "east-x2", nil)
"cave"           → ("cave", "",      nil)
"cave:south"     → ("cave", "south", nil)
"cave:south-x2"  → ("cave", "south-x2", nil)

func GetDelta

func GetDelta(exitName string) (x, y, z int)

func GetDirectionDeltaNames

func GetDirectionDeltaNames() []string

func GetMapper

func GetMapper(roomId int, forceRefresh ...bool) *mapper

Get the mapper if it exists, otherwises generates a new map from the roomId

func GetMapperIfExists

func GetMapperIfExists(roomId int) *mapper

Returns the mapper if it exists, otherwise does nothing.

func GetPath

func GetPath(startRoomId int, endRoomId ...int) ([]pathStep, error)

func GetReciprocalExit

func GetReciprocalExit(exitDirection string) string

This is a useful function to help enforce map coherence when building

func IsCompassDirection

func IsCompassDirection(exitName string) bool

Returns true if exitName is a compass direction (north, south, east, west, northwest)

func IsValidDirection

func IsValidDirection(directionName string) bool

func IsValidExitDirection

func IsValidExitDirection(exitName string) bool

Returns true if exitName resolves to any position delta

func NewMapper

func NewMapper(rootRoomId int) *mapper

func PreCacheMaps

func PreCacheMaps()

Types

type Config

type Config struct {
	ZoomLevel int // How much to zoom the map? At zero, connections are not shown.
	Width     int // Width of final map render
	Height    int // Height of final map render
	UserId    int // Optional userId to intelligently render some data
	// contains filtered or unexported fields
}

func (*Config) OverrideSymbol

func (c *Config) OverrideSymbol(roomId int, symbol rune, legend string)

type RoomGrid

type RoomGrid struct {
	// contains filtered or unexported fields
}

type SymbolOverride

type SymbolOverride struct {
	Symbol rune
	Legend string
}

Jump to

Keyboard shortcuts

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