mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-11 22:08:20 +08:00
Opt: sumbit items in island transport
This commit is contained in:
@@ -29,6 +29,7 @@ TEMPLATE_ISLAND_MANJUU = Template(file={'cn': './assets/cn/island/TEMPLATE_ISLAN
|
||||
TEMPLATE_ISLAND_SWITCH = Template(file={'cn': './assets/cn/island/TEMPLATE_ISLAND_SWITCH.png', 'en': './assets/cn/island/TEMPLATE_ISLAND_SWITCH.png', 'jp': './assets/cn/island/TEMPLATE_ISLAND_SWITCH.png', 'tw': './assets/cn/island/TEMPLATE_ISLAND_SWITCH.png'})
|
||||
TEMPLATE_ITEM_SATISFIED = Template(file={'cn': './assets/cn/island/TEMPLATE_ITEM_SATISFIED.png', 'en': './assets/cn/island/TEMPLATE_ITEM_SATISFIED.png', 'jp': './assets/cn/island/TEMPLATE_ITEM_SATISFIED.png', 'tw': './assets/cn/island/TEMPLATE_ITEM_SATISFIED.png'})
|
||||
TEMPLATE_MILK = Template(file={'cn': './assets/cn/island/TEMPLATE_MILK.png', 'en': './assets/cn/island/TEMPLATE_MILK.png', 'jp': './assets/cn/island/TEMPLATE_MILK.png', 'tw': './assets/cn/island/TEMPLATE_MILK.png'})
|
||||
TEMPLATE_PORK = Template(file={'cn': './assets/cn/island/TEMPLATE_PORK.png', 'en': './assets/cn/island/TEMPLATE_PORK.png', 'jp': './assets/cn/island/TEMPLATE_PORK.png', 'tw': './assets/cn/island/TEMPLATE_PORK.png'})
|
||||
TEMPLATE_PROJECT_LOCKED = Template(file={'cn': './assets/cn/island/TEMPLATE_PROJECT_LOCKED.png', 'en': './assets/cn/island/TEMPLATE_PROJECT_LOCKED.png', 'jp': './assets/cn/island/TEMPLATE_PROJECT_LOCKED.png', 'tw': './assets/cn/island/TEMPLATE_PROJECT_LOCKED.png'})
|
||||
TEMPLATE_SLOT_LOCKED = Template(file={'cn': './assets/cn/island/TEMPLATE_SLOT_LOCKED.png', 'en': './assets/cn/island/TEMPLATE_SLOT_LOCKED.png', 'jp': './assets/cn/island/TEMPLATE_SLOT_LOCKED.png', 'tw': './assets/cn/island/TEMPLATE_SLOT_LOCKED.png'})
|
||||
TRANSPORT_LOCKED = Button(area={'cn': (659, 380, 683, 412), 'en': (659, 380, 683, 412), 'jp': (659, 380, 683, 412), 'tw': (659, 380, 683, 412)}, color={'cn': (192, 192, 190), 'en': (192, 192, 190), 'jp': (192, 192, 190), 'tw': (192, 192, 190)}, button={'cn': (659, 380, 683, 412), 'en': (659, 380, 683, 412), 'jp': (659, 380, 683, 412), 'tw': (659, 380, 683, 412)}, file={'cn': './assets/cn/island/TRANSPORT_LOCKED.png', 'en': './assets/cn/island/TRANSPORT_LOCKED.png', 'jp': './assets/cn/island/TRANSPORT_LOCKED.png', 'tw': './assets/cn/island/TRANSPORT_LOCKED.png'})
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from datetime import datetime, timedelta
|
||||
import numpy as np
|
||||
|
||||
from cached_property import cached_property
|
||||
|
||||
from module.base.button import ButtonGrid
|
||||
from module.base.timer import Timer
|
||||
from module.base.utils import area_offset, crop, image_color_count, rgb2gray
|
||||
@@ -27,13 +29,15 @@ class IslandTransport:
|
||||
# If the transprt commission need to refresh
|
||||
refresh: bool
|
||||
|
||||
def __init__(self, main, index):
|
||||
def __init__(self, main, index, blacklist):
|
||||
"""
|
||||
Args:
|
||||
main:
|
||||
index (int):
|
||||
blacklist (list[Template]): a blacklist of templates of items to submit
|
||||
"""
|
||||
self.index = index
|
||||
self.blacklist = blacklist
|
||||
self.image = main.device.image
|
||||
self.valid = True
|
||||
self.duration = None
|
||||
@@ -75,7 +79,7 @@ class IslandTransport:
|
||||
origin_y = 174 + delta * self.index
|
||||
grids = ButtonGrid(origin=(481, origin_y), delta=(105, 0),
|
||||
button_shape=(86, 86), grid_shape=(3, 1), name='ITEMS')
|
||||
self.items = SelectedGrids([TransportItem(self.image, button)
|
||||
self.items = SelectedGrids([TransportItem(self.image, button, self.blacklist)
|
||||
for button in grids.buttons]).select(valid=True)
|
||||
self.start = self.items.select(load=True).count == self.items.count
|
||||
self.refresh = main.appear(TRANSPORT_REFRESH, offset=self.offset) and \
|
||||
@@ -145,16 +149,16 @@ class IslandTransport:
|
||||
return info
|
||||
|
||||
class TransportItem:
|
||||
BLACKLIST_ITEMS = [TEMPLATE_CHICKEN, TEMPLATE_MILK]
|
||||
|
||||
def __init__(self, image, button):
|
||||
def __init__(self, image, button, blacklist):
|
||||
"""
|
||||
Args:
|
||||
image:
|
||||
button:
|
||||
blacklist:
|
||||
"""
|
||||
self.image_raw = image
|
||||
self.button = button
|
||||
self.blacklist = blacklist
|
||||
self.image = crop(image, button.area)
|
||||
self.valid = self.predict_valid()
|
||||
self.refresh = False
|
||||
@@ -184,7 +188,7 @@ class TransportItem:
|
||||
Returns:
|
||||
bool: if any blacklist item
|
||||
"""
|
||||
for template in self.BLACKLIST_ITEMS:
|
||||
for template in self.blacklist:
|
||||
if template.match(self.image):
|
||||
return True
|
||||
return False
|
||||
@@ -197,6 +201,17 @@ class TransportItem:
|
||||
return info
|
||||
|
||||
class IslandTransportRun(IslandUI):
|
||||
@cached_property
|
||||
def blacklist(self):
|
||||
blacklist = []
|
||||
if not self.config.IslandTransport_SubmitChicken:
|
||||
blacklist.append(TEMPLATE_CHICKEN)
|
||||
if not self.config.IslandTransport_SubmitMilk:
|
||||
blacklist.append(TEMPLATE_MILK)
|
||||
if not self.config.IslandTransport_SubmitPork:
|
||||
blacklist.append(TEMPLATE_PORK)
|
||||
return blacklist
|
||||
|
||||
def _transport_detect(self):
|
||||
"""
|
||||
Get all commissions from self.device.image.
|
||||
@@ -207,7 +222,7 @@ class IslandTransportRun(IslandUI):
|
||||
logger.hr('Transport Commission detect')
|
||||
commission = []
|
||||
for index in range(3):
|
||||
comm = IslandTransport(main=self, index=index)
|
||||
comm = IslandTransport(main=self, index=index, blacklist=self.blacklist)
|
||||
logger.attr(f'Transport Commission', comm)
|
||||
for item in comm.items:
|
||||
logger.attr(item.button, item)
|
||||
|
||||
Reference in New Issue
Block a user