Merge branch 'spellsnew'
						commit
						d5ba3d2da7
					
				|  | @ -9,6 +9,7 @@ INSERT INTO actioncosts ( | ||||||
|   abbr |   abbr | ||||||
| ) | ) | ||||||
| VALUES | VALUES | ||||||
|  |   (0, 'Varies', 'Varies'), | ||||||
|   (1, 'Single Action', '1'), |   (1, 'Single Action', '1'), | ||||||
|   (2, 'Two Actions', '2'), |   (2, 'Two Actions', '2'), | ||||||
|   (3, 'Three Actions', '3'), |   (3, 'Three Actions', '3'), | ||||||
|  |  | ||||||
|  | @ -1,11 +1,12 @@ | ||||||
| import json | import json | ||||||
| import sqlite3 | import sqlite3 | ||||||
|  | import io | ||||||
| 
 | 
 | ||||||
| def main(): | def main(): | ||||||
|     # load json into python |     # load json into python | ||||||
|     print("loading json") |     print("loading json") | ||||||
|     ## read file into memory |     ## read file into memory | ||||||
|     with open('spells.json') as f: |     with io.open('spellsNEW.json', 'r', encoding='utf-8-sig') as f: | ||||||
|         # raw_data = f.read() |         # raw_data = f.read() | ||||||
|         data = json.load(f) |         data = json.load(f) | ||||||
|     print("Importing {} spells.".format(len(data))) |     print("Importing {} spells.".format(len(data))) | ||||||
|  | @ -145,12 +146,29 @@ def do_spell_actions(i,id,conn,acttypes): | ||||||
| 
 | 
 | ||||||
|     try: |     try: | ||||||
|         conn.execute(stmt, inp) |         conn.execute(stmt, inp) | ||||||
|     except: |     except sqlite3.Error as e: | ||||||
|         print("Error updating actioncosts_id") |         print("Error updating actioncosts_id: {}".format(e)) | ||||||
|  |         print("\tSpell:{}\tinp:{}".format(i['name'],inp)) | ||||||
|     else: |     else: | ||||||
|         conn.commit() |         conn.commit() | ||||||
| 
 | 
 | ||||||
| def do_spell_components(i,id,conn,ctypes): | def do_spell_components(i,id,conn,ctypes): | ||||||
|  |     # this block handles heal or harm which have all 3 | ||||||
|  |     if i['name']=='Heal' or i['name']=='Harm': | ||||||
|  |         # print("Need to handle heal and harm") | ||||||
|  |         inp = [(id, 1), (id, 2), (id, 3)] | ||||||
|  |         stmt = "INSERT INTO spells_spellcomponents (spells_id, spellcomponents_id) VALUES (?,?)" | ||||||
|  |         try: | ||||||
|  |             conn.executemany(stmt, inp) | ||||||
|  |         except sqlite3.Error as e: | ||||||
|  |             print("Error inserting spell components: {}".format(e)) | ||||||
|  |             print("\tinp: {}".format(inp)) | ||||||
|  |         else: | ||||||
|  |             print("handled {} succesfully".format(i['name'])) | ||||||
|  |             conn.commit() | ||||||
|  |             return | ||||||
|  | 
 | ||||||
|  |     # this handles the rest | ||||||
|     res = None |     res = None | ||||||
|     for j in ctypes: |     for j in ctypes: | ||||||
|         for k in i['components']: |         for k in i['components']: | ||||||
|  |  | ||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Loading…
	
		Reference in New Issue