Skip to content

Commit

Permalink
Merge pull request #4423 from LmeSzinc/dev
Browse files Browse the repository at this point in the history
Bug fix
  • Loading branch information
LmeSzinc authored Dec 11, 2024
2 parents 8081764 + bfdf6e4 commit c483cd5
Show file tree
Hide file tree
Showing 20 changed files with 211 additions and 140 deletions.
4 changes: 2 additions & 2 deletions campaign/campaign_main/campaign_15_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def map_data_init(self, map_):

map_has_mob_move = True

def strategy_set_execute(self, formation_index=None, sub_view=None, sub_hunt=None):
def strategy_set_execute(self, formation=None, sub_view=None, sub_hunt=None):
super().strategy_set_execute(
formation_index=formation_index,
formation=formation,
sub_view=sub_view,
sub_hunt=sub_hunt,
)
Expand Down
4 changes: 2 additions & 2 deletions campaign/campaign_war_archives/campaign_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from module.war_archives.dictionary import dic_archives_template

WAR_ARCHIVES_SWITCH = Switch('War_Archives_switch', is_selector=True)
WAR_ARCHIVES_SWITCH.add_status('ex', WAR_ARCHIVES_EX_ON)
WAR_ARCHIVES_SWITCH.add_status('sp', WAR_ARCHIVES_SP_ON)
WAR_ARCHIVES_SWITCH.add_state('ex', WAR_ARCHIVES_EX_ON)
WAR_ARCHIVES_SWITCH.add_state('sp', WAR_ARCHIVES_SP_ON)
WAR_ARCHIVES_SCROLL = Scroll(WAR_ARCHIVES_SCROLL, color=(247, 211, 66), name='WAR_ARCHIVES_SCROLL')


Expand Down
4 changes: 2 additions & 2 deletions campaign/event_20221124_cn/campaign_base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from module.campaign.campaign_base import CampaignBase as CampaignBase_
from module.combat.assets import GET_ITEMS_1_RYZA
from module.handler.fast_forward import auto_search
from module.handler.fast_forward import AUTO_SEARCH
from module.handler.assets import MYSTERY_ITEM
from module.logger import logger
from module.map.map_grids import SelectedGrids
Expand Down Expand Up @@ -62,7 +62,7 @@ def map_get_info(self):

# Chapter TH has no map_percentage and no 3_stars
if name.startswith('th') or name.startswith('ht'):
appear = auto_search.appear(main=self)
appear = AUTO_SEARCH.appear(main=self)
self.map_is_100_percent_clear = self.map_is_3_stars = self.map_is_threat_safe = appear
self.map_has_clear_mode = appear
self.map_show_info()
Expand Down
4 changes: 2 additions & 2 deletions campaign/event_20240725_cn/campaign_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from module.logger import logger

MODE_SWITCH_20240725 = ModeSwitch('Mode_switch_20240725', offset=(30, 30))
MODE_SWITCH_20240725.add_status('combat', SWITCH_20240725_COMBAT)
MODE_SWITCH_20240725.add_status('story', SWITCH_20240725_STORY)
MODE_SWITCH_20240725.add_state('combat', SWITCH_20240725_COMBAT)
MODE_SWITCH_20240725.add_state('story', SWITCH_20240725_STORY)


class CampaignBase(CampaignBase_):
Expand Down
4 changes: 2 additions & 2 deletions campaign/event_20240829_cn/campaign_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from module.logger import logger

MODE_SWITCH_20240725 = ModeSwitch('Mode_switch_20240725', offset=(30, 30))
MODE_SWITCH_20240725.add_status('combat', SWITCH_20240725_COMBAT)
MODE_SWITCH_20240725.add_status('story', SWITCH_20240725_STORY)
MODE_SWITCH_20240725.add_state('combat', SWITCH_20240725_COMBAT)
MODE_SWITCH_20240725.add_state('story', SWITCH_20240725_STORY)


class CampaignBase(CampaignBase_):
Expand Down
4 changes: 2 additions & 2 deletions campaign/event_20240912_cn/campaign_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@


MODE_SWITCH_20240912 = ModeSwitch('Mode_switch_20240912', is_selector=True, offset=(30, 30))
MODE_SWITCH_20240912.add_status('combat', SWITCH_20240725_COMBAT, offset=(444, 4))
MODE_SWITCH_20240912.add_status('story', SWITCH_20240725_STORY, offset=(444, 4))
MODE_SWITCH_20240912.add_state('combat', SWITCH_20240725_COMBAT, offset=(444, 4))
MODE_SWITCH_20240912.add_state('story', SWITCH_20240725_STORY, offset=(444, 4))


