1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-17 05:15:25 +08:00

Add: shop and build modules

This commit is contained in:
nEEtdo0d
2021-07-10 23:11:32 -04:00
parent 623fc1d921
commit c9bfb2d983
9 changed files with 1097 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
from module.base.decorator import cached_property
from module.logger import logger
from module.ocr.ocr import Digit
from module.shop.assets import *
from module.shop.base import ShopBase, ShopItemGrid
OCR_SHOP_GOLD_COINS = Digit(SHOP_GOLD_COINS, letter=(239, 239, 239), name='OCR_SHOP_GOLD_COINS')
OCR_SHOP_GEMS = Digit(SHOP_GEMS, letter=(255, 243, 82), name='OCR_SHOP_GEMS')
class GeneralShop(ShopBase):
_shop_gold_coins = 0
_shop_gems = 0
def shop_general_get_currency(self):
"""
Ocr shop general currency
"""
self._shop_gold_coins = OCR_SHOP_GOLD_COINS.ocr(self.device.image)
self._shop_gems = OCR_SHOP_GEMS.ocr(self.device.image)
logger.info(f'Gold coins: {self._shop_gold_coins}, Gems: {self._shop_gems}')
@cached_property
def shop_general_items(self):
"""
Returns:
ShopItemGrid:
"""
shop_grid = self.shop_grid
shop_general_items = ShopItemGrid(shop_grid, templates={}, amount_area=(60, 74, 96, 95))
shop_general_items.load_template_folder('./assets/general_shop')
shop_general_items.load_cost_template_folder('./assets/shop_cost')
return shop_general_items
def shop_general_check_item(self, item):
"""
Args:
item: Item to check
Returns:
bool: whether item can be bought
"""
if item.cost == 'Coins':
if item.price > self._shop_gold_coins:
return False
return True
if self.config.ENABLE_SHOP_GENERAL_GEMS:
if item.cost == 'Gems':
if item.price > self._shop_gems:
return False
return True
return False