mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-24 00:55:56 +08:00
Opt: Early stop medal shop if having any item soldout
This commit is contained in:
@@ -101,6 +101,15 @@ class ShopItemGrid(ItemGrid):
|
|||||||
class ShopItemGrid_250814(ShopItemGrid):
|
class ShopItemGrid_250814(ShopItemGrid):
|
||||||
item_class = ShopItem_250814
|
item_class = ShopItem_250814
|
||||||
|
|
||||||
|
def get_soldout_count(self, image):
|
||||||
|
count = 0
|
||||||
|
for button in self.grids.buttons:
|
||||||
|
item = self.item_class(image, button)
|
||||||
|
if not item.is_valid:
|
||||||
|
count += 1
|
||||||
|
logger.attr('Item soldout', count)
|
||||||
|
return count
|
||||||
|
|
||||||
|
|
||||||
class ShopBase(UI):
|
class ShopBase(UI):
|
||||||
_currency = 0
|
_currency = 0
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ import module.config.server as server
|
|||||||
from module.base.button import ButtonGrid
|
from module.base.button import ButtonGrid
|
||||||
from module.base.decorator import Config, cached_property, del_cached_property
|
from module.base.decorator import Config, cached_property, del_cached_property
|
||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
from module.base.utils import area_offset
|
from module.base.utils import area_offset, rgb2gray
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from module.base.utils import rgb2gray
|
|
||||||
from module.map_detection.utils import Points
|
from module.map_detection.utils import Points
|
||||||
from module.ocr.ocr import Digit, DigitYuv, Ocr
|
from module.ocr.ocr import Digit, DigitYuv, Ocr
|
||||||
from module.shop.assets import *
|
from module.shop.assets import *
|
||||||
@@ -340,7 +339,7 @@ class MedalShop2_250814(MedalShop2):
|
|||||||
def shop_medal_items(self):
|
def shop_medal_items(self):
|
||||||
"""
|
"""
|
||||||
Returns:
|
Returns:
|
||||||
ShopItemGrid:
|
ShopItemGrid_250814:
|
||||||
"""
|
"""
|
||||||
shop_grid = self.shop_grid
|
shop_grid = self.shop_grid
|
||||||
shop_medal_items = ShopItemGrid_250814(
|
shop_medal_items = ShopItemGrid_250814(
|
||||||
@@ -390,7 +389,14 @@ class MedalShop2_250814(MedalShop2):
|
|||||||
MEDAL_SHOP_SCROLL_250814.set_top(main=self)
|
MEDAL_SHOP_SCROLL_250814.set_top(main=self)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
while 1:
|
while 1:
|
||||||
|
# sold items are auto sorted behind
|
||||||
|
# if we find any soldout items, no need to check behind
|
||||||
|
if self.shop_items().get_soldout_count(self.device.image):
|
||||||
|
logger.info('Medal shop early stop')
|
||||||
|
break
|
||||||
|
|
||||||
self.shop_buy()
|
self.shop_buy()
|
||||||
|
|
||||||
if MEDAL_SHOP_SCROLL_250814.at_bottom(main=self):
|
if MEDAL_SHOP_SCROLL_250814.at_bottom(main=self):
|
||||||
logger.info('Medal shop reach bottom, stop')
|
logger.info('Medal shop reach bottom, stop')
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user