class CampaignBase(CampaignBase_):
Expand Down
12 changes: 6 additions & 6 deletions campaign/event_20241024_cn/campaign_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
from module.template.assets import TEMPLATE_ENEMY_BOSS

MODE_SWITCH_20240725 = ModeSwitch('Mode_switch_20240725', is_selector=True, offset=(30, 30))
MODE_SWITCH_20240725.add_status('combat', SWITCH_20240725_COMBAT, offset=(444, 4))
MODE_SWITCH_20240725.add_status('story', SWITCH_20240725_STORY, offset=(444, 4))
MODE_SWITCH_20240725.add_state('combat', SWITCH_20240725_COMBAT, offset=(444, 4))
MODE_SWITCH_20240725.add_state('story', SWITCH_20240725_STORY, offset=(444, 4))

CHAPTER_SWITCH_20241024 = ModeSwitch('Chapter_switch_20241024', is_selector=True, offset=(30, 30))
CHAPTER_SWITCH_20241024.add_status('ab', CHAPTER_20241024_AB)
CHAPTER_SWITCH_20241024.add_status('cd', CHAPTER_20241024_CD)
CHAPTER_SWITCH_20241024.add_status('sp', CHAPTER_20241024_SP)
CHAPTER_SWITCH_20241024.add_status('ex', CHAPTER_20241024_EX)
CHAPTER_SWITCH_20241024.add_state('ab', CHAPTER_20241024_AB)
CHAPTER_SWITCH_20241024.add_state('cd', CHAPTER_20241024_CD)
CHAPTER_SWITCH_20241024.add_state('sp', CHAPTER_20241024_SP)
CHAPTER_SWITCH_20241024.add_state('ex', CHAPTER_20241024_EX)


class EventGrid(Grid):
Expand Down
2 changes: 1 addition & 1 deletion module/base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def ensure_button(self, button):

return button

def appear(self, button, offset=0, interval=0, similarity=0.85, threshold=30):
def appear(self, button, offset=0, interval=0, similarity=0.85, threshold=10):
"""
Args:
button (Button, Template, HierarchyButton, str):
Expand Down
8 changes: 4 additions & 4 deletions module/campaign/campaign_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def handle_additional(self, main):


MODE_SWITCH_1 = ModeSwitch('Mode_switch_1', offset=(30, 10))
MODE_SWITCH_1.add_status('normal', SWITCH_1_NORMAL)
MODE_SWITCH_1.add_status('hard', SWITCH_1_HARD)
MODE_SWITCH_1.add_state('normal', SWITCH_1_NORMAL)
MODE_SWITCH_1.add_state('hard', SWITCH_1_HARD)
MODE_SWITCH_2 = ModeSwitch('Mode_switch_2', offset=(30, 10))
MODE_SWITCH_2.add_status('hard', SWITCH_2_HARD)
MODE_SWITCH_2.add_status('ex', SWITCH_2_EX)
MODE_SWITCH_2.add_state('hard', SWITCH_2_HARD)
MODE_SWITCH_2.add_state('ex', SWITCH_2_EX)


class CampaignUI(MapOperation, CampaignEvent, CampaignOcr):
Expand Down
2 changes: 0 additions & 2 deletions module/campaign/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import importlib
import os
import random
import re

from module.campaign.campaign_base import CampaignBase
from module.campaign.campaign_event import CampaignEvent
Expand Down Expand Up @@ -164,7 +163,6 @@ def handle_stage_name(self, name, folder, mode='normal'):
Returns:
str, str: name, folder
"""
name = re.sub('[ \t\n]', '', str(name)).lower()
name = to_map_file_name(name)
# For GemsFarming, auto choose events or main chapters
if self.config.task.command == 'GemsFarming':
Expand Down
16 changes: 8 additions & 8 deletions module/coalition/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ def coalition_ensure_mode(self, event, mode):
"""
MODE_SWITCH = Switch('CoalitionMode', offset=(20, 20))
if event == 'coalition_20230323':
MODE_SWITCH.add_status('story', FROSTFALL_MODE_STORY)
MODE_SWITCH.add_status('battle', FROSTFALL_MODE_BATTLE)
MODE_SWITCH.add_state('story', FROSTFALL_MODE_STORY)
MODE_SWITCH.add_state('battle', FROSTFALL_MODE_BATTLE)
elif event == 'coalition_20240627':
# Note that switch button are reversed
MODE_SWITCH.add_status('story', ACADEMY_MODE_BATTLE)
MODE_SWITCH.add_status('battle', ACADEMY_MODE_STORY)
MODE_SWITCH.add_state('story', ACADEMY_MODE_BATTLE)
MODE_SWITCH.add_state('battle', ACADEMY_MODE_STORY)
else:
logger.error(f'MODE_SWITCH is not defined in event {event}')
raise ScriptError
Expand All @@ -52,11 +52,11 @@ def coalition_ensure_fleet(self, event, mode):
"""
FLEET_SWITCH = Switch('FleetMode', is_selector=True, offset=0) # No offset for color match
if event == 'coalition_20230323':
FLEET_SWITCH.add_status('single', FROSTFALL_SWITCH_SINGLE)
FLEET_SWITCH.add_status('multi', FROSTFALL_SWITCH_MULTI)
FLEET_SWITCH.add_state('single', FROSTFALL_SWITCH_SINGLE)
FLEET_SWITCH.add_state('multi', FROSTFALL_SWITCH_MULTI)
elif event == 'coalition_20240627':
FLEET_SWITCH.add_status('single', ACADEMY_SWITCH_SINGLE)
FLEET_SWITCH.add_status('multi', ACADEMY_SWITCH_MULTI)
FLEET_SWITCH.add_state('single', ACADEMY_SWITCH_SINGLE)
FLEET_SWITCH.add_state('multi', ACADEMY_SWITCH_MULTI)
else:
logger.error(f'FLEET_SWITCH is not defined in event {event}')
raise ScriptError
Expand Down
4 changes: 2 additions & 2 deletions module/commission/commission.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from module.ui_white.assets import REWARD_1_WHITE, REWARD_GOTO_COMMISSION_WHITE

