Documentation ¶
Index ¶
- func BroadcastMessage(from *db.Character, message string)
- func CharactersIn(room *db.Room) db.CharacterList
- func CreateArea(name string, zone *db.Zone) (*db.Area, error)
- func CreateItem(name string) *db.Item
- func CreateNpc(name string, room *db.Room) *db.NonPlayerChar
- func CreatePlayerCharacter(name string, parentUser *db.User, startingRoom *db.Room) *db.PlayerChar
- func CreateRoom(zone *db.Zone, location db.Coordinate) (*db.Room, error)
- func CreateUser(name string, password string) *db.User
- func CreateZone(name string) (*db.Zone, error)
- func DeleteArea(area *db.Area)
- func DeleteItem(item *db.Item)
- func DeleteItemId(itemId bson.ObjectId)
- func DeleteNpc(npc *db.NonPlayerChar)
- func DeleteNpcId(id bson.ObjectId)
- func DeleteObject(obj ds.Identifiable)
- func DeletePlayerCharacter(pc *db.PlayerChar)
- func DeletePlayerCharacterId(id bson.ObjectId)
- func DeleteRoom(room *db.Room)
- func DeleteUser(user *db.User)
- func DeleteUserId(userId bson.ObjectId)
- func DeleteZone(zone *db.Zone)
- func DirectionBetween(from, to *db.Room) db.Direction
- func Emote(from *db.Character, message string)
- func GetArea(areaId bson.ObjectId) *db.Area
- func GetAreaByName(name string) *db.Area
- func GetAreas(zone *db.Zone) db.Areas
- func GetCharacterByName(name string) *db.Character
- func GetItem(id bson.ObjectId) *db.Item
- func GetItems(itemIds []bson.ObjectId) []*db.Item
- func GetNpc(id bson.ObjectId) *db.NonPlayerChar
- func GetNpcByName(name string) *db.NonPlayerChar
- func GetNpcs() db.NonPlayerCharList
- func GetOnlinePlayerCharacters() []*db.PlayerChar
- func GetOrCreatePlayerCharacter(name string, parentUser *db.User, startingRoom *db.Room) *db.PlayerChar
- func GetOrCreateUser(name string, password string) *db.User
- func GetPlayerCharacter(id bson.ObjectId) *db.PlayerChar
- func GetPlayerCharacterByName(name string) *db.PlayerChar
- func GetRoom(id bson.ObjectId) *db.Room
- func GetRoomByLocation(coordinate db.Coordinate, zone *db.Zone) *db.Room
- func GetRooms() db.Rooms
- func GetRoomsInZone(zone *db.Zone) []*db.Room
- func GetUser(id bson.ObjectId) *db.User
- func GetUserByName(username string) *db.User
- func GetUserCharacters(user *db.User) []*db.PlayerChar
- func GetUsers() db.Users
- func GetZone(zoneId bson.ObjectId) *db.Zone
- func GetZoneByName(name string) *db.Zone
- func GetZones() db.Zones
- func InCombat(character *database.Character) bool
- func Init(session db.Session, dbName string) error
- func ItemsIn(room *db.Room) []*db.Item
- func Login(character *database.PlayerChar)
- func Logout(character *database.PlayerChar)
- func MoveCharacter(character *db.Character, direction db.Direction) (*db.Room, error)
- func MoveCharacterToLocation(character *db.Character, zone *db.Zone, location db.Coordinate) (*db.Room, error)
- func MoveCharacterToRoom(character *db.Character, newRoom *db.Room)
- func NpcsIn(room *db.Room) db.NonPlayerCharList
- func PlayerCharactersIn(room *db.Room, except *db.PlayerChar) db.PlayerCharList
- func Register() chan Event
- func Say(from *db.Character, message string)
- func StartFight(attacker *database.Character, defender *database.Character)
- func StopFight(attacker *database.Character)
- func Tell(from *db.Character, to *db.Character, message string)
- func Unregister(listenerToUnregsiter chan Event)
- func ZoneCorners(zone *db.Zone) (db.Coordinate, db.Coordinate)
- type BroadcastEvent
- type CombatEvent
- type CombatStartEvent
- type CombatStopEvent
- type CreateEvent
- type DestroyEvent
- type EmoteEvent
- type EnterEvent
- type Event
- type EventType
- type LeaveEvent
- type LoginEvent
- type LogoutEvent
- type RoomUpdateEvent
- type SayEvent
- type TellEvent
- type TimerEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BroadcastMessage ¶
BroadcastMessage sends a message to all users that are logged in
func CharactersIn ¶
func CharactersIn(room *db.Room) db.CharacterList
func CreateItem ¶
CreateItem creates an item object in the database with the given name and adds it to the model. It's up to the caller to ensure that the item actually gets put somewhere meaningful.
func CreateNpc ¶
func CreateNpc(name string, room *db.Room) *db.NonPlayerChar
CreateNpc is a convenience function for creating a new character object that is an NPC (as opposed to an actual player-controlled character)
func CreatePlayerCharacter ¶
CreatePlayerCharacter creates a new player-controlled Character object in the database and adds it to the model. A pointer to the new character object is returned.
func CreateRoom ¶
CreateRoom creates a new Room object in the database and adds it to the model. A pointer to the new Room object is returned.
func CreateUser ¶
CreateUser creates a new User object in the database and adds it to the model. A pointer to the new User object is returned.
func CreateZone ¶
CreateZone creates a new Zone object in the database and adds it to the model. A pointer to the new Zone object is returned.
func DeleteArea ¶
func DeleteItem ¶
DeleteItem removes the item associated with the given id from the model and from the database
func DeleteItemId ¶
func DeleteNpc ¶
func DeleteNpc(npc *db.NonPlayerChar)
func DeleteNpcId ¶
func DeleteObject ¶
func DeleteObject(obj ds.Identifiable)
func DeletePlayerCharacter ¶
func DeletePlayerCharacter(pc *db.PlayerChar)
DeletePlayerCharacter removes the character (either NPC or player-controlled) associated with the given id from the model and from the database
func DeletePlayerCharacterId ¶
func DeleteRoom ¶
DeleteRoom removes the given room object from the model and the database. It also disables all exits in neighboring rooms that lead to the given room.
func DeleteUser ¶
Removes the given User from the model. Removes it from the database as well.
func DeleteUserId ¶
func DeleteZone ¶
Removes the given Zone from the model and the database
func DirectionBetween ¶
Returns the exit direction of the given room if it is adjacent, otherwise DirectionNone
func GetAreaByName ¶
func GetCharacterByName ¶
func GetNpcByName ¶
func GetNpcByName(name string) *db.NonPlayerChar
func GetNpcs ¶
func GetNpcs() db.NonPlayerCharList
func GetOnlinePlayerCharacters ¶
func GetOnlinePlayerCharacters() []*db.PlayerChar
GetOnlinePlayerCharacters returns a list of all of the characters who are online
func GetOrCreatePlayerCharacter ¶
func GetOrCreatePlayerCharacter(name string, parentUser *db.User, startingRoom *db.Room) *db.PlayerChar
GetOrCreatePlayerCharacter attempts to retrieve the existing user from the model by the given name. if none exists, then a new one is created. If the name matches an NPC (rather than a player) then nil will be returned.
func GetOrCreateUser ¶
GetOrCreateUser attempts to retrieve the existing user from the model by the given name. if none exists, then a new one is created with the given credentials.
func GetPlayerCharacter ¶
func GetPlayerCharacter(id bson.ObjectId) *db.PlayerChar
GetPlayerCharacter returns the Character object associated the given Id
func GetPlayerCharacterByName ¶
func GetPlayerCharacterByName(name string) *db.PlayerChar
GetPlayerCharacaterByName searches for a character with the given name. Returns a character object, or nil if it wasn't found.
func GetRoomByLocation ¶
GetRoomByLocation searches for the room associated with the given coordinate in the given zone. Returns a nil room object if it was not found.
func GetRoomsInZone ¶
GetRoomsInZone returns a slice containing all of the rooms that belong to the given zone
func GetUserByName ¶
GetUserByName searches for the User object with the given name. Returns a nil User if one was not found.
func GetUserCharacters ¶
func GetUserCharacters(user *db.User) []*db.PlayerChar
GetUserCharacters returns all of the Character objects associated with the given user id
func GetZoneByName ¶
GetZoneByName name searches for a zone with the given name
func Login ¶
func Login(character *database.PlayerChar)
func Logout ¶
func Logout(character *database.PlayerChar)
func MoveCharacter ¶
MoveCharacter moves the given character in the given direction. If there is no exit in that direction, and error is returned. If there is an exit, but no room connected to it, then a room is automatically created for the character to move in to.
func MoveCharacterToLocation ¶
func MoveCharacterToLocation(character *db.Character, zone *db.Zone, location db.Coordinate) (*db.Room, error)
MoveCharacter attempts to move the character to the given coordinates specific by location. Returns an error if there is no room to move to.
func MoveCharacterToRoom ¶
MoveCharacterTo room moves the character to the given room
func NpcsIn ¶
func NpcsIn(room *db.Room) db.NonPlayerCharList
NpcsIn returns all of the NPC characters that are in the given room
func PlayerCharactersIn ¶
func PlayerCharactersIn(room *db.Room, except *db.PlayerChar) db.PlayerCharList
PlayerCharactersIn returns a list of player characters that are in the given room
func Unregister ¶
func Unregister(listenerToUnregsiter chan Event)
func ZoneCorners ¶
func ZoneCorners(zone *db.Zone) (db.Coordinate, db.Coordinate)
ZoneCorners returns cordinates that indiate the highest and lowest points of the map in 3 dimensions
Types ¶
type BroadcastEvent ¶
func (BroadcastEvent) IsFor ¶
func (self BroadcastEvent) IsFor(receiver *database.PlayerChar) bool
func (BroadcastEvent) ToString ¶
func (self BroadcastEvent) ToString(receiver *database.Character) string
func (BroadcastEvent) Type ¶
func (self BroadcastEvent) Type() EventType
type CombatEvent ¶
func (CombatEvent) IsFor ¶
func (self CombatEvent) IsFor(receiver *database.PlayerChar) bool
type CombatStartEvent ¶
func (CombatStartEvent) IsFor ¶
func (self CombatStartEvent) IsFor(receiver *database.PlayerChar) bool
type CombatStopEvent ¶
func (CombatStopEvent) IsFor ¶
func (self CombatStopEvent) IsFor(receiver *database.PlayerChar) bool
type CreateEvent ¶
func (CreateEvent) IsFor ¶
func (self CreateEvent) IsFor(receiver *database.PlayerChar) bool
type DestroyEvent ¶
func (DestroyEvent) IsFor ¶
func (self DestroyEvent) IsFor(receiver *database.PlayerChar) bool
type EmoteEvent ¶
func (EmoteEvent) IsFor ¶
func (self EmoteEvent) IsFor(receiver *database.PlayerChar) bool
type EnterEvent ¶
type EnterEvent struct { Character *database.Character Room *database.Room SourceRoom *database.Room }
func (EnterEvent) IsFor ¶
func (self EnterEvent) IsFor(receiver *database.PlayerChar) bool
type EventType ¶
type EventType int
const ( CreateEventType EventType = iota DestroyEventType EventType = iota BroadcastEventType EventType = iota SayEventType EventType = iota EmoteEventType EventType = iota TellEventType EventType = iota EnterEventType EventType = iota LeaveEventType EventType = iota RoomUpdateEventType EventType = iota LoginEventType EventType = iota LogoutEventType EventType = iota CombatStartEventType EventType = iota CombatStopEventType EventType = iota CombatEventType EventType = iota TimerEventType EventType = iota )
type LeaveEvent ¶
type LeaveEvent struct { Character *database.Character Room *database.Room DestRoom *database.Room }
func (LeaveEvent) IsFor ¶
func (self LeaveEvent) IsFor(receiver *database.PlayerChar) bool
type LoginEvent ¶
type LoginEvent struct {
Character *database.PlayerChar
}
func (LoginEvent) IsFor ¶
func (self LoginEvent) IsFor(receiver *database.PlayerChar) bool
type LogoutEvent ¶
type LogoutEvent struct {
Character *database.PlayerChar
}
func (LogoutEvent) IsFor ¶
func (self LogoutEvent) IsFor(receiver *database.PlayerChar) bool
type RoomUpdateEvent ¶
func (RoomUpdateEvent) IsFor ¶
func (self RoomUpdateEvent) IsFor(receiver *database.PlayerChar) bool
type TimerEvent ¶
type TimerEvent struct { }
func (TimerEvent) IsFor ¶
func (self TimerEvent) IsFor(receiver *database.PlayerChar) bool