Browse Source

just use an inmem db

pull/91/head
andy 3 years ago
parent
commit
d8dee4bede
  1. 362
      tools/format_drops.py

362
tools/format_drops.py

@ -1,198 +1,184 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sqlite3
episodes = ['ep1', 'ep2', 'ep4'] episodes = ['ep1', 'ep2', 'ep4']
difficulties = ['normal', 'hard', 'veryhard', 'ultimate'] difficulties = ['normal', 'hard', 'veryhard', 'ultimate']
sectionids = ['viridia', 'greenill', 'skyly', 'bluefull', 'purplenum', 'pinkal', 'redria', 'oran', 'yellowboze', 'whitill'] sectionids = ['viridia', 'greenill', 'skyly', 'bluefull', 'purplenum', 'pinkal', 'redria', 'oran', 'yellowboze', 'whitill']
with open('drops','r') as infile: with open('drops','r') as infile:
drops = infile.readlines() drops = infile.readlines()
ep1drops = list(filter(lambda d: d.split(',')[0] == 'ep1', drops))
ep2drops = list(filter(lambda d: d.split(',')[0] == 'ep2', drops))
ep4drops = list(filter(lambda d: d.split(',')[0] == 'ep4', drops))
ep1monsters = list(set(line.split(',')[3] for line in ep1drops))
ep2monsters = list(set(line.split(',')[3] for line in ep2drops))
ep4monsters = list(set(line.split(',')[3] for line in ep4drops))
ep1monsters.sort()
ep2monsters.sort()
ep4monsters.sort()
ep1normal = list(filter(lambda d: d.split(',')[1] == 'normal', ep1drops))
ep1hard = list(filter(lambda d: d.split(',')[1] == 'hard', ep1drops))
ep1veryhard = list(filter(lambda d: d.split(',')[1] == 'veryhard', ep1drops))
ep1ultimate = list(filter(lambda d: d.split(',')[1] == 'ultimate', ep1drops))
print('ep1 normal drops')
for monster in ep1monsters:
monster_drops = list(filter(lambda d: d.split(',')[3] == monster, ep1normal)) # all drops for specific monster (list of strings)
print('{},'.format(monster), sep='', end='')
for sectionid in sectionids:
for md in monster_drops:
if sectionid in md:
print('{}'.format(md.split(',')[4]),sep='', end='')
print(',', sep='', end='')
print()
print('\n\n')
print('ep1 hard drops')
for monster in ep1monsters:
monster_drops = list(filter(lambda d: d.split(',')[3] == monster, ep1hard)) # all drops for specific monster (list of strings)
print('{},'.format(monster), sep='', end='')
for sectionid in sectionids:
for md in monster_drops:
if sectionid in md:
print('{}'.format(md.split(',')[4]),sep='', end='')
print(',', sep='', end='')
print()
print('\n\n')
print('ep1 veryhard drops')
for monster in ep1monsters:
monster_drops = list(filter(lambda d: d.split(',')[3] == monster, ep1veryhard)) # all drops for specific monster (list of strings)
print('{},'.format(monster), sep='', end='')
for sectionid in sectionids:
for md in monster_drops:
if sectionid in md:
print('{}'.format(md.split(',')[4]),sep='', end='')
print(',', sep='', end='')
print()
print('\n\n')
print('ep1 ultimate drops')
for monster in ep1monsters:
monster_drops = list(filter(lambda d: d.split(',')[3] == monster, ep1ultimate)) # all drops for specific monster (list of strings)
print('{},'.format(monster), sep='', end='')
for sectionid in sectionids:
for md in monster_drops:
if sectionid in md:
print('{}'.format(md.split(',')[4]),sep='', end='')
print(',', sep='', end='')
print()
print('\n\n')
print('\n\n\n\n\n\n')
# print drops per difficulty
ep2normal = list(filter(lambda d: d.split(',')[1] == 'normal', ep2drops))
ep2hard = list(filter(lambda d: d.split(',')[1] == 'hard', ep2drops))
ep2veryhard = list(filter(lambda d: d.split(',')[1] == 'veryhard', ep2drops))
ep2ultimate = list(filter(lambda d: d.split(',')[1] == 'ultimate', ep2drops))
print('ep2 normal drops')
for monster in ep2monsters:
monster_drops = list(filter(lambda d: d.split(',')[3] == monster, ep2normal)) # all drops for specific monster (list of strings)
print('{},'.format(monster), sep='', end='')
for sectionid in sectionids:
for md in monster_drops:
if sectionid in md:
print('{}'.format(md.split(',')[4]),sep='', end='')
print(',', sep='', end='')
print()
print('\n\n')
print('ep2 hard drops')
for monster in ep2monsters:
monster_drops = list(filter(lambda d: d.split(',')[3] == monster, ep2hard)) # all drops for specific monster (list of strings)
print('{},'.format(monster), sep='', end='')
for sectionid in sectionids:
for md in monster_drops:
if sectionid in md:
print('{}'.format(md.split(',')[4]),sep='', end='')
print(',', sep='', end='')
print()
print('\n\n')
print('ep2 veryhard drops')
for monster in ep2monsters:
monster_drops = list(filter(lambda d: d.split(',')[3] == monster, ep2veryhard)) # all drops for specific monster (list of strings)
print('{},'.format(monster), sep='', end='')
for sectionid in sectionids:
for md in monster_drops:
if sectionid in md:
print('{}'.format(md.split(',')[4]),sep='', end='')
print(',', sep='', end='')
print()
print('\n\n')
print('ep2 ultimate drops')
for monster in ep2monsters:
monster_drops = list(filter(lambda d: d.split(',')[3] == monster, ep2ultimate)) # all drops for specific monster (list of strings)
print('{},'.format(monster), sep='', end='')
for sectionid in sectionids:
for md in monster_drops:
if sectionid in md:
print('{}'.format(md.split(',')[4]),sep='', end='')
print(',', sep='', end='')
print()
print('\n\n')
print('\n\n\n\n\n\n')
# print drops per difficulty
ep4normal = list(filter(lambda d: d.split(',')[1] == 'normal', ep4drops))
ep4hard = list(filter(lambda d: d.split(',')[1] == 'hard', ep4drops))
ep4veryhard = list(filter(lambda d: d.split(',')[1] == 'veryhard', ep4drops))
ep4ultimate = list(filter(lambda d: d.split(',')[1] == 'ultimate', ep4drops))
print('ep4 normal drops')
for monster in ep4monsters:
monster_drops = list(filter(lambda d: d.split(',')[3] == monster, ep4normal)) # all drops for specific monster (list of strings)
print('{},'.format(monster), sep='', end='')
for sectionid in sectionids:
for md in monster_drops:
if sectionid in md:
print('{}'.format(md.split(',')[4]),sep='', end='')
print(',', sep='', end='')
print()
print('\n\n')
print('ep4 hard drops')
for monster in ep4monsters:
monster_drops = list(filter(lambda d: d.split(',')[3] == monster, ep4hard)) # all drops for specific monster (list of strings)
print('{},'.format(monster), sep='', end='')
for sectionid in sectionids:
for md in monster_drops:
if sectionid in md:
print('{}'.format(md.split(',')[4]),sep='', end='')
print(',', sep='', end='')
print()
print('\n\n')
print('ep4 veryhard drops')
for monster in ep4monsters:
monster_drops = list(filter(lambda d: d.split(',')[3] == monster, ep4veryhard)) # all drops for specific monster (list of strings)
print('{},'.format(monster), sep='', end='')
for sectionid in sectionids:
for md in monster_drops:
if sectionid in md:
print('{}'.format(md.split(',')[4]),sep='', end='')
print(',', sep='', end='')
print()
print('\n\n')
print('ep4 ultimate drops')
for monster in ep4monsters:
monster_drops = list(filter(lambda d: d.split(',')[3] == monster, ep4ultimate)) # all drops for specific monster (list of strings)
print('{},'.format(monster), sep='', end='')
for sectionid in sectionids:
for md in monster_drops:
if sectionid in md:
print('{}'.format(md.split(',')[4]),sep='', end='')
print(',', sep='', end='')
drops = [drop.strip() for drop in drops]
ep1monsters = [
'AlRappy',
'BarbarousWolf',
'Booma',
'Bulclaw',
'Canadine',
'Canane',
'ChaosBringer',
'ChaosSorcerer',
'Claw',
'DarkBelra',
'DarkGunner',
'Delsaber',
'Dimenian',
'Dubchic',
'EvilShark',
'Garanz',
'Gigobooma',
'Gillchic',
'Gobooma',
'GrassAssassin',
'GuilShark',
'Hidoom',
'Hildebear',
'Hildeblue',
'LaDimenian',
'Migium',
'Mothmant',
'NanoDragon',
'NarLily',
'PalShark',
'PanArms',
'PofuillySlime',
'PoisonLily',
'PouillySlime',
'RagRappy',
'SavageWolf',
'SinowBeat',
'SinowGold',
'SoDimenian',
'Dragon',
'DeRolLe',
'VolOpt',
'DarkFalz']
ep2monsters = [
'BarbarousWolf',
'ChaosSorcerer',
'DarkBelra',
'Delbiter',
'Deldepth',
'DelLily',
'Delsaber',
'Dimenian',
'Dolmdarl',
'Dolmolm',
'Dubchic',
'EasterRappy',
'Epsilon',
'Garanz',
'Gee',
'Gibbles',
'GiGue',
'Gillchic',
'GrassAssassin',
'HalloRappy',
'Hidoom',
'Hildebear',
'Hildeblue',
'IllGill',
'LaDimenian',
'LoveRappy',
'Mericarol',
'Mericus',
'Merikle',
'Merillia',
'Meriltas',
'Migium',
'Morfos',
'Mothmant',
'NarLily',
'PanArms',
'PoisonLily',
'RagRappy',
'Recon',
'SavageWolf',
'SinowBerill',
'SinowSpigell',
'SinowZele',
'SinowZoa',
'SoDimenian',
'StRappy',
'UlGibbon',
'ZolGibbon',
'BarbaRay',
'GolDragon',
'GalGryphon',
'OlgaFlow']
ep4monsters = [
'Astark',
'BaBoota',
'Boota',
'DelRappyCrater',
'DelRappyDesert',
'Dorphon',
'DorphonEclair',
'Girtablulu',
'Goran',
'GoranDetonator',
'MerissaA',
'MerissaAA',
'PazuzuCrater',
'PazuzuDesert',
'PyroGoran',
'SandRappyCrater',
'SandRappyDesert',
'SatelliteLizardCrater',
'SatelliteLizardDesert',
'YowieCrater',
'YowieDesert',
'ZeBoota',
'ZuCrater',
'ZuDesert',
'SaintMillion',
'Shambertin',
'Kondrieu']
epmonsters = {
'ep1': ep1monsters,
'ep2': ep2monsters,
'ep4': ep4monsters
}
conn = sqlite3.connect('elsewaredrops.db')
#conn = sqlite3.connect('memory:')
curs = conn.cursor()
def create_table():
curs.execute('CREATE TABLE IF NOT EXISTS drops (episode TEXT, difficulty TEXT, sectionid TEXT, monster TEXT, item TEXT, rate REAL)')
#conn.commit()
curs.execute("SELECT COUNT(*) FROM drops")
result = curs.fetchall()
if result[0][0] == 0:
for drop in drops:
line = drop.strip().split(',')
curs.execute("INSERT INTO drops (episode, difficulty, sectionid, monster, item, rate) VALUES (?, ?, ?, ?, ?, ?)", (line[0], line[1], line[2], line[3], line[4], line[5]))
else:
print("already data in the db")
conn.commit()
print('elseware drops')
for episode in episodes:
for difficulty in difficulties:
print('{} {}'.format(episode, difficulty))
print('enemy', sep='', end='')
for sectionid in sectionids:
print(',{}'.format(sectionid), sep='', end='')
print()
for monster in epmonsters[episode]:
print('{}'.format(monster), sep='', end='')
curs.execute("SELECT item FROM drops WHERE episode = '{}' AND difficulty = '{}' AND monster = '{}'".format(episode, difficulty, monster))
rows = curs.fetchall()
for row in rows:
print(',{}'.format(row[0]), sep='', end='')
print()
print()
print() print()
curs.close()
conn.close()
Loading…
Cancel
Save