示例#1
0
func dir(d string) config.Direction {
	dir, ok := config.FindDirection(d)
	if !ok {
		panic(fmt.Errorf("Can't find direction %s", d))
	}
	return dir
}
示例#2
0
文件: exit.go 项目: natefinch/claymud
// 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
}