mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-21 14:55:35 +08:00
Opt: Better arrangement of meowfficer settings
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from module.config.utils import get_server_next_update
|
||||
from module.meowfficer.assets import *
|
||||
from module.ui.assets import MEOWFFICER_CHECK, MEOWFFICER_INFO
|
||||
from module.ui.ui import UI
|
||||
@@ -59,3 +60,10 @@ class MeowfficerBase(UI):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def meow_is_sunday(self):
|
||||
"""
|
||||
Returns:
|
||||
bool:
|
||||
"""
|
||||
return get_server_next_update(self.config.Scheduler_ServerUpdate).weekday() == 0
|
||||
|
||||
@@ -170,7 +170,7 @@ class MeowfficerCollect(MeowfficerBase):
|
||||
continue
|
||||
if self.appear(MEOWFFICER_GET_CHECK, offset=(40, 40), interval=3):
|
||||
if self.appear(MEOWFFICER_GOLD_CHECK, offset=(40, 40)):
|
||||
if not self.config.Meowfficer_RetainTalentedGold or not self._meow_is_talented():
|
||||
if not self.config.MeowfficerTrain_RetainTalentedGold or not self._meow_is_talented():
|
||||
self._meow_skip_lock()
|
||||
skip_first_screenshot = True
|
||||
confirm_timer.reset()
|
||||
@@ -178,7 +178,7 @@ class MeowfficerCollect(MeowfficerBase):
|
||||
self._meow_apply_lock()
|
||||
|
||||
if self.appear(MEOWFFICER_PURPLE_CHECK, offset=(40, 40)):
|
||||
if self.config.Meowfficer_RetainTalentedPurple and self._meow_is_talented():
|
||||
if self.config.MeowfficerTrain_RetainTalentedPurple and self._meow_is_talented():
|
||||
self._meow_apply_lock()
|
||||
|
||||
# Susceptible to exception when collecting multiple
|
||||
@@ -196,7 +196,7 @@ class MeowfficerCollect(MeowfficerBase):
|
||||
else:
|
||||
confirm_timer.reset()
|
||||
|
||||
def meow_collect(self, is_sunday=False):
|
||||
def meow_collect(self, collect_all=True):
|
||||
"""
|
||||
Collect one or all trained meowfficer(s)
|
||||
Completed slots are automatically moved
|
||||
@@ -204,20 +204,20 @@ class MeowfficerCollect(MeowfficerBase):
|
||||
slot only
|
||||
|
||||
Args:
|
||||
is_sunday (bool): Whether today is Sunday or not
|
||||
collect_all (bool): Collect all or collect single
|
||||
|
||||
Pages:
|
||||
in: MEOWFFICER_TRAIN
|
||||
out: MEOWFFICER_TRAIN
|
||||
|
||||
Returns:
|
||||
Bool whether collected or not
|
||||
bool: whether collected or not
|
||||
"""
|
||||
logger.hr('Meowfficer collect', level=2)
|
||||
|
||||
if self.appear(MEOWFFICER_TRAIN_COMPLETE, offset=(20, 20)):
|
||||
# Today is Sunday, finish all else get just one
|
||||
if is_sunday:
|
||||
if collect_all:
|
||||
logger.info('Collect all trained meowfficers')
|
||||
button = MEOWFFICER_TRAIN_FINISH_ALL
|
||||
else:
|
||||
|
||||
@@ -30,7 +30,7 @@ class MeowfficerEnhance(MeowfficerBase):
|
||||
# Calculate (x, y) coordinate within
|
||||
# MEOWFFICER_SELECT/FEED_GRID (4x3) for
|
||||
# enhance target
|
||||
index = self.config.Meowfficer_EnhanceIndex - 1
|
||||
index = self.config.MeowfficerTrain_EnhanceIndex - 1
|
||||
x = index if index < 4 else index % 4
|
||||
y = index // 4
|
||||
|
||||
@@ -193,8 +193,8 @@ class MeowfficerEnhance(MeowfficerBase):
|
||||
# Base Cases
|
||||
# - Config at least > 0 but less than or equal to 12
|
||||
# - Coins at least > 1000
|
||||
if self.config.Meowfficer_EnhanceIndex <= 0 or self.config.Meowfficer_EnhanceIndex > 12:
|
||||
logger.warning(f'Meowfficer_EnhanceIndex={self.config.Meowfficer_EnhanceIndex} '
|
||||
if not (1 <= self.config.MeowfficerTrain_EnhanceIndex <= 12):
|
||||
logger.warning(f'Meowfficer_EnhanceIndex={self.config.MeowfficerTrain_EnhanceIndex} '
|
||||
f'is out of bounds. Please limit to 1~12, skip')
|
||||
return
|
||||
|
||||
|
||||
@@ -15,9 +15,8 @@ class RewardMeowfficer(MeowfficerBuy, MeowfficerFort, MeowfficerTrain):
|
||||
out: page_meowfficer
|
||||
"""
|
||||
if self.config.Meowfficer_BuyAmount <= 0 \
|
||||
and not self.config.Meowfficer_TrainMeowfficer \
|
||||
and not self.config.Meowfficer_FortChoreMeowfficer \
|
||||
and not self.config.Meowfficer_TrainMeowfficer:
|
||||
and not self.config.MeowfficerTrain_Enable:
|
||||
self.config.Scheduler_Enable = False
|
||||
self.config.task_stop()
|
||||
|
||||
@@ -25,14 +24,17 @@ class RewardMeowfficer(MeowfficerBuy, MeowfficerFort, MeowfficerTrain):
|
||||
|
||||
if self.config.Meowfficer_BuyAmount > 0:
|
||||
self.meow_buy()
|
||||
if self.config.Meowfficer_EnhanceIndex > 0:
|
||||
self.meow_enhance()
|
||||
if self.config.Meowfficer_TrainMeowfficer:
|
||||
self.meow_train()
|
||||
if self.config.Meowfficer_FortChoreMeowfficer:
|
||||
self.meow_fort()
|
||||
|
||||
if self.config.Meowfficer_TrainMeowfficer:
|
||||
# Train
|
||||
if self.config.MeowfficerTrain_Enable:
|
||||
self.meow_train()
|
||||
if self.config.MeowfficerTrain_Mode != 'seamlessly' and self.meow_is_sunday():
|
||||
self.meow_enhance()
|
||||
|
||||
# Scheduler
|
||||
if self.config.MeowfficerTrain_Enable:
|
||||
# Meowfficer training duration:
|
||||
# - Blue, 2.0h ~ 2.5h
|
||||
# - Purple, 5.5h ~ 6.5h
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from module.base.button import ButtonGrid
|
||||
from module.base.timer import Timer
|
||||
from module.config.utils import get_server_next_update
|
||||
from module.handler.assets import INFO_BAR_1
|
||||
from module.logger import logger
|
||||
from module.meowfficer.assets import *
|
||||
@@ -132,12 +131,17 @@ class MeowfficerTrain(MeowfficerCollect, MeowfficerEnhance):
|
||||
# Re-use mechanism to transition through screens
|
||||
self._meow_nqueue()
|
||||
|
||||
def meow_queue(self):
|
||||
def meow_queue(self, ascending=True):
|
||||
"""
|
||||
Enter into training window and then
|
||||
choose appropriate queue method based
|
||||
on current stock
|
||||
|
||||
Args:
|
||||
ascending (bool):
|
||||
True for Blue > Purple > Gold
|
||||
False for Gold > Purple > Blue
|
||||
|
||||
Pages:
|
||||
in: MEOWFFICER_TRAIN
|
||||
out: MEOWFFICER_TRAIN
|
||||
@@ -156,14 +160,14 @@ class MeowfficerTrain(MeowfficerCollect, MeowfficerEnhance):
|
||||
# common box sum count
|
||||
# - <= 20, low stock; queue normally
|
||||
# - > 20, high stock; queue common boxes first
|
||||
if self.config.Meowfficer_EnhanceIndex:
|
||||
if common_sum <= 20:
|
||||
if ascending:
|
||||
if common_sum > 20:
|
||||
logger.info('Queue in ascending order (Blue > Purple > Gold)')
|
||||
self._meow_rqueue()
|
||||
else:
|
||||
logger.info('Low stock of common cat boxes')
|
||||
logger.info('Queue in descending order (Gold > Purple > Blue)')
|
||||
self._meow_nqueue()
|
||||
else:
|
||||
logger.info('Queue in ascending order (Blue > Purple > Gold)')
|
||||
self._meow_rqueue()
|
||||
else:
|
||||
logger.info('Queue in descending order (Gold > Purple > Blue)')
|
||||
self._meow_nqueue()
|
||||
@@ -183,38 +187,31 @@ class MeowfficerTrain(MeowfficerCollect, MeowfficerEnhance):
|
||||
current, remain, total = MEOWFFICER_CAPACITY.ocr(self.device.image)
|
||||
logger.attr('Meowfficer_capacity_remain', remain)
|
||||
|
||||
# Check for today's weekday
|
||||
is_sunday = True
|
||||
if not self.config.Meowfficer_EnhanceIndex:
|
||||
is_sunday = get_server_next_update(self.config.Scheduler_ServerUpdate).weekday() == 0
|
||||
|
||||
# Enter MEOWFFICER_TRAIN window
|
||||
self.ui_click(MEOWFFICER_TRAIN_ENTER, check_button=MEOWFFICER_TRAIN_START, additional=self.meow_additional,
|
||||
retry_wait=3, confirm_wait=0, skip_first_screenshot=True)
|
||||
|
||||
# If today is Sunday, then collect all remainder otherwise just collect one
|
||||
# Once collected, should be back in MEOWFFICER_TRAIN window
|
||||
logger.attr('MeowfficerTrain_Mode', self.config.MeowfficerTrain_Mode)
|
||||
collected = False
|
||||
if remain > 0:
|
||||
collected = self.meow_collect(is_sunday)
|
||||
|
||||
# Fill queue to full if
|
||||
# - Attempted to collect but failed,
|
||||
# indicating in progress or completely
|
||||
# empty
|
||||
# - Today is Sunday
|
||||
# Once queued, should be back in MEOWFFICER_TRAIN window
|
||||
if (remain > 0 and not collected) or is_sunday:
|
||||
self.meow_queue()
|
||||
|
||||
self.ui_click(MEOWFFICER_GOTO_DORM, check_button=MEOWFFICER_TRAIN_ENTER,
|
||||
appear_button=MEOWFFICER_TRAIN_START, offset=None, skip_first_screenshot=True)
|
||||
|
||||
# Clear meowfficer space for upcoming week iff not configured
|
||||
# for enhancement and is_sunday
|
||||
if is_sunday and not self.config.Meowfficer_EnhanceIndex:
|
||||
backup = self.config.temporary(Meowfficer_EnhanceIndex=1)
|
||||
self.meow_enhance()
|
||||
backup.recover()
|
||||
if self.config.MeowfficerTrain_Mode == 'seamlessly':
|
||||
# Enter
|
||||
self.ui_click(MEOWFFICER_TRAIN_ENTER, check_button=MEOWFFICER_TRAIN_START, additional=self.meow_additional,
|
||||
retry_wait=3, confirm_wait=0, skip_first_screenshot=True)
|
||||
# Collect
|
||||
if remain > 0:
|
||||
collected = self.meow_collect(collect_all=True)
|
||||
# Queue
|
||||
self.meow_queue(ascending=True)
|
||||
# Exit
|
||||
self.ui_click(MEOWFFICER_GOTO_DORM, check_button=MEOWFFICER_TRAIN_ENTER,
|
||||
appear_button=MEOWFFICER_TRAIN_START, offset=None, skip_first_screenshot=True)
|
||||
else:
|
||||
# Enter
|
||||
self.ui_click(MEOWFFICER_TRAIN_ENTER, check_button=MEOWFFICER_TRAIN_START, additional=self.meow_additional,
|
||||
retry_wait=3, confirm_wait=0, skip_first_screenshot=True)
|
||||
# Collect
|
||||
if remain > 0:
|
||||
collected = self.meow_collect(collect_all=self.meow_is_sunday())
|
||||
# Queue
|
||||
self.meow_queue(ascending=False)
|
||||
# Exit
|
||||
self.ui_click(MEOWFFICER_GOTO_DORM, check_button=MEOWFFICER_TRAIN_ENTER,
|
||||
appear_button=MEOWFFICER_TRAIN_START, offset=None, skip_first_screenshot=True)
|
||||
|
||||
return collected
|
||||
|
||||
Reference in New Issue
Block a user