Chore: Move dungeon/obtain to combat/obtain

Since obtain info is indeed getting before battle
This commit is contained in:
LmeSzinc 2024-05-18 02:35:13 +08:00
parent da135402d4
commit d854a90c4c
10 changed files with 46 additions and 13 deletions

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -6,7 +6,7 @@ from module.base.button import Button, ButtonWrapper
ITEM_AMOUNT = ButtonWrapper(
name='ITEM_AMOUNT',
share=Button(
file='./assets/share/dungeon/obtain/ITEM_AMOUNT.png',
file='./assets/share/combat/obtain/ITEM_AMOUNT.png',
area=(190, 521, 490, 539),
search=(170, 501, 510, 559),
color=(195, 190, 188),
@ -16,7 +16,7 @@ ITEM_AMOUNT = ButtonWrapper(
ITEM_CLOSE = ButtonWrapper(
name='ITEM_CLOSE',
share=Button(
file='./assets/share/dungeon/obtain/ITEM_CLOSE.png',
file='./assets/share/combat/obtain/ITEM_CLOSE.png',
area=(1043, 185, 1073, 215),
search=(1023, 165, 1093, 235),
color=(170, 170, 170),
@ -26,7 +26,7 @@ ITEM_CLOSE = ButtonWrapper(
ITEM_NAME = ButtonWrapper(
name='ITEM_NAME',
share=Button(
file='./assets/share/dungeon/obtain/ITEM_NAME.png',
file='./assets/share/combat/obtain/ITEM_NAME.png',
area=(495, 187, 855, 211),
search=(475, 167, 875, 231),
color=(176, 177, 179),
@ -36,7 +36,7 @@ ITEM_NAME = ButtonWrapper(
OBTAIN_1 = ButtonWrapper(
name='OBTAIN_1',
share=Button(
file='./assets/share/dungeon/obtain/OBTAIN_1.png',
file='./assets/share/combat/obtain/OBTAIN_1.png',
area=(813, 414, 877, 478),
search=(793, 394, 897, 498),
color=(118, 96, 131),
@ -46,7 +46,7 @@ OBTAIN_1 = ButtonWrapper(
OBTAIN_2 = ButtonWrapper(
name='OBTAIN_2',
share=Button(
file='./assets/share/dungeon/obtain/OBTAIN_2.png',
file='./assets/share/combat/obtain/OBTAIN_2.png',
area=(889, 414, 953, 478),
search=(869, 394, 973, 498),
color=(71, 96, 145),
@ -56,7 +56,7 @@ OBTAIN_2 = ButtonWrapper(
OBTAIN_3 = ButtonWrapper(
name='OBTAIN_3',
share=Button(
file='./assets/share/dungeon/obtain/OBTAIN_3.png',
file='./assets/share/combat/obtain/OBTAIN_3.png',
area=(965, 414, 1029, 478),
search=(945, 394, 1049, 498),
color=(76, 101, 109),

View File

@ -5,10 +5,10 @@ from module.exception import ScriptError
from module.logger import logger
from module.ocr.ocr import Digit
from tasks.combat.assets.assets_combat_prepare import COMBAT_PREPARE, WAVE_MINUS, WAVE_PLUS
from tasks.dungeon.assets.assets_dungeon_obtain import *
from tasks.combat.assets.assets_combat_obtain import *
from tasks.dungeon.keywords import DungeonList
from tasks.planner.keywords import ITEM_CLASSES
from tasks.planner.model import ObtainedAmmount, PlannerProgressMixin
from tasks.planner.model import ObtainedAmmount, PlannerMixin
from tasks.planner.result import OcrItemName
@ -19,13 +19,16 @@ class OcrItemAmount(Digit):
return super().format_result(result)
class DungeonObtain(PlannerProgressMixin):
class CombatObtain(PlannerMixin):
"""
Parse items that can be obtained from dungeon
Pages:
in: COMBAT_PREPARE
"""
# False to click again when combat ends
# True to exit and reenter to get obtained items
obtain_frequent_check = False
def _obtain_enter(self, entry, skip_first_screenshot=True):
"""
@ -200,6 +203,8 @@ class DungeonObtain(PlannerProgressMixin):
logger.hr('Obtained Result')
for item in items:
# Pretend everything is full
# item.value += 1000
logger.info(f'Obtained item: {item.item.name}, {item.value}')
"""
<<< OBTAIN GET RESULT >>>
@ -211,8 +216,35 @@ class DungeonObtain(PlannerProgressMixin):
self.planner_write()
return items
def obtained_is_full(self, dungeon: DungeonList | None) -> bool:
if dungeon is None:
self.obtain_frequent_check = False
return False
row = self.planner.row_come_from_dungeon(dungeon)
if row is None:
self.obtain_frequent_check = False
return False
# Update
self.obtain_get(dungeon)
# Check progress
row = self.planner.row_come_from_dungeon(dungeon)
if row is None:
logger.error(f'obtained_is_full: Row disappeared after obtain_get')
self.obtain_frequent_check = False
return False
if not row.need_farm():
logger.info('Planner row full')
self.obtain_frequent_check = False
return True
# obtain_frequent_check
self.obtain_frequent_check = True
return False
if __name__ == '__main__':
self = DungeonObtain('src')
self = CombatObtain('src')
self.device.screenshot()
self.obtain_get()

View File

@ -346,7 +346,8 @@ class PlannerProgressParser:
return None
class PlannerProgressMixin(UI):
class PlannerMixin(UI):
def planner_write_results(self, results: list[PlannerResultRow]):
"""
Write planner detection results info user config

View File

@ -11,7 +11,7 @@ from tasks.daily.synthesize import SynthesizeUI
from tasks.planner.assets.assets_planner_result import *
from tasks.planner.keywords import ITEM_CLASSES
from tasks.planner.keywords.classes import ItemCurrency
from tasks.planner.model import PlannerProgressMixin, PlannerResultRow
from tasks.planner.model import PlannerMixin, PlannerResultRow
CALCULATE_TITLE.load_search(RESULT_CHECK.search)
MATERIAL_TITLE.load_search(RESULT_CHECK.search)
@ -75,7 +75,7 @@ class OcrPlannerResult(OcrWhiteLetterOnComplexBackground, OcrItemName):
return image
class PlannerResult(SynthesizeUI, PlannerProgressMixin):
class PlannerResult(SynthesizeUI, PlannerMixin):
def is_in_planner_result(self):
if self.appear(RESULT_CHECK):
return True