def sendFinal(self, message): self.send(message) self.send( ANSI.magenta("\n\r[") + ANSI.yellow("HP: ") + ANSI.white(self.attributes["player"].attributes["currentHP"]) + ANSI.yellow(" Mana: ") + ANSI.white(self.attributes["player"].attributes["currentMana"]) + ANSI.magenta("]: ") )
def sendFinal(self, message): self.send(message) self.send('\n\r{}\n\r\t{} {}\n\r\t{} {}\n\r\t{}{}\n\r{}: '.format( ANSI.magenta('['), ANSI.yellow('HP:'), ANSI.white(self.attributes['player'].attributes['currentHP']), ANSI.yellow('Mana:'), ANSI.white(self.attributes['player'].attributes['currentMana']), ANSI.yellow('Options:'), self.attributes['player'].attributes['menus'][-1].getOptions(), ANSI.magenta(']')))
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)
def listEquipment(self): equipArray = [] equipment = filter(lambda item: item != None, [ self.attributes['equipment']['Head'], self.attributes['equipment']['Ears'], self.attributes['equipment']['Eyes'], self.attributes['equipment']['Face'], self.attributes['equipment']['Neck'][0], self.attributes['equipment']['Neck'][1], self.attributes['equipment']['Body'], self.attributes['equipment']['Arms'], self.attributes['equipment']['Wrist'][0], self.attributes['equipment']['Wrist'][1], self.attributes['equipment']['Hands'], self.attributes['equipment']['Finger'][0], self.attributes['equipment']['Finger'][1], self.attributes['equipment']['Waist'], self.attributes['equipment']['Legs'], self.attributes['equipment']['Feet'], self.attributes['equipment']['Shield'], self.attributes['equipment']['Wielded'] ]) for item in equipment: slot = item.attributes['itemClass'] equipArray.append('{}\t: {} {}'.format( ANSI.yellow(slot), item.attributes['adjective'], item.attributes['name'])) return equipArray
def listEquipment(self): equipArray = [] equipment = filter(lambda item: item != None, [self.attributes['equipment']['Head'], self.attributes['equipment']['Ears'], self.attributes['equipment']['Eyes'], self.attributes['equipment']['Face'], self.attributes['equipment']['Neck'][0], self.attributes['equipment']['Neck'][1], self.attributes['equipment']['Body'], self.attributes['equipment']['Arms'], self.attributes['equipment']['Wrist'][0], self.attributes['equipment']['Wrist'][1], self.attributes['equipment']['Hands'], self.attributes['equipment']['Finger'][0], self.attributes['equipment']['Finger'][1], self.attributes['equipment']['Waist'], self.attributes['equipment']['Legs'], self.attributes['equipment']['Feet'], self.attributes['equipment']['Shield'], self.attributes['equipment']['Wielded']]) for item in equipment: slot = item.attributes['itemClass'] equipArray.append('{}\t: {} {}'.format(ANSI.yellow(slot), item.attributes['adjective'], item.attributes['name'])) return equipArray
def getDescription(self): description = [ANSI.yellow("You see {} the {}.".format(self.attributes["name"], self.attributes["race"]))] if len(self.attributes["description"]) > 0: for line in self.attributes["description"]: description.append(ANSI.cyan(line)) equipment = self.attributes["inventory"].listEquipment() if len(equipment) > 0: description = description + equipment return description
def getDescription(self): description = [ ANSI.yellow('You see {} the {}.'.format(self.attributes['name'], self.attributes['race'])) ] if len(self.attributes['description']) > 0: for line in self.attributes['description']: description.append(ANSI.cyan(line)) equipment = self.attributes['inventory'].listEquipment() if len(equipment) > 0: description = description + equipment return description
def handleEvent(self, event): receiver = event.attributes['receiver'] option = event.attributes['data']['option'] validOptions = receiver.attributes['options'] player = receiver.attributes['player'] if validOptions.has_key(option): tuple = validOptions[option] function = tuple[1] function() else: feedbackEvent = Event() feedbackEvent.attributes['signature'] = 'received_feedback' feedbackEvent.attributes['data']['feedback'] = ANSI.yellow('Invalid option!') feedbackEvent.attributes['data']['actor'] = player Engine.ActorEngine.emitEvent(feedbackEvent)
def handleEvent(self, event): receiver = event.attributes['receiver'] option = event.attributes['data']['option'] validOptions = receiver.attributes['options'] player = receiver.attributes['player'] if validOptions.has_key(option): tuple = validOptions[option] function = tuple[1] function() else: feedbackEvent = Event() feedbackEvent.attributes['signature'] = 'received_feedback' feedbackEvent.attributes['data']['feedback'] = ANSI.yellow( 'Invalid option!') feedbackEvent.attributes['data']['actor'] = player Engine.ActorEngine.emitEvent(feedbackEvent)