Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

Commit

Permalink
game 7.0.0 update: fixes for new UI style
Browse files Browse the repository at this point in the history
  • Loading branch information
tmarenko committed Apr 22, 2021
1 parent e6290a2 commit ad29c5a
Show file tree
Hide file tree
Showing 29 changed files with 1,183 additions and 1,473 deletions.
Binary file modified images/autoplay_toggle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/gold_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/home_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/main_menu_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/melee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/no_character.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/repeat_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/repeat_toggle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/skill_coop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 6 additions & 14 deletions lib/game/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,26 +260,18 @@ def get_mode_from_element(self, board_rect, element_rect):
element_ui.rect.parent = board_rect
self.ui['CONTENT_STATUS_ELEMENT_LABEL'].rect.parent = element_ui.rect
self.ui['CONTENT_STATUS_ELEMENT_STAGE'].rect.parent = element_ui.rect
self.ui['CONTENT_STATUS_ELEMENT_COMPLETE'].rect.parent = element_ui.rect
# Getting board image and element image. Use it for stage recognize
board_image = self.player.get_screen_image(board_rect.value)
element_image = self.player.get_image_from_image(board_image, element_ui)
stage_label_image = self.player.get_image_from_image(element_image,
self.ui['CONTENT_STATUS_ELEMENT_LABEL'])
stage_label = self.player.get_screen_text(self.ui['CONTENT_STATUS_ELEMENT_LABEL'], screen=stage_label_image)
logger.debug(f"Stage found: {stage_label}")
stage_completion_screen = self.player.get_image_from_image(element_image,
self.ui['CONTENT_STATUS_ELEMENT_COMPLETE'])
if self.player.is_ui_element_on_screen(self.ui['CONTENT_STATUS_ELEMENT_COMPLETE'],
screen=stage_completion_screen):
current_stages, max_stages = 0, 0
else:
stage_counter_image = self.player.get_image_from_image(element_image,
self.ui['CONTENT_STATUS_ELEMENT_STAGE'])
stage_counter_text = self.player.get_screen_text(self.ui['CONTENT_STATUS_ELEMENT_STAGE'],
screen=stage_counter_image)
logger.debug(f"Stage: {stage_label}; stages: {stage_counter_text}")
current_stages, max_stages = self.get_current_and_max_values_from_text(stage_counter_text)
stage_counter_image = self.player.get_image_from_image(element_image,
self.ui['CONTENT_STATUS_ELEMENT_STAGE'])
stage_counter_text = self.player.get_screen_text(self.ui['CONTENT_STATUS_ELEMENT_STAGE'],
screen=stage_counter_image)
logger.debug(f"Stage: {stage_label}; stages: {stage_counter_text}")
current_stages, max_stages = self.get_current_and_max_values_from_text(stage_counter_text)
# Find mode and return info about stages and board
for mode_name in self._mode_names:
if is_strings_similar(mode_name, stage_label):
Expand Down
7 changes: 6 additions & 1 deletion lib/game/missions/coop.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ def battle_over_conditions(self):
def coop_completion():
return self.player.is_ui_element_on_screen(self.ui['COOP_COMPLETION'])

return [coop_completion]
def coop_home_button():
if self.player.is_image_on_screen(self.ui['COOP_HOME_BUTTON']):
logger.debug("Found COOP HOME button image on screen.")
return True

return [coop_completion, coop_home_button]

def start_missions(self):
"""Start available missions."""
Expand Down
14 changes: 11 additions & 3 deletions lib/game/missions/danger_room.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
from lib.game.battle_bot import ManualBattleBot
from lib.game.missions.missions import Missions
from lib.functions import wait_until, r_sleep
from lib.functions import wait_until, r_sleep, convert_colors_in_image
import lib.logger as logging

