r/CodingHelp • u/BrokenDJDreams • Oct 18 '25
Which one? Can someone tell me what this is
Found in a file on my iPad and seems sketchy, thanks in advance, was getting some new brushes but am feeling scammed…
r/CodingHelp • u/BrokenDJDreams • Oct 18 '25
Found in a file on my iPad and seems sketchy, thanks in advance, was getting some new brushes but am feeling scammed…
r/CodingHelp • u/ItisCurlyFries • Oct 17 '25
r/CodingHelp • u/hood_ninja666 • Oct 16 '25
software that pulls a users listening hours from different music platforms, specifically Apple Music and Spotify . im not interested in building but i want to know if its achievable in this Programmer/developer era. Would you need to have an agreement between the company to allow access into select parts on a users data
r/CodingHelp • u/Rich-Type-9066 • Oct 16 '25
books = int(input("Enter how many books you have borrowed: "))
due_date = input("Enter the due date (YYYY-MM-DD): ")
current_date = input("Enter the current date (YYYY-MM-DD): ")
def calculate_fine(books, due_date, current_date):
try:
if books < 0:
return 0
if len(due_date) != 10 or len(current_date) != 10:
return "invalid date!"
if current_date <= due_date:
return 0
if due_date > current_date:
days_late = current_date - due_date
fine = days_late * books *2
return fine
except:
return ValueError
def process_borrowers(filename, current_date):
with open("borrowers.csv", 'r') as file:
file = file.read()
if file[1]== books and file[2] == due_date:
return "Valid"
else:
calculate_fine(file, current_date)
return file[0] and "Fine"
r/CodingHelp • u/tsilvs0 • Oct 16 '25
I want to be able to effortlessly shift hierarchies with optional structure preservation between levels in a similar manner:
A file like this:
+
Becomes a file structure like this:
./
└── H1
└── H2
└── H3
├── F1.md
├── F2.md
└── F3.md
Or like this:
./
└── H1
└── H2
├── H3-F1.md
├── H3-F2.md
└── H3-F3.md
Or like this:
./
└── H1
├── H2-H3-F1.md
├── H2-H3-F2.md
└── H2-H3-F3.md
Or like this:
./
└── H1
└── H2
└── H3-F.md
And possibly in reverse.
Preferrably not limited to markdown, but supporting:
With a single click / short command call / keybind / other simple user action.
Looking for anything that may be:
For example, it can be:
neovim scriptvscode pluginr/CodingHelp • u/Warm-Run7333 • Oct 16 '25
So it works completely fine apart from the fact that when you input a word that isn't "rock paper or scissors" it won't print the message instead it just moves on :,) . I would love If someone could help me!
import random
choice = ["rock", "paper", "scissors"]
print("Welcome to the AMAZING: \nROCK, PAPER, SCISSORS simulator! \n\n\nPlease try your luck against the computer and see if you can beat it before it beats you!")
print("It's first to 3, GOOD LUCK!!!")
compoint = 0
playpoint = 0
while playpoint != 3 and compoint != 3:
move = input("\n\nplease enter your move").lower()
if move == "rock" or "paper" or "scissors":
pass
elif move != "rock" or "paper" or "scissors":
print ("thats not an option silly")
compmove = random.choice(choice)
if move == compmove:
print("Both players selected",move,". It's a tie!")
elif move == "rock":
if compmove == "scissors":
print("\nRock smashes scissors! You win this round!")
playpoint = playpoint + 1
else:
print("\nPaper covers rock! You lose this round.")
compoint = compoint + 1
elif move == "paper":
if compmove == "rock":
print("\nPaper covers rock! You win this round!")
playpoint = playpoint + 1
else:
print("\nScissors cuts paper! You lose this round!")
compoint = compoint + 1
elif move == "scissors":
if compmove == "paper":
print("\nScissors cuts paper! You win this round!")
playpoint = playpoint + 1
else:
print("\nRock smashes scissors! You lose this round!")
compoint = compoint + 1
print("Your points:",playpoint)
print("Computer's points:",compoint)
if playpoint == 3:
print("\nYOU WON THE GAME CONGRATS!!!")
else:
print("\nYOU LOSE TO THE COMPUTER >:D ")r/CodingHelp • u/JetpackDinosaur • Oct 15 '25
Hi! I'm trying to create multi-level dropdown logic in a PDF. Basically the first drop down is a location, then the second dropdown is the type of activity, and the third dropdown is the activity, but they are dependent on each other.
For example, the first dropdown could have choices like London, Paris, Tokyo. The second dropdown in this case would have the same options (Dining, Recreation, Theater), but the third dropdown would change the final options available based on the first dropdown. So London + Dining should serve up London restaurants, but Tokyo + Dining should show Tokyo restaurants, etc.
The logic I have so far works perfect with one dependent dropdown (I'm making a different Adobe PDF for each city), with the impacted dropdown called "ActivityDropdown1.0" and it's in the custom validation script on the dropdown properties:
var options = {
"Dining" : [ "LondonDining1™",
"LondonDining2",
"LondonDining3",],
"Theater" : [ "LondonTheater1",
"LondonTheater2",
"LondonTheater3",],
};
this.getField("ActivityDropdown1.0").setItems(options[event.value])
ListEntrySort("ActivityDropdown1.0");
So I want to add another column with a dropdown that lets you pick between London, Paris, or Tokyo, which then changes what "ActivityDropdown1.0" will show, based on the category dropdown (Dining, Recreation, Theater).
I couldn't find much on this except for the above, any help would be appreciated!
r/CodingHelp • u/Perfect_Carrot96 • Oct 15 '25
So for some context, I decided to change careers and I’m in first year of software development but I feel so crushed already and despite all my efforts I don’t know how to put myself on a path to get better.
In one of my classes I’m doing HTLM and I don’t feel I’m being thought well, basically we see one element and instead of practice applying it’s like “learned already” and we pass to the next topic, without much room to ask questions and when someone does ask we receive a short answer. My course is intense I’m 8h a day in classes and since the semester started I go home to continue studying but despite my effort I’m not feeing leveled or close to follow without problem.
What I want to ask is: Do you have any recommendations for someone starting in computing science and also valuable material specifically to learn HTML? At the moment I’m watching BroCode tutorials on YouTube but my academic pressure is crushing me since my other classes are very difficult too (but this one with HTML is the worst).
I’d appreciate any kind advice or recommendations, I feel I’m going crazy and getting burned out quickly without any results. I have no doubts about wanting to study this major but I’m very disappointed by the teaching of some of my professors (I have other classes where they’re actually very good at teaching).
r/CodingHelp • u/SafeAd80 • Oct 15 '25
First off i have zero knowledge of coding and especially servers. The game jurassic park builder shut down 5 years ago and while you can download the apk almost everything is sent to the now gone Ludia Jpb servers. I was wondering if there could be a way to mimic the servers on the backend. I just want to be able to to find a way to preserve and play the game so it isn’t lost like others.
r/CodingHelp • u/Boi_Minecraft • Oct 15 '25
FYI i do have a windows PC and I do most of it on there. I was just wondering, since i'm getting an ipad soon, if its a bad idea to code on it, or if it's possible. It would be nice to be able to code out and about, but it's not that big of a deal.
r/CodingHelp • u/Sumblefore • Oct 15 '25
I am running a program that uses the every minute polls api https://us.api.iheart.com/api/v3/live-meta/stream/2501/currentTrackMeta?defaultMetadata=true to get the currently playing song name artist and start and end time. However, it is only getting the api only gets what iheart radio posts as the most recently played song. Is there another way I can get information from what is actually playing because sometimes the api is not updated with the most recently played song and I end up missing songs so I am trying to figure how to get every song played's title artist start and end date. I use a python script to get everything, but i mostly just need the route for the api or whatever way I get the information
r/CodingHelp • u/kitchendew • Oct 15 '25
hello, i am an amateur at coding. i have been wanting to create a blogging platform for a while now, just for personal use.
i really love the layout of this website https://everynoise.com and want to figure out how to code something similar. where every post of mine is sort of floating in this ether space. i’d like it to function similarly to how every noise does, where i can click on each “post”.
could anyone point me in the right direction on how to actualize this? i realize i have a lot to learn but im not even sure where to start.
r/CodingHelp • u/Horror-Tower2571 • Oct 14 '25
Hi guys,
I've been helping my school out with an ML project, however the main training dataset (totalling ~50gb) is stored in sharepoint and i need to transfer it to s3 quickly, these are videos for training and aren't compressed. Is there an sdk or something for chunking sharepoint or onedrive downloads and then i can stream that to s3 because im at a bit of a dead end.
r/CodingHelp • • Oct 14 '25
I am 18F currently a dropper preparing for BITSAT and I am learning web development also. So, my instructor started with backend and I have done C, C++ and currently on java (making projects). What else should I do to make my skills strong and to revise the previous languages I have done already. If you're going to say DSA then Tell me how to start and where to do it.
Thank you.
r/CodingHelp • u/DramaPlastic7573 • Oct 14 '25
Hey everyone,
A few colleagues and I are working on a small project for students who get stuck on programming problems or concepts.
The idea is simple: they describe what’s going wrong, book a short 1:1 session, and work through it together with someone who already understands the topic.
Right now, it’s just us testing it locally, but we’d really appreciate some honest feedback — both on the website and on the service itself.
Here’s the link: https://studysos-production.up.railway.app/
We’re not promoting anything, just trying to figure out if the idea and experience make sense before going further. Any feedback is super helpful, thanks!
r/CodingHelp • u/Born_Compote_5048 • Oct 14 '25
Hey guys I’m new here and looking for any sort of help I can get, I’ve taken on an extremely ambitious project by creating my own add on based off of the DC universe for Minecraft bedrock. I’ve ran into a lot of hangups such as not getting uis to work, powers not working, gadgets not rendering or working as intended, and the capes breaking recently. These are just a few of my issues. Can anyone suggest places to start my learning process or help out in anyway? Thanks for your time!
Here’s two suits I’ve added so far just for a proof of concept.
r/CodingHelp • • Oct 13 '25
Hello all, not sure if this is THE place to ask questions as a beginner but I’m just asking to get the opinions of others:
I’ve been doing what I can for the first few weeks - enrolling onto CS50X, watching on freecodecamp, tinkering with VS and writing crazy notes on different variables. I understand basic functions and variables and can write small pieces of code containing mathematics, loop functions and lists.
I feel quite overwhelmed however considering this is all very new to me, and I’m a bit scared that I might be messing up since I’m not fully getting it the first time round.
I’m just wondering if this is a normal reaction to learning code/programming, and if there are steps I can take to mitigate? I’m probably gonna order a rubber duck as an investment lol
Cheers in advance!
r/CodingHelp • u/Nerpua • Oct 13 '25
I run blog with mostly book reviews. I also started university and I think I want to learn more about data analysis. So i wanted to get familiar with google analytics but it seems just annoying for me because there are no data like ‚publication date’ or ,author’ (bcs im not the only author here).
So i tried to do some research and encountered google tag manager. But I don’t know what to do next. I can’t find any tutorials about exactly what i want to do. Someone before me connected wordpress, gtm and ga4 (or I just think so) but I don’t get what do I do now. I found tag for my page but i thought I need tag for author and tag for publication date and I don't see any option to add them? Where do I do that?
I found some information about some php or java files but I don’t know where are they? I am willing to learn programming languages and study those files but I don’t understand anything about it.
r/CodingHelp • u/Independent-East2430 • Oct 13 '25
Hello there. I'm having troubles with my email signature at work, I have to program a new one for our company.
I've got the html code in html xmlns / office 2004 schema format. It's working properly on every client (google, apple, ms outlook new) but the main problem is:
I've embedded icons as png files and deposited website-links on them. But every time, I click on them on my Apple Iphone, it might open the picture itself as well as the website-link. So basically, the link is working but I don't want the picture to be opened.
Can anyone help me pls? That would help me a lot ♥️🥰 Thats a current example:
<a href="example.com/"><span style='font-size:9.0pt;font-family:"Tahoma",sans-serif;color:black; mso-ligatures:none;text-decoration:none;text-underline:none'><!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"/> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"/> <v:f eqn="sum @0 1 0"/> <v:f eqn="sum 0 0 @1"/> <v:f eqn="prod @2 1 2"/> <v:f eqn="prod @3 21600 pixelWidth"/> <v:f eqn="prod @3 21600 pixelHeight"/> <v:f eqn="sum @0 0 1"/> <v:f eqn="prod @6 1 2"/> <v:f eqn="prod @7 21600 pixelWidth"/> <v:f eqn="sum @8 21600 0"/> <v:f eqn="prod @7 21600 pixelHeight"/> <v:f eqn="sum @10 21600 0"/> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/> <o:lock v:ext="edit" aspectratio="t"/> </v:shapetype><v:shape id="Grafik_x0020_9" o:spid="_x0000_i1057" type="#_x0000_t75" alt="" style='width:80.25pt;height:14.25pt'> <v:imagedata src="0310%20(example@example.at)-Dateien/image001.png" o:href="cid:image002.png@01DC3939.8B172060"/> </v:shape><![endif]--><![if !vml]><img border=0 width=107 height=19 src="0310%20(example@example.at)-Dateien/image001.png" style='height:.197in;width:1.114in' v:shapes="Grafik_x0020_9"><![endif]></span></a><span style='font-size:9.0pt;font-family:"Tahoma",sans-serif;color:black; mso-ligatures:none'><o:p></o:p></span></p>
</td>
r/CodingHelp • u/Positive-Ad7513 • Oct 12 '25
I installed mx linux a while ago and just now wanted to start using it or at least practice with it and I can't for the life of me remember what the password is for sudo permissions.
r/CodingHelp • u/HUG0gamingHD • Oct 11 '25
So I have this problem where the fan pushes the objects and player away even if it is outside of the airflow.
The fan loops through every single object, and uses a bounding box (with very light math) to determine if an object is close enough to be affected, and only then it performs the heavy calculation which uses sqrt to determine the precise distance between the object and the fan to know how hard I should push or pull an object.
Now the problem I'm running into is checking if the object is in front of the fan. Since the fan can be rotated in any direction, I can't just simply check if the y coordinate of the object is within a specific range in front of the fan. I've thought of using sin and cos to determine if it's inside of the "line of sight" of the fan, but without luck.
I made a schematic to show exactly what result I'm seeking and a little help would be awesome. I've also shared the current code used for the fan.
The game: https://www.cattiesworld.nl
r/CodingHelp • u/Large_Newspaper6113 • Oct 11 '25
I'm working on a project, yet for some reason my random.sample isn't doing anything, yet there are no errors. Code below:
from selenium import webdriver
from selenium.webdriver.common. by import By
from selenium.webdriver.common.keys import Keys
import random
import time
Browser = webdriver.Edge()
Browser.maximize_window()
Browser.delete_all_cookies()
Browser.get('https://www.facebook.com/login/?privacy_mutation_token=eyJ0eXBlIjowLCJjcmVhdGlvbl90aW1lIjoxNzYwMjEwNjcxLCJjYWxsc2l0ZV9pZCI6MzgxMjI5MDc5NTc1OTQ2fQ%3D%3D&next')
input('Press enter to continue')
while True == True:
Password = ['A', 'a', 'B', 'b', 'C', 'c', 'D', 'd', 'E', 'e', 'F', 'f', 'G', 'g', 'H', 'h', 'I', 'i', 'J', 'j', 'K', 'k', 'L', 'l', 'M', 'm', 'N', 'n', 'O', 'o', 'P', 'p', 'Q', 'q', 'R', 'r', 'S', 's', 'T', 't', 'U', 'u', 'V', 'v', 'W', 'w', 'X', 'x', 'Y', 'y', 'Z', 'z', '!', '1', '@', '2', '#', '3', '$', '4', '%', '5', '^', '6', '&', '7', '*', '8','(', '9', ')', '0', '_', '-', '+', '=', '~', '\']
random.sample(Password, 6)
print(Password)
Passenter = Browser.find_element(By.XPATH, '//*[@id="pass"]')
Passenter.click()
Passenter.send_keys(''.join(Password))
time.sleep(5)
PS: the by was moved because reddit kept making it a link
r/CodingHelp • u/NancokALT • Oct 11 '25
As the title says, trying to do an ECS (Entity, Component, System) approach.
So, currently my structure works like this.
- I have a bunch of "systems" whose only purpose is to iterate over AND operate on components of an specific type/interface.
- Entities and components are merely an entry in a dictionary with a long, List<ComponentObject> typing. Where long is the entity ID and the List are the components i need to iterate over.
- The components are SUPPOSED to be only data containers.
Currently, when a component is created, it "tags" its entity. So if there is a BatteryComponent being added, the whole entity is now tagged to be considered by the EnergySystem
I NEED to iterate over entities, because systems need access to various types of components per entity (the EnergySystem needs to both check BatteryComponent and GeneratorComponent of the same entity).
The problem? Currently i am using something like Components.OfType<BatteryComponent>() per type of component. Meaning that just the EnergySystem has to do 3 calls of these, PER entity, 60 times a second.
I've been trying a bunch of weird stuff, like having the systems keep their own lists of components to iterate over. But it is not working too well and it is getting more convoluted. Any ideas?
r/CodingHelp • u/Daboniiii • Oct 11 '25
This is all done via python, I need help editing this bot code to import the chosen bots state of play so the bot is harder to fight against. Im doing this in attempt to make a bot harder than chosen and hopefully gain recognition, for people not wanting to open the source code I dpnt knw how to link heres the entire source code below after this
import queue
from time import time
from config import *
from direct_input import *
from menu import find_element, regenerate_layout
from windows import *
CONNECTION_LEVELS = (
(0, 204, 51), # green
(255, 255, 51), # yellow
(255, 153, 0), # orange
(255, 0, 0), # red
)class QueuedRecalculation(Exception):
pass
class ResizedError(Exception):
pass
class DangerZoneError(Exception):
pass
class InvalidStateError(Exception):
pass
class BrawlhallaBot:
def __init__(self, config, hotkeys, bot_queue):
self.config = config
self.hotkeys = hotkeys
self.queue = bot_queue
self.mode = self.config.mode(bot=self)
self.characters = []
self.unlocked_characters = []
self.character = None
self.duration = None
self.brawlhalla = None
self.virtual_input = None
self.level_definer = None
self.last_pause = time()
self.games_completed = 0
self.total_xp = 0
self.total_gold = 0
self.crashes = 0
self.time_started = time()
self._time_started = self.time_started
self.last_states = set()
self.state_detection_pixels = get_menu_pixels()
self.current_menu_element = None
def find_brawlhalla(self):
brawlhalla = BrawlhallaProcess.find()
if brawlhalla:
self.brawlhalla = brawlhalla
return True
return False
def ensure_brawlhalla(self):
if self.find_brawlhalla():
self.brawlhalla.kill()
sleep(5)
try:
steam = SteamClient()
except SteamExeNotFound:
logger.error("no_steam_exe")
return self.on_exit()
count = 10000
while not self.find_brawlhalla():
logger.debug("waiting_for_bh_window")
self.process_queue()
count += 1
if count >= 10000:
steam.run_brawlhalla()
count = 0
self.virtual_input = VirtualInput(self.brawlhalla, self.hotkeys)
self.level_definer = LevelDefiner(self.brawlhalla)
logger.info("found_bh")
self.virtual_input.esc() # idk why but it puts bh into windowed
sleep(1)
if self.brawlhalla.fullscreen:
logger.info("not_windowed_mode")
raise NotRespondingError
self.brawlhalla.resize()
self.get_states()
if self.config.stealth:
logger.info("stealth_mode")
self.brawlhalla.hide()
self.brawlhalla.set_low_priority()
def initialize(self):
self.ensure_brawlhalla()
self.duration = 15
self.go_to_menu(True)
regenerate_layout()
self.current_menu_element = find_element("first_column").current_element
sleep(2)
if self.config.mute:
self.mute()
if not self.characters:
if self.mode.parse_character_levels:
self.characters = self.get_characters()
self.unlocked_characters = [
character for character in self.characters if character.unlocked
]
else:
self.characters = [Character(name) for name in characters]
self.unlocked_characters = self.characters
self.character = self.unlocked_characters[0]
logger.debug("initialized")
def on_exit(self):
if self.virtual_input:
self.virtual_input.release_keys()
if self.config.stealth and self.brawlhalla:
self.brawlhalla.kill()
text = global_settings.messages.get("initial_on_exit", "initial_on_exit") % (
format_time(time() - self.time_started),
self.games_completed,
self.crashes,
self.total_xp,
)
if self.mode.parse_character_levels:
text += global_settings.messages.get(
"on_exit_has_rewards", "on_exit_has_rewards"
) % (self.total_gold,)
else:
text += global_settings.messages.get(
"on_exit_no_rewards", "on_exit_no_rewards"
) % (self.total_gold,)
box(text, endmargin=False)
global_settings.update_stats(time=time() - self._time_started)
stats = global_settings.get_stats()
total = global_settings.messages.get("total_stats", "total_stats") % (
stats.get("games", 0),
stats.get("xp", 0),
stats.get("gold", 0),
format_time(stats.get("time", 0)),
)
box(total, endmargin=False)
sys.exit()
def process_queue(self, stop_delayed=False):
put_back = []
while not self.queue.empty():
try:
msg = self.queue.get_nowait()
except queue.Empty:
continue
self.queue.task_done()
if msg == "STOP":
raise KeyboardInterrupt
elif msg == "DELAYED_STOP":
if stop_delayed:
raise KeyboardInterrupt
put_back.append(msg) # cycle it in queue waiting for delayed_stop check
for item in put_back:
self.queue.put_nowait(item)
def check_stuff(self):
self.process_queue()
if self.brawlhalla and not self.brawlhalla.responding:
self.brawlhalla.kill()
sleep(1)
raise NotRespondingError
@property
def state_conditions(self):
conn_x = 1806 - ceil(98.5 * 2) # 1609
low_conn_x = conn_x - 26 # 1583
_new_menu = {"pixels": ((1890, 70),), "colors": ((255, 255, 255),)}
res = {
"ingame": {
"pixels": ((conn_x, 58),),
"colors": (CONNECTION_LEVELS[0],),
},
"low_connection": {
"pixels": ((low_conn_x, 74),),
"colors": CONNECTION_LEVELS,
},
"menu": self.state_detection_pixels.get("menu") or _new_menu,
"loading": {
"pixels": ((899, 85),),
"colors": ((227, 248, 255),),
},
"bonus": {
"pixels": ((930, 320),),
"colors": ((109, 198, 211),),
},
"offline": {
"pixels": ((1674, 26),),
"colors": ((55, 66, 100), (57, 67, 101)),
},
"sorted_by_date": {
"pixels": ((331, 766),),
"colors": ((254, 254, 255),),
},
"lobby": {
"pixels": ((1325, 22),),
"colors": ((255, 255, 255),),
},
"game_in_progress": {
"pixels": ((960, 395),),
"colors": ((111, 200, 211),),
},
"settings_open": {
"pixels": ((1221, 106),),
"colors": ((220, 220, 222),),
},
"disconnected": {
"pixels": ((934, 623),),
"colors": ((247, 248, 249),),
},
"system_settings_selected": {
"pixels": ((1607, 195),),
"colors": ((39, 85, 136),),
},
"on_rewards_screen": {
"pixels": ((1035, 121),),
"colors": ((255, 255, 255),),
},
"level_up": {
"pixels": ((1363, 320),),
"colors": ((19, 133, 51),),
},
"popup": {
"pixels": ((940, 790),),
"colors": ((247, 248, 249),),
},
"in_mallhalla": {
"pixels": ((338, 972),),
"colors": ((100, 77, 255),),
},
"in_battle_pass": {
"pixels": ((171, 660),),
"colors": ((181, 201, 225),),
},
}
for key in res.keys():
if key != "menu" and key in self.state_detection_pixels:
res[key] = self.state_detection_pixels[key]
return res
@property
def duration_setting(self):
return (
[self.open_settings, 1]
+ [self.virtual_input.down] * 3
+ (self.mode.next_duration - self.duration) * [self.virtual_input.right]
+ (self.duration - self.mode.next_duration) * [self.virtual_input.left]
+ [self.virtual_input.quick]
)
@property
def danger_zone(self):
return {"in_mallhalla", "in_battle_pass"}
@property
def safe_states(self):
return {"ingame", "low_connection"}
@staticmethod
def is_color(screenshot, pixels, colors):
tmp = [screenshot.getpixel(pixel) for pixel in pixels]
return any(screenshot.getpixel(pixel) in colors for pixel in pixels)
def execute_steps(self, *steps, delay=0.2):
self.get_states()
for step in steps:
if isinstance(step, (int, float)):
sleep(step)
elif isinstance(step, str):
if step in self.virtual_input.keys:
self.virtual_input.press_key(self.virtual_input.keys[step])
else:
logger.info(step)
else:
step()
self.get_states()
sleep(delay)
def main_sequence(self):
try:
self.initialize()
self.initial_setup()
while True:
self.execute_steps(self.before_fight, self.go_to_fight)
logger.info("started_fighting")
last, ig = (
True,
True,
) # To avoid failing ingame detection on low connection bc of "Double kill" popup covering first connection column for 1 frame
while last or ig:
self.get_states()
last, ig = ig, self.has_state("ingame", "low_connection")
self.virtual_input.fight()
self.execute_steps("ended_fighting", 5, self.after_fight)
except NotRespondingError:
self.crashes += 1
sleep(5)
logger.info("reinitializing")
except QueuedRecalculation:
sleep(5)
logger.info("queued_recalc")
except ResizedError:
logger.warning("resized_warning")
sleep(5)
except DangerZoneError:
logger.warning("danger_zone_warning")
sleep(5)
except InvalidStateError:
self.crashes += 1
logger.warning("invalid_state_warning")
sleep(5)
def main_loop(self):
while True:
try:
self.main_sequence()
except KeyboardInterrupt:
self.on_exit()
except Exception as e:
logger.exception(e)
self.crashes += 1
self.on_exit()
def get_states(self):
self.check_stuff()
states = set()
screenshot = self.brawlhalla.make_screenshot()
if screenshot.size != (1920, 1080):
raise ResizedError
for state in self.state_conditions:
if self.is_color(screenshot, **self.state_conditions[state]):
states.add(state)
logger.debug(states)
if self.danger_zone & states and not self.safe_states & states:
raise DangerZoneError
self.last_states = states
def has_state(self, *states):
return self.last_states & set(states)
def go_to_menu(self, initial=False):
iters = 0
self.get_states()
while not self.has_state("menu"):
iters += 1
logger.debug("not_in_menu")
self.virtual_input.esc()
sleep(1)
if self.has_state("bonus"):
logger.info("collecting_bonus")
self.virtual_input.quick()
if self.has_state("popup"):
logger.info("accepting_event_popup")
self.virtual_input.quick()
if not initial and self.has_state("offline"):
logger.info("offline")
self.select_menu_item("custom_game_room")
self.go_to_lobby(100)
logger.info("reconnected")
self.go_to_menu()
if iters > 100:
raise NotRespondingError
self.get_states()
def select_item(self, item, *steps):
while not self.has_state(f"{item}_selected"):
logger.debug("item_not_selected", item)
self.execute_steps(*steps, delay=0.05)
if self.has_state("game_in_progress"):
self.virtual_input.dodge()
def select_menu_item(self, name):
target = find_element(name)
keys = self.current_menu_element.move_to(target, self.virtual_input)
self.current_menu_element = target
self.execute_steps(*keys)
def mute(self):
logger.info("muting")
self.select_menu_item("system_settings")
self.get_states()
if not self.has_state("system_settings_selected"):
raise InvalidStateError
self.execute_steps(
self.virtual_input.quick,
*([self.virtual_input.left] * 10),
self.virtual_input.down,
*([self.virtual_input.left] * 10),
self.virtual_input.dodge,
)
def sort_by_date(self):
counter = 0
while not self.has_state("sorted_by_date"):
logger.debug("sorting_by_date")
self.virtual_input.enter()
sleep(0.5)
self.get_states()
if counter > 10:
raise InvalidStateError
counter += 1
def get_characters(self):
_characters = []
rotation = get_rotation()
self.select_menu_item("meet_the_legends")
self.execute_steps(self.virtual_input.quick, 0.5, self.sort_by_date)
logger.info("collecting_character_data")
for line in level_character_matrix:
for character in line:
self.get_states()
level = self.level_definer.get_level()
xp = self.level_definer.get_xp(level)
unlocked = character in rotation or self.level_definer.get_unlocked()
_characters.append(Character(character, level, xp, unlocked))
logger.info(_characters[-1])
self.virtual_input.right()
sleep(0.15)
# self.virtual_input.down()
sleep(0.15)
unlocked_characters = [
character.name for character in _characters if character.unlocked
]
locked_characters = [
character.name for character in _characters if not character.unlocked
]
fixed_characters = unlocked_characters + ["random"] + locked_characters
build_character_matrix(fixed_characters)
self.go_to_menu()
return _characters
def go_to_lobby(self, max_iters=10):
iters = 0
while not self.has_state("lobby"):
self.virtual_input.quick()
sleep(2)
if iters > max_iters:
raise InvalidStateError
self.get_states()
iters += 1
def validate_level(self):
self.go_to_rewards_screen()
if self.duration < 3 or self.has_state("level_up"):
logger.debug("skip_lvl_valid")
return True
xp = self.level_definer.get_xp(self.character.level, True)
calculated_xp = get_duration_xp(self.duration)
logger.debug("calc_xp", calculated_xp)
logger.debug("pixel_xp", xp)
if self.character.level < 40 and abs(xp - calculated_xp) > calculated_xp / 3:
logger.info("xp_discrep")
return False
return True
def go_to_rewards_screen(self):
while not self.has_state("on_rewards_screen"):
self.virtual_input.quick()
sleep(5)
self.get_states()
def open_settings(self):
while not self.has_state("settings_open"):
self.virtual_input.heavy()
sleep(2)
self.get_states()
def wait_for_loading(self):
iters = 0
while not self.has_state("loading"):
logger.debug("waiting_for_loading")
iters += 1
self.virtual_input.quick()
sleep(2)
if iters > self.duration * 60:
raise NotRespondingError
self.get_states()
def wait_for_loaded(self):
iters = 0
while self.has_state("loading"):
logger.debug("loading")
iters += 1
sleep(1)
if iters > 100:
raise InvalidStateError
self.get_states()
def pick_character(self):
logger.info("pick_char", self.mode.next_character)
if self.character != self.mode.next_character:
self.execute_steps(
*self.character.get_path_to(self.mode.next_character.name)
)
self.character = self.mode.next_character
def set_duration(self):
logger.info("setting_dur", self.mode.next_duration)
if self.duration != self.mode.next_duration:
self.execute_steps(*self.duration_setting)
self.duration = self.mode.next_duration
def reset_xp(self):
self.execute_steps(
self.virtual_input.dodge, self.virtual_input.dodge, self.go_to_menu
)
waiting_start = time()
logger.info("wait_for_xp_reset", self.config.auto_stop_duration)
while time() - waiting_start < self.config.auto_stop_duration * 60:
logger.debug(
"wait_remaining",
int(waiting_start + self.config.auto_stop_duration * 60 - time()),
)
self.check_stuff()
sleep(1)
self.last_pause = time()
self.characters = []
self.unlocked_characters = []
raise QueuedRecalculation
def setup_lobby(self):
# noinspection PyTypeChecker
steps = (
[self.open_settings]
+ [self.virtual_input.right] * 8
+ [self.virtual_input.down] * 3
+ [self.virtual_input.left] * (2 - self.duration)
+ [self.virtual_input.right] * (self.duration - 2)
+ [self.virtual_input.down] * 2
+ [self.virtual_input.left] * 6
+ [self.virtual_input.down] * 2
+ [self.virtual_input.right]
+ [self.virtual_input.rbr]
+ [self.virtual_input.down] * 3
+ [self.virtual_input.left, self.virtual_input.down] * 3
+ [self.virtual_input.left, self.virtual_input.quick]
)
self.execute_steps(*steps)
def add_bots(self):
steps = (
[self.virtual_input.throw, 1]
+ [self.virtual_input.down] * 3
+ [self.virtual_input.quick] * 4
+ [self.virtual_input.throw]
)
self.execute_steps(*steps)
def initial_setup(self):
self.execute_steps("creating_lobby", 1, 1)
self.select_menu_item("custom_game_room")
self.execute_steps(
self.go_to_lobby, "setting_lobby", self.setup_lobby, 4, self.add_bots
)
def before_fight(self):
self.execute_steps(2, self.pick_character, 1, self.set_duration, 1)
def go_to_fight(self):
self.process_queue(True)
self.execute_steps(
"starting_game", self.wait_for_loading, self.wait_for_loaded, "loaded", 5
)
def after_fight(self):
self.get_states()
if self.has_state("disconnected", "game_in_progress", "offline"):
logger.info("disconnected")
raise NotRespondingError
self.games_completed += 1
calc_xp = get_duration_xp(self.duration)
time_to_sleep = self.config.auto_stop and (
(
not self.config.auto_detect_auto_stop
and time() - self.last_pause > self.config.auto_stop_frequency * 3600
)
or (self.config.auto_detect_auto_stop and not self.validate_level())
)
gold_for_level_up = self.character.add_xp(calc_xp)
calc_gold = get_duration_gold(self.duration) + gold_for_level_up
self.total_xp += calc_xp
self.total_gold += calc_gold
logger.debug("update_total_stats")
global_settings.update_stats(
games=1, time=time() - self._time_started, gold=calc_gold, xp=calc_xp
)
self._time_started = time()
logger.info("return_to_lobby")
self.go_to_lobby()
sleep(2)
self.process_queue(True)
if time_to_sleep:
self.reset_xp()
import queue
from time import time
from config import *
from direct_input import *
from menu import find_element, regenerate_layout
from windows import *
CONNECTION_LEVELS = (
(0, 204, 51), # green
(255, 255, 51), # yellow
(255, 153, 0), # orange
(255, 0, 0), # red
)
class QueuedRecalculation(Exception):
pass
class ResizedError(Exception):
pass
class DangerZoneError(Exception):
pass
class InvalidStateError(Exception):
pass
class BrawlhallaBot:
def __init__(self, config, hotkeys, bot_queue):
self.config = config
self.hotkeys = hotkeys
self.queue = bot_queue
self.mode = self.config.mode(bot=self)
self.characters = []
self.unlocked_characters = []
self.character = None
self.duration = None
self.brawlhalla = None
self.virtual_input = None
self.level_definer = None
self.last_pause = time()
self.games_completed = 0
self.total_xp = 0
self.total_gold = 0
self.crashes = 0
self.time_started = time()
self._time_started = self.time_started
self.last_states = set()
self.state_detection_pixels = get_menu_pixels()
self.current_menu_element = None
def find_brawlhalla(self):
brawlhalla = BrawlhallaProcess.find()
if brawlhalla:
self.brawlhalla = brawlhalla
return True
return False
def ensure_brawlhalla(self):
if self.find_brawlhalla():
self.brawlhalla.kill()
sleep(5)
try:
steam = SteamClient()
except SteamExeNotFound:
logger.error("no_steam_exe")
return self.on_exit()
count = 10000
while not self.find_brawlhalla():
logger.debug("waiting_for_bh_window")
self.process_queue()
count += 1
if count >= 10000:
steam.run_brawlhalla()
count = 0
self.virtual_input = VirtualInput(self.brawlhalla, self.hotkeys)
self.level_definer = LevelDefiner(self.brawlhalla)
logger.info("found_bh")
self.virtual_input.esc() # idk why but it puts bh into windowed
sleep(1)
if self.brawlhalla.fullscreen:
logger.info("not_windowed_mode")
raise NotRespondingError
self.brawlhalla.resize()
self.get_states()
if self.config.stealth:
logger.info("stealth_mode")
self.brawlhalla.hide()
self.brawlhalla.set_low_priority()
def initialize(self):
self.ensure_brawlhalla()
self.duration = 15
self.go_to_menu(True)
regenerate_layout()
self.current_menu_element = find_element("first_column").current_element
sleep(2)
if self.config.mute:
self.mute()
if not self.characters:
if self.mode.parse_character_levels:
self.characters = self.get_characters()
self.unlocked_characters = [
character for character in self.characters if character.unlocked
]
else:
self.characters = [Character(name) for name in characters]
self.unlocked_characters = self.characters
self.character = self.unlocked_characters[0]
logger.debug("initialized")
def on_exit(self):
if self.virtual_input:
self.virtual_input.release_keys()
if self.config.stealth and self.brawlhalla:
self.brawlhalla.kill()
text = global_settings.messages.get("initial_on_exit", "initial_on_exit") % (
format_time(time() - self.time_started),
self.games_completed,
self.crashes,
self.total_xp,
)
if self.mode.parse_character_levels:
text += global_settings.messages.get(
"on_exit_has_rewards", "on_exit_has_rewards"
) % (self.total_gold,)
else:
text += global_settings.messages.get(
"on_exit_no_rewards", "on_exit_no_rewards"
) % (self.total_gold,)
box(text, endmargin=False)
global_settings.update_stats(time=time() - self._time_started)
stats = global_settings.get_stats()
total = global_settings.messages.get("total_stats", "total_stats") % (
stats.get("games", 0),
stats.get("xp", 0),
stats.get("gold", 0),
format_time(stats.get("time", 0)),
)
box(total, endmargin=False)
sys.exit()
def process_queue(self, stop_delayed=False):
put_back = []
while not self.queue.empty():
try:
msg = self.queue.get_nowait()
except queue.Empty:
continue
self.queue.task_done()
if msg == "STOP":
raise KeyboardInterrupt
elif msg == "DELAYED_STOP":
if stop_delayed:
raise KeyboardInterrupt
put_back.append(msg) # cycle it in queue waiting for delayed_stop check
for item in put_back:
self.queue.put_nowait(item)
def check_stuff(self):
self.process_queue()
if self.brawlhalla and not self.brawlhalla.responding:
self.brawlhalla.kill()
sleep(1)
raise NotRespondingError
@property
def state_conditions(self):
conn_x = 1806 - ceil(98.5 * 2) # 1609
low_conn_x = conn_x - 26 # 1583
_new_menu = {"pixels": ((1890, 70),), "colors": ((255, 255, 255),)}
res = {
"ingame": {
"pixels": ((conn_x, 58),),
"colors": (CONNECTION_LEVELS[0],),
},
"low_connection": {
"pixels": ((low_conn_x, 74),),
"colors": CONNECTION_LEVELS,
},
"menu": self.state_detection_pixels.get("menu") or _new_menu,
"loading": {
"pixels": ((899, 85),),
"colors": ((227, 248, 255),),
},
"bonus": {
"pixels": ((930, 320),),
"colors": ((109, 198, 211),),
},
"offline": {
"pixels": ((1674, 26),),
"colors": ((55, 66, 100), (57, 67, 101)),
},
"sorted_by_date": {
"pixels": ((331, 766),),
"colors": ((254, 254, 255),),
},
"lobby": {
"pixels": ((1325, 22),),
"colors": ((255, 255, 255),),
},
"game_in_progress": {
"pixels": ((960, 395),),
"colors": ((111, 200, 211),),
},
"settings_open": {
"pixels": ((1221, 106),),
"colors": ((220, 220, 222),),
},
"disconnected": {
"pixels": ((934, 623),),
"colors": ((247, 248, 249),),
},
"system_settings_selected": {
"pixels": ((1607, 195),),
"colors": ((39, 85, 136),),
},
"on_rewards_screen": {
"pixels": ((1035, 121),),
"colors": ((255, 255, 255),),
},
"level_up": {
"pixels": ((1363, 320),),
"colors": ((19, 133, 51),),
},
"popup": {
"pixels": ((940, 790),),
"colors": ((247, 248, 249),),
},
"in_mallhalla": {
"pixels": ((338, 972),),
"colors": ((100, 77, 255),),
},
"in_battle_pass": {
"pixels": ((171, 660),),
"colors": ((181, 201, 225),),
},
}
for key in res.keys():
if key != "menu" and key in self.state_detection_pixels:
res[key] = self.state_detection_pixels[key]
return res
@property
def duration_setting(self):
return (
[self.open_settings, 1]
+ [self.virtual_input.down] * 3
+ (self.mode.next_duration - self.duration) * [self.virtual_input.right]
+ (self.duration - self.mode.next_duration) * [self.virtual_input.left]
+ [self.virtual_input.quick]
)
@property
def danger_zone(self):
return {"in_mallhalla", "in_battle_pass"}
@property
def safe_states(self):
return {"ingame", "low_connection"}
@staticmethod
def is_color(screenshot, pixels, colors):
tmp = [screenshot.getpixel(pixel) for pixel in pixels]
return any(screenshot.getpixel(pixel) in colors for pixel in pixels)
def execute_steps(self, *steps, delay=0.2):
self.get_states()
for step in steps:
if isinstance(step, (int, float)):
sleep(step)
elif isinstance(step, str):
if step in self.virtual_input.keys:
self.virtual_input.press_key(self.virtual_input.keys[step])
else:
logger.info(step)
else:
step()
self.get_states()
sleep(delay)
def main_sequence(self):
try:
self.initialize()
self.initial_setup()
while True:
self.execute_steps(self.before_fight, self.go_to_fight)
logger.info("started_fighting")
last, ig = (
True,
True,
) # To avoid failing ingame detection on low connection bc of "Double kill" popup covering first connection column for 1 frame
while last or ig:
self.get_states()
last, ig = ig, self.has_state("ingame", "low_connection")
self.virtual_input.fight()
self.execute_steps("ended_fighting", 5, self.after_fight)
except NotRespondingError:
self.crashes += 1
sleep(5)
logger.info("reinitializing")
except QueuedRecalculation:
sleep(5)
logger.info("queued_recalc")
except ResizedError:
logger.warning("resized_warning")
sleep(5)
except DangerZoneError:
logger.warning("danger_zone_warning")
sleep(5)
except InvalidStateError:
self.crashes += 1
logger.warning("invalid_state_warning")
sleep(5)
def main_loop(self):
while True:
try:
self.main_sequence()
except KeyboardInterrupt:
self.on_exit()
except Exception as e:
logger.exception(e)
self.crashes += 1
self.on_exit()
def get_states(self):
self.check_stuff()
states = set()
screenshot = self.brawlhalla.make_screenshot()
if screenshot.size != (1920, 1080):
raise ResizedError
for state in self.state_conditions:
if self.is_color(screenshot, **self.state_conditions[state]):
states.add(state)
logger.debug(states)
if self.danger_zone & states and not self.safe_states & states:
raise DangerZoneError
self.last_states = states
def has_state(self, *states):
return self.last_states & set(states)
def go_to_menu(self, initial=False):
iters = 0
self.get_states()
while not self.has_state("menu"):
iters += 1
logger.debug("not_in_menu")
self.virtual_input.esc()
sleep(1)
if self.has_state("bonus"):
logger.info("collecting_bonus")
self.virtual_input.quick()
if self.has_state("popup"):
logger.info("accepting_event_popup")
self.virtual_input.quick()
if not initial and self.has_state("offline"):
logger.info("offline")
self.select_menu_item("custom_game_room")
self.go_to_lobby(100)
logger.info("reconnected")
self.go_to_menu()
if iters > 100:
raise NotRespondingError
self.get_states()
def select_item(self, item, *steps):
while not self.has_state(f"{item}_selected"):
logger.debug("item_not_selected", item)
self.execute_steps(*steps, delay=0.05)
if self.has_state("game_in_progress"):
self.virtual_input.dodge()
def select_menu_item(self, name):
target = find_element(name)
keys = self.current_menu_element.move_to(target, self.virtual_input)
self.current_menu_element = target
self.execute_steps(*keys)
def mute(self):
logger.info("muting")
self.select_menu_item("system_settings")
self.get_states()
if not self.has_state("system_settings_selected"):
raise InvalidStateError
self.execute_steps(
self.virtual_input.quick,
*([self.virtual_input.left] * 10),
self.virtual_input.down,
*([self.virtual_input.left] * 10),
self.virtual_input.dodge,
)
def sort_by_date(self):
counter = 0
while not self.has_state("sorted_by_date"):
logger.debug("sorting_by_date")
self.virtual_input.enter()
sleep(0.5)
self.get_states()
if counter > 10:
raise InvalidStateError
counter += 1
def get_characters(self):
_characters = []
rotation = get_rotation()
self.select_menu_item("meet_the_legends")
self.execute_steps(self.virtual_input.quick, 0.5, self.sort_by_date)
logger.info("collecting_character_data")
for line in level_character_matrix:
for character in line:
self.get_states()
level = self.level_definer.get_level()
xp = self.level_definer.get_xp(level)
unlocked = character in rotation or self.level_definer.get_unlocked()
_characters.append(Character(character, level, xp, unlocked))
logger.info(_characters[-1])
self.virtual_input.right()
sleep(0.15)
# self.virtual_input.down()
sleep(0.15)
unlocked_characters = [
character.name for character in _characters if character.unlocked
]
locked_characters = [
character.name for character in _characters if not character.unlocked
]
fixed_characters = unlocked_characters + ["random"] + locked_characters
build_character_matrix(fixed_characters)
self.go_to_menu()
return _characters
def go_to_lobby(self, max_iters=10):
iters = 0
while not self.has_state("lobby"):
self.virtual_input.quick()
sleep(2)
if iters > max_iters:
raise InvalidStateError
self.get_states()
iters += 1
def validate_level(self):
self.go_to_rewards_screen()
if self.duration < 3 or self.has_state("level_up"):
logger.debug("skip_lvl_valid")
return True
xp = self.level_definer.get_xp(self.character.level, True)
calculated_xp = get_duration_xp(self.duration)
logger.debug("calc_xp", calculated_xp)
logger.debug("pixel_xp", xp)
if self.character.level < 40 and abs(xp - calculated_xp) > calculated_xp / 3:
logger.info("xp_discrep")
return False
return True
def go_to_rewards_screen(self):
while not self.has_state("on_rewards_screen"):
self.virtual_input.quick()
sleep(5)
self.get_states()
def open_settings(self):
while not self.has_state("settings_open"):
self.virtual_input.heavy()
sleep(2)
self.get_states()
def wait_for_loading(self):
iters = 0
while not self.has_state("loading"):
logger.debug("waiting_for_loading")
iters += 1
self.virtual_input.quick()
sleep(2)
if iters > self.duration * 60:
raise NotRespondingError
self.get_states()
def wait_for_loaded(self):
iters = 0
while self.has_state("loading"):
logger.debug("loading")
iters += 1
sleep(1)
if iters > 100:
raise InvalidStateError
self.get_states()
def pick_character(self):
logger.info("pick_char", self.mode.next_character)
if self.character != self.mode.next_character:
self.execute_steps(
*self.character.get_path_to(self.mode.next_character.name)
)
self.character = self.mode.next_character
def set_duration(self):
logger.info("setting_dur", self.mode.next_duration)
if self.duration != self.mode.next_duration:
self.execute_steps(*self.duration_setting)
self.duration = self.mode.next_duration
def reset_xp(self):
self.execute_steps(
self.virtual_input.dodge, self.virtual_input.dodge, self.go_to_menu
)
waiting_start = time()
logger.info("wait_for_xp_reset", self.config.auto_stop_duration)
while time() - waiting_start < self.config.auto_stop_duration * 60:
logger.debug(
"wait_remaining",
int(waiting_start + self.config.auto_stop_duration * 60 - time()),
)
self.check_stuff()
sleep(1)
self.last_pause = time()
self.characters = []
self.unlocked_characters = []
raise QueuedRecalculation
def setup_lobby(self):
# noinspection PyTypeChecker
steps = (
[self.open_settings]
+ [self.virtual_input.right] * 8
+ [self.virtual_input.down] * 3
+ [self.virtual_input.left] * (2 - self.duration)
+ [self.virtual_input.right] * (self.duration - 2)
+ [self.virtual_input.down] * 2
+ [self.virtual_input.left] * 6
+ [self.virtual_input.down] * 2
+ [self.virtual_input.right]
+ [self.virtual_input.rbr]
+ [self.virtual_input.down] * 3
+ [self.virtual_input.left, self.virtual_input.down] * 3
+ [self.virtual_input.left, self.virtual_input.quick]
)
self.execute_steps(*steps)
def add_bots(self):
steps = (
[self.virtual_input.throw, 1]
+ [self.virtual_input.down] * 3
+ [self.virtual_input.quick] * 4
+ [self.virtual_input.throw]
)
self.execute_steps(*steps)
def initial_setup(self):
self.execute_steps("creating_lobby", 1, 1)
self.select_menu_item("custom_game_room")
self.execute_steps(
self.go_to_lobby, "setting_lobby", self.setup_lobby, 4, self.add_bots
)
def before_fight(self):
self.execute_steps(2, self.pick_character, 1, self.set_duration, 1)
def go_to_fight(self):
self.process_queue(True)
self.execute_steps(
"starting_game", self.wait_for_loading, self.wait_for_loaded, "loaded", 5
)
def after_fight(self):
self.get_states()
if self.has_state("disconnected", "game_in_progress", "offline"):
logger.info("disconnected")
raise NotRespondingError
self.games_completed += 1
calc_xp = get_duration_xp(self.duration)
time_to_sleep = self.config.auto_stop and (
(
not self.config.auto_detect_auto_stop
and time() - self.last_pause > self.config.auto_stop_frequency * 3600
)
or (self.config.auto_detect_auto_stop and not self.validate_level())
)
gold_for_level_up = self.character.add_xp(calc_xp)
calc_gold = get_duration_gold(self.duration) + gold_for_level_up
self.total_xp += calc_xp
self.total_gold += calc_gold
logger.debug("update_total_stats")
global_settings.update_stats(
games=1, time=time() - self._time_started, gold=calc_gold, xp=calc_xp
)
self._time_started = time()
logger.info("return_to_lobby")
self.go_to_lobby()
sleep(2)
self.process_queue(True)
if time_to_sleep:
self.reset_xp()