Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyColor(colorName, text string) string
- func AutoSave(game *Game, stop chan os.Signal)
- func Challenge(attacker, defender, balance float64) float64
- func ChangePassword(player *Player, oldPassword, newPassword string) error
- func ConfirmUser(email, confirmationCode string, config Configuration) (*cognitoidentityprovider.ConfirmSignUpOutput, error)
- func DisplayArchetypes(g *Game)
- func DisplayPrototypes(prototypes map[uuid.UUID]*Prototype)
- func DisplayRooms(rooms map[int64]*Room)
- func DisplayUnseenMOTDs(server *Server, player *Player)
- func EnableXRay(cfg *Configuration) error
- func ExecuteAdvanceCommand(character *Character, tokens []string) bool
- func ExecuteAssessCommand(character *Character, tokens []string) bool
- func ExecuteChallengeCommand(character *Character, tokens []string) bool
- func ExecuteCommand(character *Character, verb string, tokens []string) bool
- func ExecuteDropCommand(character *Character, tokens []string) bool
- func ExecuteExamineCommand(character *Character, tokens []string) bool
- func ExecuteFaceCommand(character *Character, tokens []string) bool
- func ExecuteGoCommand(character *Character, tokens []string) bool
- func ExecuteHelpCommand(character *Character, tokens []string) bool
- func ExecuteInventoryCommand(character *Character, tokens []string) bool
- func ExecuteLookCommand(character *Character, tokens []string) bool
- func ExecutePasswordCommand(character *Character, tokens []string) bool
- func ExecuteQuitCommand(character *Character, tokens []string) bool
- func ExecuteRemoveCommand(character *Character, tokens []string) bool
- func ExecuteRetreatCommand(character *Character, tokens []string) bool
- func ExecuteSayCommand(character *Character, tokens []string) bool
- func ExecuteShowCommand(character *Character, tokens []string) bool
- func ExecuteTakeCommand(character *Character, tokens []string) bool
- func ExecuteWearCommand(character *Character, tokens []string) bool
- func ExecuteWhoCommand(character *Character, tokens []string) bool
- func GetEnv(key, defaultValue string) string
- func GetUserData(accessToken string, config Configuration) (*cognitoidentityprovider.GetUserOutput, error)
- func InitializeBloomFilter(game *Game) error
- func InitializeLogging(cfg *Configuration) error
- func InputLoop(c *Character)
- func LoadArchetypes(g *Game) error
- func ParseDims(b []byte) (width, height int)
- func PlayerInput(p *Player)
- func PlayerOutput(p *Player)
- func SendMetrics(s *Server, stop chan os.Signal, interval time.Duration) error
- func SendRoomMessage(r *Room, message string)
- func SendRoomMessageExcept(r *Room, message string, character *Character)
- func SignInUser(email, password string, config *Configuration) (*cognitoidentityprovider.InitiateAuthOutput, error)
- func SignUpUser(email, password string, config Configuration) (*cognitoidentityprovider.SignUpOutput, error)
- func ValidateCommand(command string) (string, []string, error)
- type Archetype
- type Character
- func (c *Character) AddToInventory(item *Item)
- func (c *Character) CanCarryItem(item *Item) bool
- func (c *Character) CanEscape() bool
- func (c *Character) Cleanup()
- func (c *Character) ClearFacing()
- func (c *Character) EnterCombat()
- func (c *Character) ExitCombat()
- func (c *Character) FindInInventory(itemName string) *Item
- func (c *Character) FromData(cd *CharacterData, game *Game) error
- func (c *Character) GetCombatRange(target *Character) float64
- func (c *Character) GetFacing() *Character
- func (c *Character) IsInCombat() bool
- func (c *Character) ListInventory() string
- func (c *Character) RemoveFromInventory(item *Item)
- func (c *Character) RemoveWornItem(item *Item) error
- func (c *Character) SetCombatRange(target *Character, distance float64)
- func (c *Character) SetFacing(target *Character)
- func (c *Character) ToData() *CharacterData
- func (c *Character) WearItem(item *Item) error
- type CharacterData
- type CloudWatchHandler
- type CommandHandler
- type Configuration
- type Exit
- type ExitData
- type Game
- func (game *Game) AddCharacterName(name string)
- func (game *Game) CharacterNameExists(name string) bool
- func (g *Game) CreateCharacter(player *Player) (*Character, error)
- func (g *Game) CreateItemFromPrototype(prototypeID uuid.UUID) (*Item, error)
- func (g *Game) NewCharacter(name string, player *Player, room *Room, archetypeName string) (*Character, error)
- func (g *Game) SaveActiveCharacters() error
- func (g *Game) SaveActiveItems() error
- func (g *Game) SaveActiveRooms() error
- func (g *Game) StoreArchetypes() error
- type Index
- type Item
- type ItemData
- type KeyPair
- func (k *KeyPair) Delete(tableName string, key map[string]*dynamodb.AttributeValue) error
- func (kp *KeyPair) DeleteCharacter(player *Player, characterName string) error
- func (k *KeyPair) Get(tableName string, key map[string]*dynamodb.AttributeValue, item interface{}) error
- func (k *KeyPair) GetAllMOTDs() ([]*MOTD, error)
- func (kp *KeyPair) LoadAllExits() (map[string]*Exit, error)
- func (kp *KeyPair) LoadAllItems() (map[string]*Item, error)
- func (kp *KeyPair) LoadCharacter(characterID uuid.UUID, player *Player, game *Game) (*Character, error)
- func (kp *KeyPair) LoadCharacterNames() (map[string]bool, error)
- func (k *KeyPair) LoadItem(id string) (*Item, error)
- func (kp *KeyPair) LoadItemsForRoom(roomID int64) (map[uuid.UUID]*Item, error)
- func (kp *KeyPair) LoadPrototypes() (map[uuid.UUID]*Prototype, error)
- func (kp *KeyPair) LoadRooms() (map[int64]*Room, error)
- func (k *KeyPair) Put(tableName string, item interface{}) error
- func (k *KeyPair) Query(tableName string, keyConditionExpression string, ...) error
- func (k *KeyPair) ReadPlayer(playerName string) (string, map[string]uuid.UUID, []uuid.UUID, error)
- func (k *KeyPair) Scan(tableName string, items interface{}) error
- func (kp *KeyPair) StorePrototypes(prototypes map[uuid.UUID]*Prototype) error
- func (kp *KeyPair) StoreRooms(rooms map[int64]*Room) error
- func (kp *KeyPair) WriteCharacter(character *Character) error
- func (k *KeyPair) WriteItem(obj *Item) error
- func (k *KeyPair) WritePlayer(player *Player) error
- func (kp *KeyPair) WriteRoom(room *Room) error
- type MOTD
- type MOTDData
- type MultiHandler
- type Player
- type PlayerData
- type Prototype
- type PrototypeData
- type Room
- type RoomData
- type Server
Constants ¶
const ( DefaultDistance = 30.0 // Default starting distance MeleeRange = 5.0 // Distance for melee combat PoleRange = 10.0 // Distance for pole weapons FarRange = 30.0 // Distance for far range VeryFarRange = 50.0 // Maximum combat distance )
const FalsePositiveRate = 0.01 // 1% bloom filter false positive rate
Variables ¶
var ColorMap = map[string]string{
"black": "30",
"red": "31",
"green": "32",
"yellow": "33",
"blue": "34",
"magenta": "35",
"cyan": "36",
"white": "37",
"bright_black": "90",
"bright_red": "91",
"bright_green": "92",
"bright_yellow": "93",
"bright_blue": "94",
"bright_magenta": "95",
"bright_cyan": "96",
"bright_white": "97",
}
ColorMap maps color names to ANSI color codes.
var CommandHandlers = map[string]CommandHandler{ "quit": ExecuteQuitCommand, "show": ExecuteShowCommand, "look": ExecuteLookCommand, "say": ExecuteSayCommand, "go": ExecuteGoCommand, "help": ExecuteHelpCommand, "who": ExecuteWhoCommand, "password": ExecutePasswordCommand, "challenge": ExecuteChallengeCommand, "take": ExecuteTakeCommand, "get": ExecuteTakeCommand, "drop": ExecuteDropCommand, "inventory": ExecuteInventoryCommand, "wear": ExecuteWearCommand, "remove": ExecuteRemoveCommand, "examine": ExecuteExamineCommand, "assess": ExecuteAssessCommand, "face": ExecuteFaceCommand, "advance": ExecuteAdvanceCommand, "retreat": ExecuteRetreatCommand, "i": ExecuteInventoryCommand, "inv": ExecuteInventoryCommand, "\"": ExecuteSayCommand, "'": ExecuteSayCommand, "q!": ExecuteQuitCommand, }
var (
Logger *slog.Logger
)
Global variables
var WearLocations = map[string]bool{ "head": true, "neck": true, "shoulders": true, "chest": true, "back": true, "arms": true, "hands": true, "waist": true, "legs": true, "feet": true, "left_finger": true, "right_finger": true, "left_wrist": true, "right_wrist": true, }
WearLocations defines all possible locations where an item can be worn
Functions ¶
func ApplyColor ¶
ApplyColor applies the specified color to the text if the color exists in ColorMap.
func ChangePassword ¶
func ConfirmUser ¶
func ConfirmUser(email, confirmationCode string, config Configuration) (*cognitoidentityprovider.ConfirmSignUpOutput, error)
func DisplayArchetypes ¶
func DisplayArchetypes(g *Game)
DisplayArchetypes logs the loaded archetypes for debugging purposes.
func DisplayPrototypes ¶
DisplayPrototypes logs the details of each prototype for debugging purposes.
func DisplayRooms ¶
DisplayRooms logs information about all rooms, useful for debugging.
func DisplayUnseenMOTDs ¶
func EnableXRay ¶
func EnableXRay(cfg *Configuration) error
func ExecuteAdvanceCommand ¶
func ExecuteAssessCommand ¶
func ExecuteChallengeCommand ¶
func ExecuteDropCommand ¶
func ExecuteExamineCommand ¶
func ExecuteFaceCommand ¶
func ExecuteGoCommand ¶
func ExecuteHelpCommand ¶
func ExecuteInventoryCommand ¶
func ExecuteLookCommand ¶
func ExecutePasswordCommand ¶
func ExecuteQuitCommand ¶
func ExecuteRemoveCommand ¶
func ExecuteRetreatCommand ¶
func ExecuteSayCommand ¶
func ExecuteShowCommand ¶
func ExecuteTakeCommand ¶
func ExecuteWearCommand ¶
func ExecuteWhoCommand ¶
func GetUserData ¶
func GetUserData(accessToken string, config Configuration) (*cognitoidentityprovider.GetUserOutput, error)
func InitializeBloomFilter ¶
InitializeBloomFilter initializes the bloom filter with existing character names, as well as names from ../data/names.txt and ../data/obscenity.txt.
func InitializeLogging ¶
func InitializeLogging(cfg *Configuration) error
func InputLoop ¶
func InputLoop(c *Character)
InputLoop is the main loop that handles player commands. It reads commands from the player's input and executes them accordingly.
func LoadArchetypes ¶
LoadArchetypes retrieves all archetypes from the DynamoDB table and stores them in the Server's ArcheTypes map.
func PlayerInput ¶
func PlayerInput(p *Player)
PlayerInput handles the player's input in a separate goroutine. It reads input from the player's SSH connection and sends it to the FromPlayer channel.
func PlayerOutput ¶
func PlayerOutput(p *Player)
PlayerOutput handles sending messages to the player in a separate goroutine. It reads messages from the ToPlayer channel and writes them to the player's SSH connection.
func SendRoomMessage ¶
SendRoomMessage sends a message to all characters in the room.
func SendRoomMessageExcept ¶
SendRoomMessageExcept sends a message to all characters in the room except for the specified character.
func SignInUser ¶
func SignInUser(email, password string, config *Configuration) (*cognitoidentityprovider.InitiateAuthOutput, error)
SignInUser attempts to sign in a user with the provided credentials
func SignUpUser ¶
func SignUpUser(email, password string, config Configuration) (*cognitoidentityprovider.SignUpOutput, error)
Types ¶
type Archetype ¶
type Archetype struct { ArchetypeName string `json:"ArchetypeName" dynamodbav:"ArchetypeName"` Description string `json:"Description" dynamodbav:"Description"` Attributes map[string]float64 `json:"Attributes" dynamodbav:"Attributes"` Abilities map[string]float64 `json:"Abilities" dynamodbav:"Abilities"` StartRoom int64 `json:"StartRoom" dynamodbav:"StartRoom"` }
type Character ¶
type Character struct { Game *Game ID uuid.UUID Player *Player Name string Attributes map[string]float64 Abilities map[string]float64 Essence float64 Health float64 Room *Room Inventory map[string]*Item Mutex sync.RWMutex Facing *Character Advancing bool // true when character is advancing towards their facing target CombatRange map[uuid.UUID]float64 LastEdited time.Time LastSaved time.Time }
func SelectCharacter ¶
SelectCharacter handles the character selection process for a player. It presents the player with options to select or create a character.
func (*Character) AddToInventory ¶
AddToInventory adds an item to the character's inventory.
func (*Character) CanCarryItem ¶
CanCarryItem checks if the character can carry the specified item. This is a placeholder for future weight and capacity checks.
func (*Character) CanEscape ¶
CanEscape checks if the character can escape from combat Returns true if no other characters are at melee range
func (*Character) ClearFacing ¶
func (c *Character) ClearFacing()
ClearFacing clears the character's facing
func (*Character) EnterCombat ¶
func (c *Character) EnterCombat()
EnterCombat initializes the CombatRange map when a character enters combat
func (*Character) ExitCombat ¶
func (c *Character) ExitCombat()
ExitCombat clears the CombatRange map when a character exits combat
func (*Character) FindInInventory ¶
FindInInventory searches for an item in the character's inventory by name.
func (*Character) FromData ¶
func (c *Character) FromData(cd *CharacterData, game *Game) error
FromData populates a Character object from a CharacterData struct retrieved from the database.
func (*Character) GetCombatRange ¶
GetCombatRange gets the distance to a target character, returning DefaultDistance if not in combat
func (*Character) IsInCombat ¶
IsInCombat checks if the character is currently in combat
func (*Character) ListInventory ¶
ListInventory lists the items in a character's inventory.
func (*Character) RemoveFromInventory ¶
RemoveFromInventory removes an item from the character's inventory.
func (*Character) RemoveWornItem ¶
RemoveWornItem allows a character to remove a worn item.
func (*Character) SetCombatRange ¶
SetCombatRange sets the distance to a target character, initializing the map if necessary
func (*Character) ToData ¶
func (c *Character) ToData() *CharacterData
ToData converts a Character object into a CharacterData struct for database storage.
type CharacterData ¶
type CharacterData struct { CharacterID string `json:"CharacterID" dynamodbav:"CharacterID"` PlayerID string `json:"PlayerID" dynamodbav:"PlayerID"` CharacterName string `json:"Name" dynamodbav:"Name"` Attributes map[string]float64 `json:"Attributes" dynamodbav:"Attributes"` Abilities map[string]float64 `json:"Abilities" dynamodbav:"Abilities"` Essence float64 `json:"Essence" dynamodbav:"Essence"` Health float64 `json:"Health" dynamodbav:"Health"` RoomID int64 `json:"RoomID" dynamodbav:"RoomID"` Inventory map[string]string `json:"Inventory" dynamodbav:"Inventory"` }
CharacterData for unmarshalling character.
type CloudWatchHandler ¶
type CloudWatchHandler struct {
// contains filtered or unexported fields
}
func NewCloudWatchHandler ¶
func NewCloudWatchHandler(client *cloudwatchlogs.Client, logGroup, logStream string) *CloudWatchHandler
type CommandHandler ¶
type Configuration ¶
type Configuration struct { Server struct { Port uint16 `yaml:"Port"` PrivateKeyPath string `yaml:"PrivateKeyPath"` } `yaml:"Server"` Aws struct { Region string `yaml:"Region"` } `yaml:"Aws"` Cognito struct { UserPoolID string `yaml:"UserPoolId"` ClientSecret string `yaml:"UserPoolClientSecret"` ClientID string `yaml:"UserPoolClientId"` UserPoolDomain string `yaml:"UserPoolDomain"` UserPoolArn string `yaml:"UserPoolArn"` } `yaml:"Cognito"` Game struct { Balance float64 `yaml:"Balance"` AutoSave uint16 `yaml:"AutoSave"` StartingEssence uint16 `yaml:"StartingEssence"` StartingHealth uint16 `yaml:"StartingHealth"` } `yaml:"Game"` Logging struct { ApplicationName string `yaml:"ApplicationName"` LogLevel int `yaml:"LogLevel"` LogGroup string `yaml:"LogGroup"` LogStream string `yaml:"LogStream"` MetricNamespace string `yaml:"MetricNamespace"` } `yaml:"Logging"` }
type Exit ¶
type Exit struct { ExitID uuid.UUID Direction string TargetRoom *Room Visible bool LastEdited time.Time LastSaved time.Time }
Exit represents the in-memory structure for an exit
type ExitData ¶
type ExitData struct { ExitID string `json:"ExitID" dynamodbav:"ExitID"` Direction string `json:"Direction" dynamodbav:"Direction"` TargetRoom int64 `json:"TargetRoom" dynamodbav:"TargetRoom"` Visible bool `json:"Visible" dynamodbav:"Visible"` }
ExitData represents the structure for storing exit data in DynamoDB
type Game ¶
type Game struct { Config *Configuration Context context.Context Mutex sync.RWMutex WaitGroup sync.WaitGroup Ticker *time.Ticker Database *KeyPair ArcheTypes map[string]*Archetype CharacterBloomFilter *bloom.BloomFilter Characters map[uuid.UUID]*Character Rooms map[int64]*Room Prototypes map[uuid.UUID]*Prototype Items map[uuid.UUID]*Item }
func NewGame ¶
func NewGame(config *Configuration) (*Game, error)
NewGame initializes the game struct.
func (*Game) AddCharacterName ¶
AddCharacterName adds a character name to the bloom filter to prevent duplicates.
func (*Game) CharacterNameExists ¶
CharacterNameExists checks if a character name already exists using the bloom filter.
func (*Game) CreateCharacter ¶
CreateCharacter handles the character creation process for a player. It prompts the player for a character name and archetype, and initializes the character.
func (*Game) CreateItemFromPrototype ¶
func (*Game) NewCharacter ¶
func (g *Game) NewCharacter(name string, player *Player, room *Room, archetypeName string) (*Character, error)
NewCharacter creates a new character with the specified name and archetype.
func (*Game) SaveActiveCharacters ¶
SaveActiveCharacters saves all active characters to the database if they have been edited since the last save.
func (*Game) SaveActiveItems ¶
SaveActiveItems saves all active items from rooms and characters to the database.
func (*Game) SaveActiveRooms ¶
SaveActiveRooms saves all active rooms to the database if they have been edited since the last save.
func (*Game) StoreArchetypes ¶
StoreArchetypes stores all archetypes from the Server's ArcheTypes map into the DynamoDB table.
type Index ¶
type Index struct { IndexID uint64 // contains filtered or unexported fields }
The Index struct is to be depricated in favor of UUIDs
type Item ¶
type Item struct { ID uuid.UUID PrototypeID uuid.UUID Name string Description string Mass float64 Value uint64 Stackable bool MaxStack uint32 Quantity uint32 Wearable bool WornOn []string Verbs map[string]string Overrides map[string]string TraitMods map[string]int8 Container bool Contents []*Item IsWorn bool CanPickUp bool Metadata map[string]string Mutex sync.RWMutex LastEdited time.Time LastSaved time.Time }
type ItemData ¶
type ItemData struct { ItemID string `json:"itemId" dynamodbav:"ItemID"` PrototypeID string `json:"prototypeID" dynamodbav:"PrototypeID"` Name string `json:"name" dynamodbav:"Name"` Description string `json:"description" dynamodbav:"Description"` Mass float64 `json:"mass" dynamodbav:"Mass"` Value uint64 `json:"value" dynamodbav:"Value"` Stackable bool `json:"stackable" dynamodbav:"Stackable"` MaxStack uint32 `json:"max_stack" dynamodbav:"MaxStack"` Quantity uint32 `json:"quantity" dynamodbav:"Quantity"` Wearable bool `json:"wearable" dynamodbav:"Wearable"` WornOn []string `json:"worn_on" dynamodbav:"WornOn"` Verbs map[string]string `json:"verbs" dynamodbav:"Verbs"` Overrides map[string]string `json:"overrides" dynamodbav:"Overrides"` TraitMods map[string]int8 `json:"trait_mods" dynamodbav:"TraitMods"` Container bool `json:"container" dynamodbav:"Container"` Contents []string `json:"contents" dynamodbav:"Contents"` IsWorn bool `json:"is_worn" dynamodbav:"IsWorn"` CanPickUp bool `json:"can_pick_up" dynamodbav:"CanPickUp"` Metadata map[string]string `json:"metadata" dynamodbav:"Metadata"` }
type KeyPair ¶
type KeyPair struct {
// contains filtered or unexported fields
}
func NewKeyPair ¶
NewKeyPair initializes a new DynamoDB client.
func (*KeyPair) DeleteCharacter ¶
DeleteCharacter removes a character from the player's character list and the database.
func (*KeyPair) Get ¶
func (k *KeyPair) Get(tableName string, key map[string]*dynamodb.AttributeValue, item interface{}) error
Get retrieves an item from the DynamoDB table.
func (*KeyPair) GetAllMOTDs ¶
func (*KeyPair) LoadAllExits ¶
LoadAllExits loads all exits for all rooms.
func (*KeyPair) LoadAllItems ¶
LoadAllItems loads all items for all rooms.
func (*KeyPair) LoadCharacter ¶
func (kp *KeyPair) LoadCharacter(characterID uuid.UUID, player *Player, game *Game) (*Character, error)
LoadCharacter retrieves a character from the DynamoDB database and reconstructs the Character object.
func (*KeyPair) LoadCharacterNames ¶
LoadCharacterNames loads all character names from the database to initialize the bloom filter.
func (*KeyPair) LoadItemsForRoom ¶
LoadItemsForRoom loads all items for a specific room
func (*KeyPair) LoadPrototypes ¶
LoadPrototypes retrieves all item prototypes from the DynamoDB table.
func (*KeyPair) LoadRooms ¶
LoadRooms retrieves all rooms from the DynamoDB database and returns them as a map of Room instances.
func (*KeyPair) Query ¶
func (k *KeyPair) Query(tableName string, keyConditionExpression string, expressionAttributeValues map[string]*dynamodb.AttributeValue, items interface{}) error
Query performs a query operation on the DynamoDB table.
func (*KeyPair) ReadPlayer ¶
ReadPlayer retrieves the player data from the DynamoDB database.
func (*KeyPair) StorePrototypes ¶
StorePrototypes stores item prototypes into the DynamoDB table.
func (*KeyPair) StoreRooms ¶
StoreRooms stores all rooms into the DynamoDB database.
func (*KeyPair) WriteCharacter ¶
WriteCharacter saves the character to the DynamoDB database.
func (*KeyPair) WriteItem ¶
WriteItem stores an item into the DynamoDB table, handling nested contents if it's a container.
func (*KeyPair) WritePlayer ¶
WritePlayer stores the player data into the DynamoDB database.
type MultiHandler ¶
type MultiHandler struct {
// contains filtered or unexported fields
}
func NewMultiHandler ¶
func NewMultiHandler(handlers ...slog.Handler) *MultiHandler
type Player ¶
type Player struct { Server *Server Index uint64 PlayerID string ToPlayer chan string FromPlayer chan string PlayerError chan error Echo bool Prompt string Connection ssh.Channel ConsoleWidth int ConsoleHeight int SeenMotD []uuid.UUID CharacterList map[string]uuid.UUID Character *Character LoginTime time.Time Mutex sync.RWMutex Context context.Context Cancel context.CancelFunc }
type PlayerData ¶
type Prototype ¶
type Prototype struct { ID uuid.UUID Name string Description string Mass float64 Value uint64 Stackable bool MaxStack uint32 Quantity uint32 Wearable bool WornOn []string Verbs map[string]string Overrides map[string]string TraitMods map[string]int8 Container bool Contents []uuid.UUID CanPickUp bool Metadata map[string]string Mutex sync.RWMutex LastEdited time.Time LastSaved time.Time }
type PrototypeData ¶
type PrototypeData struct { PrototypeID string `json:"id" dynamodbav:"prototypeID"` Name string `json:"name" dynamodbav:"name"` Description string `json:"description" dynamodbav:"description"` Mass float64 `json:"mass" dynamodbav:"mass"` Value uint64 `json:"value" dynamodbav:"value"` Stackable bool `json:"stackable" dynamodbav:"stackable"` MaxStack uint32 `json:"max_stack" dynamodbav:"max_stack"` Quantity uint32 `json:"quantity" dynamodbav:"quantity"` Wearable bool `json:"wearable" dynamodbav:"wearable"` WornOn []string `json:"worn_on" dynamodbav:"worn_on"` Verbs map[string]string `json:"verbs" dynamodbav:"verbs"` Overrides map[string]string `json:"overrides" dynamodbav:"overrides"` TraitMods map[string]int8 `json:"trait_mods" dynamodbav:"trait_mods"` Container bool `json:"container" dynamodbav:"container"` Contents []string `json:"contents" dynamodbav:"contents"` CanPickUp bool `json:"can_pick_up" dynamodbav:"can_pick_up"` Metadata map[string]string `json:"metadata" dynamodbav:"metadata"` }
type Room ¶
type Room struct { RoomID int64 Area string Title string Description string Exits map[string]*Exit Characters map[uuid.UUID]*Character Items map[uuid.UUID]*Item Mutex sync.RWMutex LastEdited time.Time LastSaved time.Time }
Room represents the in-memory structure for a room
func (*Room) CleanupNilItems ¶
func (r *Room) CleanupNilItems()
CleanupNilItems removes any nil items from the room's item list.
func (*Room) RemoveItem ¶
RemoveItem removes an item from the room's item list.
type RoomData ¶
type RoomData struct { RoomID int64 `json:"roomID" dynamodbav:"RoomID"` Area string `json:"area" dynamodbav:"Area"` Title string `json:"title" dynamodbav:"Title"` Description string `json:"description" dynamodbav:"Description"` ExitIDs []string `json:"exitID" dynamodbav:"ExitID"` ItemIDs []string `json:"itemID" dynamodbav:"ItemID"` }
RoomData represents the structure for storing room data in DynamoDB
type Server ¶
type Server struct { Config *Configuration Context context.Context Mutex sync.RWMutex WaitGroup sync.WaitGroup Database *KeyPair StartTime time.Time Port uint16 Listener net.Listener SSHConfig *ssh.ServerConfig PlayerCount uint64 PlayerIndex *Index Players map[uint64]*Player ActiveMotDs []*MOTD }
func NewServer ¶
func NewServer(config *Configuration) (*Server, error)
NewServer initializes a new server instance with the given configuration. It sets up the database connection, loads game data, and prepares the server for incoming connections.