Пример #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+"\"")
}
Пример #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
}
Пример #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
}
Пример #4
0
func (self LoginEvent) IsFor(receiver *database.Character) bool {
	return receiver.GetId() != self.Character.GetId()
}
Пример #5
0
func (self RoomUpdateEvent) IsFor(receiver *database.Character) bool {
	return receiver.GetRoomId() == self.Room.GetId()
}
Пример #6
0
func (self LeaveEvent) IsFor(receiver *database.Character) bool {
	return receiver.GetRoomId() == self.Room.GetId() &&
		receiver.GetId() != self.Character.GetId()
}
Пример #7
0
func (self TellEvent) IsFor(receiver *database.Character) bool {
	return receiver.GetId() == self.To.GetId()
}
Пример #8
0
func (self SayEvent) IsFor(receiver *database.Character) bool {
	return receiver.GetRoomId() == self.Character.GetRoomId()
}