Upd:Adds the Meowfficer maximum level option for enhance (#4267)

* Upd:Adds the Meowfficer maximum level option for enhance

* Upd:Move ocr and judgment logic out of the loop

---------

Co-authored-by: LmeSzinc <lmeszincsales@gmail.com>
Co-authored-by: yx800 <yoyo.duan@cfnet.com.cn>
This commit is contained in:
coconutjuice 2024-10-12 00:45:56 +08:00 committed by GitHub
parent 1ca4f6388a
commit 6b7ea0448c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 52 additions and 2 deletions

View File

@ -1285,7 +1285,8 @@
"Mode": "seamlessly",
"RetainTalentedGold": true,
"RetainTalentedPurple": true,
"EnhanceIndex": 1
"EnhanceIndex": 1,
"MaxFeedLevel": 5
},
"Storage": {
"Storage": {}

View File

@ -7035,6 +7035,10 @@
"EnhanceIndex": {
"type": "input",
"value": 1
},
"MaxFeedLevel": {
"type": "input",
"value": 5
}
},
"Storage": {

View File

@ -427,6 +427,7 @@ MeowfficerTrain:
RetainTalentedGold: true
RetainTalentedPurple: true
EnhanceIndex: 1
MaxFeedLevel: 5
GuildLogistics:
Enable: true
SelectNewMission: false

View File

@ -229,6 +229,7 @@ class GeneratedConfig:
MeowfficerTrain_RetainTalentedGold = True
MeowfficerTrain_RetainTalentedPurple = True
MeowfficerTrain_EnhanceIndex = 1
MeowfficerTrain_MaxFeedLevel = 5
# Group `GuildLogistics`
GuildLogistics_Enable = True

View File

@ -1503,6 +1503,10 @@
"EnhanceIndex": {
"name": "Enhance Index",
"help": "Index of target meowfficer to enhance. Limited in 1 ~ 12; indices are in ascending order from left to right of the 4 x 3 grid."
},
"MaxFeedLevel": {
"name": "Do not use meowfficer larger than level X as enhancing materials",
"help": "The X value is limited to 1 to 30"
}
},
"GuildLogistics": {

View File

@ -1503,6 +1503,10 @@
"EnhanceIndex": {
"name": "MeowfficerTrain.EnhanceIndex.name",
"help": "MeowfficerTrain.EnhanceIndex.help"
},
"MaxFeedLevel": {
"name": "レベル X 以上の猫を強化材料にしない",
"help": "X 値は1~30に制限します"
}
},
"GuildLogistics": {

View File

@ -1503,6 +1503,10 @@
"EnhanceIndex": {
"name": "用无特殊天赋的猫给第 X 只猫强化",
"help": "猫仓库的第 X 只猫,限制在 1 ~ 12顺序从左上到右下"
},
"MaxFeedLevel": {
"name": "不使用大于 X 级的猫作为强化材料",
"help": "X 值限制在 1 ~ 30"
}
},
"GuildLogistics": {

View File

@ -1503,6 +1503,10 @@
"EnhanceIndex": {
"name": "用無特殊天賦的貓給第 X 隻貓強化",
"help": "貓倉庫的第 X 隻貓,限制在 1 ~ 12順序從左上到右下"
},
"MaxFeedLevel": {
"name": "不使用大於 X 級的貓作為強化材料",
"help": "X 值限制在 1 ~ 30"
}
},
"GuildLogistics": {

View File

@ -14,6 +14,9 @@ MEOWFFICER_SELECT_GRID = ButtonGrid(
MEOWFFICER_FEED_GRID = ButtonGrid(
origin=(783, 189), delta=(130, 148), button_shape=(46, 46), grid_shape=(4, 3),
name='MEOWFFICER_FEED_GRID')
MEOWFICER_FEED_LEVEL_GRID = ButtonGrid(
origin=(738, 211), delta=(130, 148), button_shape=(20, 22), grid_shape=(4, 3),
name='MEOWFFICER_FEED_LEVEL_GRID')
MEOWFFICER_FEED = DigitCounter(OCR_MEOWFFICER_FEED, letter=(131, 121, 123), threshold=64)
@ -85,7 +88,26 @@ class MeowfficerEnhance(MeowfficerBase):
list(Button)
"""
clickable = []
for index, button in enumerate(MEOWFFICER_FEED_GRID.buttons):
# Reset invalid value of MeowfficerTrain_MaxFeedLevel
# it can work without this code, just for rigor
reset_max_feed_level = -1
if self.config.MeowfficerTrain_MaxFeedLevel < 1:
reset_max_feed_level = 1
elif self.config.MeowfficerTrain_MaxFeedLevel > 30:
reset_max_feed_level = 30
if -1 != reset_max_feed_level:
logger.warning(f"Condition '1 <= MeowfficerTrain_MaxFeedLevel <= 30' needs to be satisfied, "
f'now MeowfficerTrain_MaxFeedLevel is {self.config.MeowfficerTrain_MaxFeedLevel}, '
f'reset to {reset_max_feed_level}')
self.config.MeowfficerTrain_MaxFeedLevel = reset_max_feed_level
# Get all the cat levels ready for enhance
feed_level_list = Digit(MEOWFICER_FEED_LEVEL_GRID.buttons, letter=(49, 48, 49),
name='FEED_MEOWFFICER_LEVEL').ocr(self.device.image)
for index, (button, level) in enumerate(zip(MEOWFFICER_FEED_GRID.buttons, feed_level_list)):
# Exit if 11th button; no need to validate as not
# possible to click beyond this point
if index >= 10:
@ -100,6 +122,11 @@ class MeowfficerEnhance(MeowfficerBase):
if self.image_color_count(button, color=(95, 229, 108), threshold=221, count=150):
continue
# Continue onto next If the target Meowfficer's level
# is greater than the maximum feed level set
if level > self.config.MeowfficerTrain_MaxFeedLevel:
continue
# Neither base case, so presume
# button is clickable
clickable.append(button)