Exemple #1
0
 def __build_reply(self, ob):
     result = ''
     for reply in ob.replies:
         if Helpers.is_string(reply):
             result += ' ' + reply
             continue
         args = reply['args']
         key = reply['key']
         item = None
         if 'item' in args.keys():
             item_name = args['item']
             item = self.get_room_item_by_name(item_name)
         template = args['template']
         if 'attacker_name' in args.keys():
             if args['attacker_name'].lower() in ['thief','ranger','fighter','mage']:
                 key = 'player_'+key
             else:
                 key = 'monster_'+key
         if template == ReplyHelpers.TEMPLATE_ACTION:
             result += ' ' + ReplyHelpers.render_action_template(key, **args)
         elif template == ReplyHelpers.TEMPLATE_ROOM:
             if item:
                 result += ' ' + ReplyHelpers.try_render_room_template(self, item, key, **args)
             else:
                 result += ' ' + ReplyHelpers.render_room_template(key, **args)
         elif template == ReplyHelpers.TEMPLATE_COMMON:
             result += ' ' + ReplyHelpers.render_common_template(key, **args)
         elif template == ReplyHelpers.TEMPLATE_DESCRIPTION:
             result += ' ' + ReplyHelpers.render_descr_template(key, **args)
     return result
Exemple #2
0
 def open(self, item):
     if isinstance(item, RoomOpenableItem):
         with Observer(item) as ob:
             item.open(self.__player)
             return self.__build_reply(ob)
     else:
         return ReplyHelpers.try_render_room_template(self, item, 'open_cannot')