fix bug for Alchemical Bombs in weapons.py and clean up output
parent
d710e27024
commit
b1f5ba95e2
|
@ -3,19 +3,19 @@ import sqlite3
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# load json into python
|
# load json into python
|
||||||
print("loading melee.csv")
|
print("loading melee.csv and ranged.csv")
|
||||||
## read file into memory
|
## read file into memory
|
||||||
rows = []
|
rows = []
|
||||||
with open('melee.csv') as f:
|
with open('melee.csv') as f:
|
||||||
reader = csv.DictReader(f)
|
reader = csv.DictReader(f)
|
||||||
print(reader)
|
# print(reader)
|
||||||
for row in reader:
|
for row in reader:
|
||||||
rows.append(row)
|
rows.append(row)
|
||||||
|
|
||||||
ranged_rows = []
|
ranged_rows = []
|
||||||
with open('ranged.csv') as f:
|
with open('ranged.csv') as f:
|
||||||
reader = csv.DictReader(f)
|
reader = csv.DictReader(f)
|
||||||
print(reader)
|
# print(reader)
|
||||||
for row in reader:
|
for row in reader:
|
||||||
ranged_rows.append(row)
|
ranged_rows.append(row)
|
||||||
|
|
||||||
|
@ -53,6 +53,8 @@ def main():
|
||||||
insert_traits(row, conn, traits)
|
insert_traits(row, conn, traits)
|
||||||
insert_fks(row, conn)
|
insert_fks(row, conn)
|
||||||
|
|
||||||
|
print("finished weapons")
|
||||||
|
|
||||||
def insert_fks(row, conn):
|
def insert_fks(row, conn):
|
||||||
# get category id
|
# get category id
|
||||||
rcat = row['category']
|
rcat = row['category']
|
||||||
|
@ -111,8 +113,10 @@ def insert_fks(row, conn):
|
||||||
dmg_id = 2
|
dmg_id = 2
|
||||||
elif dmg == 'S':
|
elif dmg == 'S':
|
||||||
dmg_id = 3
|
dmg_id = 3
|
||||||
|
elif row['name'] == "Alchemical Bomb":
|
||||||
|
dmg_id = None
|
||||||
else:
|
else:
|
||||||
print("Something went wrong here in weapon damage type land.")
|
print("Something went wrong here in weapon damage type land.{}".format(row))
|
||||||
|
|
||||||
inp = (res_id, grp_id, dmg_id, row['weapon_id'])
|
inp = (res_id, grp_id, dmg_id, row['weapon_id'])
|
||||||
stmt = "UPDATE weapons SET weaponcategories_id=?, weapongroups_id=?, damagetypes_id=? WHERE weapons_id=?;"
|
stmt = "UPDATE weapons SET weaponcategories_id=?, weapongroups_id=?, damagetypes_id=? WHERE weapons_id=?;"
|
||||||
|
@ -140,9 +144,9 @@ def insert_traits (row, conn, traits):
|
||||||
for i in traits:
|
for i in traits:
|
||||||
for j in splits:
|
for j in splits:
|
||||||
if i[1] == j:
|
if i[1] == j:
|
||||||
print("Trait_id:{}\tname:{}".format(i[0],i[1]))
|
# print("Trait_id:{}\tname:{}".format(i[0],i[1]))
|
||||||
trait_ids.append(i[0])
|
trait_ids.append(i[0])
|
||||||
print(trait_ids)
|
# print(trait_ids)
|
||||||
# all this mess removes non weapon traits that have duplicate names like
|
# all this mess removes non weapon traits that have duplicate names like
|
||||||
# Monk Ancestry versus Monk Weapon trait
|
# Monk Ancestry versus Monk Weapon trait
|
||||||
if len(splits) != len(trait_ids):
|
if len(splits) != len(trait_ids):
|
||||||
|
@ -176,7 +180,7 @@ def insert_traits (row, conn, traits):
|
||||||
|
|
||||||
|
|
||||||
def insert_ranged_weapon_basics(row, conn):
|
def insert_ranged_weapon_basics(row, conn):
|
||||||
print("Inserting: {}".format(row['name']))
|
# print("Inserting: {}".format(row['name']))
|
||||||
# insert everything that's not a lookup
|
# insert everything that's not a lookup
|
||||||
stmt = """
|
stmt = """
|
||||||
INSERT INTO weapons (
|
INSERT INTO weapons (
|
||||||
|
@ -208,7 +212,7 @@ def insert_ranged_weapon_basics(row, conn):
|
||||||
# print("Successfully inserted row")
|
# print("Successfully inserted row")
|
||||||
|
|
||||||
def insert_melee_weapon_basics(row, conn):
|
def insert_melee_weapon_basics(row, conn):
|
||||||
print("Inserting: {}".format(row['name']))
|
# print("Inserting: {}".format(row['name']))
|
||||||
# insert everything that's not a lookup
|
# insert everything that's not a lookup
|
||||||
stmt = """
|
stmt = """
|
||||||
INSERT INTO weapons (
|
INSERT INTO weapons (
|
||||||
|
|
Loading…
Reference in New Issue