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+"\"") }
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 }
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 }
func (self LoginEvent) IsFor(receiver *database.Character) bool { return receiver.GetId() != self.Character.GetId() }
func (self RoomUpdateEvent) IsFor(receiver *database.Character) bool { return receiver.GetRoomId() == self.Room.GetId() }
func (self LeaveEvent) IsFor(receiver *database.Character) bool { return receiver.GetRoomId() == self.Room.GetId() && receiver.GetId() != self.Character.GetId() }
func (self TellEvent) IsFor(receiver *database.Character) bool { return receiver.GetId() == self.To.GetId() }
func (self SayEvent) IsFor(receiver *database.Character) bool { return receiver.GetRoomId() == self.Character.GetRoomId() }