1
0
mirror of https://github.com/sui-feng-cb/AzurLaneAutoScript1.git synced 2026-08-19 20:55:05 +08:00
This commit is contained in:
GH Action - Upstream Sync
2026-08-17 05:40:29 +00:00
7 changed files with 98 additions and 46 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -60,7 +60,7 @@ FROSTFALL_SWITCH_SINGLE = Button(area={'cn': (968, 449, 1098, 478), 'en': (968,
FROSTFALL_TC1 = Button(area={'cn': (304, 320, 330, 332), 'en': (304, 320, 330, 332), 'jp': (304, 320, 330, 332), 'tw': (304, 320, 330, 332)}, color={'cn': (204, 162, 254), 'en': (204, 162, 254), 'jp': (204, 162, 254), 'tw': (188, 137, 254)}, button={'cn': (304, 320, 330, 332), 'en': (304, 320, 330, 332), 'jp': (304, 320, 330, 332), 'tw': (304, 320, 330, 332)}, file={'cn': './assets/cn/coalition/FROSTFALL_TC1.png', 'en': './assets/en/coalition/FROSTFALL_TC1.png', 'jp': './assets/jp/coalition/FROSTFALL_TC1.png', 'tw': './assets/tw/coalition/FROSTFALL_TC1.png'}) FROSTFALL_TC1 = Button(area={'cn': (304, 320, 330, 332), 'en': (304, 320, 330, 332), 'jp': (304, 320, 330, 332), 'tw': (304, 320, 330, 332)}, color={'cn': (204, 162, 254), 'en': (204, 162, 254), 'jp': (204, 162, 254), 'tw': (188, 137, 254)}, button={'cn': (304, 320, 330, 332), 'en': (304, 320, 330, 332), 'jp': (304, 320, 330, 332), 'tw': (304, 320, 330, 332)}, file={'cn': './assets/cn/coalition/FROSTFALL_TC1.png', 'en': './assets/en/coalition/FROSTFALL_TC1.png', 'jp': './assets/jp/coalition/FROSTFALL_TC1.png', 'tw': './assets/tw/coalition/FROSTFALL_TC1.png'})
FROSTFALL_TC2 = Button(area={'cn': (631, 160, 658, 173), 'en': (631, 160, 658, 173), 'jp': (631, 160, 658, 173), 'tw': (631, 160, 658, 173)}, color={'cn': (186, 136, 252), 'en': (186, 136, 252), 'jp': (186, 136, 252), 'tw': (186, 136, 252)}, button={'cn': (631, 160, 658, 173), 'en': (631, 160, 658, 173), 'jp': (631, 160, 658, 173), 'tw': (631, 160, 658, 173)}, file={'cn': './assets/cn/coalition/FROSTFALL_TC2.png', 'en': './assets/en/coalition/FROSTFALL_TC2.png', 'jp': './assets/jp/coalition/FROSTFALL_TC2.png', 'tw': './assets/tw/coalition/FROSTFALL_TC2.png'}) FROSTFALL_TC2 = Button(area={'cn': (631, 160, 658, 173), 'en': (631, 160, 658, 173), 'jp': (631, 160, 658, 173), 'tw': (631, 160, 658, 173)}, color={'cn': (186, 136, 252), 'en': (186, 136, 252), 'jp': (186, 136, 252), 'tw': (186, 136, 252)}, button={'cn': (631, 160, 658, 173), 'en': (631, 160, 658, 173), 'jp': (631, 160, 658, 173), 'tw': (631, 160, 658, 173)}, file={'cn': './assets/cn/coalition/FROSTFALL_TC2.png', 'en': './assets/en/coalition/FROSTFALL_TC2.png', 'jp': './assets/jp/coalition/FROSTFALL_TC2.png', 'tw': './assets/tw/coalition/FROSTFALL_TC2.png'})
FROSTFALL_TC3 = Button(area={'cn': (810, 362, 835, 373), 'en': (810, 362, 835, 373), 'jp': (810, 362, 835, 373), 'tw': (810, 362, 835, 373)}, color={'cn': (197, 153, 255), 'en': (197, 153, 255), 'jp': (197, 153, 255), 'tw': (197, 153, 255)}, button={'cn': (810, 362, 835, 373), 'en': (810, 362, 835, 373), 'jp': (810, 362, 835, 373), 'tw': (810, 362, 835, 373)}, file={'cn': './assets/cn/coalition/FROSTFALL_TC3.png', 'en': './assets/en/coalition/FROSTFALL_TC3.png', 'jp': './assets/jp/coalition/FROSTFALL_TC3.png', 'tw': './assets/tw/coalition/FROSTFALL_TC3.png'}) FROSTFALL_TC3 = Button(area={'cn': (810, 362, 835, 373), 'en': (810, 362, 835, 373), 'jp': (810, 362, 835, 373), 'tw': (810, 362, 835, 373)}, color={'cn': (197, 153, 255), 'en': (197, 153, 255), 'jp': (197, 153, 255), 'tw': (197, 153, 255)}, button={'cn': (810, 362, 835, 373), 'en': (810, 362, 835, 373), 'jp': (810, 362, 835, 373), 'tw': (810, 362, 835, 373)}, file={'cn': './assets/cn/coalition/FROSTFALL_TC3.png', 'en': './assets/en/coalition/FROSTFALL_TC3.png', 'jp': './assets/jp/coalition/FROSTFALL_TC3.png', 'tw': './assets/tw/coalition/FROSTFALL_TC3.png'})
HORROR_COALITION_CHECK = Button(area={'cn': (204, 49, 250, 70), 'en': (182, 40, 238, 65), 'jp': (204, 50, 250, 67), 'tw': (186, 24, 223, 57)}, color={'cn': (142, 142, 164), 'en': (161, 158, 163), 'jp': (136, 137, 159), 'tw': (146, 146, 157)}, button={'cn': (204, 49, 250, 70), 'en': (182, 40, 238, 65), 'jp': (204, 50, 250, 67), 'tw': (186, 24, 223, 57)}, file={'cn': './assets/cn/coalition/HORROR_COALITION_CHECK.png', 'en': './assets/en/coalition/HORROR_COALITION_CHECK.png', 'jp': './assets/jp/coalition/HORROR_COALITION_CHECK.png', 'tw': './assets/tw/coalition/HORROR_COALITION_CHECK.png'}) HORROR_COALITION_CHECK = Button(area={'cn': (204, 49, 250, 70), 'en': (182, 40, 238, 65), 'jp': (204, 50, 250, 67), 'tw': (186, 24, 222, 57)}, color={'cn': (142, 142, 164), 'en': (161, 158, 163), 'jp': (136, 137, 159), 'tw': (148, 147, 158)}, button={'cn': (204, 49, 250, 70), 'en': (182, 40, 238, 65), 'jp': (204, 50, 250, 67), 'tw': (186, 24, 222, 57)}, file={'cn': './assets/cn/coalition/HORROR_COALITION_CHECK.png', 'en': './assets/en/coalition/HORROR_COALITION_CHECK.png', 'jp': './assets/jp/coalition/HORROR_COALITION_CHECK.png', 'tw': './assets/tw/coalition/HORROR_COALITION_CHECK.png'})
HORROR_EASY = Button(area={'cn': (863, 425, 890, 464), 'en': (863, 425, 890, 464), 'jp': (863, 425, 890, 464), 'tw': (863, 425, 890, 464)}, color={'cn': (76, 76, 96), 'en': (76, 76, 96), 'jp': (76, 76, 96), 'tw': (76, 76, 96)}, button={'cn': (863, 425, 890, 464), 'en': (863, 425, 890, 464), 'jp': (863, 425, 890, 464), 'tw': (863, 425, 890, 464)}, file={'cn': './assets/cn/coalition/HORROR_EASY.png', 'en': './assets/cn/coalition/HORROR_EASY.png', 'jp': './assets/cn/coalition/HORROR_EASY.png', 'tw': './assets/cn/coalition/HORROR_EASY.png'}) HORROR_EASY = Button(area={'cn': (863, 425, 890, 464), 'en': (863, 425, 890, 464), 'jp': (863, 425, 890, 464), 'tw': (863, 425, 890, 464)}, color={'cn': (76, 76, 96), 'en': (76, 76, 96), 'jp': (76, 76, 96), 'tw': (76, 76, 96)}, button={'cn': (863, 425, 890, 464), 'en': (863, 425, 890, 464), 'jp': (863, 425, 890, 464), 'tw': (863, 425, 890, 464)}, file={'cn': './assets/cn/coalition/HORROR_EASY.png', 'en': './assets/cn/coalition/HORROR_EASY.png', 'jp': './assets/cn/coalition/HORROR_EASY.png', 'tw': './assets/cn/coalition/HORROR_EASY.png'})
HORROR_EX = Button(area={'cn': (172, 410, 200, 448), 'en': (172, 410, 200, 448), 'jp': (172, 410, 200, 448), 'tw': (172, 410, 200, 448)}, color={'cn': (150, 101, 105), 'en': (150, 101, 105), 'jp': (150, 101, 105), 'tw': (150, 101, 105)}, button={'cn': (172, 410, 200, 448), 'en': (172, 410, 200, 448), 'jp': (172, 410, 200, 448), 'tw': (172, 410, 200, 448)}, file={'cn': './assets/cn/coalition/HORROR_EX.png', 'en': './assets/cn/coalition/HORROR_EX.png', 'jp': './assets/cn/coalition/HORROR_EX.png', 'tw': './assets/cn/coalition/HORROR_EX.png'}) HORROR_EX = Button(area={'cn': (172, 410, 200, 448), 'en': (172, 410, 200, 448), 'jp': (172, 410, 200, 448), 'tw': (172, 410, 200, 448)}, color={'cn': (150, 101, 105), 'en': (150, 101, 105), 'jp': (150, 101, 105), 'tw': (150, 101, 105)}, button={'cn': (172, 410, 200, 448), 'en': (172, 410, 200, 448), 'jp': (172, 410, 200, 448), 'tw': (172, 410, 200, 448)}, file={'cn': './assets/cn/coalition/HORROR_EX.png', 'en': './assets/cn/coalition/HORROR_EX.png', 'jp': './assets/cn/coalition/HORROR_EX.png', 'tw': './assets/cn/coalition/HORROR_EX.png'})
HORROR_FLEET_PREPARATION = Button(area={'cn': (1026, 514, 1139, 542), 'en': (1039, 516, 1125, 538), 'jp': (1042, 514, 1124, 542), 'tw': (1026, 514, 1139, 542)}, color={'cn': (146, 132, 183), 'en': (158, 149, 194), 'jp': (135, 117, 173), 'tw': (146, 132, 183)}, button={'cn': (1026, 514, 1139, 542), 'en': (1039, 516, 1125, 538), 'jp': (1042, 514, 1124, 542), 'tw': (1026, 514, 1139, 542)}, file={'cn': './assets/cn/coalition/HORROR_FLEET_PREPARATION.png', 'en': './assets/en/coalition/HORROR_FLEET_PREPARATION.png', 'jp': './assets/jp/coalition/HORROR_FLEET_PREPARATION.png', 'tw': './assets/cn/coalition/HORROR_FLEET_PREPARATION.png'}) HORROR_FLEET_PREPARATION = Button(area={'cn': (1026, 514, 1139, 542), 'en': (1039, 516, 1125, 538), 'jp': (1042, 514, 1124, 542), 'tw': (1026, 514, 1139, 542)}, color={'cn': (146, 132, 183), 'en': (158, 149, 194), 'jp': (135, 117, 173), 'tw': (146, 132, 183)}, button={'cn': (1026, 514, 1139, 542), 'en': (1039, 516, 1125, 538), 'jp': (1042, 514, 1124, 542), 'tw': (1026, 514, 1139, 542)}, file={'cn': './assets/cn/coalition/HORROR_FLEET_PREPARATION.png', 'en': './assets/en/coalition/HORROR_FLEET_PREPARATION.png', 'jp': './assets/jp/coalition/HORROR_FLEET_PREPARATION.png', 'tw': './assets/cn/coalition/HORROR_FLEET_PREPARATION.png'})

View File

@@ -229,6 +229,8 @@ class IslandProduction(IslandRecipe, IslandDock):
logger.warning(f'Failed to select character {worker} for slot {slot_id}, try to select manjuu instead') logger.warning(f'Failed to select character {worker} for slot {slot_id}, try to select manjuu instead')
worker = 'manjuu' worker = 'manjuu'
self.ensure_dock_page_at_top() self.ensure_dock_page_at_top()
else:
self.island_dock_select_one(character.button)
if worker == 'manjuu': if worker == 'manjuu':
self.island_dock_select_manjuu() self.island_dock_select_manjuu()
self.island_dock_select_confirm(self.is_in_recipe_menu) self.island_dock_select_confirm(self.is_in_recipe_menu)

View File

@@ -300,6 +300,14 @@ def get_stuck_season_order_requirements(stuck_order_id):
return dict(requirements) return dict(requirements)
def merge_task_target_stuck_order_items(task_target_items, stuck_order_items):
"""Normalize and merge configured tasks with remaining stuck-order needs."""
return merge_item_needs(
normalize_item_needs(task_target_items, default_period=10),
normalize_item_needs(stuck_order_items, default_period=10),
)
def normalize_stuck_season_order_id(stuck_order_id): def normalize_stuck_season_order_id(stuck_order_id):
try: try:
stuck_order_id = int(stuck_order_id) stuck_order_id = int(stuck_order_id)

View File

@@ -97,13 +97,17 @@ class IslandDock(IslandUI):
def ensure_dock_page_at_top(self): def ensure_dock_page_at_top(self):
ISLAND_DOCK_DETECT.load_color(self.device.image) ISLAND_DOCK_DETECT.load_color(self.device.image)
ISLAND_DOCK_DETECT._match_init = True ISLAND_DOCK_DETECT._match_init = True
drag_count = 0
for _ in self.loop(timeout=10): for _ in self.loop(timeout=10):
self.prev_dock_page() self.prev_dock_page()
drag_count += 1
if self.appear(ISLAND_DOCK_DETECT, offset=(20, 20)): if self.appear(ISLAND_DOCK_DETECT, offset=(20, 20)):
logger.warning('Reached top of dock page') if drag_count >= 2:
return True logger.info('Reached top of dock page')
return True
else: else:
ISLAND_DOCK_DETECT.load_color(self.device.image) ISLAND_DOCK_DETECT.load_color(self.device.image)
drag_count = 0
return False return False
def island_dock_select_one(self, button, skip_first=False): def island_dock_select_one(self, button, skip_first=False):
@@ -137,6 +141,7 @@ class IslandDock(IslandUI):
def island_dock_select_manjuu(self): def island_dock_select_manjuu(self):
self.island_dock_sort_method_dsc_set(enable=False, wait_loading=True) self.island_dock_sort_method_dsc_set(enable=False, wait_loading=True)
# self.ensure_dock_page_at_top() # not necessary for now since usually Manjuu is searched first
scanner = CharacterScanner(self.dock_grid, identity=['Manjuu'], status='free') scanner = CharacterScanner(self.dock_grid, identity=['Manjuu'], status='free')
candidates = scanner.scan(self.device.image) candidates = scanner.scan(self.device.image)
if candidates: if candidates:
@@ -147,9 +152,11 @@ class IslandDock(IslandUI):
return False return False
def island_dock_find_character(self, identity): def island_dock_find_character(self, identity):
self.ensure_dock_page_at_top()
self.island_dock_sort_method_dsc_set(enable=True) self.island_dock_sort_method_dsc_set(enable=True)
ISLAND_DOCK_DETECT.load_color(self.device.image) ISLAND_DOCK_DETECT.load_color(self.device.image)
ISLAND_DOCK_DETECT._match_init = True ISLAND_DOCK_DETECT._match_init = True
drag_count = 0
for _ in self.loop(timeout=40, skip_first=False): for _ in self.loop(timeout=40, skip_first=False):
# dock_grid needs refresh after each page swipe, so we need to get a new scanner each time # dock_grid needs refresh after each page swipe, so we need to get a new scanner each time
scanner = CharacterScanner(self.dock_grid, identity=identity, status=None) scanner = CharacterScanner(self.dock_grid, identity=identity, status=None)
@@ -159,19 +166,24 @@ class IslandDock(IslandUI):
continue continue
return candidate return candidate
self.next_dock_page() self.next_dock_page()
drag_count += 1
if self.appear(ISLAND_DOCK_DETECT, offset=(20, 20)): if self.appear(ISLAND_DOCK_DETECT, offset=(20, 20)):
logger.warning('Reached end of dock page') if drag_count >= 2:
break logger.warning('Reached end of dock page')
break
else: else:
ISLAND_DOCK_DETECT.load_color(self.device.image) ISLAND_DOCK_DETECT.load_color(self.device.image)
drag_count = 0
else: else:
logger.warning('Failed to find all requested characters') logger.warning('Failed to find all requested characters')
return None return None
def island_dock_select_character_with_blacklist(self, blacklist): def island_dock_find_character_with_blacklist(self, blacklist):
self.ensure_dock_page_at_top()
self.island_dock_sort_method_dsc_set(enable=True) self.island_dock_sort_method_dsc_set(enable=True)
ISLAND_DOCK_DETECT.load_color(self.device.image) ISLAND_DOCK_DETECT.load_color(self.device.image)
ISLAND_DOCK_DETECT._match_init = True ISLAND_DOCK_DETECT._match_init = True
drag_count = 0
for _ in self.loop(timeout=40, skip_first=False): for _ in self.loop(timeout=40, skip_first=False):
# dock_grid needs refresh after each page swipe, so we need to get a new scanner each time # dock_grid needs refresh after each page swipe, so we need to get a new scanner each time
scanner = CharacterScanner(self.dock_grid, identity='any', status='free') scanner = CharacterScanner(self.dock_grid, identity='any', status='free')
@@ -191,13 +203,15 @@ class IslandDock(IslandUI):
elif self.is_button_selected(candidate.button, color=(19, 181, 231)): elif self.is_button_selected(candidate.button, color=(19, 181, 231)):
continue continue
else: else:
self.island_dock_select_one(candidate.button) return candidate
return candidate.identity
self.next_dock_page() self.next_dock_page()
drag_count += 1
if self.appear(ISLAND_DOCK_DETECT, offset=(20, 20)): if self.appear(ISLAND_DOCK_DETECT, offset=(20, 20)):
logger.warning('Reached end of dock page') if drag_count >= 2:
break logger.warning('Reached end of dock page')
break
else: else:
ISLAND_DOCK_DETECT.load_color(self.device.image) ISLAND_DOCK_DETECT.load_color(self.device.image)
drag_count = 0
logger.warning('Failed to find any character not in blacklist') logger.warning('Failed to find any character not in blacklist')
return None return None

View File

@@ -21,9 +21,8 @@ from module.island.utils import (
load_hard_floor_items, load_hard_floor_items,
load_item_mapping, load_item_mapping,
load_reserve_items, load_reserve_items,
merge_item_needs, merge_task_target_stuck_order_items,
normalize_item_keys, normalize_item_keys,
normalize_item_needs,
parse_item_need_deadlines, parse_item_need_deadlines,
) )
from module.island_handler.assets import * from module.island_handler.assets import *
@@ -122,6 +121,16 @@ def get_recipe_product_id(recipe_id):
return next(iter(DIC_ISLAND_RECIPE[recipe_id]['commission_product'])) return next(iter(DIC_ISLAND_RECIPE[recipe_id]['commission_product']))
def get_ingredient_available_stock(stock, hard_floor, reserve, task_target_reserve):
return max(
stock
- max(hard_floor, 0)
- max(reserve, 0)
- max(task_target_reserve, 0),
0,
)
def get_target_stock_weight(stock, target_stock, hard_floor, reserve): def get_target_stock_weight(stock, target_stock, hard_floor, reserve):
if stock >= target_stock or target_stock <= 0: if stock >= target_stock or target_stock <= 0:
return 0 return 0
@@ -349,6 +358,20 @@ class IslandRecipe(IslandExchange, IslandShop):
yaml_text = self.config.cross_get("IslandProduction.IslandProduction.ReserveItems", "") yaml_text = self.config.cross_get("IslandProduction.IslandProduction.ReserveItems", "")
return normalize_item_keys(load_reserve_items(yaml_text)) return normalize_item_keys(load_reserve_items(yaml_text))
def get_task_target_items(self, task_target_items=None):
if task_target_items is None:
task_target_items = load_item_mapping(
self.config.cross_get("IslandSeasonTask.IslandSeasonTask.TaskTarget", "{}"),
config_name='TaskTarget',
)
stuck_season_order_id = self.config.cross_get(
"IslandOrder.IslandOrder.StuckSeasonOrderId", 0
)
return merge_task_target_stuck_order_items(
task_target_items,
get_stuck_season_order_requirements(stuck_season_order_id),
)
def get_recipe_id_sequence_to_run( def get_recipe_id_sequence_to_run(
self, self,
daily_buffer_items_dict=None, daily_buffer_items_dict=None,
@@ -372,21 +395,8 @@ class IslandRecipe(IslandExchange, IslandShop):
reserve_items_dict = self.reserve_items reserve_items_dict = self.reserve_items
else: else:
reserve_items_dict = normalize_item_keys(reserve_items_dict) reserve_items_dict = normalize_item_keys(reserve_items_dict)
if task_target_items_dict is None: task_target_items_dict = self.get_task_target_items(task_target_items_dict)
yaml_text = self.config.cross_get("IslandSeasonTask.IslandSeasonTask.TaskTarget", "{}") self.task_target_items = task_target_items_dict
task_target_items_dict = load_item_mapping(yaml_text, config_name='TaskTarget')
task_target_items_dict = normalize_item_needs(task_target_items_dict, default_period=10)
stuck_season_order_id = self.config.cross_get(
"IslandOrder.IslandOrder.StuckSeasonOrderId", 0
)
stuck_season_order_items = normalize_item_needs(
get_stuck_season_order_requirements(stuck_season_order_id),
default_period=10,
)
task_target_items_dict = merge_item_needs(
task_target_items_dict,
stuck_season_order_items,
)
if idle_accumulating_items_dict is None: if idle_accumulating_items_dict is None:
yaml_text = self.config.cross_get("IslandProduction.IslandProduction.IdleAccumulatingItems", "") yaml_text = self.config.cross_get("IslandProduction.IslandProduction.IdleAccumulatingItems", "")
if yaml_text is None: if yaml_text is None:
@@ -556,6 +566,9 @@ class IslandRecipe(IslandExchange, IslandShop):
# since ranch recipes may have boosted ingredient requirement for higher batch production. # since ranch recipes may have boosted ingredient requirement for higher batch production.
counters = self.get_recipe_ingredient_counters() counters = self.get_recipe_ingredient_counters()
recipe_cost = DIC_ISLAND_RECIPE[recipe_id]['commission_cost'] recipe_cost = DIC_ISLAND_RECIPE[recipe_id]['commission_cost']
task_target_items = getattr(self, 'task_target_items', None)
if task_target_items is None:
task_target_items = self.get_task_target_items()
if counters is None: if counters is None:
logger.warning(f'Unable to read ingredient counters for recipe {recipe_id}') logger.warning(f'Unable to read ingredient counters for recipe {recipe_id}')
return False, 0 return False, 0
@@ -564,11 +577,12 @@ class IslandRecipe(IslandExchange, IslandShop):
for ingredient_key, counter in zip(recipe_cost, counters): for ingredient_key, counter in zip(recipe_cost, counters):
if ingredient_key in DIC_ISLAND_SHOP_ITEM_TO_RECIPE or ingredient_key in (2521, 2522): if ingredient_key in DIC_ISLAND_SHOP_ITEM_TO_RECIPE or ingredient_key in (2521, 2522):
continue continue
available_stock = max( task_target_reserve = task_target_items.get(ingredient_key, {}).get('total_need_count', 0)
counter[0] available_stock = get_ingredient_available_stock(
- self.hard_floor_items.get(ingredient_key, 0) counter[0],
- self.reserve_items.get(ingredient_key, 0), self.hard_floor_items.get(ingredient_key, 0),
0, self.reserve_items.get(ingredient_key, 0),
task_target_reserve,
) )
count = available_stock // counter[1] if counter[1] > 0 else float('inf') count = available_stock // counter[1] if counter[1] > 0 else float('inf')
if count < max_count: if count < max_count:
@@ -586,7 +600,10 @@ class IslandRecipe(IslandExchange, IslandShop):
for ingredient_key, counter, button in zip(recipe_cost, counters, ingredient_buttons): for ingredient_key, counter, button in zip(recipe_cost, counters, ingredient_buttons):
hard_floor = self.hard_floor_items.get(ingredient_key, 0) hard_floor = self.hard_floor_items.get(ingredient_key, 0)
reserve = self.reserve_items.get(ingredient_key, 0) reserve = self.reserve_items.get(ingredient_key, 0)
available_stock = max(counter[0] - hard_floor - reserve, 0) task_target_reserve = task_target_items.get(ingredient_key, {}).get('total_need_count', 0)
available_stock = get_ingredient_available_stock(
counter[0], hard_floor, reserve, task_target_reserve
)
if available_stock < real_count * counter[1]: if available_stock < real_count * counter[1]:
if ingredient_key in (2521, 2522): if ingredient_key in (2521, 2522):
if ingredient_key in failed_buy_items: if ingredient_key in failed_buy_items:
@@ -639,7 +656,8 @@ class IslandRecipe(IslandExchange, IslandShop):
else: else:
logger.warning( logger.warning(
f'Ingredient {ingredient_key} cannot be bought from shop, ' f'Ingredient {ingredient_key} cannot be bought from shop, '
f'insufficient ingredient for recipe production after hard floor {hard_floor} and reserve {reserve}' f'insufficient ingredient for recipe production after hard floor {hard_floor}, '
f'reserve {reserve}, and task target {task_target_reserve}'
) )
real_count = min(real_count, available_stock // counter[1]) if counter[1] > 0 else 0 real_count = min(real_count, available_stock // counter[1]) if counter[1] > 0 else 0
success = False success = False

View File

@@ -15,6 +15,8 @@ from module.island.data import DIC_ISLAND_ITEM, DIC_ISLAND_RESTAURANT_MENU_TO_RE
from module.island.utils import ( from module.island.utils import (
get_stuck_season_order_requirements, get_stuck_season_order_requirements,
load_hard_floor_items, load_hard_floor_items,
load_item_mapping,
merge_task_target_stuck_order_items,
normalize_item_keys, normalize_item_keys,
) )
from module.island_handler.assets import * from module.island_handler.assets import *
@@ -277,8 +279,9 @@ class IslandRestaurant(IslandDock):
item for item in items item for item in items
if item.id in menu if item.id in menu
# Sell one full waitress-capacity tranche while preserving manual # Sell one full waitress-capacity tranche while preserving manual
# hard floors and remaining season-order requirements. Reserves and # hard floors, task targets, and remaining season-order
# daily buffers are soft and may be consumed by restaurants. # requirements. Reserves and daily buffers are soft and may be
# consumed by restaurants.
and has_sellable_capacity(item) and has_sellable_capacity(item)
] ]
surplus_items = [ surplus_items = [
@@ -303,13 +306,18 @@ class IslandRestaurant(IslandDock):
stuck_season_order_id = self.config.cross_get( stuck_season_order_id = self.config.cross_get(
"IslandOrder.IslandOrder.StuckSeasonOrderId", 0 "IslandOrder.IslandOrder.StuckSeasonOrderId", 0
) )
season_order_items = normalize_item_keys( task_target_items = load_item_mapping(
get_stuck_season_order_requirements(stuck_season_order_id) self.config.cross_get("IslandSeasonTask.IslandSeasonTask.TaskTarget", "{}"),
config_name='TaskTarget',
) )
item_ids = set(hard_floor_items) | set(season_order_items) protected_target_items = merge_task_target_stuck_order_items(
task_target_items,
get_stuck_season_order_requirements(stuck_season_order_id),
)
item_ids = set(hard_floor_items) | set(protected_target_items)
return { return {
item_id: max(hard_floor_items.get(item_id, 0), 0) item_id: max(hard_floor_items.get(item_id, 0), 0)
+ max(season_order_items.get(item_id, 0), 0) + max(protected_target_items.get(item_id, {}).get('total_need_count', 0), 0)
for item_id in item_ids for item_id in item_ids
} }
@@ -397,19 +405,21 @@ class IslandRestaurant(IslandDock):
| selected_waitresses | selected_waitresses
| all_named_waitresses | all_named_waitresses
) )
selected = self.island_dock_select_character_with_blacklist(fallback_blacklist) candidate = self.island_dock_find_character_with_blacklist(fallback_blacklist)
if selected is None: if candidate is None:
success = False success = False
else: else:
selected_waitresses.add(selected) self.island_dock_select_one(candidate.button)
selected_waitresses.add(candidate.identity)
for _ in range(active_waitresses.count(WAITRESS_ANY)): for _ in range(active_waitresses.count(WAITRESS_ANY)):
blacklist = unavailable_waitress_list | selected_waitresses | all_named_waitresses blacklist = unavailable_waitress_list | selected_waitresses | all_named_waitresses
selected = self.island_dock_select_character_with_blacklist(blacklist) candidate = self.island_dock_find_character_with_blacklist(blacklist)
if selected is None: if candidate is None:
success = False success = False
else: else:
selected_waitresses.add(selected) self.island_dock_select_one(candidate.button)
selected_waitresses.add(candidate.identity)
if not success: if not success:
logger.warning("Failed to choose waitress") logger.warning("Failed to choose waitress")
self.ui_back(check_button=self.is_in_island_restaurant) self.ui_back(check_button=self.is_in_island_restaurant)