Exemplo n.º 1
0
    def init_recipe(self):
        # fills the item helper areas from data in config.json
        # get data
        data = util.get_options()

        table_picker = {
            'chrome': self.contents.chrome_items,
            'firefox': self.contents.firefox_items
        }

        tree_picker = {
            'chrome': self.contents.chrome_recipe,
            'firefox': self.contents.firefox_recipe
        }

        # we connect signal here to avoid calling update_full_recipe when user interacts with options window
        self.signals.recipe_signal.connect(self.update_full_recipe)

        # fill chrome_items table
        for browser in table_picker:
            if data[browser]['LW']:
                self.browser = browser  # need this so update_full_recipe knows which to update
                tree_picker[browser].addTopLevelItem(
                    QtWidgets.QTreeWidgetItem([data[browser]['LW'], '1']))
                total_basic_items = self.db.find_recipe(data[browser]['LW'], 1)
                for item in total_basic_items:
                    table_picker[browser].addItem(item + ': ' +
                                                  str(total_basic_items[item]))
                tree_picker[browser].expandAll()
                table_picker[browser].sortItems()

        del self.browser
        self.signals.recipe_signal.disconnect(self.update_full_recipe)
Exemplo n.º 2
0
    def change_cooldown(self, gui_lower, gui_upper, browser: str):
        # changes the time between arena and world actions in MINUTES
        try:
            lower = float(gui_lower.displayText()) * 60
            upper = float(gui_upper.displayText()) * 60
        except ValueError:
            return

        if lower and upper:  # make sure the fields at least have text in them
            # save to file
            data = util.get_options()
            data[browser]['cooldown']['lower'] = lower
            data[browser]['cooldown']['upper'] = upper
            util.save_options(data)

            # update data
            self.signals.options_signal.emit(data)

            # log
            self.signals.options_msg_signal.emit(
                f'cooldown changed to {lower/60} - {upper/60} minutes',
                browser)

            # clear fields
            gui_lower.clear()
            gui_upper.clear()
Exemplo n.º 3
0
    def save_mission(self, area: str, mission: str, browser: str):
        # changes the world mission
        if area and mission:  # make sure they're not empty strings
            # save to file
            data = util.get_options()
            data[browser]['world']['area_url'] = area
            data[browser]['world']['mission_num'] = mission
            util.save_options(data)

            # update data
            self.signals.options_signal.emit(data)

            # log
            self.signals.options_msg_signal.emit(
                f'mission changed to {area}/{mission}', browser)
Exemplo n.º 4
0
    def change_mission(self, gui_object, browser: str):
        row = gui_object.currentRow()
        if row == -1:  # if nothing is selected
            return

        url = gui_object.item(row, 2).text()
        mission = gui_object.item(row, 3).text()

        data = util.get_options()
        data[browser]['world']['area_url'] = url
        data[browser]['world']['mission_num'] = mission
        util.save_options(data)

        self.signals.options_signal.emit(data)
        self.log(f'mission changed to {url}/{mission}', browser)
Exemplo n.º 5
0
    def __init__(self, loggers, stats, signals, db):
        # pyqt definitions
        self.window = QtWidgets.QMainWindow()
        self.contents = main_ui.Ui_main_window()
        self.contents.setupUi(self.window)

        # variables received
        self.loggers = loggers
        self.stats = stats
        self.signals = signals
        self.db = db

        # variables created
        self.browsers = {}
        self.items = {}

        # init
        self.connect_events()
        self.ui_changes()
        self.init_recipe()
        self.contents.chrome_notes.setText(
            util.get_options()['chrome']['notes'])
        self.contents.firefox_notes.setText(
            util.get_options()['firefox']['notes'])
Exemplo n.º 6
0
    def __init__(self, signals, db):
        # pyqt definitions
        self.window = QtWidgets.QMainWindow()
        self.contents = options_ui.Ui_options_window()
        self.contents.setupUi(self.window)

        # variables received
        self.signals = signals
        self.db = db

        # variables created
        self.options = util.get_options()

        # init
        self.connect_events()
        self.ui_changes()
        self.fill_fields()
        self.populate_tables()
Exemplo n.º 7
0
    def change_repeat(self, gui, browser: str):
        # changes how many times the world missions are repeated
        try:
            new_repeat = int(gui.displayText())
        except ValueError:
            return

        if new_repeat:  # make sure the fields at least have text in them
            # save to file
            data = util.get_options()
            data[browser]['world']['repeat'] = new_repeat
            util.save_options(data)

            # update data
            self.signals.options_signal.emit(data)

            # log
            self.signals.options_msg_signal.emit(
                f'repeat changed to {new_repeat}', browser)

            # clear fields
            gui.clear()
Exemplo n.º 8
0
    def __init__(self, stats, logger, signals, browser: str):
        # variables received
        self.stats = stats
        self.logger = logger
        self.browser = browser
        self.signals = signals

        # variables created
        self.errors = 0
        self.options = util.get_options()
        self.turn_off = False
        self.logged_in = False
        self.arena_energy = True
        self.world_energy = True
        if self.browser == 'chrome':
            self.bot = webdriver.Chrome(
                executable_path=r'drivers\chromedriver.exe')
        elif self.browser == 'firefox':
            self.bot = webdriver.Firefox(
                executable_path=r'drivers\geckodriver.exe')

        # start
        self.startup()
Exemplo n.º 9
0
    def pin_recipe(self, browser):
        # copies contents of recipe and basic items to main window
        transfer = {}

        # recipe
        transfer['recipe'] = self.contents.recipe.takeTopLevelItem(0)

        # basic items
        transfer['items'] = []
        for row in range(len(self.contents.basic_items)):
            transfer['items'].append(self.contents.basic_items.takeItem(0))

        # clear areas
        self.contents.areas.clear()

        # output
        self.signals.pin_signal.emit(transfer, browser)

        # save so we don't have to keep selecting the LW every time we open the program
        data = util.get_options()
        data[browser]['LW'] = transfer['recipe'].text(0)
        util.save_options(data)

        self.options = data
Exemplo n.º 10
0
 def save_notes(self, gui_object, browser: str):
     data = util.get_options()
     data[browser]['notes'] = gui_object.toPlainText()
     util.save_options(data)