mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-15 22:19:18 +00:00
Add: Participate in double planer event
This commit is contained in:
parent
0f8456f98d
commit
4707e47f73
BIN
assets/share/dungeon/event/DOUBLE_ROGUE_EVENT_TAG.png
Normal file
BIN
assets/share/dungeon/event/DOUBLE_ROGUE_EVENT_TAG.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
@ -23,6 +23,16 @@ DOUBLE_RELIC_EVENT_TAG = ButtonWrapper(
|
||||
button=(329, 505, 425, 589),
|
||||
),
|
||||
)
|
||||
DOUBLE_ROGUE_EVENT_TAG = ButtonWrapper(
|
||||
name='DOUBLE_ROGUE_EVENT_TAG',
|
||||
share=Button(
|
||||
file='./assets/share/dungeon/event/DOUBLE_ROGUE_EVENT_TAG.png',
|
||||
area=(346, 156, 431, 217),
|
||||
search=(326, 136, 451, 237),
|
||||
color=(141, 135, 123),
|
||||
button=(346, 156, 431, 217),
|
||||
),
|
||||
)
|
||||
OCR_DOUBLE_EVENT_REMAIN = ButtonWrapper(
|
||||
name='OCR_DOUBLE_EVENT_REMAIN',
|
||||
share=Button(
|
||||
|
@ -201,7 +201,8 @@ class Dungeon(DungeonStamina, DungeonEvent, Combat):
|
||||
# Update double event records
|
||||
if (self.config.stored.DungeonDouble.is_expired()
|
||||
or self.config.stored.DungeonDouble.calyx > 0
|
||||
or self.config.stored.DungeonDouble.relic > 0):
|
||||
or self.config.stored.DungeonDouble.relic > 0
|
||||
or self.config.stored.DungeonDouble.rogue > 0):
|
||||
logger.info('Get dungeon double remains')
|
||||
# UI switches
|
||||
switched = self.dungeon_tab_goto(KEYWORDS_DUNGEON_TAB.Survival_Index)
|
||||
@ -212,6 +213,9 @@ class Dungeon(DungeonStamina, DungeonEvent, Combat):
|
||||
# Check remains
|
||||
calyx = 0
|
||||
relic = 0
|
||||
rogue = 0
|
||||
if self.has_double_rogue_event():
|
||||
rogue = self.get_double_event_remain()
|
||||
if self.has_double_calyx_event():
|
||||
self._dungeon_nav_goto(KEYWORDS_DUNGEON_LIST.Calyx_Golden_Treasures)
|
||||
calyx = self.get_double_event_remain()
|
||||
@ -221,6 +225,7 @@ class Dungeon(DungeonStamina, DungeonEvent, Combat):
|
||||
with self.config.multi_set():
|
||||
self.config.stored.DungeonDouble.calyx = calyx
|
||||
self.config.stored.DungeonDouble.relic = relic
|
||||
self.config.stored.DungeonDouble.rogue = rogue
|
||||
|
||||
# Run double events
|
||||
ran_calyx_golden = False
|
||||
@ -248,7 +253,16 @@ class Dungeon(DungeonStamina, DungeonEvent, Combat):
|
||||
self.running_double = False
|
||||
|
||||
# Dungeon to clear all trailblaze power
|
||||
if self.config.is_task_enabled('Rogue') and self.config.cross_get('Rogue.RogueWorld.UseStamina'):
|
||||
do_rogue = False
|
||||
if self.config.is_task_enabled('Rogue'):
|
||||
if self.config.cross_get('Rogue.RogueWorld.UseStamina'):
|
||||
logger.info('Going to use stamina in rogue')
|
||||
do_rogue = True
|
||||
elif self.config.cross_get('Rogue.RogueWorld.DoubleEvent') \
|
||||
and self.config.stored.DungeonDouble.rogue > 0:
|
||||
logger.info('Going to use stamina in double rogue event')
|
||||
do_rogue = True
|
||||
if do_rogue:
|
||||
final = KEYWORDS_DUNGEON_LIST.Simulated_Universe_World_1
|
||||
else:
|
||||
final = DungeonList.find(self.config.Dungeon_Name)
|
||||
@ -300,9 +314,15 @@ class Dungeon(DungeonStamina, DungeonEvent, Combat):
|
||||
if self.require_compulsory_support():
|
||||
logger.info('Run dungeon with support once as stamina is rogue prioritized')
|
||||
self.dungeon_run(dungeon=DungeonList.find(self.config.Dungeon_Name), wave_limit=1)
|
||||
# Store immersifiers and call rogue task if accumulated to 4
|
||||
# Store immersifiers
|
||||
logger.info('Prioritize stamina for simulated universe, skip dungeon')
|
||||
self.immersifier_store()
|
||||
amount = 0
|
||||
if not self.config.cross_get('Rogue.RogueWorld.UseStamina') \
|
||||
and self.config.cross_get('Rogue.RogueWorld.DoubleEvent') \
|
||||
and self.config.stored.DungeonDouble.rogue > 0:
|
||||
amount = self.config.stored.DungeonDouble.rogue
|
||||
self.immersifier_store(max_store=amount)
|
||||
# call rogue task if accumulated to 4
|
||||
with self.config.multi_set():
|
||||
if self.config.stored.Immersifier.value >= 4:
|
||||
# Schedule behind rogue
|
||||
|
@ -6,6 +6,7 @@ from tasks.base.ui import UI
|
||||
from tasks.dungeon.assets.assets_dungeon_event import (
|
||||
DOUBLE_CALYX_EVENT_TAG,
|
||||
DOUBLE_RELIC_EVENT_TAG,
|
||||
DOUBLE_ROGUE_EVENT_TAG,
|
||||
OCR_DOUBLE_EVENT_REMAIN,
|
||||
OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT,
|
||||
)
|
||||
@ -43,6 +44,16 @@ class DungeonEvent(UI):
|
||||
logger.attr('Double relic', has)
|
||||
return has
|
||||
|
||||
def has_double_rogue_event(self) -> bool:
|
||||
"""
|
||||
Pages:
|
||||
in: page_guide, Survival_Index, nav at top
|
||||
"""
|
||||
has = self.image_color_count(DOUBLE_ROGUE_EVENT_TAG, color=(252, 209, 123), threshold=221, count=50)
|
||||
has |= self.image_color_count(DOUBLE_ROGUE_EVENT_TAG, color=(252, 251, 140), threshold=221, count=50)
|
||||
logger.attr('Double rogue', has)
|
||||
return has
|
||||
|
||||
def has_double_event_at_combat(self) -> bool:
|
||||
"""
|
||||
Pages:
|
||||
|
@ -122,10 +122,13 @@ class DungeonStamina(DungeonUI):
|
||||
if self.handle_reward():
|
||||
continue
|
||||
|
||||
def immersifier_store(self):
|
||||
def immersifier_store(self, max_store: int = 0):
|
||||
"""
|
||||
Store immersifiers using all trailblaze power
|
||||
|
||||
Args:
|
||||
max_store: Maximum amount to store this time
|
||||
|
||||
Returns:
|
||||
bool: If stored any
|
||||
|
||||
@ -134,6 +137,7 @@ class DungeonStamina(DungeonUI):
|
||||
out: page_guide, Survival_Index, Simulated_Universe
|
||||
"""
|
||||
logger.hr('Immersifier store', level=2)
|
||||
logger.info(f'Max store: {max_store}')
|
||||
self.dungeon_goto_rogue()
|
||||
self.dungeon_update_stamina()
|
||||
|
||||
@ -144,6 +148,8 @@ class DungeonStamina(DungeonUI):
|
||||
self.config.stored.TrailblazePower.value // 40,
|
||||
self.config.stored.Immersifier.get_remain(),
|
||||
)
|
||||
if max_store:
|
||||
amount = min(amount, max_store)
|
||||
if amount <= 0:
|
||||
logger.info('Not enough stamina to store 1 immersifier')
|
||||
return False
|
||||
|
@ -306,11 +306,15 @@ class RogueEntry(RouteBase, RogueRewardHandler, RoguePathHandler, DungeonUI):
|
||||
"""
|
||||
logger.info(f'RogueWorld_UseImmersifier={self.config.RogueWorld_UseImmersifier}, '
|
||||
f'RogueWorld_UseStamina={self.config.RogueWorld_UseStamina}, '
|
||||
f'RogueWorld_DoubleEvent={self.config.RogueWorld_DoubleEvent}'
|
||||
f'RogueDebug_DebugMode={self.config.RogueDebug_DebugMode}')
|
||||
# This shouldn't happen
|
||||
if self.config.RogueWorld_UseStamina and not self.config.RogueWorld_UseImmersifier:
|
||||
logger.error('Invalid rogue reward settings')
|
||||
raise ScriptError
|
||||
if self.config.RogueWorld_DoubleEvent and not self.config.RogueWorld_UseImmersifier:
|
||||
logger.error('Invalid rogue reward settings')
|
||||
raise ScriptError
|
||||
|
||||
if self.config.RogueDebug_DebugMode:
|
||||
# Always run
|
||||
|
@ -26,7 +26,11 @@ class RogueReward(RogueUI, CombatInteract, DungeonState):
|
||||
return
|
||||
|
||||
confirm = Timer(0.6, count=2).start()
|
||||
init = False
|
||||
initial_stamina = 0
|
||||
initial_immersifier = 0
|
||||
exhausted = False
|
||||
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
@ -36,6 +40,8 @@ class RogueReward(RogueUI, CombatInteract, DungeonState):
|
||||
if self.is_in_main():
|
||||
if confirm.reached():
|
||||
break
|
||||
if exhausted:
|
||||
break
|
||||
else:
|
||||
confirm.reset()
|
||||
|
||||
@ -49,6 +55,10 @@ class RogueReward(RogueUI, CombatInteract, DungeonState):
|
||||
continue
|
||||
if self.appear(REWARD_CLOSE, interval=2):
|
||||
self.dungeon_update_stamina()
|
||||
if not init:
|
||||
initial_stamina = self.config.stored.TrailblazePower.value
|
||||
initial_immersifier = self.config.stored.Immersifier.value
|
||||
init = True
|
||||
if use_trailblaze_power and self.config.stored.TrailblazePower.value >= 40:
|
||||
self.device.click(USE_STAMINA)
|
||||
self.interval_reset(USE_STAMINA)
|
||||
@ -69,6 +79,31 @@ class RogueReward(RogueUI, CombatInteract, DungeonState):
|
||||
exhausted = True
|
||||
continue
|
||||
|
||||
with self.config.multi_set():
|
||||
claimed = 0
|
||||
diff = initial_immersifier - self.config.stored.Immersifier.value
|
||||
if diff >= 1:
|
||||
claimed += diff
|
||||
self.config.stored.Immersifier.add(-diff)
|
||||
diff = initial_stamina - self.config.stored.TrailblazePower.value
|
||||
if diff + 2 >= 40:
|
||||
# Stamina may recover while receiving
|
||||
diff = int((diff + 2) // 40)
|
||||
claimed += diff
|
||||
self.config.stored.TrailblazePower.add(-diff)
|
||||
# Clicked button, closed reward popup, planer page closed by game itself, exhausted=False, claimed once
|
||||
# Cannot claim more, clicked REWARD_CLOSE to close planer page, exhausted=True, nothing claimed at last
|
||||
if not exhausted:
|
||||
claimed += 1
|
||||
if use_trailblaze_power:
|
||||
self.config.stored.TrailblazePower.add(-1)
|
||||
elif use_immersifier:
|
||||
self.config.stored.Immersifier.add(-1)
|
||||
logger.info(f'Claimed planer reward {claimed} times')
|
||||
if self.config.stored.DungeonDouble.rogue > 0:
|
||||
self.config.stored.DungeonDouble.rogue -= claimed
|
||||
return claimed
|
||||
|
||||
def can_claim_domain_reward(
|
||||
self,
|
||||
use_trailblaze_power=False,
|
||||
|
@ -33,6 +33,10 @@ class Rogue(RouteLoader, RogueEntry):
|
||||
def run(self):
|
||||
self.config.update_battle_pass_quests()
|
||||
self.config.update_daily_quests()
|
||||
if self.config.stored.DungeonDouble.is_expired():
|
||||
self.config.task_call('Dungeon')
|
||||
self.config.task_stop()
|
||||
|
||||
while 1:
|
||||
# Run
|
||||
success = self.rogue_once()
|
||||
|
Loading…
Reference in New Issue
Block a user