本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)