Skip to content

Commit

Permalink
- Fixing error with item store
Browse files Browse the repository at this point in the history
- Fixing incorrect number of fails with cron stones
- Fixing pictures for enhance for profit gear to display cron stones
  • Loading branch information
Graveflo committed May 19, 2021
1 parent 84a8db7 commit 92c3ab1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
8 changes: 5 additions & 3 deletions src/BDO_Enhancement_Tool/Widgets/TreeEquipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,13 @@ def populate_row(this_head, this_gear:Gear, eh_idx):
this_head.setText(idx_MAT_COST, MONNIES_FORMAT.format(round(restore_cost_vec_min)))

this_fail_map = numpy.array(this_gear.gear_type.map)[eh_idx]
#avg_num_fails = numpy.divide(numpy.ones(this_fail_map.shape), this_fail_map)[idx_] - 1
avg_num_fails = this_gear.gear_type.p_num_atmpt_map[eh_idx][idx_] - 1
if uses_crons:
avg_num_fails = (1/this_gear.gear_type.map[eh_idx][idx_])
else:
avg_num_fails = this_gear.gear_type.p_num_atmpt_map[eh_idx][idx_] - 1

this_head.setText(idx_NUM_FAILS, STR_TWO_DEC_FORMAT.format(avg_num_fails))
this_head.setText(idx_PROBABILITY, STR_PERCENT_FORMAT.format(this_fail_map[idx_] * 100.0))
this_head.setText(idx_PROBABILITY, STR_PERCENT_FORMAT.format(this_fail_map[idx_]))
if hasattr(this_gear, 'using_memfrags'):
this_head.setText(idx_USES_MEMFRAGS, str(this_gear.using_memfrags))

Expand Down
24 changes: 22 additions & 2 deletions src/BDO_Enhancement_Tool/Widgets/treeForProfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from BDO_Enhancement_Tool.Qt_common import SpeedUpTable, QBlockSig, lbl_color_MainWindow, NoScrollCombo, QColor
from BDO_Enhancement_Tool.Core.Gear import Gear, Smashable
from BDO_Enhancement_Tool.model import Enhance_model, Invalid_FS_Parameters
from BDO_Enhancement_Tool.qt_UI_Common import pix, STR_CALC_PIC
from BDO_Enhancement_Tool.qt_UI_Common import pix, STR_CALC_PIC, STR_PIC_CRON
from BDO_Enhancement_Tool.enh_for_profit import GearManager, GearNotProfitableException
from BDO_Enhancement_Tool.utilities import fmt_traceback
from .Abstract_Gear_Tree import AbstractGearTree, HEADER_NAME, HEADER_GEAR_TYPE, HEADER_BASE_ITEM_COST, HEADER_TARGET
Expand Down Expand Up @@ -153,8 +153,21 @@ def cmdCalc_clicked(self):
start = gear_widget.cmbLevel.get_level()
stop = manager.find_best_margin_for_start(start)
margin = manager.get_margin(start, stop)

eh_idx = start + 1
fs = numpy.argmin(this_gear.cost_vec[stop])
this_gear.set_enhance_lvl(this_gear.gear_type.idx_lvl_map[start + 1])
this_gear.set_enhance_lvl(this_gear.gear_type.idx_lvl_map[eh_idx])

uses_crons = eh_idx in this_gear.cron_use
if uses_crons:
if gear_widget.trinket is None:
gear_widget.set_trinket(pix[STR_PIC_CRON])
else:
if gear_widget.trinket is not None:
gear_widget.set_trinket(None)

gear_widget.set_pixmap(enhance_overlay=True)

self.add_children(this_head, start, stop, manager)
this_head.setText(idx_SELL_OUT, str(this_gear.gear_type.idx_lvl_map[stop]))
this_head.setText(idx_MARGIN, MONNIES_FORMAT.format(margin))
Expand Down Expand Up @@ -203,6 +216,13 @@ def add_children(self, top_lvl: QTreeWidgetItem, start, stop, manager):
fs = numpy.argmin(this_gear.cost_vec[i])
twi.setText(idx_FS, str(fs))
twi.setText(idx_MARGIN, MONNIES_FORMAT.format(margin))
uses_crons = i in this_gear.cron_use
if uses_crons:
if this_gw.trinket is None:
this_gw.set_trinket(pix[STR_PIC_CRON])
else:
if this_gw.trinket is not None:
this_gw.set_trinket(None)

def create_TreeWidgetItem(self, parent_wid, this_gear, check_state, icon_overlay=True) -> QTreeWidgetItem:
top_lvl = super(TableForProfit, self).create_TreeWidgetItem(parent_wid, this_gear, check_state, icon_overlay=False)
Expand Down
5 changes: 4 additions & 1 deletion src/BDO_Enhancement_Tool/bdo_database/gear_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def lookup_id(self, item_id) -> T:
with self:
conn = self.conn
cur = conn.cursor()
result = cur.fetchone('SELECT * FROM Gear WHERE gear_id=?', int(item_id))
cur.execute('SELECT * FROM Gear WHERE gear_id=?', (int(item_id),))
result = cur.fetchone()
if result is None:
raise KeyError('Item is not in gear database: {}'.format(item_id))
return self.process_row(result)

def query(self, str_query) -> List[T]:
Expand Down
10 changes: 5 additions & 5 deletions src/BDO_Enhancement_Tool/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def relative_path_convert(x):
from .Core.CronStones import initialize_cronstone_manager
DB_FOLDER = relative_path_convert('bdo_database') # Could be error if this is a file for some reason
initialize_cronstone_manager(os.path.join(DB_FOLDER, GEAR_DB)) # initialize this database before everything loads
GEAR_DB_MANAGER = CachedGearDataBase()
from .Core.Gear import gear_types, GearType, Gear
from .Core.ItemStore import ItemStore, ItemStoreException, STR_FMT_ITM_ID, ItemStoreItem

Expand Down Expand Up @@ -208,9 +207,9 @@ def get_gear_type(self) -> GearType:
return gear_types[self.get_gt_str()]


class CachedGearDataBase(CachedGearDataBase):
class GearGTDataBase(CachedGearDataBase):
def __init__(self, db_path=None):
super(CachedGearDataBase, self).__init__(db_path=db_path)
super(GearGTDataBase, self).__init__(db_path=db_path)
self.id_cache: Dict[int, GtGearData] = {}

def process_row(self, row) -> GtGearData:
Expand All @@ -219,8 +218,9 @@ def process_row(self, row) -> GtGearData:
return gd

def process_rows(self, rows) -> List[GtGearData]:
return super(CachedGearDataBase, self).process_rows(rows)
return super(GearGTDataBase, self).process_rows(rows)

def lookup_id(self, item_id) -> GtGearData:
return super(CachedGearDataBase, self).lookup_id(item_id)
return super(GearGTDataBase, self).lookup_id(item_id)

GEAR_DB_MANAGER = GearGTDataBase()

0 comments on commit 92c3ab1

Please sign in to comment.