mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-30 15:33:52 +08:00
Fix: Check currency > 0 before shop_buy_execute()
This commit is contained in:
@@ -289,23 +289,21 @@ class ShopBase(UI):
|
|||||||
selection: String user configured value, items desired
|
selection: String user configured value, items desired
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
int:
|
bool: If success, and able to continue.
|
||||||
"""
|
"""
|
||||||
logger.hr(f'{shop_type} shop buy', level=2)
|
logger.hr(f'{shop_type} shop buy', level=2)
|
||||||
count = 0
|
|
||||||
for _ in range(12):
|
for _ in range(12):
|
||||||
currency = self.shop_get_currency(key=shop_type)
|
currency = self.shop_get_currency(key=shop_type)
|
||||||
if currency <= 0:
|
if currency <= 0:
|
||||||
logger.warning(f'Not having enough currency: {currency}')
|
logger.warning(f'Not having enough currency: {currency}')
|
||||||
break
|
return False
|
||||||
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')
|
||||||
return count
|
return True
|
||||||
else:
|
else:
|
||||||
self.shop_buy_execute(item)
|
self.shop_buy_execute(item)
|
||||||
count += 1
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logger.warning('Too many items to buy, stopped')
|
logger.warning('Too many items to buy, stopped')
|
||||||
return count
|
return True
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ class RewardShop(GachaUI, ShopUI, GeneralShop, GuildShop, MedalShop, MeritShop):
|
|||||||
return
|
return
|
||||||
|
|
||||||
for _ in range(2):
|
for _ in range(2):
|
||||||
self.shop_buy(shop_type=shop_type, selection=selection)
|
success = self.shop_buy(shop_type=shop_type, selection=selection)
|
||||||
|
if not success:
|
||||||
|
break
|
||||||
if refresh and self.shop_refresh(shop_type):
|
if refresh and self.shop_refresh(shop_type):
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user