1111OCR_SHOP_PURPLE_COINS = Digit (SHOP_PURPLE_COINS , letter = (255 , 255 , 255 ), name = 'OCR_SHOP_PURPLE_COINS' )
1212
1313
14+ class ShopPriceOcr (Digit ):
15+ def __init__ (self , * args , ** kwargs ):
16+ kwargs ['alphabet' ] = '0123456789ID'
17+ super ().__init__ (* args , ** kwargs )
18+
19+ def after_process (self , result ):
20+ result = '' .join (result )
21+
22+ # I00 -> 100
23+ result = result .replace ('I' , '1' )
24+ # 1D -> 10
25+ result = result .replace ('D' , '0' )
26+ result = int (result ) if result else 0
27+ return result
28+
29+
1430class OSShopHandler (UI , MapEventHandler ):
1531 _shop_yellow_coins = 0
1632 _shop_purple_coins = 0
@@ -31,6 +47,7 @@ def os_shop_items(self):
3147 shop_items = ItemGrid (shop_grid , templates = {}, amount_area = (60 , 74 , 96 , 95 ))
3248 shop_items .load_template_folder ('./assets/shop/os' )
3349 shop_items .load_cost_template_folder ('./assets/shop/os_cost' )
50+ shop_items .price_ocr = ShopPriceOcr ([], letter = (255 , 223 , 57 ), threshold = 32 , name = 'Price_ocr' )
3451 return shop_items
3552
3653 def os_shop_get_items (self , name = True ):
0 commit comments