Skip to content

Commit

Permalink
Merge pull request #6 from renatofmmaia/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
hiagopinacio authored Feb 6, 2022
2 parents 3e22870 + 820f373 commit b78f71b
Show file tree
Hide file tree
Showing 20 changed files with 64 additions and 27 deletions.
Binary file modified assets/images/targets/hero_bar_0.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 added assets/images/targets/hero_bar_10.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 assets/images/targets/hero_bar_100.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 assets/images/targets/hero_bar_20.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 added assets/images/targets/hero_bar_30.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 assets/images/targets/hero_bar_40.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 added assets/images/targets/hero_bar_50.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 assets/images/targets/hero_bar_60.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 added assets/images/targets/hero_bar_70.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 assets/images/targets/hero_bar_80.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 added assets/images/targets/hero_bar_90.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 removed assets/images/targets/hero_bar_green.png
Binary file not shown.
Binary file added assets/images/targets/hero_rarity_Common.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 added assets/images/targets/hero_rarity_Epic.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 added assets/images/targets/hero_rarity_Rare.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 added assets/images/targets/hero_rarity_SuperRare.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 added assets/images/targets/hero_search_area.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 17 additions & 9 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ generals:
# Which hotkey is used to refresh the browser
# 1: CTRL + F5
# 2: CTRL + SHIFT + R
refresh_page_shortcut: 1
refresh_page_shortcut: 2
# Time format to show on logs:
# Dafault: "%Y-%m-%d %H:%M:%S"
time_format: "%Y-%m-%d %H:%M:%S"

hero:
# Propertie that identifies heros to work according life %;
# Available options: 0, 20, 40, 60, 80 or 100.
work_mod: 60

heroes_work_mod:
# Properties that identifies heroes to work according rarity and life %;
# Available options: 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 or 100.
Common: 60
Rare: 40
SuperRare: 30
Epic: 30
# If you have Legend or Super Legend, send print to us.


screen:
Expand All @@ -43,16 +51,16 @@ screen:

scroll_heroes:
# total number of times the screen scrolls down
repeat: 5
repeat: 2

# distance when scrolling down
distance: -200
distance: -375

# duration of scrolling
duration: 1

# time waiting when scrolling down
wait: 1.5
# Wait time to stop scrolling before checking the heroes on the screen.
wait: 0.5

telegram:
# Settings for telegram integration
Expand Down
59 changes: 44 additions & 15 deletions module/bombScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,35 +203,64 @@ def do_login(manager):

class Hero:
def who_needs_work(manager):
logger_translated(f"Heroes to work(config: {Config.get('hero','work_mod')}%)", LoggerEnum.ACTION)
logger_translated(f"Heroes to work", LoggerEnum.ACTION)

heroes_bar = ["hero_bar_0", "hero_bar_20", "hero_bar_40", "hero_bar_60", "hero_bar_80", "hero_bar_100"]
scale_factor = 20
heroes_bar = [
"hero_bar_0", "hero_bar_10", "hero_bar_20",
"hero_bar_30", "hero_bar_40", "hero_bar_50",
"hero_bar_60", "hero_bar_70", "hero_bar_80",
"hero_bar_90", "hero_bar_100"
]
heroes_rarity = [
"hero_rarity_Common", "hero_rarity_Rare", "hero_rarity_SuperRare", "hero_rarity_Epic",
]

scale_factor = 10

BombScreen.go_to_home(manager)
BombScreen.go_to_heroes(manager)

def click_available_heroes():
n_clicks = 0
screen_img = Image.screen()

buttons_position = Image.get_target_positions("button_work_unchecked", not_target="button_work_checked", screen_image=screen_img)
logger(f"{len(buttons_position)} Heroes found.")
logger(f"👁️ Found {len(buttons_position)} Heroes resting:")

if not buttons_position:
return 0

x_buttons = buttons_position[0][0]
height, width = Image.TARGETS["hero_search_area"].shape[:2]
screen_img = screen_img[:,x_buttons-width:x_buttons, :]
logger("↳", end=" ", datetime=False)
for button_position in buttons_position:
x,y,w,h = button_position
search_img = screen_img[y:y+h+5, :, :]
compare_values = [Image.get_compare_result(search_img, Image.TARGETS[bar]).max() for bar in heroes_bar]
index, max_value= 0, 0

for i, value in enumerate(compare_values):
index, max_value = (i, value) if value > max_value else (index, max_value)
logger(f"life: {index*scale_factor} %.")
if index*scale_factor >= Config.get('hero', 'work_mod'):
search_img = screen_img[y:y+height, :, :]

rarity_max_values = [Image.get_compare_result(search_img, Image.TARGETS[rarity]).max() for rarity in heroes_rarity]
rarity_index, rarity_max_value= 0, 0
for i, value in enumerate(rarity_max_values):
rarity_index, rarity_max_value = (i, value) if value > rarity_max_value else (rarity_index, rarity_max_value)

hero_rarity = heroes_rarity[rarity_index].split("_")[-1]
logger(f"{hero_rarity}:", end=" ", datetime=False)

life_max_values = [Image.get_compare_result(search_img, Image.TARGETS[bar]).max() for bar in heroes_bar]
life_index, life_max_value= 0, 0
for i, value in enumerate(life_max_values):
life_index, life_max_value = (i, value) if value > life_max_value else (life_index, life_max_value)


logger(f"{life_index*scale_factor}%", end=" ", datetime=False)
if life_index*scale_factor >= Config.get('heroes_work_mod', hero_rarity):
click_randomly_in_position(x,y,w,h)
n_clicks += 1

logger(f"Detected {n_clicks} in fight conditions.")

logger("💪;", end=" ",datetime=False)
else:
logger("💤;", end=" ", datetime=False)

logger("", datetime=False)
return n_clicks

n_clicks_per_scrool = scroll_and_click_on_targets(
Expand Down
6 changes: 3 additions & 3 deletions module/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class LoggerEnum(Enum):
}


def logger(message, color="default", force_log_file=False, terminal=True, datetime=True):
def logger(message, color="default", force_log_file=False, terminal=True, datetime=True, end='\n'):
color_formatted = COLOR.get(color.lower(), COLOR["default"])
formatted_datetime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
formatted_datetime = time.strftime(Config.get("generals", "time_format"), time.localtime())

if datetime:
formatted_message = "[{}] => {}".format(formatted_datetime, message)
Expand All @@ -39,7 +39,7 @@ def logger(message, color="default", force_log_file=False, terminal=True, dateti
if terminal:
sys.stdout.write(color_formatted)
sys.stdout.flush()
print(formatted_message_colored)
print(formatted_message_colored, end=end)

if Config.get('generals','save_log_file') or force_log_file:
with open("./logs/logger.log", "a+", encoding='utf-8') as logger_file:
Expand Down

0 comments on commit b78f71b

Please sign in to comment.