mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-17 04:05:36 +08:00
Fix: Check currency > 0 before shop_buy_execute()
This commit is contained in:
@@ -75,11 +75,15 @@ class ShopBase(UI):
|
|||||||
Args:
|
Args:
|
||||||
key: String identifies func to acquire currency
|
key: String identifies func to acquire currency
|
||||||
for shop
|
for shop
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
int:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.__getattribute__(f'shop_{key}_get_currency')()
|
return self.__getattribute__(f'shop_{key}_get_currency')()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
logger.warning(f'shop_get_currency --> Missing func shop_{key}_get_currency')
|
logger.warning(f'shop_get_currency --> Missing func shop_{key}_get_currency')
|
||||||
|
return 0
|
||||||
|
|
||||||
def shop_items_loading_finished(self, items, key='medal'):
|
def shop_items_loading_finished(self, items, key='medal'):
|
||||||
"""
|
"""
|
||||||
@@ -209,7 +213,6 @@ class ShopBase(UI):
|
|||||||
Item: Item to buy, or None.
|
Item: Item to buy, or None.
|
||||||
"""
|
"""
|
||||||
items = self.shop_get_items(key=shop_type)
|
items = self.shop_get_items(key=shop_type)
|
||||||
self.shop_get_currency(key=shop_type)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
selection = selection.replace(' ', '').replace('\n', '').split('>')
|
selection = selection.replace(' ', '').replace('\n', '').split('>')
|
||||||
@@ -291,6 +294,10 @@ class ShopBase(UI):
|
|||||||
logger.hr(f'{shop_type} shop buy', level=2)
|
logger.hr(f'{shop_type} shop buy', level=2)
|
||||||
count = 0
|
count = 0
|
||||||
for _ in range(12):
|
for _ in range(12):
|
||||||
|
currency = self.shop_get_currency(key=shop_type)
|
||||||
|
if currency <= 0:
|
||||||
|
logger.warning(f'Not having enough currency: {currency}')
|
||||||
|
break
|
||||||
item = self.shop_get_item_to_buy(shop_type, selection)
|
item = self.shop_get_item_to_buy(shop_type, selection)
|
||||||
if item is None:
|
if item is None:
|
||||||
logger.info('Shop buy finished')
|
logger.info('Shop buy finished')
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class GeneralShop(ShopBase):
|
|||||||
self._shop_gold_coins = OCR_SHOP_GOLD_COINS.ocr(self.device.image)
|
self._shop_gold_coins = OCR_SHOP_GOLD_COINS.ocr(self.device.image)
|
||||||
self._shop_gems = OCR_SHOP_GEMS.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}')
|
logger.info(f'Gold coins: {self._shop_gold_coins}, Gems: {self._shop_gems}')
|
||||||
|
return self._shop_gold_coins
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def shop_general_items(self):
|
def shop_general_items(self):
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class GuildShop(ShopBase):
|
|||||||
"""
|
"""
|
||||||
self._shop_guild_coins = OCR_SHOP_GUILD_COINS.ocr(self.device.image)
|
self._shop_guild_coins = OCR_SHOP_GUILD_COINS.ocr(self.device.image)
|
||||||
logger.info(f'Guild coins: {self._shop_guild_coins}')
|
logger.info(f'Guild coins: {self._shop_guild_coins}')
|
||||||
|
return self._shop_guild_coins
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
@Config.when(SERVER='cn')
|
@Config.when(SERVER='cn')
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class MedalShop(ShopBase):
|
|||||||
"""
|
"""
|
||||||
self._shop_medal = OCR_SHOP_MEDAL.ocr(self.device.image)
|
self._shop_medal = OCR_SHOP_MEDAL.ocr(self.device.image)
|
||||||
logger.info(f'Medal: {self._shop_medal}')
|
logger.info(f'Medal: {self._shop_medal}')
|
||||||
|
return self._shop_medal
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def shop_medal_grid(self):
|
def shop_medal_grid(self):
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class MeritShop(ShopBase):
|
|||||||
"""
|
"""
|
||||||
self._shop_merit = OCR_SHOP_MERIT.ocr(self.device.image)
|
self._shop_merit = OCR_SHOP_MERIT.ocr(self.device.image)
|
||||||
logger.info(f'Merit: {self._shop_merit}')
|
logger.info(f'Merit: {self._shop_merit}')
|
||||||
|
return self._shop_merit
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def shop_merit_items(self):
|
def shop_merit_items(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user