1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package world
- import "gitlab.com/beoran/woe/sitef"
- import "gitlab.com/beoran/woe/monolog"
- import "errors"
- type Direction string
- type Exit struct {
- Direction
- ToRoomID int
- toRoom *Room
- }
- type Room struct {
- Entity
- Exits map[Direction]Exit
- }
- func LoadRoom(dirname string, id string) (room *Room, err error) {
- path := SavePathFor(dirname, "room", id)
- records, err := sitef.ParseFilename(path)
- if err != nil {
- return nil, err
- }
- if len(records) < 1 {
- return nil, errors.New("No room found!")
- }
- record := records[0]
- monolog.Info("Loading Room record: %s %v", path, record)
- room = new(Room)
- room.Entity.LoadSitef(*record)
-
- monolog.Info("Loaded Room: %s %v", path, room)
- return room, nil
- }
|