Exemplo n.º 1
0
func (self SayEvent) ToString(receiver *database.Character) string {
	who := ""
	if receiver.GetId() == self.Character.GetId() {
		who = "You say"
	} else {
		who = self.Character.GetName() + " says"
	}

	return utils.Colorize(utils.ColorBlue, who+", ") +
		utils.Colorize(utils.ColorWhite, "\""+self.Message+"\"")
}
Exemplo n.º 2
0
func (self EnterEvent) ToString(receiver *database.Character) string {
	if receiver.GetId() == self.Character.GetId() {
		return ""
	}

	str := fmt.Sprintf("%v%s %vhas entered the room", utils.ColorBlue, self.Character.GetName(), utils.ColorWhite)

	dir := DirectionBetween(self.Room, self.SourceRoom)
	if dir != database.DirectionNone {
		str = str + " from the " + database.DirectionToString(dir)
	}

	return str
}
Exemplo n.º 3
0
func Register(character *database.Character) chan Event {
	_mutex.Lock()
	if _listeners == nil {
		_listeners = map[chan Event]*database.Character{}
	}
	_mutex.Unlock()

	listener := make(chan Event, 100)

	_mutex.Lock()
	_listeners[listener] = character
	_mutex.Unlock()

	character.SetOnline(true)

	queueEvent(LoginEvent{character})

	return listener
}
Exemplo n.º 4
0
func (self LoginEvent) IsFor(receiver *database.Character) bool {
	return receiver.GetId() != self.Character.GetId()
}
Exemplo n.º 5
0
func (self RoomUpdateEvent) IsFor(receiver *database.Character) bool {
	return receiver.GetRoomId() == self.Room.GetId()
}
Exemplo n.º 6
0
func (self LeaveEvent) IsFor(receiver *database.Character) bool {
	return receiver.GetRoomId() == self.Room.GetId() &&
		receiver.GetId() != self.Character.GetId()
}
Exemplo n.º 7
0
func (self TellEvent) IsFor(receiver *database.Character) bool {
	return receiver.GetId() == self.To.GetId()
}
Exemplo n.º 8
0
func (self SayEvent) IsFor(receiver *database.Character) bool {
	return receiver.GetRoomId() == self.Character.GetRoomId()
}