-got weapon traits for ranged and melee working
parent
80f77b6c76
commit
0c1dbb4010
|
@ -1,4 +1,4 @@
|
|||
weapon_m_id,name,category,price_gp,dice_size,damage_type,bulk,hands,group,traits,sources_id,sources_pg,description
|
||||
weapon_id,name,category,price_gp,dice_size,damage_type,bulk,hands,group,traits,sources_id,sources_pg,description
|
||||
0,Fist,Unarmed,0,4,B,0,1,Brawling,"Agile, Finesse, Nonlethal, Unarmed",1,280,Nethys Note: no description was provided for this item
|
||||
1,Clan Dagger,Simple,2,4,P,0.1,1,Knife,"Agile, Dwarf, Parry, Uncommon, Versatile B",1,280,"This broad dagger is carried by dwarves as a weapon, tool, and designation of clan. Losing or having to surrender a clan dagger is considered a mark of embarrassment to most dwarves."
|
||||
2,Club,Simple,0,6,B,1,1,Club,"Thrown 10 ft., Thrown",1,280,This is a piece of stout wood shaped or repurposed to bludgeon an enemy. Clubs can be intricately carved pieces of martial art or as simple as a tree branch or piece of wood.
|
||||
|
|
|
|
@ -1,4 +1,4 @@
|
|||
weapon_r_id,name,category,price_gp,dice_size,damage_type,range,reload,bulk,hands,group,traits,sources_id,sources_pg,description
|
||||
weapon_id,name,category,price_gp,dice_size,damage_type,range,reload,bulk,hands,group,traits,sources_id,sources_pg,description
|
||||
67,Blowgun,Simple,0.1,1,P,20,1,0.1,1,Dart,"Agile, Nonlethal",1,281,"This long, narrow tube is used for shooting blowgun darts, using only the power of a forcefully exhaled breath."
|
||||
68,Crossbow,Simple,3,8,P,120,1,1,2,Bow,,1,281,"This ranged weapon has a bow-like assembly mounted on a handled frame called a tiller. The tiller has a mechanism to lock the bowstring in place, attached to a trigger mechanism that releases the tension and launches a bolt."
|
||||
69,Dart,Simple,0.01,4,P,20,,0.1,1,Dart,"Agile, Thrown",1,281,This thrown weapon is larger than an arrow but shorter than a javelin. It typically has a short shaft of wood ending in a metal tip and is sometimes stabilized by feathers or fur.
|
||||
|
|
|
|
@ -45,9 +45,62 @@ def main():
|
|||
|
||||
for row in rows:
|
||||
insert_melee_weapon_basics(row, conn)
|
||||
insert_traits(row, conn, traits)
|
||||
|
||||
for row in ranged_rows:
|
||||
insert_ranged_weapon_basics(row, conn)
|
||||
insert_traits(row, conn, traits)
|
||||
|
||||
def insert_traits (row, conn, traits):
|
||||
|
||||
# get list of traits from row
|
||||
tmp = row['traits']
|
||||
# exit this if no traits
|
||||
if tmp == '':
|
||||
return
|
||||
splits = tmp.split(", ")
|
||||
# print(tmp)
|
||||
# print(tmp.split(", "))
|
||||
|
||||
trait_ids = []
|
||||
# get trait IDs
|
||||
for i in traits:
|
||||
for j in splits:
|
||||
if i[1] == j:
|
||||
print("Trait_id:{}\tname:{}".format(i[0],i[1]))
|
||||
trait_ids.append(i[0])
|
||||
print(trait_ids)
|
||||
# all this mess removes non weapon traits that have duplicate names like
|
||||
# Monk Ancestry versus Monk Weapon trait
|
||||
if len(splits) != len(trait_ids):
|
||||
remove_me = []
|
||||
for i in trait_ids:
|
||||
if i >= 217 and i <= 251:
|
||||
continue
|
||||
elif i >= 255 and i <= 269:
|
||||
continue
|
||||
# 203 = uncommon trait
|
||||
elif i == 203:
|
||||
continue
|
||||
else:
|
||||
remove_me.append(i)
|
||||
for i in remove_me:
|
||||
trait_ids.remove(i)
|
||||
# print(trait_ids)
|
||||
|
||||
stmt = "INSERT INTO weapons_traits (weapons_id, trait_id) VALUES (?,?);"
|
||||
|
||||
for i in trait_ids:
|
||||
inp = (row['weapon_id'], i)
|
||||
try:
|
||||
conn.execute(stmt, inp)
|
||||
except sqlite.Error as e:
|
||||
print("Error inserting trait information: {}".format(e))
|
||||
else:
|
||||
conn.commit()
|
||||
# print("Successfully inserted row")
|
||||
|
||||
|
||||
|
||||
def insert_ranged_weapon_basics(row, conn):
|
||||
print("Inserting: {}".format(row['name']))
|
||||
|
@ -69,7 +122,7 @@ def insert_ranged_weapon_basics(row, conn):
|
|||
VALUES (?,?,?,?,?,?,?,?,?,?,?);
|
||||
"""
|
||||
r = row
|
||||
inp = (r['weapon_r_id'],r['sources_id'],r['sources_pg'],r['price_gp'],
|
||||
inp = (r['weapon_id'],r['sources_id'],r['sources_pg'],r['price_gp'],
|
||||
r['dice_size'],r['bulk'],r['hands'],r['name'],r['description'],
|
||||
r['range'],r['reload'])
|
||||
|
||||
|
@ -98,7 +151,7 @@ def insert_melee_weapon_basics(row, conn):
|
|||
VALUES (?,?,?,?,?,?,?,?,?);
|
||||
"""
|
||||
r = row
|
||||
inp = (r['weapon_m_id'],r['sources_id'],r['sources_pg'],r['price_gp'],
|
||||
inp = (r['weapon_id'],r['sources_id'],r['sources_pg'],r['price_gp'],
|
||||
r['dice_size'],r['bulk'],r['hands'],r['name'],r['description'])
|
||||
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue