Updated as per Blitzmanns feedback

https://github.com/pyfa-org/Pyfa/pull/639#issuecomment-225749245
This commit is contained in:
Ebag333
2016-06-15 23:42:38 -07:00
parent 47828c38d2
commit 12ccc96f46
3 changed files with 23 additions and 18 deletions

View File

@@ -25,8 +25,8 @@ class ImportError(Exception):
class defaultDatabaseValues(): class defaultDatabaseValues():
instance = None instance = None
@classmethod
@classmethod
def importDamageProfileDefaults(self): def importDamageProfileDefaults(self):
damageProfileList = [] damageProfileList = []
damageProfileList.append(["Uniform", "25", "25", "25", "25"]) damageProfileList.append(["Uniform", "25", "25", "25", "25"])
@@ -115,12 +115,14 @@ class defaultDatabaseValues():
damageProfileList.append(["[NPC][Other] Sansha Incursion", "1682", "1347", "3678", "3678"]) damageProfileList.append(["[NPC][Other] Sansha Incursion", "1682", "1347", "3678", "3678"])
for damageProfileRow in damageProfileList: for damageProfileRow in damageProfileList:
damageProfile = eos.db.getDamagePattern(damageProfileRow[0]) name, em, therm, kin, exp = damageProfileRow
damageProfile = eos.db.getDamagePattern(name)
if damageProfile is None: if damageProfile is None:
damageProfile = eos.types.DamagePattern(damageProfileRow[1], damageProfileRow[2], damageProfileRow[3], damageProfileRow[4]) damageProfile = eos.types.DamagePattern(em, therm, kin, exp)
damageProfile.name = damageProfileRow[0] damageProfile.name = name
eos.db.save(damageProfile) eos.db.save(damageProfile)
@classmethod
def importResistProfileDefaults(self): def importResistProfileDefaults(self):
targetResistProfileList = [] targetResistProfileList = []
targetResistProfileList.append(["Uniform (25%)", "0.25", "0.25", "0.25", "0.25"]) targetResistProfileList.append(["Uniform (25%)", "0.25", "0.25", "0.25", "0.25"])
@@ -165,22 +167,24 @@ class defaultDatabaseValues():
targetResistProfileList.append(["[NPC][Burner] Ashimmu (Blood Raiders)", "0.8", "0.76", "0.68", "0.7"]) targetResistProfileList.append(["[NPC][Burner] Ashimmu (Blood Raiders)", "0.8", "0.76", "0.68", "0.7"])
targetResistProfileList.append(["[NPC][Burner] Talos", "0.68", "0.59", "0.59", "0.43"]) targetResistProfileList.append(["[NPC][Burner] Talos", "0.68", "0.59", "0.59", "0.43"])
targetResistProfileList.append(["[NPC][Burner] Sentinel", "0.58", "0.45", "0.52", "0.66"]) targetResistProfileList.append(["[NPC][Burner] Sentinel", "0.58", "0.45", "0.52", "0.66"])
for targetResistProfileRow in targetResistProfileList: for targetResistProfileRow in targetResistProfileList:
resistsProfile = eos.db.getTargetResists(targetResistProfileRow[0]) name, em, therm, kin, exp = targetResistProfileRow
resistsProfile = eos.db.eos.db.getTargetResists(name)
if resistsProfile is None: if resistsProfile is None:
resistsProfile = eos.types.eos.types.TargetResists(targetResistProfileRow[1], targetResistProfileRow[2], targetResistProfileRow[3], targetResistProfileRow[4]) resistsProfile = eos.types.TargetResists(em, therm, kin, exp)
resistsProfile.name = targetResistProfileRow[0] resistsProfile.name = name
eos.db.save(resistsProfile) eos.db.save(resistsProfile)
@classmethod
def importRequiredDefaults(self): def importRequiredDefaults(self):
damageProfileList = [] damageProfileList = []
damageProfileList.append(["Uniform", "25", "25", "25", "25"]) damageProfileList.append(["Uniform", "25", "25", "25", "25"])
for damageProfileRow in damageProfileList: for damageProfileRow in damageProfileList:
damageProfile = eos.db.getDamagePattern(damageProfileRow[0]) name, em, therm, kin, exp = damageProfileRow
damageProfile = eos.db.getDamagePattern(name)
if damageProfile is None: if damageProfile is None:
damageProfile = eos.types.DamagePattern(damageProfileRow[1], damageProfileRow[2], damageProfileRow[3], damageProfile = eos.types.DamagePattern(em, therm, kin, exp)
damageProfileRow[4]) damageProfile.name = name
damageProfile.name = damageProfileRow[0]
eos.db.save(damageProfile) eos.db.save(damageProfile)

View File

@@ -36,9 +36,8 @@ class DamagePattern():
def __init__(self): def __init__(self):
uniform = eos.db.getDamagePattern("Uniform") uniform = eos.db.getDamagePattern("Uniform")
importDBDefaults = loadDefaultDatabaseValues.defaultDatabaseValues()
if uniform is None: if uniform is None:
importDBDefaults.importRequiredDefaults() loadDefaultDatabaseValues.defaultDatabaseValues.importRequiredDefaults()
def getDamagePatternList(self): def getDamagePatternList(self):
return eos.db.getDamagePatternList() return eos.db.getDamagePatternList()

View File

@@ -52,17 +52,19 @@ if os.path.isfile(config.saveDB):
# If database exists, run migration after init'd database # If database exists, run migration after init'd database
eos.db.saveddata_meta.create_all() eos.db.saveddata_meta.create_all()
migration.update(eos.db.saveddata_engine) migration.update(eos.db.saveddata_engine)
# Import default database values
# Import values that must exist otherwise Pyfa breaks
loadDefaultDatabaseValues.defaultDatabaseValues.importRequiredDefaults()
else: else:
# If database does not exist, do not worry about migration. Simply # If database does not exist, do not worry about migration. Simply
# create and set version # create and set version
eos.db.saveddata_meta.create_all() eos.db.saveddata_meta.create_all()
eos.db.saveddata_engine.execute('PRAGMA user_version = {}'.format(migration.getAppVersion())) eos.db.saveddata_engine.execute('PRAGMA user_version = {}'.format(migration.getAppVersion()))
#Import default database values #Import default database values
importDBDefaults = loadDefaultDatabaseValues.defaultDatabaseValues()
#Import values that must exist otherwise Pyfa breaks #Import values that must exist otherwise Pyfa breaks
importDBDefaults.importRequiredDefaults() loadDefaultDatabaseValues.defaultDatabaseValues.importRequiredDefaults()
#Import default values for damage profiles #Import default values for damage profiles
importDBDefaults.importDamageProfileDefaults() loadDefaultDatabaseValues.defaultDatabaseValues.importDamageProfileDefaults()
#Import default values for target resist profiles #Import default values for target resist profiles
importDBDefaults.importResistProfileDefaults() loadDefaultDatabaseValues.defaultDatabaseValues.importResistProfileDefaults()