COMMISSION_SWITCH = Switch('Commission_switch', is_selector=True)
COMMISSION_SWITCH.add_status('daily', COMMISSION_DAILY)
COMMISSION_SWITCH.add_status('urgent', COMMISSION_URGENT)
COMMISSION_SWITCH.add_state('daily', COMMISSION_DAILY)
COMMISSION_SWITCH.add_state('urgent', COMMISSION_URGENT)
COMMISSION_SCROLL = Scroll(COMMISSION_SCROLL_AREA, color=(247, 211, 66), name='COMMISSION_SCROLL')


Expand Down
4 changes: 2 additions & 2 deletions module/equipment/equipment_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
SIM_VALUE = 0.90

equipping_filter = Switch('Equipping_filter')
equipping_filter.add_status('on', check_button=EQUIPPING_ON)
equipping_filter.add_status('off', check_button=EQUIPPING_OFF)
equipping_filter.add_state('on', check_button=EQUIPPING_ON)
equipping_filter.add_state('off', check_button=EQUIPPING_OFF)


class EquipmentChange(Equipment):
Expand Down
61 changes: 38 additions & 23 deletions module/handler/fast_forward.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re

from module.base.timer import Timer
from module.base.utils import color_bar_percentage
Expand All @@ -7,15 +8,15 @@
from module.logger import logger
from module.ui.switch import Switch

fast_forward = Switch('Fast_Forward')
fast_forward.add_status('on', check_button=FAST_FORWARD_ON)
fast_forward.add_status('off', check_button=FAST_FORWARD_OFF)
fleet_lock = Switch('Fleet_Lock', offset=(5, 20))
fleet_lock.add_status('on', check_button=FLEET_LOCKED)
fleet_lock.add_status('off', check_button=FLEET_UNLOCKED)
auto_search = Switch('Auto_Search', offset=(20, 20))
auto_search.add_status('on', check_button=AUTO_SEARCH_ON)
auto_search.add_status('off', check_button=AUTO_SEARCH_OFF)
FAST_FORWARD = Switch('Fast_Forward')
FAST_FORWARD.add_state('on', check_button=FAST_FORWARD_ON)
FAST_FORWARD.add_state('off', check_button=FAST_FORWARD_OFF)
FLEET_LOCK = Switch('Fleet_Lock', offset=(5, 20))
FLEET_LOCK.add_state('on', check_button=FLEET_LOCKED)
FLEET_LOCK.add_state('off', check_button=FLEET_UNLOCKED)
AUTO_SEARCH = Switch('Auto_Search', offset=(20, 20))
AUTO_SEARCH.add_state('on', check_button=AUTO_SEARCH_ON)
AUTO_SEARCH.add_state('off', check_button=AUTO_SEARCH_OFF)


