diff --git a/assets/share/combat/obtain/OBTAIN_4.png b/assets/share/combat/obtain/OBTAIN_4.png new file mode 100644 index 000000000..0d8a51d9a Binary files /dev/null and b/assets/share/combat/obtain/OBTAIN_4.png differ diff --git a/assets/share/combat/obtain/OBTAIN_TRAILBLAZE_EXP.SEARCH.png b/assets/share/combat/obtain/OBTAIN_TRAILBLAZE_EXP.SEARCH.png new file mode 100644 index 000000000..a42ebf0bc Binary files /dev/null and b/assets/share/combat/obtain/OBTAIN_TRAILBLAZE_EXP.SEARCH.png differ diff --git a/assets/share/combat/obtain/OBTAIN_TRAILBLAZE_EXP.png b/assets/share/combat/obtain/OBTAIN_TRAILBLAZE_EXP.png new file mode 100644 index 000000000..ebc15a452 Binary files /dev/null and b/assets/share/combat/obtain/OBTAIN_TRAILBLAZE_EXP.png differ diff --git a/dev_tools/keywords/item.py b/dev_tools/keywords/item.py index 9a0662622..bd8e20dd1 100644 --- a/dev_tools/keywords/item.py +++ b/dev_tools/keywords/item.py @@ -71,8 +71,8 @@ class GenerateItemBase(GenerateKeyword): class GenerateItemCurrency(GenerateItemBase): output_file = './tasks/planner/keywords/item_currency.py' - # Leave 'Credit' only - whitelist = [2] + # Leave 'Credit' and `Trailblaze_EXP` + whitelist = [2, 22] def iter_keywords(self) -> t.Iterable[dict]: for data in self.iter_items(): diff --git a/tasks/combat/assets/assets_combat_obtain.py b/tasks/combat/assets/assets_combat_obtain.py index 3f0a01df7..10b0259a2 100644 --- a/tasks/combat/assets/assets_combat_obtain.py +++ b/tasks/combat/assets/assets_combat_obtain.py @@ -80,3 +80,23 @@ OBTAIN_3 = ButtonWrapper( button=(965, 414, 1029, 478), ), ) +OBTAIN_4 = ButtonWrapper( + name='OBTAIN_4', + share=Button( + file='./assets/share/combat/obtain/OBTAIN_4.png', + area=(1041, 414, 1105, 478), + search=(1021, 394, 1125, 498), + color=(76, 101, 109), + button=(1041, 414, 1105, 478), + ), +) +OBTAIN_TRAILBLAZE_EXP = ButtonWrapper( + name='OBTAIN_TRAILBLAZE_EXP', + share=Button( + file='./assets/share/combat/obtain/OBTAIN_TRAILBLAZE_EXP.png', + area=(827, 425, 860, 451), + search=(813, 349, 877, 589), + color=(167, 173, 194), + button=(827, 425, 860, 451), + ), +) diff --git a/tasks/combat/obtain.py b/tasks/combat/obtain.py index c1f61b3d3..ed58c6132 100644 --- a/tasks/combat/obtain.py +++ b/tasks/combat/obtain.py @@ -7,7 +7,7 @@ from module.ocr.ocr import Digit from tasks.combat.assets.assets_combat_obtain import * from tasks.combat.assets.assets_combat_prepare import COMBAT_PREPARE from tasks.dungeon.keywords import DungeonList -from tasks.planner.keywords import ITEM_CLASSES +from tasks.planner.keywords import ITEM_CLASSES, KEYWORDS_ITEM_CURRENCY from tasks.planner.model import ObtainedAmmount, PlannerMixin from tasks.planner.scan import OcrItemName @@ -93,7 +93,7 @@ class CombatObtain(PlannerMixin): continue @staticmethod - def _obtain_get_entry(dungeon: DungeonList, index: int = 1, prev: ObtainedAmmount = None): + def _obtain_get_entry(dungeon: DungeonList, index: int = 1, prev: ObtainedAmmount = None, start: int = 0): """ Args: dungeon: Current dungeon @@ -101,7 +101,7 @@ class CombatObtain(PlannerMixin): prev: Previous item checked Returns: - ButtonWrapper: Item entry, or None if no more check needed + int: Item entry index, or None if no more check needed """ if (index > 1 and prev is None) or (index <= 1 and prev is not None): raise ScriptError(f'_obtain_get_entry: index and prev must be set together, index={index}, prev={prev}') @@ -111,20 +111,29 @@ class CombatObtain(PlannerMixin): def may_obtain_one(): if prev is None: - return OBTAIN_1 + if start: + return 1 + start + else: + return 1 else: return None def may_obtain_multi(): if prev is None: - return OBTAIN_1 + if start: + return 1 + start + else: + return 1 # End at the item with the lowest rarity if prev.item.is_rarity_green: return None - if index == 2: - return OBTAIN_2 - if index == 3: - return OBTAIN_3 + # End at credict + if prev.item == KEYWORDS_ITEM_CURRENCY.Credit: + return None + if start: + return index + start + else: + return index if dungeon is None: return may_obtain_multi() @@ -185,18 +194,38 @@ class CombatObtain(PlannerMixin): index = 1 prev = None items = [] + dic_entry = { + 1: OBTAIN_1, + 2: OBTAIN_2, + 3: OBTAIN_3, + 4: OBTAIN_4, + } self._find_may_obtain() + trailblaze_exp = False for _ in range(5): - entry = self._obtain_get_entry(dungeon, index=index, prev=prev) - if entry is None: + if not trailblaze_exp and self.appear(OBTAIN_TRAILBLAZE_EXP): + trailblaze_exp = True + logger.attr('trailblaze_exp', trailblaze_exp) + + entry_index = self._obtain_get_entry(dungeon, index=index, prev=prev, start=int(trailblaze_exp)) + if entry_index is None: logger.info('Obtain get end') break + try: + entry = dic_entry[entry_index] + except KeyError: + logger.error(f'No obtain entry for {entry_index}') + break self._obtain_enter(entry) item = self._obtain_parse() - if item is not None: + if item.item == KEYWORDS_ITEM_CURRENCY.Trailblaze_EXP: + logger.warning('Trailblaze_EXP is in obtain list, OBTAIN_TRAILBLAZE_EXP may need to verify') + index += 1 + prev = item + elif item is not None: items.append(item) index += 1 prev = item @@ -258,6 +287,7 @@ class CombatObtain(PlannerMixin): OBTAIN_1.load_offset(MAY_OBTAIN) OBTAIN_2.load_offset(MAY_OBTAIN) OBTAIN_3.load_offset(MAY_OBTAIN) + OBTAIN_4.load_offset(MAY_OBTAIN) return True diff --git a/tasks/planner/keywords/item_currency.py b/tasks/planner/keywords/item_currency.py index 9ba85a4b7..07ac9a841 100644 --- a/tasks/planner/keywords/item_currency.py +++ b/tasks/planner/keywords/item_currency.py @@ -16,3 +16,16 @@ Credit = ItemCurrency( item_group=0, dungeon_id=-1, ) +Trailblaze_EXP = ItemCurrency( + id=2, + name='Trailblaze_EXP', + cn='里程', + cht='里程', + en='Trailblaze EXP', + jp='マイレージ', + es='EXP trazacaminos', + rarity='Rare', + item_id=22, + item_group=0, + dungeon_id=-1, +) diff --git a/tasks/planner/scan.py b/tasks/planner/scan.py index 80d064340..c8ae60745 100644 --- a/tasks/planner/scan.py +++ b/tasks/planner/scan.py @@ -22,7 +22,7 @@ class OcrItemName(Ocr): result = result.replace('念火之心', '忿火之心') result = re.sub('工造机$', '工造机杼', result) result = re.sub('工造轮', '工造迴轮', result) - result = re.sub('月狂牙', '月狂獠牙', result) + result = re.sub('月狂[療撩]?牙', '月狂獠牙', result) return result