def __init__(self, templateJson, room): import EventHandlers.SpawnTemplate EventReceiver.__init__(self) EventEmitter.__init__(self, None) attributes = { 'npcID' : '', 'npcs' : [], 'wanderRate' : .5, 'spawnRate' : .5, 'room' : room } for key in attributes.keys(): self.attributes[key] = attributes[key] for key in templateJson.keys(): if key == 'eventHandlers': for element in templateJson[key]: adjusters = (lambda dictionary: dictionary.has_key('adjusters') and dictionary['adjusters'] or None)(element) self.addEventHandlerByNameWithAdjusters(element['name'], adjusters) else: self.attributes[key] = templateJson[key] room.addEventSubscriber(self)
def __init__(self, templateJson, room): import EventHandlers.SpawnTemplate EventReceiver.__init__(self) EventEmitter.__init__(self, None) attributes = { 'npcID': '', 'npcs': [], 'wanderRate': .5, 'spawnRate': .5, 'room': room } for key in attributes.keys(): self.attributes[key] = attributes[key] for key in templateJson.keys(): if key == 'eventHandlers': for element in templateJson[key]: adjusters = ( lambda dictionary: dictionary.has_key('adjusters') and dictionary['adjusters'] or None)(element) self.addEventHandlerByNameWithAdjusters( element['name'], adjusters) else: self.attributes[key] = templateJson[key] room.addEventSubscriber(self)
def __init__(self): EventReceiver.__init__(self) EventEmitter.__init__(self, None) attributes = {'name': '', 'destination': '', 'isHidden': False} for key in attributes.keys(): self.attributes[key] = attributes[key]
def __init__(self): threading.Thread.__init__(self) EventEmitter.__init__(self, None) tickEvent = Event() tickEvent.attributes['signature'] = 'game_tick' self.tickEvent = tickEvent TickDriver.instance = self
def __init__(self): EventReceiver.__init__(self) EventEmitter.__init__(self, None) attributes = { 'name' : '', 'destination' : '', 'isHidden' : False } for key in attributes.keys(): self.attributes[key] = attributes[key]
def __init__(self, inventoryJson, owner): EventReceiver.__init__(self) EventEmitter.__init__(self, None) self.attributes['items'] = [] self.attributes['owner'] = owner if inventoryJson != None: for itemJson in inventoryJson['items']: item = self.createItem(itemJson) if item != None: self.attributes['items'].append(item) owner.addEventSubscriber(self)
def __init__(self, itemJson, inventory): EventReceiver.__init__(self) attributes = { 'itemType' : '', 'itemClass' : '', 'itemID' : '', 'name' : '', 'pluralName' : '', 'description' : [], 'inventory' : inventory, 'stats' : { 'weight':0 } } for key in attributes.keys(): self.attributes[key] = attributes[key] out_adjusters = [] if itemJson != None: for key in itemJson.keys(): if key == 'out_adjusters': out_adjusters = itemJson[key] else: self.attributes[key] = itemJson[key] self.attributes['adjective'] = (lambda char: ((char == 'a' or char == 'e' or char == 'i' or char == 'o' or char == 'u') and 'an') or 'a')(self.attributes['name'].lower()[0]) self.addEventHandlerByNameWithAdjusters('Item.EventHandlers.Item.ActorAttemptedDropHandler', None) self.addEventHandlerByNameWithAdjusters('Item.EventHandlers.Item.ItemDroppedHandler', None) self.addEventHandlerByNameWithAdjusters('Item.EventHandlers.Item.ActorAttemptedItemGrabHandler', None) self.addEventHandlerByNameWithAdjusters('Item.EventHandlers.Item.ActorGrabbedItemHandler', None) self.addEventHandlerByNameWithAdjusters('Item.EventHandlers.Item.ActorAttemptedItemEquipHandler', None) self.addEventHandlerByNameWithAdjusters('Item.EventHandlers.Item.WasObservedHandler', None) EventEmitter.__init__(self, out_adjusters) inventory.addEventSubscriber(self)
def __init__(self, actorJSON): import Engine.RoomEngine import Engine.ActorEngine from Inventory.ActorInventory import ActorInventory from AI.AI import AI EventReceiver.__init__(self) attributes = { 'id': '', 'name': '', 'description': [], 'race': 'Human', 'gender': '', 'roomID': '0', 'stats': { 'strength': 0, #physical skills, inventory limit 'constitution': 0, #combat tree, max hp 'agility': 0, #stealth tree, dodging 'energy': 0, #magic skills, max mana 'focus': 0, #psionic skills, mana regen 'awareness': 0, #traps tree, searching 'ingenuity': 0, #crafting tree, critical hits 'composure': 0 #support tree, hp regen }, 'currentHP': 0, 'maxHP': 0, 'currentMana': 0, 'maxMana': 0, 'eventAdjusters': {}, 'eventHandlers': {}, 'inventory': None } out_adjusters = [] inventory = None if actorJSON != None: for key in actorJSON.keys(): if key == 'inventory': inventory = actorJSON[key] elif key == 'eventHandlers': for element in actorJSON[key]: adjusters = ( lambda dictionary: dictionary.has_key('adjusters') and dictionary['adjusters'] or None)(element) self.addEventHandlerByNameWithAdjusters( element['name'], adjusters) elif key == 'out_adjusters': out_adjusters = actorJSON[key] elif key == 'AI': self.attributes['AI'] = AI(actorJSON[key]) else: attributes[key] = actorJSON[key] for key in attributes.keys(): self.attributes[key] = attributes[key] Engine.ActorEngine.addEventSubscriber(self) startingRoom = Engine.RoomEngine.getRoom(self.attributes['roomID']) startingRoom.addEventSubscriber(self) self.addEventHandlerByNameWithAdjusters( 'Actor.EventHandlers.Actor.ActorAttemptedDropHandler', None) self.addEventHandlerByNameWithAdjusters( 'Actor.EventHandlers.Actor.ItemDroppedHandler', None) self.addEventHandlerByNameWithAdjusters( 'Actor.EventHandlers.Actor.ActorInitiatedItemGrabHandler', None) self.addEventHandlerByNameWithAdjusters( 'Actor.EventHandlers.Actor.ActorGrabbedItemHandler', None) self.addEventHandlerByNameWithAdjusters( 'Actor.EventHandlers.Actor.ActorAttemptedItemEquipHandler', None) self.addEventHandlerByNameWithAdjusters( 'Actor.EventHandlers.Actor.ActorAttemptedItemRemovalHandler', None) self.addEventHandlerByNameWithAdjusters( 'Actor.EventHandlers.Actor.ActorMovedFromRoomEventHandler', None) self.addEventHandlerByNameWithAdjusters( 'Actor.EventHandlers.Actor.ActorGainedHealthFromTickHandler', None) #add event handlers specific to this actor's race filePath = '{}/Content/races/{}.txt'.format(currentDir, self.attributes['race']) raceFile = open(filePath, 'r') jsonString = raceFile.read() jsonObj = json.loads(jsonString) handlers = jsonObj['eventHandlers'] if jsonObj.has_key('out_adjusters'): out_adjusters = out_adjusters + jsonObj['out_adjusters'] raceFile.close() for handler in handlers: adjusters = (lambda dictionary: dictionary.has_key('adjusters') and dictionary['adjusters'] or None)(handler) self.addEventHandlerByNameWithAdjusters(handler['name'], adjusters) EventEmitter.__init__(self, out_adjusters) if inventory != None: self.attributes['inventory'] = ActorInventory(inventory, self) else: self.attributes['inventory'] = ActorInventory(None, self)
def __init__(self): threading.Thread.__init__(self) EventEmitter.__init__(self, None) UpdateDriver.instance = self
def __init__(self): threading.Thread.__init__(self) EventEmitter.__init__(self, None) LoginListener.instance = self
def __init__(self): EventReceiver.__init__(self) EventEmitter.__init__(self, None)
def __init__(self, actorJSON): import Engine.RoomEngine import Engine.ActorEngine from Inventory.ActorInventory import ActorInventory from AI.AI import AI EventReceiver.__init__(self) attributes = { "id": "", "name": "", "description": [], "race": "Human", "gender": "", "roomID": "0", "stats": { "strength": 0, # physical skills, inventory limit "constitution": 0, # combat tree, max hp "agility": 0, # stealth tree, dodging "energy": 0, # magic skills, max mana "focus": 0, # psionic skills, mana regen "awareness": 0, # traps tree, searching "ingenuity": 0, # crafting tree, critical hits "composure": 0, # support tree, hp regen }, "currentHP": 0, "maxHP": 0, "currentMana": 0, "maxMana": 0, "eventAdjusters": {}, "eventHandlers": {}, "inventory": None, } out_adjusters = [] inventory = None if actorJSON != None: for key in actorJSON.keys(): if key == "inventory": inventory = actorJSON[key] elif key == "eventHandlers": for element in actorJSON[key]: adjusters = ( lambda dictionary: dictionary.has_key("adjusters") and dictionary["adjusters"] or None )(element) self.addEventHandlerByNameWithAdjusters(element["name"], adjusters) elif key == "out_adjusters": out_adjusters = actorJSON[key] elif key == "AI": self.attributes["AI"] = AI(actorJSON[key]) else: attributes[key] = actorJSON[key] for key in attributes.keys(): self.attributes[key] = attributes[key] Engine.ActorEngine.addEventSubscriber(self) startingRoom = Engine.RoomEngine.getRoom(self.attributes["roomID"]) startingRoom.addEventSubscriber(self) self.addEventHandlerByNameWithAdjusters("Actor.EventHandlers.Actor.ActorAttemptedDropHandler", None) self.addEventHandlerByNameWithAdjusters("Actor.EventHandlers.Actor.ItemDroppedHandler", None) self.addEventHandlerByNameWithAdjusters("Actor.EventHandlers.Actor.ActorInitiatedItemGrabHandler", None) self.addEventHandlerByNameWithAdjusters("Actor.EventHandlers.Actor.ActorGrabbedItemHandler", None) self.addEventHandlerByNameWithAdjusters("Actor.EventHandlers.Actor.ActorAttemptedItemEquipHandler", None) self.addEventHandlerByNameWithAdjusters("Actor.EventHandlers.Actor.ActorAttemptedItemRemovalHandler", None) self.addEventHandlerByNameWithAdjusters("Actor.EventHandlers.Actor.ActorMovedFromRoomEventHandler", None) self.addEventHandlerByNameWithAdjusters("Actor.EventHandlers.Actor.ActorGainedHealthFromTickHandler", None) # add event handlers specific to this actor's race filePath = "{}/Content/races/{}.txt".format(currentDir, self.attributes["race"]) raceFile = open(filePath, "r") jsonString = raceFile.read() jsonObj = json.loads(jsonString) handlers = jsonObj["eventHandlers"] if jsonObj.has_key("out_adjusters"): out_adjusters = out_adjusters + jsonObj["out_adjusters"] raceFile.close() for handler in handlers: adjusters = (lambda dictionary: dictionary.has_key("adjusters") and dictionary["adjusters"] or None)( handler ) self.addEventHandlerByNameWithAdjusters(handler["name"], adjusters) EventEmitter.__init__(self, out_adjusters) if inventory != None: self.attributes["inventory"] = ActorInventory(inventory, self) else: self.attributes["inventory"] = ActorInventory(None, self)
def __init__(self): threading.Thread.__init__(self) EventEmitter.__init__(self, None) ConnectionListUpdater.instance = self
def __init__(self): EventEmitter.__init__(self, None)
def __init__(self, roomJson): import threading from Exit import Exit import Engine.RoomEngine from Inventory.RoomInventory import RoomInventory from SpawnTemplate import SpawnTemplate EventReceiver.__init__(self) attributes = { 'playerSemaphore' : threading.BoundedSemaphore(1), 'roomID' : '', 'name' : '', 'description' : [], 'exits' : [], 'players' : [], 'npcs' : [], 'spawnableNPCs' : [], 'inventory' : None, 'spawnTemplates' : [] } out_adjusters = [] inventory = None spawnTemplates = None for key in attributes.keys(): self.attributes[key] = attributes[key] for key in roomJson.keys(): if key == 'exits': for exitJson in roomJson[key]: exit = Exit() for field in exitJson.keys(): exit.attributes[field] = exitJson[field] self.attributes[key].append(exit) elif key == 'eventHandlers': for element in roomJson[key]: adjusters = (lambda dictionary: dictionary.has_key('adjusters') and dictionary['adjusters'] or None)(element) self.addEventHandlerByNameWithAdjusters(element['name'], adjusters) elif key == 'inventory': inventory = roomJson[key] elif key == 'spawnTemplates': spawnTemplates = roomJson[key] elif key == 'out_adjusters': out_adjusters = roomJson[key] else: self.attributes[key] = roomJson[key] self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.ActorAttemptedMovementEventHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.ActorMovedFromRoomEventHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.ActorAddedToRoomEventHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.ActorObservedHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.WasObservedHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.ActorEmotedHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.PlayerLogoutHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.SpellCastAttempted', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.ActorAttemptedItemGrabHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.ActorGrabbedItemHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.ItemDroppedHandler', None) Engine.RoomEngine.addEventSubscriber(self) EventEmitter.__init__(self, out_adjusters) if inventory != None: self.attributes['inventory'] = RoomInventory(inventory, self) else: self.attributes['inventory'] = RoomInventory(None, self) if spawnTemplates != None: for template in spawnTemplates: spawnTemplate = SpawnTemplate(template, self) self.attributes['spawnTemplates'].append(spawnTemplate)