Skip to content

Commit cb9114c

Browse files
authored
Fix: none cost (#3947)
* fix: none cost * upd: assets
1 parent 674f79e commit cb9114c

5 files changed

Lines changed: 14 additions & 31 deletions

File tree

assets/shop/os/EmptyT1_1.png

12.8 KB
Loading

assets/shop/os/EmptyT2_1.png

14.4 KB
Loading

module/os_shop/item.py

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -115,44 +115,27 @@ def __init__(self, grids, templates, template_area=(40, 21, 89, 70), amount_area
115115
self.price_ocr = PRICE_OCR
116116
self.counter_area = counter_area
117117

118-
def predict(self, image, shop_index=None, scroll_pos=None) -> List[OSShopItem]:
118+
def predict(self, image, counter=False, shop_index=None, scroll_pos=None) -> List[OSShopItem]:
119119
"""
120120
Args:
121121
image (np.ndarray):
122+
counter (bool): If predict item counter.
122123
shop_index (bool): If predict shop index.
123124
scroll_pos (bool): If predict scroll position.
124125
125126
Returns:
126127
list[Item]:
127128
"""
128-
self._load_image(image)
129-
amount_list = [item.crop(self.amount_area) for item in self.items]
130-
amount_list = self.amount_ocr.ocr(amount_list, direct_ocr=True)
131-
counter_list = [item.crop(self.counter_area) for item in self.items]
132-
counter_list = self.counter_ocr.ocr(counter_list, direct_ocr=True)
133-
name_list = [self.match_template(item.image) for item in self.items]
134-
cost_list = [self.match_cost_template(item) for item in self.items]
135-
price_list = [item.crop(self.price_area) for item in self.items]
136-
price_list = self.price_ocr.ocr(price_list, direct_ocr=True)
137-
ignore = 0
138-
items = []
139-
140-
for i, a, t, n, c, p in zip(self.items, amount_list, counter_list, name_list, cost_list, price_list):
141-
if (p <= 0):
142-
ignore += 1
143-
continue
144-
i.amount = a
145-
i.count, i.total_count = t
146-
i.name = n
147-
i.cost = c
148-
i.price = p
149-
if isinstance(shop_index, int):
129+
super().predict(image, name=True, amount=True, cost=True, price=True)
130+
if counter and len(self.items):
131+
counter_list = [item.crop(self.counter_area) for item in self.items]
132+
counter_list = self.counter_ocr.ocr(counter_list, direct_ocr=True)
133+
for i, t in zip(self.items, counter_list):
134+
i.count, i.total_count = t
135+
136+
if isinstance(shop_index, int) and isinstance(scroll_pos, float) and len(self.items):
137+
for i in self.items:
150138
i.shop_index = shop_index
151-
if isinstance(scroll_pos, float):
152139
i.scroll_pos = scroll_pos
153-
items.append(i)
154140

155-
if ignore > 0:
156-
logger.warning(f'Ignore {ignore} items, because price <= 0')
157-
158-
return items
141+
return self.items

module/os_shop/port_shop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def os_shop_get_items(self, shop_index=False, scroll_pos=False) -> List[Item]:
7979
self.os_shop_items.grids = self._get_os_shop_grid()
8080
if self.config.SHOP_EXTRACT_TEMPLATE:
8181
self.os_shop_items.extract_template(self.device.image, './assets/shop/os')
82-
self.os_shop_items.predict(self.device.image, shop_index=shop_index, scroll_pos=scroll_pos)
82+
self.os_shop_items.predict(self.device.image, counter=True, shop_index=shop_index, scroll_pos=scroll_pos)
8383
shop_items = self.os_shop_items.items
8484

8585
if len(shop_items):

module/os_shop/shop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def handle_akashi_supply_buy(self, grid):
178178
def get_currency_coins(self, item):
179179
if item.cost == 'YellowCoins':
180180
if get_os_reset_remain() == 0:
181-
return self._shop_yellow_coins
181+
return self._shop_yellow_coins - 100
182182
elif self.is_cl1_enabled:
183183
return self._shop_yellow_coins - self.config.OS_CL1_YELLOW_COINS_PRESERVE
184184
else:

0 commit comments

Comments
 (0)