SegFault

在2016年5月6日 (星期五)加入
删除23字节 、​ 2016年10月17日 (星期一)
无编辑摘要
无编辑摘要
无编辑摘要
 
第5行: 第5行:
url = 'http://login.jianniang.com/index/getInitConfigs'
url = 'http://login.jianniang.com/index/getInitConfigs'


specialShipNames = [ '重庆', '奥希金斯', '信赖', '萝德尼' ]
countryNames = [ '', '日本', '德国', '英国', '美国', '意大利', '法国', '苏联', '中国' ]
 
countryNames = [ '', '日本', '德国', '英国', '美国', '意大利', '法国', '苏联', '中国', '???' ]
shipTypeNames = [ '', '航空母舰', '轻型航空母舰', '装甲航母', '战列舰', '航空战列舰', '战列巡洋舰', '重巡洋舰', \
shipTypeNames = [ '', '航空母舰', '轻型航空母舰', '装甲航母', '战列舰', '航空战列舰', '战列巡洋舰', '重巡洋舰', \
         'CAV', 'CLT', '轻巡洋舰', '浅水重炮舰', '驱逐舰', 'SSV', '潜艇', '重炮潜艇', '补给舰' ]
         'CAV', 'CLT', '轻巡洋舰', '浅水重炮舰', '驱逐舰', 'SSV', '潜艇', '重炮潜艇', '补给舰' ]
第14行: 第12行:


remodelPostfix = '·改'
remodelPostfix = '·改'
specialPostfix = '(特殊)'
canNotEquip = '不可装备'
canNotEquip = '不可装备'
noEquipt = '无'
noEquipt = '无'
第27行: 第24行:
desc = '简介'
desc = '简介'


def getShipName(ship):
def getShipName(ship, allShips):
     name = ship['title'].strip()
     name = ship['title'].strip()
     idx = int(ship['shipIndex'])
     idx = int(ship['shipIndex'])
     if idx < 1000 or name in specialShipNames:
     if idx < 1000:
         return name
         return name
     elif idx < 2000:
 
         return name + remodelPostfix
     orig = [ s for s in allShips if int(s['shipIndex']) == idx % 1000 ][0]
     else:
    if name == orig['title'].strip():
        return name + specialPostfix
         name += remodelPostfix
     return name


def getShipAttr(ship, allShips, equipts):
def getShipAttr(ship, allShips, equipts):
第53行: 第51行:
         eq[i] = noEquipt
         eq[i] = noEquipt


     ret = "ships['%s'] = {\n    " % getShipName(ship)
     ret = "ships['%s'] = {\n    " % getShipName(ship, allShips)


     ret += "index=%s, " % int(ship['shipIndex'])
     ret += "index=%s, " % int(ship['shipIndex'])
第120行: 第118行:


         ret = ret[:-1] + '\n    '
         ret = ret[:-1] + '\n    '
         ret += "mod='%s', " % getShipName(t[0])
         ret += "mod='%s', " % getShipName(t[0], allShips)
         ret += "modLv=%s, " % ship['evoLevel']
         ret += "modLv=%s, " % ship['evoLevel']
         ret += "coreType='%s', " % coreNames[ship['evoNeedItemCid']]
         ret += "coreType='%s', " % coreNames[ship['evoNeedItemCid']]
第131行: 第129行:
     return ret[:-2] + '\n}\n'
     return ret[:-2] + '\n}\n'


def getDialogue(ship):
def getDialogue(ship, allShips):
     name = getShipName(ship)
     name = getShipName(ship, allShips)
     ret = "ships['" + name + "']['" + aquire + "'] = '" + ship['getDialogue'].strip() + "'\n"
     ret = "ships['" + name + "']['" + aquire + "'] = '" + ship['getDialogue'].strip() + "'\n"
     if ship['mainDialogue'] and ship['mainDialogue'][0]:
     if ship['mainDialogue'] and ship['mainDialogue'][0]:
第174行: 第172行:


def parse(data):
def parse(data):
     f = open('数据.txt', 'w')
     f = open('data.lua', 'w')
     f.write('local equipts = { }\nlocal ships = { }\n\n')
     f.write('local equipts = { }\nlocal ships = { }\n\n')


第180行: 第178行:
     f.write('-' * 100 + '\n\n')
     f.write('-' * 100 + '\n\n')
     for equipt in data['shipEquipmnt']:
     for equipt in data['shipEquipmnt']:
         if equipt['picId'] == 998: continue
         #if equipt['picId'] == 998: continue
         if equipt['title'] == '喵' or equipt['title'] == '': continue
         if equipt['title'] == '喵' or equipt['title'] == '': continue
         f.write(getEquiptAttr(equipt))
         f.write(getEquiptAttr(equipt))
第195行: 第193行:
     f.write('-' * 100 + '\n\n')
     f.write('-' * 100 + '\n\n')
     for s in ships:
     for s in ships:
         f.write(getDialogue(s))
         f.write(getDialogue(s, ships))


     f.write('-' * 100 + '\n\n')
     f.write('-' * 100 + '\n\n')