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

Commit

Permalink
black formatter
Browse files Browse the repository at this point in the history
black formatter
  • Loading branch information
Nick2bad4u committed May 12, 2024
1 parent 09ab312 commit 3aaca28
Show file tree
Hide file tree
Showing 14 changed files with 132 additions and 60 deletions.
1 change: 1 addition & 0 deletions abstract_mode.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from abc import ABCMeta, abstractmethod
from utils import *


class Mode(metaclass=ABCMeta):
name = None
character_selection_enabled = True
Expand Down
5 changes: 5 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@
(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
Expand Down
6 changes: 6 additions & 0 deletions characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
character_matrix_width = 13
character_matrix = []


def build_character_matrix(_characters):
global character_matrix
character_matrix = list(
Expand All @@ -85,18 +86,22 @@ def build_character_matrix(_characters):
]
)


build_character_matrix(characters + ["random"])


def find_char(name):
for i, row in enumerate(character_matrix):
try:
return i + 1, row.index(name) + 1
except ValueError:
pass


def map_to_char(row, col):
return ["down"] * (row - 1) + ["right"] * (col - 1)


def parse_pos(inp):
try:
pos = tuple(map(int, inp.split()))
Expand All @@ -106,6 +111,7 @@ def parse_pos(inp):
return None
return map_to_char(*pos)


class Character:
def __init__(self, name, level=0, xp=0, unlocked=True):
self.name = name
Expand Down
8 changes: 4 additions & 4 deletions client_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ClientConfig(object):
PUBLIC_KEY = 'fwL+l4+Xb4lAf5zdgwEKqr+zu+cO9kZ1/6uOb3/RNoA'
APP_NAME = 'BHBot'
COMPANY_NAME = 'Nick2bad4u'
PUBLIC_KEY = "fwL+l4+Xb4lAf5zdgwEKqr+zu+cO9kZ1/6uOb3/RNoA"
APP_NAME = "BHBot"
COMPANY_NAME = "Nick2bad4u"
HTTP_TIMEOUT = 30
MAX_DOWNLOAD_RETRIES = 3
UPDATE_URLS = ['https://sovamor.co/bhbot/versions']
UPDATE_URLS = ["https://sovamor.co/bhbot/versions"]
4 changes: 4 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from direct_input import *
from utils import *


def display_changelog():
changelog_path = Path(os.getenv("LOCALAPPDATA")) / "BHBot" / "changelog"
if global_settings.compiled and (
Expand All @@ -22,6 +23,7 @@ def display_changelog():
changelog_path.parent.mkdir(parents=True, exist_ok=True)
changelog_path.write_text(global_settings.APP_VERSION, "utf-8")


class Config:
def __init__(self, config):
self.character = config.get("character", "Random")
Expand Down Expand Up @@ -50,6 +52,7 @@ def load(cls):
return cls(res)
except FileNotFoundError:
return cls({})

# noinspection PyUnresolvedReferences
@staticmethod
def get_modes():
Expand Down Expand Up @@ -91,6 +94,7 @@ def __str__(self):
"config", 'Missing "config" entry in language'
).format(self)


# noinspection PyUnresolvedReferences
class GUIConfig:
def __init__(self):
Expand Down
4 changes: 4 additions & 0 deletions direct_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
MAP_VSC_TO_VK = 1
MAP_VK_TO_CHAR = 2


# noinspection PyPep8Naming
class VirtualInput:
def __init__(self, brawlhalla, hotkeys):
Expand Down Expand Up @@ -87,6 +88,7 @@ def fight(self):
]
self.press_key(choice(move_keys), choice(fight_keys), delay=0.2)


class Hotkeys:
def __init__(self, hotkeys):
self.up = hotkeys.get("up", win32con.VK_UP)
Expand Down Expand Up @@ -116,6 +118,7 @@ def save(self):
except Exception as e:
logger.error("cant_save_hotkeys", e)


class GUIHotkeys:
def __init__(self):
self.hotkeys = Hotkeys.load()
Expand All @@ -127,6 +130,7 @@ def __init__(self):
def hook_keyboard(self):
def inner_hook(event):
self.last_keyboard_event = event

if not self.hook:
self.hook = keyboard.hook(inner_hook)

Expand Down
2 changes: 2 additions & 0 deletions font_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

FONT_SPECIFIER_NAME_ID = 4


def get_font_name(file):
font = TTFont(file)
name = ""
Expand All @@ -16,6 +17,7 @@ def get_font_name(file):
return name_str
return ""


def load_font(fontpath):
flags = 0x10 | 0x20
num_fonts_added = ctypes.windll.gdi32.AddFontResourceExW(
Expand Down
3 changes: 3 additions & 0 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from bot import *


class Handler(logging.StreamHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand All @@ -13,6 +14,7 @@ def emit(self, record):
record.msg = global_settings.messages[record.msg]
Sg.cprint(self.format(record), text_color=colors.get(record.levelno, "red"))


class GUI:
def __init__(self):
self.queue = queue.Queue()
Expand Down Expand Up @@ -265,6 +267,7 @@ def main_loop(self):

self.window.close()


if __name__ == "__main__":
Singleton()
gui = GUI()
Expand Down
3 changes: 3 additions & 0 deletions gui.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import uuid

from bot import *


class Handler(logging.StreamHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand All @@ -13,6 +14,7 @@ class Handler(logging.StreamHandler):
record.msg = global_settings.messages[record.msg]
Sg.cprint(self.format(record), text_color=colors.get(record.levelno, "red"))


class GUI:
def __init__(self):
self.queue = queue.Queue()
Expand Down Expand Up @@ -265,6 +267,7 @@ class GUI:

self.window.close()


if __name__ == "__main__":
Singleton()
gui = GUI()
Expand Down
Loading

0 comments on commit 3aaca28

Please sign in to comment.