123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package world
- import "github.com/beoran/woe/sitef"
- import "github.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
- }
|