func dir(d string) config.Direction { dir, ok := config.FindDirection(d) if !ok { panic(fmt.Errorf("Can't find direction %s", d)) } return dir }
// Returns the room that exists in the given direction. Returns valid == false // if the alias is not a valid direction alias. Returns dest == nil if there's // no exit in that direction. func (e Exits) Find(alias string) (valid bool, dest *Location) { dir, found := config.FindDirection(alias) if !found { return false, nil } for _, exit := range e { if exit.Direction.Id == dir.Id { return true, exit.Destination } } return true, nil }