logger = logging.get_logger(__name__)
Expand Down Expand Up @@ -160,8 +160,7 @@ def press_start_button(self, start_button_ui='DANGER_ROOM_JOIN'):
"""Press start button of the mission."""
if self.player.is_ui_element_on_screen(self.ui[start_button_ui]):
self.player.click_button(self.ui[start_button_ui].button)
if wait_until(self.player.is_ui_element_on_screen,
ui_element=self.ui['DANGER_ROOM_CANCEL_SEARCH'], timeout=3):
if wait_until(self._check_cancel_button, timeout=3):
if wait_until(self.player.is_ui_element_on_screen,
ui_element=self.ui['DANGER_ROOM_CHARACTER_SELECT_MENU'], timeout=180):
logger.debug("Danger Room: successfully get to character selector.")
Expand Down Expand Up @@ -323,3 +322,12 @@ def start_manual_bot_for_danger_room(self):
manual_bot.is_battle = lambda: old_is_battle() and not self.player.is_ui_element_on_screen(
self.ui['DANGER_ROOM_BATTLE_REVIVE'])
manual_bot.fight(move_around=True)

def _check_cancel_button(self):
"""Returns if CANCEL button is on screen."""
# Convert red colors to white because fancy UI is unreadable
extreme_red_color = ([200, 0, 0], [255, 30, 30])
image = self.player.get_screen_image(rect=self.ui['DANGER_ROOM_CANCEL_SEARCH'].rect)
converted_image = convert_colors_in_image(image=image, colors=[extreme_red_color])
return self.player.is_ui_element_on_screen(ui_element=self.ui['DANGER_ROOM_CANCEL_SEARCH'],
screen=converted_image)
2 changes: 1 addition & 1 deletion lib/game/missions/missions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class _DIFFICULTY_4:
class _DIFFICULTY_6:
STAGE_1 = "DIFFICULTY_STAGE_1"
STAGE_2 = "DIFFICULTY_STAGE_2"
STAGE_3 = "DIFFICULTY_STAGE_2_3"
STAGE_3 = "DIFFICULTY_STAGE_3"
STAGE_4 = "DIFFICULTY_STAGE_2_4"
STAGE_5 = "DIFFICULTY_STAGE_2_5"
STAGE_6 = "DIFFICULTY_STAGE_2_6"
Expand Down
1 change: 1 addition & 0 deletions lib/game/missions/world_bosses.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def change_world_boss_of_the_day(self, world_boss, max_resets=0):
return self._reset_world_boss(target_world_boss=target_world_boss, current_reset=0, max_resets=max_resets)
else:
logger.warning("World Boss: can't open Reset Menu. Probably your VIP status is low.")
self.stages = 0

