當前位置: 首頁>>代碼示例>>Python>>正文


Python Event.Event類代碼示例

本文整理匯總了Python中Event.Event.Event的典型用法代碼示例。如果您正苦於以下問題:Python Event類的具體用法?Python Event怎麽用?Python Event使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Event類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: actorEmoted

    def actorEmoted(self, receiver, event):
        targetName = event.attributes["data"]["target"]
        playerList = filter(lambda player: player != event.attributes["data"]["emoter"], receiver.attributes["players"])
        target = None

        if targetName != None and targetName != "":
            targetList = filter(
                lambda player: player.attributes["name"].lower().startswith(targetName.lower()), playerList
            )

            if len(targetList) > 0:
                target = targetList[0]
            else:
                emoter = event.attributes["data"]["emoter"]
                feedbackEvent = Event()
                feedbackEvent.attributes["signature"] = "received_feedback"
                feedbackEvent.attributes["data"]["feedback"] = "You don't see that here."

                emoter.receiveEvent(feedbackEvent)

                return

        event.attributes["data"]["target"] = target

        for player in receiver.attributes["players"]:
            player.receiveEvent(event)
開發者ID:DaneBettis,項目名稱:python_mud,代碼行數:26,代碼來源:Room.py

示例2: execute

	def execute(self, source, args):
		feedbackEvent									= Event()
		feedbackEvent.attributes['signature']			= 'received_feedback'
		feedbackEvent.attributes['data']['feedback']	= Engine.ActorEngine.getPlayerList()
		feedbackEvent.attributes['data']['actor']		= source

		Engine.ActorEngine.emitEvent(feedbackEvent)
開發者ID:longstl,項目名稱:python_mud,代碼行數:7,代碼來源:Who.py

示例3: handleEvent

	def handleEvent(self, event):
		receiver = event.attributes['receiver']
		
		if event.attributes['data']['target'] == receiver:
			description = ['There is nothing interesting about this object.']
			descArray	= receiver.attributes['description']
			
			if descArray != None and len(descArray) != 0:
				description = descArray
			
			observer										= event.attributes['data']['observer']
			describeEvent									= Event()
			describeEvent.attributes['signature']			= 'entity_described_self'
			describeEvent.attributes['data']['description'] = description
			describeEvent.attributes['data']['observer']	= observer
			room											= Engine.RoomEngine.getRoom(observer.attributes['roomID'])
			
			Engine.ActorEngine.emitEvent(describeEvent)
				
				
				
				
				
				
				
開發者ID:longstl,項目名稱:python_mud,代碼行數:18,代碼來源:Item.py

示例4: execute

	def execute(self):
		healEvent								= Event()
		healEvent.attributes['signature']		= 'gained_health'
		healEvent.attributes['data']['target']	= self.attributes['target']
		healEvent.attributes['data']['amount']	= self.attributes['amount']
		
		Engine.ActorEngine.emitEvent(healEvent)
開發者ID:longstl,項目名稱:python_mud,代碼行數:7,代碼來源:GainHealth.py

示例5: execute

	def execute(self, source, args):
		actor		= source
		words		= args
		roomID		= actor.attributes['roomID']
		room		= Engine.RoomEngine.getRoom(roomID)
		speakEvent	= Event()
		
		speakEvent.attributes['signature']			= 'actor_emoted'
		speakEvent.attributes['data']['emoter']		= actor
		speakEvent.attributes['data']['target']		= None
		speakEvent.attributes['data']['room']		= room
		speakEvent.attributes['data']['command']	= 'say'

		if words == None or len(words) == 0:
			speakEvent.attributes['data']['emoterText']		= 'Say what?'
			speakEvent.attributes['data']['audienceText']	= None		
		else:	
			sentence = ''
		
			for word in words:
				sentence										= '{} {}'.format(sentence, word)
				speakEvent.attributes['data']['emoterText']		= 'You say, "{}".'.format(sentence[1:])
				speakEvent.attributes['data']['audienceText']	= '{} says, "{}".'.format(actor.attributes['name'], sentence[1:])
		
		Engine.RoomEngine.emitEvent(speakEvent)
開發者ID:longstl,項目名稱:python_mud,代碼行數:25,代碼來源:Say.py

示例6: handleEvent

	def handleEvent(self, event):
		receiver	= event.attributes['receiver']
		observer	= event.attributes['data']['observer']
		target		= event.attributes['data']['target']
		items		= receiver.attributes['items']
		equipment	= receiver.attributes['equipment']
		equipped	= []
		
		for key in equipment.keys():
			equippedItem = equipment[key]
			
			if key == 'Neck' or key == 'Wrist' or key == 'Finger':
				for item in equippedItem:
					if item != None:
						equipped.append(item)
			else:
				if equippedItem != None:
					equipped.append(equippedItem)
		
		if target != None and target in set(items + equipped):
			lookEvent									= Event()
			lookEvent.attributes['data']['observer']	= observer
			lookEvent.attributes['data']['target']		= target
			lookEvent.attributes['signature']			= 'was_observed'

			receiver.emitEvent(lookEvent)
		else:
			#The actor meant to look at the room, or something in it
			if target == None:
				event.attributes['signature'] = 'was_observed'
			
			Engine.RoomEngine.emitEvent(event)
開發者ID:longstl,項目名稱:python_mud,代碼行數:32,代碼來源:ActorInventory.py

示例7: execute

	def execute(self, source, args):
		feedbackEvent									= Event()
		feedbackEvent.attributes['signature']			= 'received_feedback'
		feedbackEvent.attributes['data']['feedback']	= source.attributes['inventory'].listItems()
		feedbackEvent.attributes['data']['actor']		= source

		Engine.ActorEngine.emitEvent(feedbackEvent)
