当前位置: 首页>>代码示例>>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;未经允许,请勿转载。