def map_files(event):
Expand Down Expand Up @@ -51,7 +52,14 @@ def to_map_input_name(name: str) -> str:
campaign_7_2 -> 7-2
d3 -> D3
"""
name = name.upper()
name = str(name).upper()
# Remove whitespaces
name = re.sub('[ \t\n]', '', name).lower()
# B-1 -> B1
res = re.match(r'([a-zA-Z])+[- ]+(\d+)', name)
if res:
name = f'{res.group(1)}{res.group(2)}'
# campaign_7_2 -> 7-2
name = name.replace('CAMPAIGN_', '').replace('_', '-')
return name

Expand All @@ -64,7 +72,14 @@ def to_map_file_name(name: str) -> str:
campaign_7_2 -> campaign_7_2
D3 -> d3
"""
name = name.lower()
name = str(name).lower()
# Remove whitespaces
name = re.sub('[ \t\n]', '', name).lower()
# B-1 -> B1
res = re.match(r'([a-zA-Z])+[- ]+(\d+)', name)
if res:
name = f'{res.group(1)}{res.group(2)}'
# 7-2 to campaign_7_2
if name and name[0].isdigit():
name = 'campaign_' + name.replace('-', '_')
return name
Expand Down Expand Up @@ -127,9 +142,9 @@ def map_get_info(self):
# Minor issue here
# Using auto_search option because clear mode cannot be detected whether on SP
# If user manually turn off auto search, alas can't enable it again
self.map_has_clear_mode = auto_search.appear(main=self)
self.map_has_clear_mode = AUTO_SEARCH.appear(main=self)
else:
self.map_has_clear_mode = self.map_is_100_percent_clear and fast_forward.appear(main=self)
self.map_has_clear_mode = self.map_is_100_percent_clear and FAST_FORWARD.appear(main=self)

# Override config
if self.map_achieved_star_1:
Expand Down Expand Up @@ -187,8 +202,8 @@ def handle_fast_forward(self):
self.map_is_2x_book = False
pass

status = 'on' if self.config.Campaign_UseClearMode else 'off'
changed = fast_forward.set(status=status, main=self)
state = 'on' if self.config.Campaign_UseClearMode else 'off'
changed = FAST_FORWARD.set(state, main=self)
return changed

def handle_map_fleet_lock(self, enable=None):
Expand All @@ -201,14 +216,14 @@ def handle_map_fleet_lock(self, enable=None):
"""
# Fleet lock depends on if it appear on map, not depends on map status.
# Because if already in map, there's no map status,
if not fleet_lock.appear(main=self):
if not FLEET_LOCK.appear(main=self):
logger.info('No fleet lock option.')
return False

if enable is None:
enable = self.config.Campaign_UseFleetLock
status = 'on' if enable else 'off'
changed = fleet_lock.set(status=status, main=self)
state = 'on' if enable else 'off'
changed = FLEET_LOCK.set(state, main=self)

return changed

Expand All @@ -223,13 +238,13 @@ def handle_auto_search(self):
# if not self.map_is_clear_mode:
# return False

if not auto_search.appear(main=self):
if not AUTO_SEARCH.appear(main=self):
logger.info('No auto search option.')
self.map_is_auto_search = False
return False

status = 'on' if self.map_is_auto_search else 'off'
changed = auto_search.set(status=status, main=self)
state = 'on' if self.map_is_auto_search else 'off'
changed = AUTO_SEARCH.set(state, main=self)

return changed

Expand Down Expand Up @@ -461,8 +476,8 @@ def handle_2x_book_setting(self, mode='prep'):
book_check = BOOK_CHECK_AUTO
book_box = BOOK_BOX_AUTO

status = 'on' if self.map_is_2x_book else 'off'
if self._set_2x_book_status(status, book_check, book_box):
state = 'on' if self.map_is_2x_book else 'off'
if self._set_2x_book_status(state, book_check, book_box):
self.emotion.map_is_2x_book = self.map_is_2x_book
else:
self.map_is_2x_book = False
Expand Down
Loading

0 comments on commit c483cd5

Please sign in to comment.