開發者ID:longstl,項目名稱:python_mud,代碼行數:7,代碼來源:Inventory.py

示例8: sendUnknownAffectFeedbackEvent

	def sendUnknownAffectFeedbackEvent(self, actor):
		feedbackEvent									= Event()
		feedbackEvent.attributes['signature']			= 'received_feedback'
		feedbackEvent.attributes['data']['feedback']	= 'Cast what?'
		feedbackEvent.attributes['data']['actor']		= actor

		Engine.ActorEngine.emitEvent(feedbackEvent)
開發者ID:longstl,項目名稱:python_mud,代碼行數:7,代碼來源:Cast.py

示例9: __init__

	def __init__(self):
		threading.Thread.__init__(self)
		EventEmitter.__init__(self, None)
		
		tickEvent				= Event()
		tickEvent.attributes['signature']	= 'game_tick'
		self.tickEvent				= tickEvent
		TickDriver.instance			= self
開發者ID:longstl,項目名稱:python_mud,代碼行數:8,代碼來源:TickDriver.py

示例10: wasObserved

	def wasObserved(self, receiver, event):
			observer										= event.attributes['data']['observer']
			description										= receiver.attributes['description'][:]
			describeEvent									= Event()
			describeEvent.attributes['signature']			= 'entity_described_self'
			describeEvent.attributes['data']['description'] = description

			observer.receiveEvent(describeEvent)
開發者ID:DaneBettis,項目名稱:python_mud,代碼行數:8,代碼來源:Actor.py

示例11: insertCommand

	def insertCommand(self, command, args = None):
		commandEvent	= Event()
		
		commandEvent.attributes['signature']			= 'execute_command'
		commandEvent.attributes['data']['command']		= command
		commandEvent.attributes['data']['args']			= args
		commandEvent.attributes['data']['source']		= self

		Engine.ActorEngine.emitEvent(commandEvent)
開發者ID:longstl,項目名稱:python_mud,代碼行數:9,代碼來源:Player.py

示例12: playerLogin

	def playerLogin(self, receiver, event):
		player			= event.attributes['data']['player']
		roomID			= player.attributes['roomID']
		room			= receiver.getRoom(roomID)
		playerInEvent	= Event()

		playerInEvent.attributes['signature']		= 'player_entered'
		playerInEvent.attributes['data']['player']	= player

		room.receiveEvent(playerInEvent)
開發者ID:DaneBettis,項目名稱:python_mud,代碼行數:10,代碼來源:RoomEngine.py

示例13: moveActor

    def moveActor(self, receiver, event):
        actor = event.attributes["data"]["source"]
        direction = event.attributes["data"]["direction"]
        exit = None

        if direction != None and direction != "":
            exitList = filter(
                lambda e: e.attributes["name"].lower().startswith(direction.lower()), receiver.attributes["exits"]
            )

            if len(exitList) > 0:
                exit = exitList[0]

        if exit == None:
            feedbackEvent = Event()
            feedbackEvent.attributes["signature"] = "received_feedback"
            feedbackEvent.attributes["data"]["feedback"] = ANSI.yellow("You can't go that way!")

            actor.receiveEvent(feedbackEvent)

        else:
            currentRoom = receiver.attributes["roomID"]
            destination = exit.attributes["destination"]
            moveEvent = Event()
            moveEvent.attributes["signature"] = "move_actor"
            moveEvent.attributes["data"]["actor"] = actor
            moveEvent.attributes["data"]["fromRoomID"] = currentRoom
            moveEvent.attributes["data"]["toRoomID"] = destination
            moveEvent.attributes["data"]["exitMessage"] = "{} leaves {}.".format(
                actor.attributes["name"], exit.attributes["name"]
            )

            from Engine import RoomEngine

            RoomEngine.receiveEvent(moveEvent)
開發者ID:DaneBettis,項目名稱:python_mud,代碼行數:35,代碼來源:Room.py

示例14: execute

	def execute(self, receiver, event):
		actor	= event.attributes['data']['source']
		words	= event.attributes['data']['args']
		
		if words == None or len(words) == 0:
			feedbackEvent									= Event()
			feedbackEvent.attributes['signature']			= 'received_feedback'
			feedbackEvent.attributes['data']['feedback']	= 'Say what?'
			
			actor.receiveEvent(feedbackEvent)
		else:
			roomID		= actor.attributes['roomID']
			room		= RoomEngine.getRoom(roomID)
			speakEvent	= Event()
			sentence	= ''
			
			for word in words:
				sentence = '{} {}'.format(sentence, word)
				
			speakEvent.attributes['signature']				= 'actor_emoted'
			speakEvent.attributes['data']['emoter']			= actor
			speakEvent.attributes['data']['target']			= None
			speakEvent.attributes['data']['emoterText']		= 'You say, "{}".'.format(sentence[1:])
			speakEvent.attributes['data']['audienceText']	= '{} says, "{}".'.format(actor.attributes['name'], sentence[1:])
			
			room.receiveEvent(speakEvent)
開發者ID:DaneBettis,項目名稱:python_mud,代碼行數:26,代碼來源:Say.py

示例15: wander

	def wander(self):
		from Event.Event import Event
		import Engine.ActorEngine
		
		commandEvent									= Event()
		commandEvent.attributes['signature']			= 'execute_command'
		commandEvent.attributes['data']['command']		= 'go'
		commandEvent.attributes['data']['args']			= 'n'
		commandEvent.attributes['data']['source']		= self
	
		Engine.ActorEngine.emitEvent(commandEvent)
開發者ID:longstl,項目名稱:python_mud,代碼行數:11,代碼來源:NPC.py


注:本文中的Event.Event.Event類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。