Skip to content

Commit

Permalink
- more error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Graveflo committed Aug 5, 2020
1 parent a5051c5 commit 41f014e
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 11 deletions.
10 changes: 10 additions & 0 deletions DlgCompact.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,16 @@ def insert_after_swap(self, insert_me, decision):
def validate(self):
settings = self.frmMain.model.settings
alts = settings[settings.P_ALTS]

if self.frmMain.fs_c is None:
self.frmMain.show_warning_msg('Cannot calculate strategy. Check fail stacking and enhancement equipment.')
self.ui.spinFS.setEnabled(False)
return False
if self.frmMain.eh_c is None:
self.frmMain.show_warning_msg('Cannot calculate strategy. Check fail stacking and enhancement equipment.')
self.ui.spinFS.setEnabled(False)
return False

if len(alts) <= 0:
self.frmMain.show_warning_msg('You must have at least one alt/toon registered to do this.')
self.ui.spinFS.setEnabled(False)
Expand Down
11 changes: 8 additions & 3 deletions FrmMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,11 @@ def cmdStrat_go_clicked(self):
if not len(model.cum_fs_cost) > 0:
self.cmdFSRefresh_clicked()
if not len(model.equipment_costs) > 0:
self.cmdEquipCost_clicked()
try:
self.cmdEquipCost_clicked()
except ValueError as e:
self.show_warning_msg(str(e))
return

mod_idx_gear_map = {}

Expand Down Expand Up @@ -1407,7 +1411,7 @@ def cmdStrat_go_clicked(self):
fs_c, eh_c = model.calcEnhances(enhance_me=mod_enhance_me)
self.fs_c = fs_c
self.eh_c = eh_c
except Invalid_FS_Parameters as f:
except ValueError as f:
self.show_warning_msg(str(f))
return
fs_c_T = fs_c.T
Expand Down Expand Up @@ -1554,7 +1558,7 @@ def cmdEquipCost_clicked(self):

try:
model.calc_equip_costs()
except Invalid_FS_Parameters as f:
except ValueError as f:
self.show_warning_msg(str(f))
return

Expand Down Expand Up @@ -2046,6 +2050,7 @@ def chk_click(state):
else:
if lvl not in this_gear.target_lvls:
this_gear.target_lvls.append(lvl)
#self.model.invalidate_enahce_list()

for lvl in these_lvls:
twi = QTreeWidgetItem(top_lvl_wid, [''] * tw.columnCount())
Expand Down
67 changes: 59 additions & 8 deletions based_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -570,20 +570,71 @@
"r_enhance_me": [],
"fail_stackers_count": {},
"alts": [],
"valks": [],
"valks": {},
"naderrs_band": [],
"quest_fs_inc": 0,
"_version": "0.0.1.1",
"_version": "0.0.1.3",
"num_fs": 300,
"cost_cron": 2000000,
"cost_cleanse": 100000,
"item_store": {
"items": {
"BLACK_STONE_ARMOR": 208000.0,
"BLACK_STONE_WEAPON": 213000.0,
"CONC_ARMOR": 2180000.0,
"CONC_WEAPON": 2940000.0,
"MEMORY_FRAG": 1270000.0,
"DRAGON_SCALE": 302000.0
"00016002": {
"name": "BLACK_STONE_ARMOR",
"prices": [
208000.0
],
"expires": 1596609683.1732109
},
"00016001": {
"name": "BLACK_STONE_WEAPON",
"prices": [
213000.0
],
"expires": 1596609683.1732109
},
"00016005": {
"name": "CONC_ARMOR",
"prices": [
2180000.0
],
"expires": 1596609683.1732109
},
"00016004": {
"name": "CONC_WEAPON",
"prices": [
2940000.0
],
"expires": 1596609683.1732109
},
"00004997": {
"name": "Hard Black Crystal Shard",
"prices": [
1470000
],
"expires": -1
},
"00004998": {
"name": "Sharp Black Crystal Shard",
"prices": [
2590000
],
"expires": -1
},
"00044195": {
"name": "MEMORY_FRAG",
"prices": [
1270000.0
],
"expires": 1596609683.1732109
},
"00044364": {
"name": "DRAGON_SCALE",
"prices": [
302000.0
],
"expires": 1596609683.1732109
}
}
},
"central_market_tax_rate": 0.65,
Expand Down
10 changes: 10 additions & 0 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ def calc_equip_costs(self):
fail_stackers = settings[EnhanceModelSettings.P_FAIL_STACKERS]
num_fs = settings[EnhanceSettings.P_NUM_FS]

if len(enhance_me) < 1:
raise ValueError('No enhancement Items')

gts = [x.gear_type for x in enhance_me]
gts.extend([x.gear_type for x in r_enhance_me])
gts = set(gts)
Expand Down Expand Up @@ -448,6 +451,13 @@ def calcEnhances(self, enhance_me=None, fail_stackers=None, count_fs=False, coun
if fail_stackers is None:
fail_stackers = settings[EnhanceModelSettings.P_FAIL_STACKERS]

if len(enhance_me) < 1:
raise ValueError('No enhance items')
return
if len(fail_stackers) < 1:
raise ValueError('No fail stacking items')
return

num_fs = settings[EnhanceSettings.P_NUM_FS]
cum_fs_cost = self.cum_fs_cost
cum_fs_cost = numpy.roll(cum_fs_cost, 1)
Expand Down

0 comments on commit 41f014e

Please sign in to comment.