示例#1
0
文件: Item.py 项目: nloadholtes/brass
 def __init__(self, manager):
     Item.__init__(self, manager)
     self.name = 'Ammo'
     self.stat = 'ammo'
     self.adj = 'reloads'
     self.value = 1
     self.amt = 10
示例#2
0
文件: Item.py 项目: nloadholtes/brass
 def __init__(self, manager):
     Item.__init__(self, manager)
     self.name = 'Bomb'
     self.adj = 'blasts'
     self.empty = 'The %s has already been detonated!'
     self.value = -100
     self.amt = 1
示例#3
0
文件: Item.py 项目: nloadholtes/brass
 def __init__(self, manager):
     Item.__init__(self, manager)
     self.name = 'Food'
     self.fmtline = '@TARGET eats the @NAME '
     self.stat = 'health'
     self.empty = "The %s has already been eaten!"
     self.value = 1
     self.amt = 1
示例#4
0
文件: Item.py 项目: nloadholtes/brass
 def __init__(self, manager):
     Item.__init__(self, manager)
     self.name = 'Gun'
     self.stat = 'health'
     self.value = -10
     self.amt = 1
     self.range = 100
     self.fmtline = "@TARGET @ADJ @VALUE points"
     self.adj = ('gets blasted for', 'sucks it down for', 'eats hot lead and looses', 'gets shot up for', 'gets nailed for', 'isn\'t fast enough and gets hit for' ,
         'feels the kiss of hot lead and looses')
示例#5
0
文件: JavLib.py 项目: fredzs/JavLib
def key_check_new():
    logging.info('----------开始更新----------')
    base_dir = Config.get_config_field()['updating_dir']
    updating_list = os.listdir(base_dir)
    # start_index = updating_list.index('NTRD') + 1
    for key in updating_list:
        try:
            start = Utility.find_num(DBItemService.db_find_max_code(key)) + 1
            global retry
            retry = 0
            for cur_num in range(start, 1000):
                item = Item(key, cur_num)
                if retry > int(Config.get_config_field()["retry_times"]):
                    logging.info("番号处理完毕" + key)
                    break
                search_by_code(item, True, 'updating')
                if cur_num % 20 == 0:
                    DBItemService.db_commit(item.get_key)
        except Exception as e:
            logging.error(e)
        finally:
            DBItemService.db_commit(key)

            db_key = DBKeyService.copy_to_db(key)
            DBKeyService.db_update(db_key)
            DBKeyService.db_commit(db_key.key_)

            Utility.delete_extra_file(key, 'updating')
    logging.info('----------更新结束----------')
示例#6
0
文件: JavLib.py 项目: fredzs/JavLib
def download_failed():
    logging.info('----------重新处理失败的Code----------')
    todo_list = list()
    failed_list = list()
    with open('failed_list.txt', 'r') as f:
        for line in f:
            todo_list.append(line.strip('\n'))
            failed_list.append(line.strip('\n'))

    i = 0
    for code in todo_list:
        try:
            item = Item(Utility.find_key(code), Utility.find_num(code))
            keyset = KeySet(item.get_key)
            keyset.set_download_path(Config.get_config_field()["download_dir"])
            search_by_code(item, True, 'download')
            if os.path.exists(keyset.get_key_path + item.get_title + ".jpg"):
                failed_list.pop(i)
            else:
                i += 1
        except Exception as e:
            logging.error(e)
        finally:
            DBItemService.db_commit(item.get_key)
            with open('failed_list.txt', 'w') as file:
                for line in failed_list:
                    file.writelines('{0}\n'.format(line))
    logging.info('处理失败的Code结束。')
示例#7
0
文件: Item.py 项目: nloadholtes/brass
 def use(self, target):
     log = logging.getLogger(__name__ + ".use")
     if target.__class__ == Ammo:
         #print "reload!"
         #print target.__class__
         #val = getattr(target, self.stat, 0) + self.value
         s = self.fmtline
         s = s.replace('@NAME', self.name)
         s = s.replace('@TARGET', target.name)
         s = s.replace('@ADJ', 'reloads with')
         s = s.replace('@STAT', self.stat)
         s = s.replace('@VALUE', str(abs(target.amt)))
         log.debug(s)
         #setattr(target, target.amt, val)
         #target.amt = val
         #print '\tAmmo has ', target.amt, ' amt'
         #print '\tgun has ', self.amt, ' amt'
         self.amt += target.amt
         target.amt = 0
     else:
         Item.use(self, target)
示例#8
0
文件: JavLib.py 项目: fredzs/JavLib
def search_codes():
    logging.info('----------开始按Code搜索----------')
    for i, code in enumerate(Config.get_code_list()):
        if code != "":
            download_path = Config.get_config_field(
            )["download_dir"] + Utility.find_key(code) + '/'
            if not os.path.exists(download_path):
                os.makedirs(download_path)
            global retry
            retry = 0
            item = Item(Utility.find_key(code), Utility.find_num(code))
            if retry > int(Config.get_config_field()["retry_times"]):
                break
            search_by_code(item, True, "download")
            if i % 20 == 19:
                DBItemService.db_commit(item.get_key)
    logging.info('按Code搜索结束。')
示例#9
0
文件: JavLib.py 项目: fredzs/JavLib
def search_keys():
    logging.info('----------开始按Key搜索----------')
    for keyset in Config.get_key_list():
        if not os.path.exists(keyset.get_key_path):
            os.makedirs(keyset.get_key_path)
        global retry
        retry = 0
        for cur_num in range(keyset.get_start, keyset.get_end):
            item = Item(keyset.get_key, cur_num)
            if retry > int(Config.get_config_field()["retry_times"]):
                logging.info("番号处理完毕" + keyset.get_key)
                break
            search_by_code(item, True, 'download')
            if cur_num % 20 == 0:
                DBItemService.db_commit(item.get_key)
        DBItemService.db_commit(keyset.get_key)
        Utility.delete_extra_file(keyset.get_key, 'download')
    logging.info('----------按Key搜索结束----------')
示例#10
0
文件: JavLib.py 项目: fredzs/JavLib
def db_add():
    logging.info('开始向数据库中导入。')
    base_dir = Config.get_config_field()['arrange_dir']
    for key in os.listdir(base_dir):
        key_dir = base_dir + key
        global retry
        retry = 0
        if os.path.exists(key_dir):
            for i, file in enumerate(
                    filter(lambda x: x.endswith(".jpg"), os.listdir(key_dir))):
                item = Item(Utility.find_key(file), Utility.find_num(file))
                if retry > int(Config.get_config_field()["retry_times"]):
                    logging.info("番号处理完毕" + key)
                    break
                search_by_code(item, False, 'download')
                if i % 5 == 4:
                    DBItemService.db_commit(item.get_key)
        DBItemService.db_commit(key)
    logging.info('----------向数据库中导入结束----------')
示例#11
0
文件: Item.py 项目: nloadholtes/brass
 def __init__(self, manager):
     Item.__init__(self, manager)
     self.name = 'Belladonna'
     self.adj = 'poisons'
     self.value = -1
     self.amt = 1
示例#12
0
文件: Item.py 项目: nloadholtes/brass
 def __init__(self, manager):
     Item.__init__(self, manager)
     self.name = 'Health Potion'
     self.adj = 'heals'
     self.value = 10
     self.amt = 1
示例#13
0
 def get_bill(p):
     return Item.get_all(p)
示例#14
0
 def set_bill(name, patient, cost):
     item = Item(name=name, p=patient, cost=cost)
     item.add_item()
     return