def _reset_world_boss(self, target_world_boss, current_reset, max_resets):
"""Resets World Boss in reset menu.
Expand Down
52 changes: 26 additions & 26 deletions settings/ui/alliance_battles.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"y2": 0.9774412741522804
},
"text": "EXTREME MODE - READY",
"image_threshold": 175,
"image_threshold": 100,
"chars": null,
"image_save_file": "ab_extreme_ready_button",
"description": "Extreme mode READY button."
Expand All @@ -93,7 +93,7 @@
"y2": 0.9667147678066141
},
"text": "EXTREME MODE - START",
"image_threshold": 175,
"image_threshold": 100,
"chars": null,
"image_save_file": "ab_extreme_start_button",
"description": "Extreme mode START button."
Expand All @@ -103,10 +103,10 @@
"AB_CHARACTER_1": {
"text_rect": null,
"button_rect": {
"x1": 0.6695034955857719,
"y1": 0.3396166177066397,
"x2": 0.7144589734621398,
"y2": 0.4199162390634803
"x1": 0.6952032514709209,
"y1": 0.33992999777040783,
"x2": 0.7378994984998849,
"y2": 0.41583443693301053
},
"text": null,
"image_threshold": null,
Expand All @@ -119,10 +119,10 @@
"AB_CHARACTER_2": {
"text_rect": null,
"button_rect": {
"x1": 0.760479747022782,
"y1": 0.3411317049020518,
"x2": 0.8033046335306018,
"y2": 0.42370395705201047
"x1": 0.7783485746325876,
"y1": 0.3328619730710562,
"x2": 0.8255391634540743,
"y2": 0.41429790982445575
},
"text": null,
"image_threshold": null,
Expand All @@ -135,10 +135,10 @@
"AB_CHARACTER_3": {
"text_rect": null,
"button_rect": {
"x1": 0.8516690575966469,
"y1": 0.33696521511466854,
"x2": 0.8908719387779347,
"y2": 0.4195374672646273
"x1": 0.8621853349931041,
"y1": 0.32702317005854825,
"x2": 0.9073016122180417,
"y2": 0.41245407729419015
},
"text": null,
"image_threshold": null,
Expand All @@ -151,10 +151,10 @@
"AB_CHARACTER_4": {
"text_rect": null,
"button_rect": {
"x1": 0.6694713357160579,
"y1": 0.5109887378439065,
"x2": 0.7143343539669984,
"y2": 0.597391587808681
"x1": 0.6951700866052783,
"y1": 0.4845336806186346,
"x2": 0.7391466984472285,
"y2": 0.5633825345194912
},
"text": null,
"image_threshold": null,
Expand All @@ -167,10 +167,10 @@
"AB_CHARACTER_5": {
"text_rect": null,
"button_rect": {
"x1": 0.7599450891887879,
"y1": 0.5136472870735921,
"x2": 0.8003218056146343,
"y2": 0.5947330385789954
"x1": 0.7778611516072357,
"y1": 0.47918799560840697,
"x2": 0.8231533031196716,
"y2": 0.5637166398326302
},
"text": null,
"image_threshold": null,
Expand All @@ -183,10 +183,10 @@
"AB_CHARACTER_6": {
"text_rect": null,
"button_rect": {
"x1": 0.8526619935740648,
"y1": 0.5216229347626482,
"x2": 0.8922909930290622,
"y2": 0.597391587808681
"x1": 0.8626194932342421,
"y1": 0.477517469042711,
"x2": 0.9082875132239595,
"y2": 0.5640507451457695
},
"text": null,
"image_threshold": null,
Expand Down
45 changes: 31 additions & 14 deletions settings/ui/battle.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@
{
"LEGENDARY_SCORE": {
"text_rect": {
"x1": 0.23917995444191345,
"y1": 0.2732793522267207,
"x2": 0.296127562642369,
"y2": 0.31376518218623484
"x1": 0.0855043814829831,
"y1": 0.3248902917659314,
"x2": 0.14382630520920567,
"y2": 0.3700856286705826
},
"button_rect": null,
"text": "SCORE",
Expand All @@ -94,17 +94,34 @@
"description": "Score text in legendary battle. Determines that we see end of battle screen."
}
},
{
"COOP_HOME_BUTTON": {
"text_rect": null,
"button_rect": {
"x1": 0.759375,
"y1": 0.8944444444444445,
"x2": 0.8088541666666667,
"y2": 0.9629629629629629
},
"text": null,
"image_threshold": 0.7,
"chars": null,
"image_path": "home_button.png",
"image_save_file": "coop_home_button",
"description": "Co-op home button (middle position)."
}
},
{
"COOP_COMPLETION": {
"text_rect": {
"x1": 0.4226740603820086,
"y1": 0.13157894736842105,
"x2": 0.5083179297597042,
"y2": 0.1611842105263158
"x1": 0.4327797196011332,
"y1": 0.1578875053276198,
"x2": 0.5397740986455049,
"y2": 0.18089521211879808
},
"button_rect": null,
"text": "COMPLETION",
"image_threshold": 130,
"text": "COMPLETION TIME:",
"image_threshold": 160,
"chars": null,
"image_save_file": "coop_completion_time",
"description": "Completion time in Coop battles. Determines that we see end of battle screen."
Expand Down Expand Up @@ -381,10 +398,10 @@
"AUTOPLAY_TOGGLE": {
"text_rect": null,
"button_rect": {
"x1": 0.31354166666666666,
"y1": 0.9120370370370371,
"x2": 0.3328125,
"y2": 0.9472222222222222
"x1": 0.3067708333333333,
"y1": 0.9166666666666666,
"x2": 0.32864583333333336,
"y2": 0.9564814814814815
},
"text": null,
"image_threshold": 0.6,
Expand Down
Loading

0 comments on commit ad29c5a

Please sign in to comment.