1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-16 05:47:23 +08:00

Add: Purchase SkinBox by position

This commit is contained in:
positnuec
2026-03-09 16:49:48 +08:00
parent a07dffbeda
commit d0401e432c
9 changed files with 48 additions and 0 deletions

View File

@@ -1,10 +1,15 @@
import re
from module.base.decorator import cached_property
from module.base.filter import Filter
from module.logger import logger
from module.shop.base import ShopItemGrid, ShopItemGrid_250814
from module.shop.clerk import ShopClerk
from module.shop.shop_status import ShopStatus
from module.shop.ui import ShopUI
SKINBOX_POSITION_FILTER = Filter(re.compile(r'^(\d+)$'), ('position',))
class GeneralShop_250814(ShopClerk, ShopUI, ShopStatus):
gems = 0
@@ -18,6 +23,20 @@ class GeneralShop_250814(ShopClerk, ShopUI, ShopStatus):
"""
return self.config.GeneralShop_Filter.strip()
@cached_property
def skinbox_allowed_positions(self):
"""
Returns:
set[int]: allowed 1-based positions, or None if unrestricted.
"""
position_raw = self.config.GeneralShop_BuySkinBoxPosition
position_str = str(position_raw).strip() if position_raw is not None else None
if position_str is None:
return None
SKINBOX_POSITION_FILTER.load(position_str)
allowed = {int(r) for r in SKINBOX_POSITION_FILTER.filter_raw if r.isdigit()}
return allowed if allowed else None
# New UI in 2025-08-14
@cached_property
def shop_general_items(self):
@@ -132,6 +151,12 @@ class GeneralShop_250814(ShopClerk, ShopUI, ShopStatus):
# and design constantly changes i.e. equip skin box
logger.info(f'Item {item} is considered to be an equip skin box')
if self._currency >= item.price:
allowed = self.skinbox_allowed_positions
if allowed is not None:
grids = self.shop_general_items.grids
abs_pos = round((item.button[0] - grids.origin[0]) / grids.delta[0]) + 1
if abs_pos not in allowed:
return False
if mode == 'specified':
self.config.GeneralShop_BuySkinBoxAmount -= 1
return True