mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-12 08:38:20 +08:00
Feature: New OpsiShop. (#3086)
* feat: New OpsiShop * fix: use AdaptiveScroll * feat: scan counter * perf: calculate y value
This commit is contained in:
@@ -8,13 +8,18 @@ from module.logger import logger
|
||||
from module.map.map_grids import SelectedGrids
|
||||
from module.ocr.ocr import Digit
|
||||
from module.os_handler.assets import *
|
||||
from module.os_shop.assets import OS_SHOP_CHECK, OS_SHOP_PURPLE_COINS, SHOP_PURPLE_COINS, SHOP_YELLOW_COINS
|
||||
from module.ui.ui import UI
|
||||
|
||||
OCR_SHOP_YELLOW_COINS = Digit(SHOP_YELLOW_COINS, letter=(239, 239, 239), threshold=160, name='OCR_SHOP_YELLOW_COINS')
|
||||
OCR_SHOP_PURPLE_COINS = Digit(SHOP_PURPLE_COINS, letter=(255, 255, 255), name='OCR_SHOP_PURPLE_COINS')
|
||||
OCR_OS_SHOP_PURPLE_COINS = Digit(OS_SHOP_PURPLE_COINS, letter=(255, 255, 255), name='OCR_OS_SHOP_PURPLE_COINS')
|
||||
|
||||
|
||||
class OSStatus(UI):
|
||||
_shop_yellow_coins = 0
|
||||
_shop_purple_coins = 0
|
||||
|
||||
@property
|
||||
def is_in_task_explore(self) -> bool:
|
||||
return self.config.task.command == 'OpsiExplore'
|
||||
@@ -54,7 +59,7 @@ class OSStatus(UI):
|
||||
|
||||
def get_yellow_coins(self, skip_first_screenshot=True) -> int:
|
||||
timeout = Timer(2, count=3).start()
|
||||
while 1:
|
||||
while True:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
@@ -75,5 +80,24 @@ class OSStatus(UI):
|
||||
return yellow_coins
|
||||
|
||||
def get_purple_coins(self) -> int:
|
||||
amount = OCR_SHOP_PURPLE_COINS.ocr(self.device.image)
|
||||
return amount
|
||||
if self.appear(OS_SHOP_CHECK):
|
||||
return OCR_OS_SHOP_PURPLE_COINS.ocr(self.device.image)
|
||||
else:
|
||||
return OCR_SHOP_PURPLE_COINS.ocr(self.device.image)
|
||||
|
||||
def os_shop_get_coins(self):
|
||||
self._shop_yellow_coins = self.get_yellow_coins()
|
||||
self._shop_purple_coins = self.get_purple_coins()
|
||||
logger.info(f'Yellow coins: {self._shop_yellow_coins}, purple coins: {self._shop_purple_coins}')
|
||||
|
||||
def get_currency_coins(self, item):
|
||||
return self._shop_yellow_coins - (
|
||||
self.config.OS_CL1_YELLOW_COINS_PRESERVE if self.is_cl1_enabled else
|
||||
self.config.OS_NORMAL_YELLOW_COINS_PRESERVE
|
||||
) if item.cost == 'YellowCoins' \
|
||||
else self._shop_purple_coins - self.config.OS_NORMAL_PURPLE_COINS_PRESERVE
|
||||
|
||||
def is_coins_both_not_enough(self):
|
||||
return self._shop_yellow_coins < (self.config.OS_CL1_YELLOW_COINS_PRESERVE if self.is_cl1_enabled else
|
||||
self.config.OS_NORMAL_YELLOW_COINS_PRESERVE) \
|
||||
and self._shop_purple_coins < self.config.OS_NORMAL_PURPLE_COINS_PRESERVE
|
||||
|
||||
Reference in New Issue
Block a user