Exemplo n.º 1
0
func (d *Default) L(what string) *messages.Error {
	if what == "" {
		return d.look()
	}

	matches, err := util.Identify(d.M, what)
	if err != nil {
		return err
	}
	if len(matches) == 0 {
		util.SendToClient(d.M, "Look at what?\n")
	}
	for _, resource := range matches {
		shortDesc, err := util.GetShortDesc(d.M, resource)
		if err != nil {
			return err
		}
		longDesc, err := util.GetLongDesc(d.M, resource)
		if err != nil && !util.IsNoSuchMethod(err) {
			return err
		}
		if longDesc != "" {
			util.SendToClient(d.M, util.Sprintf("%v\n%v\n", util.Capitalize(shortDesc.IndefArticlize()), longDesc))
		} else {
			util.SendToClient(d.M, util.Sprintf("%v\n", shortDesc.IndefArticlize()))
		}
	}
	return nil
}
Exemplo n.º 2
0
func (d *Default) Ident(what string) *messages.Error {
	matches, err := util.Identify(d.M, what)
	if err != nil {
		return err
	}
	if len(matches) == 0 {
		util.SendToClient(d.M, "Identify what?\n")
	}
	for _, match := range matches {
		util.SendToClient(d.M, util.Sprintf("%+v\n", match))
	}

	return nil
}