示例#1
0
文件: engine.go 项目: jworrell/GoMU
func (eng *Engine) Do(obj **object.Object, msg *message.Message) {
	cmd := Commands[msg.Command]

	if cmd.function == nil {
		obj.Hear(message.MakeMessage("error", msg.Command+" is not a valid command!"))
	} else if obj.GetID() != object.DUMMY_ID || cmd.UseUnathenticated() {
		cmd.function(eng, obj, msg)
	} else {
		obj.Hear(message.MakeMessage("error", "You must be logged on to use "+msg.Command))
	}
}
示例#2
0
文件: command.go 项目: jworrell/GoMU
func (eng *Engine) login(obj **object.Object, msg *message.Message) {
	player := eng.db.GetPlayer(msg.Data)

	if player == nil {
		obj.Hear(message.MakeMessage("error", "No player named %s exists!", msg.Data))
	} else {
		writer := obj.GetWriter()
		player.SetWriter(writer)
		player.Hear(message.MakeMessage("result", "Successfully logged in as %s", player.GetAttr("name")))
		(*obj) = player
		player.GetLocation().Emit(message.MakeMessage("emit", "%s has connected!", player.GetAttr("name")))
		eng.look(obj, &message.Message{})
	}
}
示例#3
0
文件: command.go 项目: jworrell/GoMU
func (eng *Engine) move(obj **object.Object, msg *message.Message) {
	location := obj.GetLocation()
	exit := location.FindInside("name", msg.Data)

	if exit != nil && exit.GetType() == object.EXIT {
		dest := exit.GetLink()
		location.Emit(message.MakeMessage("emit", "%s left through %s", obj.GetAttr("name"), exit.GetAttr("name")))
		obj.Move(dest)
		dest.Emit(message.MakeMessage("emit", "%s arrived from %s", obj.GetAttr("name"), location.GetAttr("name")))
		eng.look(obj, &message.Message{})
	} else {
		obj.Hear(message.MakeMessage("error", "%s not found or not an exit!", msg.Data))
	}
}
示例#4
0
文件: command.go 项目: jworrell/GoMU
func (eng *Engine) register(obj **object.Object, msg *message.Message) {
	player := eng.db.GetPlayer(msg.Data)

	if player != nil {
		obj.Hear(message.MakeMessage("error", "Player named %s already exists!", msg.Data))
	} else {
		writer := obj.GetWriter()
		newPlayer := eng.db.CreateObject()
		newPlayer.SetWriter(writer)
		newPlayer.SetAttr("name", msg.Data)
		newPlayer.SetType(object.PLAYER)
		newPlayer.SetOwner(newPlayer)

		location := eng.db.GetObject(object.DEFAULT_LOCATION)
		newPlayer.SetHome(location)
		newPlayer.Move(location)

		newPlayer.Hear(message.MakeMessage("result", "Successfully registered as %s", msg.Data))

		(*obj) = newPlayer
		newPlayer.GetLocation().Emit(message.MakeMessage("emit", "%s has connected!", newPlayer.GetAttr("name")))
		eng.look(obj, &message.Message{})
	}
}
示例#5
0
文件: command.go 项目: jworrell/GoMU
func (eng *Engine) pose(obj **object.Object, msg *message.Message) {
	obj.GetLocation().Emit(message.MakeMessage("emit", "%s %s", obj.GetAttr("name"), msg.Data))
}
示例#6
0
文件: command.go 项目: jworrell/GoMU
func (eng *Engine) shutdown(obj **object.Object, msg *message.Message) {
	eng.wall(obj, message.MakeMessage("emit", "Server is shutting down now!"))
	eng.Shutdown()
}