mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-16 16:17:21 +08:00
Add: Purchase SkinBox by position
This commit is contained in:
@@ -1783,6 +1783,7 @@
|
|||||||
"Refresh": false,
|
"Refresh": false,
|
||||||
"BuySkinBox": "disabled",
|
"BuySkinBox": "disabled",
|
||||||
"BuySkinBoxAmount": 0,
|
"BuySkinBoxAmount": 0,
|
||||||
|
"SkinBoxPositionFilter": "1 > 2 > 3",
|
||||||
"ConsumeCoins": false,
|
"ConsumeCoins": false,
|
||||||
"Filter": "BookRedT3 > BookYellowT3 > BookBlueT3 > BookRedT2\n> Cube\n> FoodT6 > FoodT5"
|
"Filter": "BookRedT3 > BookYellowT3 > BookBlueT3 > BookRedT2\n> Cube\n> FoodT6 > FoodT5"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9987,6 +9987,10 @@
|
|||||||
"type": "input",
|
"type": "input",
|
||||||
"value": 0
|
"value": 0
|
||||||
},
|
},
|
||||||
|
"SkinBoxPositionFilter": {
|
||||||
|
"type": "textarea",
|
||||||
|
"value": "1 > 2 > 3"
|
||||||
|
},
|
||||||
"ConsumeCoins": {
|
"ConsumeCoins": {
|
||||||
"type": "checkbox",
|
"type": "checkbox",
|
||||||
"value": false
|
"value": false
|
||||||
|
|||||||
@@ -679,6 +679,8 @@ GeneralShop:
|
|||||||
value: disabled
|
value: disabled
|
||||||
option: [ disabled, unlimited, specified ]
|
option: [ disabled, unlimited, specified ]
|
||||||
BuySkinBoxAmount: 0
|
BuySkinBoxAmount: 0
|
||||||
|
SkinBoxPositionFilter: |-
|
||||||
|
1 > 2 > 3
|
||||||
ConsumeCoins: false
|
ConsumeCoins: false
|
||||||
Filter: |-
|
Filter: |-
|
||||||
BookRedT3 > BookYellowT3 > BookBlueT3 > BookRedT2
|
BookRedT3 > BookYellowT3 > BookBlueT3 > BookRedT2
|
||||||
|
|||||||
@@ -417,6 +417,7 @@ class GeneratedConfig:
|
|||||||
GeneralShop_Refresh = False
|
GeneralShop_Refresh = False
|
||||||
GeneralShop_BuySkinBox = 'disabled' # disabled, unlimited, specified
|
GeneralShop_BuySkinBox = 'disabled' # disabled, unlimited, specified
|
||||||
GeneralShop_BuySkinBoxAmount = 0
|
GeneralShop_BuySkinBoxAmount = 0
|
||||||
|
GeneralShop_SkinBoxPositionFilter = '1 > 2 > 3'
|
||||||
GeneralShop_ConsumeCoins = False
|
GeneralShop_ConsumeCoins = False
|
||||||
GeneralShop_Filter = 'BookRedT3 > BookYellowT3 > BookBlueT3 > BookRedT2\n> Cube\n> FoodT6 > FoodT5'
|
GeneralShop_Filter = 'BookRedT3 > BookYellowT3 > BookBlueT3 > BookRedT2\n> Cube\n> FoodT6 > FoodT5'
|
||||||
|
|
||||||
|
|||||||
@@ -3393,6 +3393,10 @@
|
|||||||
"name": "Purchase X Skin Boxes",
|
"name": "Purchase X Skin Boxes",
|
||||||
"help": "Takes effect when \"Purchase Specified Quantity\" is selected."
|
"help": "Takes effect when \"Purchase Specified Quantity\" is selected."
|
||||||
},
|
},
|
||||||
|
"SkinBoxPositionFilter": {
|
||||||
|
"name": "Specific Skin Box Filter",
|
||||||
|
"help": "Used when multiple skin box types are sold simultaneously in the shop. Enter position(s) to target specific skin boxes; positions start from 1 (left to right). Uses the same format as filters, e.g. 1 > 2 > 3.\nLeave empty for no restriction."
|
||||||
|
},
|
||||||
"ConsumeCoins": {
|
"ConsumeCoins": {
|
||||||
"name": "Consume Spilled Coins",
|
"name": "Consume Spilled Coins",
|
||||||
"help": "Buy all items when the coins exceed 550000"
|
"help": "Buy all items when the coins exceed 550000"
|
||||||
|
|||||||
@@ -3393,6 +3393,10 @@
|
|||||||
"name": "GeneralShop.BuySkinBoxAmount.name",
|
"name": "GeneralShop.BuySkinBoxAmount.name",
|
||||||
"help": "GeneralShop.BuySkinBoxAmount.help"
|
"help": "GeneralShop.BuySkinBoxAmount.help"
|
||||||
},
|
},
|
||||||
|
"SkinBoxPositionFilter": {
|
||||||
|
"name": "GeneralShop.SkinBoxPositionFilter.name",
|
||||||
|
"help": "GeneralShop.SkinBoxPositionFilter.help"
|
||||||
|
},
|
||||||
"ConsumeCoins": {
|
"ConsumeCoins": {
|
||||||
"name": "GeneralShop.ConsumeCoins.name",
|
"name": "GeneralShop.ConsumeCoins.name",
|
||||||
"help": "GeneralShop.ConsumeCoins.help"
|
"help": "GeneralShop.ConsumeCoins.help"
|
||||||
|
|||||||
@@ -3393,6 +3393,10 @@
|
|||||||
"name": "购买 X 个外观箱",
|
"name": "购买 X 个外观箱",
|
||||||
"help": "在选择“购买指定数量”时生效"
|
"help": "在选择“购买指定数量”时生效"
|
||||||
},
|
},
|
||||||
|
"SkinBoxPositionFilter": {
|
||||||
|
"name": "外观箱位置过滤器",
|
||||||
|
"help": "当商店中同时售卖多种外观箱时,通过填写外观箱位置,指定需要购买的外观箱,位置从左至右,由1开始,如:1 > 2 > 3\n空格表示无限制"
|
||||||
|
},
|
||||||
"ConsumeCoins": {
|
"ConsumeCoins": {
|
||||||
"name": "消耗溢出物资",
|
"name": "消耗溢出物资",
|
||||||
"help": "物资超过550000时购买所有消耗物资的物品"
|
"help": "物资超过550000时购买所有消耗物资的物品"
|
||||||
|
|||||||
@@ -3393,6 +3393,10 @@
|
|||||||
"name": "購買 X 個外觀箱",
|
"name": "購買 X 個外觀箱",
|
||||||
"help": "在選擇「購買指定數量」時生效"
|
"help": "在選擇「購買指定數量」時生效"
|
||||||
},
|
},
|
||||||
|
"SkinBoxPositionFilter": {
|
||||||
|
"name": "外觀箱位置過濾器",
|
||||||
|
"help": "當商店中同時售賣多種外觀箱時,通過填寫外觀箱位置,指定需要購買的外觀箱,位置從左至右,由1開始,如:1 > 2 > 3\n空格表示無限制"
|
||||||
|
},
|
||||||
"ConsumeCoins": {
|
"ConsumeCoins": {
|
||||||
"name": "消耗溢出物資",
|
"name": "消耗溢出物資",
|
||||||
"help": "物資超過550000時購買所有消耗物資的物品"
|
"help": "物資超過550000時購買所有消耗物資的物品"
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
from module.base.decorator import cached_property
|
from module.base.decorator import cached_property
|
||||||
|
from module.base.filter import Filter
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from module.shop.base import ShopItemGrid, ShopItemGrid_250814
|
from module.shop.base import ShopItemGrid, ShopItemGrid_250814
|
||||||
from module.shop.clerk import ShopClerk
|
from module.shop.clerk import ShopClerk
|
||||||
from module.shop.shop_status import ShopStatus
|
from module.shop.shop_status import ShopStatus
|
||||||
from module.shop.ui import ShopUI
|
from module.shop.ui import ShopUI
|
||||||
|
|
||||||
|
SKINBOX_POSITION_FILTER = Filter(re.compile(r'^(\d+)$'), ('position',))
|
||||||
|
|
||||||
|
|
||||||
class GeneralShop_250814(ShopClerk, ShopUI, ShopStatus):
|
class GeneralShop_250814(ShopClerk, ShopUI, ShopStatus):
|
||||||
gems = 0
|
gems = 0
|
||||||
@@ -18,6 +23,20 @@ class GeneralShop_250814(ShopClerk, ShopUI, ShopStatus):
|
|||||||
"""
|
"""
|
||||||
return self.config.GeneralShop_Filter.strip()
|
return self.config.GeneralShop_Filter.strip()
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def skinbox_allowed_positions(self):
|
||||||
|
"""
|
||||||
|
Returns:
|
||||||
|
set[int]: allowed 1-based positions, or None if unrestricted.
|
||||||
|
"""
|
||||||
|
skin_box_filter = self.config.GeneralShop_SkinBoxPositionFilter.strip()
|
||||||
|
if not skin_box_filter:
|
||||||
|
return None
|
||||||
|
SKINBOX_POSITION_FILTER.load(skin_box_filter)
|
||||||
|
allowed = {int(pos) for pos in SKINBOX_POSITION_FILTER.filter_raw if pos.isdigit()}
|
||||||
|
logger.attr('Skin_box_filter', ' > '.join([str(pos) for pos in allowed]))
|
||||||
|
return allowed if allowed else None
|
||||||
|
|
||||||
# New UI in 2025-08-14
|
# New UI in 2025-08-14
|
||||||
@cached_property
|
@cached_property
|
||||||
def shop_general_items(self):
|
def shop_general_items(self):
|
||||||
@@ -132,12 +151,32 @@ class GeneralShop_250814(ShopClerk, ShopUI, ShopStatus):
|
|||||||
# and design constantly changes i.e. equip skin box
|
# and design constantly changes i.e. equip skin box
|
||||||
logger.info(f'Item {item} is considered to be an equip skin box')
|
logger.info(f'Item {item} is considered to be an equip skin box')
|
||||||
if self._currency >= item.price:
|
if self._currency >= item.price:
|
||||||
|
if not self.skinbox_position_check():
|
||||||
|
return False
|
||||||
if mode == 'specified':
|
if mode == 'specified':
|
||||||
self.config.GeneralShop_BuySkinBoxAmount -= 1
|
self.config.GeneralShop_BuySkinBoxAmount -= 1
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def skinbox_position_check(self, item):
|
||||||
|
"""
|
||||||
|
Check if a skin box is in the allowed position where it should be bought.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
item: Item to check
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: whether the skin box is in the allowed position
|
||||||
|
"""
|
||||||
|
allowed = self.skinbox_allowed_positions
|
||||||
|
if allowed is None:
|
||||||
|
return True
|
||||||
|
|
||||||
|
grids = self.shop_general_items.grids
|
||||||
|
abs_pos = round((item.button[0] - grids.origin[0]) / grids.delta[0]) + 1
|
||||||
|
return abs_pos in allowed
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""
|
"""
|
||||||
Run General Shop
|
Run General Shop
|
||||||
|
|||||||
Reference in New Issue
Block a user