diff --git a/umalauncher/carrotjuicer.py b/umalauncher/carrotjuicer.py
index 03a7d0e..3783821 100644
--- a/umalauncher/carrotjuicer.py
+++ b/umalauncher/carrotjuicer.py
@@ -231,6 +231,16 @@ def handle_response(self, message):
self.screen_state_handler.carrotjuicer_state = new_state
return
+ # Team Building
+ if 'scout_ranking_state' in data:
+ if data.get("own_team_info") and data['own_team_info'].get('team_score') and self.screen_state_handler:
+ team_score = data['own_team_info'].get('team_score')
+ leader_chara_id = data['own_team_info'].get('entry_chara_array',[{}])[0].get('trained_chara', {}).get('card_id')
+
+ if team_score and leader_chara_id:
+ logger.debug(f"Team score: {team_score}, leader chara id: {leader_chara_id}")
+ self.screen_state_handler.carrotjuicer_state = screenstate_utils.make_scouting_state(self.screen_state_handler, team_score, leader_chara_id)
+
# League of Heroes
if 'heroes_id' in data:
if data.get("own_team_info") and data['own_team_info']['team_name'] and data['own_team_info']['league_score'] and self.screen_state_handler:
@@ -342,10 +352,19 @@ def handle_response(self, message):
if event_data['event_contents_info']['support_card_id'] and event_data['event_contents_info']['support_card_id'] not in supports:
# Random support card event
logger.debug("Random support card detected")
+
self.browser.execute_script("""document.getElementById("boxSupportExtra").click();""")
self.browser.execute_script(
"""
- document.getElementById(arguments[0].toString()).click();
+ var cont = document.getElementById("30021").parentElement.parentElement;
+
+ var ele = cont.getElementById(arguments[0].toString());
+
+ if (ele) {
+ ele.click();
+ } else {
+ cont.querySelector("img[src=\"/images/ui/close.png\"]").click();
+ }
""",
event_data['event_contents_info']['support_card_id']
)
diff --git a/umalauncher/constants.py b/umalauncher/constants.py
index 2e436a9..f6f8db5 100644
--- a/umalauncher/constants.py
+++ b/umalauncher/constants.py
@@ -134,4 +134,37 @@
23000: "Platinum 2",
26000: "Platinum 3",
30000: "Platinum 4"
+}
+
+SCOUTING_SCORE_TO_RANK_DICT = {
+ 0: "No rank",
+ 60000: "E",
+ 63000: "E1",
+ 66000: "E2",
+ 69000: "E3",
+ 72000: "D",
+ 76000: "D1",
+ 80000: "D2",
+ 85000: "D3",
+ 90000: "C",
+ 95000: "C1",
+ 100000: "C2",
+ 105000: "C3",
+ 110000: "B",
+ 115000: "B1",
+ 120000: "B2",
+ 125000: "B3",
+ 130000: "A",
+ 135000: "A1",
+ 140000: "A2",
+ 145000: "A3",
+ 150000: "A4",
+ 155000: "A5",
+ 160000: "S",
+ 165000: "S1",
+ 170000: "S2",
+ 180000: "S3",
+ 190000: "S4",
+ 200000: "S5",
+ 210000: "SS"
}
\ No newline at end of file
diff --git a/umalauncher/helper_table.py b/umalauncher/helper_table.py
index 6ccb001..b899635 100644
--- a/umalauncher/helper_table.py
+++ b/umalauncher/helper_table.py
@@ -268,6 +268,7 @@ def calc_bond_gain(partner_id, amount):
scheduled_races.append({
"turn": turn,
+ "fans": program_data['need_fan_count'],
"thumb_url": thumb_url
})
@@ -292,6 +293,7 @@ def calc_bond_gain(partner_id, amount):
"scenario_id": data['chara_info']['scenario_id'],
"energy": data['chara_info']['vital'],
"max_energy": data['chara_info']['max_vital'],
+ "fans": data['chara_info']['fans'],
"scheduled_races": scheduled_races,
"gm_fragments": gm_fragments,
"gl_stats": gl_stats,
diff --git a/umalauncher/helper_table_elements.py b/umalauncher/helper_table_elements.py
index 8379570..0e61523 100644
--- a/umalauncher/helper_table_elements.py
+++ b/umalauncher/helper_table_elements.py
@@ -242,7 +242,14 @@ def generate_schedule(self, main_info):
turns_left = next_race['turn'] - cur_turn
text = f"
{turns_left} turn{'' if turns_left == 1 else 's'} until
"
img = f""
- return f"""{text}{img}
"""
+
+ fan_warning = ""
+
+ if main_info['fans'] < next_race['fans']:
+ fans_needed = next_race['fans'] - main_info['fans']
+ fan_warning = f"""{fans_needed} more fans needed!
"""
+
+ return f""""""
def to_dict(self):
return {
diff --git a/umalauncher/horsium.py b/umalauncher/horsium.py
index f5aadeb..0365e58 100644
--- a/umalauncher/horsium.py
+++ b/umalauncher/horsium.py
@@ -59,8 +59,8 @@ def edge_setup(helper_url):
)
BROWSER_LIST = {
- 'Chrome': chrome_setup,
'Firefox': firefox_setup,
+ 'Chrome': chrome_setup,
'Edge': edge_setup,
}
@@ -97,14 +97,16 @@ def init_browser(self) -> RemoteWebDriver:
browser_list = []
if browser_name == "Auto":
- browser_list = BROWSER_LIST.values()
+ browser_list = BROWSER_LIST.items()
else:
- browser_list = [BROWSER_LIST[browser_name]]
+ browser_list = [(browser_name, BROWSER_LIST[browser_name])]
- for browser_setup in browser_list:
+ for browser_data in browser_list:
+ browser_name, browser_setup = browser_data
try:
logger.info("Attempting " + str(browser_setup.__name__))
driver = browser_setup(self.url)
+ self.browser_name = browser_name
break
except Exception:
logger.error("Failed to start browser")
@@ -131,7 +133,12 @@ def ensure_tab_open(self):
window_handles = self.driver.window_handles
try:
if self.active_tab_handle in window_handles:
- self.driver.switch_to.window(self.active_tab_handle)
+ if self.browser_name in ['Chrome', 'Edge']:
+ if self.driver.current_window_handle != self.active_tab_handle:
+ raise Exception("Wrong window handle")
+
+ if self.browser_name == 'Firefox' and self.driver.current_window_handle != self.active_tab_handle:
+ self.driver.switch_to.window(self.active_tab_handle)
if urls_match(self.driver.current_url, self.url):
from_script = self.driver.execute_script("return window.from_script;")
@@ -156,6 +163,10 @@ def ensure_tab_open(self):
OLD_DRIVERS.append(self.driver)
self.driver = self.init_browser()
+
+ if not self.driver:
+ return
+
self.active_tab_handle = self.driver.window_handles[0]
self.driver.switch_to.window(self.active_tab_handle)
self.run_script_at_launch()
diff --git a/umalauncher/screenstate.py b/umalauncher/screenstate.py
index a33fc0d..e673523 100644
--- a/umalauncher/screenstate.py
+++ b/umalauncher/screenstate.py
@@ -22,6 +22,7 @@ class Location(Enum):
TRAINING = 3
EVENT = 4
LEAGUE_OF_HEROES = 5
+ SCOUTING_EVENT = 6
class ScreenState:
location = None
diff --git a/umalauncher/screenstate_utils.py b/umalauncher/screenstate_utils.py
index 66bd860..170c51f 100644
--- a/umalauncher/screenstate_utils.py
+++ b/umalauncher/screenstate_utils.py
@@ -44,4 +44,16 @@ def make_league_of_heroes_state(handler, team_name, league_score) -> ss.ScreenSt
new_state.location = ss.Location.LEAGUE_OF_HEROES
new_state.main = f"League of Heroes - {team_name}"
new_state.sub = get_league_of_heroes_substate(league_score)
+ return new_state
+
+def make_scouting_state(handler: ss.ScreenStateHandler, team_score, outfit_id) -> ss.ScreenState:
+ new_state = ss.ScreenState(handler)
+ new_state.location = ss.Location.SCOUTING_EVENT
+ new_state.main = f"Team Building - {team_score} pt."
+ new_state.sub = f"Rank: {util.scouting_score_to_rank_string(team_score)}"
+
+ chara_id = str(outfit_id)[:-2]
+
+ new_state.set_chara(chara_id, outfit_id=int(outfit_id), small_text="Team Leader")
+
return new_state
\ No newline at end of file
diff --git a/umalauncher/util.py b/umalauncher/util.py
index c412118..98ef774 100644
--- a/umalauncher/util.py
+++ b/umalauncher/util.py
@@ -102,6 +102,7 @@ def log_set_trace():
has_failed_once = False
def do_get_request(url, error_title=None, error_message=None, ignore_timeout=False):
global last_failed_request
+ global has_failed_once
try:
if not ignore_timeout and last_failed_request is not None:
@@ -114,8 +115,11 @@ def do_get_request(url, error_title=None, error_message=None, ignore_timeout=Fal
response = requests.get(url)
response.raise_for_status()
return response
- except requests.exceptions.RequestException:
- if (last_failed_request is None and not has_failed_once) or ignore_timeout:
+ except:
+ logger.warning(f"Failed to connect to {url}")
+ logger.warning(traceback.format_exc())
+ if ignore_timeout or not has_failed_once:
+ has_failed_once = True
logger.warning(traceback.format_exc())
show_warning_box(
"Failed to connect to server" if error_title is None else error_title,
@@ -434,4 +438,13 @@ def heroes_score_to_league_string(score):
current_league = league
else:
break
- return current_league
\ No newline at end of file
+ return current_league
+
+def scouting_score_to_rank_string(score):
+ current_rank = list(constants.SCOUTING_SCORE_TO_RANK_DICT.keys())[0]
+ for score_threshold, rank in constants.SCOUTING_SCORE_TO_RANK_DICT.items():
+ if score >= score_threshold:
+ current_rank = rank
+ else:
+ break
+ return current_rank
\ No newline at end of file
diff --git a/umalauncher/version.py b/umalauncher/version.py
index 9fbd153..6c57fb4 100644
--- a/umalauncher/version.py
+++ b/umalauncher/version.py
@@ -10,7 +10,7 @@
import util
import gui
-VERSION = "1.6.0"
+VERSION = "1.6.1"
def parse_version(version_string: str):
"""Convert version string to tuple."""