Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion module/campaign/gems_farming.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

class GemsCampaignOverride(CampaignBase):

def handle_combat_low_emotion(self):
def handle_combat_low_emotion(self, fleet_index=None):
"""
Overwrite info_handler.handle_combat_low_emotion()
If change vanguard is enabled, withdraw combat and change flagship and vanguard
Expand Down
2 changes: 1 addition & 1 deletion module/combat/combat.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def combat_preparation(self, balance_hp=False, emotion_reduce=False, auto='comba
continue
if self.handle_retirement():
continue
if self.handle_combat_low_emotion():
if self.handle_combat_low_emotion(fleet_index=fleet_index):
continue
if balance_hp and self.handle_emergency_repair_use():
continue
Expand Down
48 changes: 48 additions & 0 deletions module/combat/emotion.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,54 @@ def reduce_per_battle_before_entering(self):
else:
return 2

def _fleet_indexes(self, fleet_index=None):
try:
fleet_index = int(fleet_index)
except (TypeError, ValueError):
return [1, 2]

if fleet_index in [1, 2]:
return [fleet_index]
return [1, 2]

def reset_low_emotion(self, fleet_index=None):
"""
Reset emotion ledger after the game client reports low emotion.

Args:
fleet_index (int, None): 1 or 2. Unknown fleets reset both ledgers.

Returns:
list[FleetEmotion]: Fleets whose values were reset.
"""
indexes = self._fleet_indexes(fleet_index=fleet_index)
if len(indexes) > 1:
logger.warning('Unable to identify low-emotion fleet, reset both fleet ledgers')

logger.hr('Emotion control')
self.update()
fleets = [self.fleets[index - 1] for index in indexes]
for fleet in fleets:
fleet.current = max(fleet.limit - 1, 0)
logger.info(f'Reset emotion fleet {fleet.fleet} to {fleet.current}')

self.record()
self.show()
return fleets
Comment on lines +329 to +342

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是,ai写的代码自己审一下啊,弹低心情就把心情设置为最大,那计算心情的意义是什么呢

设置为0,然后让 Emotion.wait() 在图内等待,然后等到下一场战斗的心情再继续,结束关卡之后等待下一把的预期心情消耗再进图

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

抱歉这个是我记错了,我记成心情40点以下就出现弹窗,所以max(fleet.limit - 1, 0)这设成出现弹窗就默认心情到了39点


def delay_after_low_emotion(self, fleet_index=None):
"""
Delay current task after backing out of the low-emotion sortie popup.

Raise:
ScriptEnd: Stop current task normally so scheduler can continue.
"""
fleets = self.reset_low_emotion(fleet_index=fleet_index)
recovered = max([fleet.get_recovered(expected_reduce=self.reduce_per_battle) for fleet in fleets])
logger.info(f'Delay current task until emotion recovers at {recovered}')
self.config.task_delay(target=recovered)
raise ScriptEnd('Emotion control')

def check_reduce(self, battle):
"""
Check emotion before entering a campaign.
Expand Down
2 changes: 1 addition & 1 deletion module/event_hospital/combat.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def check_coin():
check_coin()
if self.handle_retirement():
continue
if self.handle_combat_low_emotion():
if self.handle_combat_low_emotion(fleet_index=fleet_index):
continue
if self.appear_then_click(BATTLE_PREPARATION, offset=(30, 20), interval=2):
continue
Expand Down
16 changes: 12 additions & 4 deletions module/handler/info_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def handle_popup_cancel(self, name='', offset=None, interval=2):
return True
if self.appear(POPUP_CANCEL_WHITE, offset=offset, interval=interval):
POPUP_CANCEL_WHITE.name = POPUP_CANCEL_WHITE.name + '_' + name
self.device.click(POPUP_CONFIRM_WHITE)
self.device.click(POPUP_CANCEL_WHITE)
POPUP_CANCEL_WHITE.name = POPUP_CANCEL_WHITE.name[:-len(name) - 1]
return True
return False
Expand Down Expand Up @@ -184,14 +184,22 @@ def handle_urgent_commission(self, drop=None):

return appear

def handle_combat_low_emotion(self):
if not self.emotion.is_ignore:
def handle_combat_low_emotion(self, fleet_index=None):
if self.emotion.is_ignore:
result = self.handle_popup_confirm('IGNORE_LOW_EMOTION')
if result:
# Avoid clicking AUTO_SEARCH_MAP_OPTION_OFF
self.interval_reset(AUTO_SEARCH_MAP_OPTION_OFF)
return result

if not self.emotion.is_calculate:
return False

result = self.handle_popup_confirm('IGNORE_LOW_EMOTION')
result = self.handle_popup_cancel('LOW_EMOTION_CONTROL')
if result:
# Avoid clicking AUTO_SEARCH_MAP_OPTION_OFF
self.interval_reset(AUTO_SEARCH_MAP_OPTION_OFF)
self.emotion.delay_after_low_emotion(fleet_index=fleet_index)
return result

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handle 系方法不应该有修改配置文件的行为


def handle_use_data_key(self):
Expand Down
2 changes: 1 addition & 1 deletion module/raid/raid.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def combat_preparation(self, balance_hp=False, emotion_reduce=False, auto='comba
continue
if self.handle_retirement():
continue
if self.handle_combat_low_emotion():
if self.handle_combat_low_emotion(fleet_index=fleet_index):
continue
if self.appear_then_click(BATTLE_PREPARATION, offset=(30, 20), interval=2):
continue
Expand Down