def moveTo(move, findFunc):
    maxIterations = 26

    while findFunc() is None and maxIterations > 0:
        checkIfPaused()
        move()
        maxIterations = maxIterations - 1
Beispiel #2
0
def processGuild():
    guild = findGuild()
    if guild is None:
        randSleepSec(60, 120)
        return
    else:
        pressEsc()
    with lock:
        checkIfPaused()
        x = guild.left
        y = guild.top + guild.height + 1
        leftRegion = (x + 3, y, 8, 7)
        rightRegion = (x + guild.width / 2 + 2, y, 8, 7)
        leftScreen = pyautogui.screenshot(region=leftRegion)
        rightScreen = pyautogui.screenshot(region=rightRegion)
        found = pyautogui.locate(leftScreen, rightScreen, confidence=0.8)
        if found:
            logging.info("Found full guild")
            pyautogui.moveTo(guild.left,
                             guild.top + guild.height + ydiff1,
                             duration=randDur())
            pyautogui.click()
            guildGet = findPic('guildGet')
            tries = 10
            while guildGet is None and tries > 0:
                tries = tries - 1
                randSleepSec(1, 3)
                guildGet = findPic('guildGet')
            pressButton(guildGet, False)
        else:
            logging.debug("Guild is not full")
            pressEsc()
    randSleepSec(60, 180)
Beispiel #3
0
def reboot():
    with lock:
        checkIfPaused()
        activateWindow()
        pyautogui.press('f5')
        GameState.rebooted()
        sleep(1)
Beispiel #4
0
def safeInfiniteLoop(func):
    while True:
        try:
            logging.info("Bot iteration")
            checkIfPaused()
            func()
        except Exception as e:
            logging.error(traceback.format_exc())
            logging.error(e)
Beispiel #5
0
def switchSlave():
    windows = foe_desktops.getGameWindows()
    foe_desktops.hideAll()
    for window in itertools.cycle(windows):
        with lock:
            checkIfPaused()
            foe_desktops.show(window)
            initSocialProcesses()
        sleep(minimumTimeOnDesktop)
        with lock:
            foe_desktops.hide(window)
Beispiel #6
0
def zoomOut():
    if findLandscape() is not None:
        randSleepSec(60, 120)
        return
    panel = findButtonsPanel()
    if panel is None:
        randSleepSec(5, 10)
        return
    with lock:
        checkIfPaused()
        logging.info("Zooming out")
        pyautogui.moveTo(panel[0], panel[1], duration=randDur())
        pyautogui.moveRel(50, -50, duration=randDur())
        pyautogui.click()
        randSleepMs()
        scroll(-1, 1)
        randSleepMs()
        scroll(-1, 1)
        randSleepMs()
        logging.info("Zoomed out")
    randSleepSec(60, 120)
Beispiel #7
0
def goldCollector():  # gold icons
    if not isThereSomethingToCollect():
        randSleepSec(5, 15)
        return

    output = findGold()

    if output is not None:
        logging.info("Found gold %s", output)
        with lock:
            checkIfPaused()
            # get coordinates to click from output
            pressCollect1(output)
            if waitGoldCollected(output.left, output.top + ydiff1):
                return

            pressEsc()
            pressCollect2(output)
            if waitGoldCollected(output.left, output.top + ydiff1 + ydiff2):
                return

            pressEsc()
    else:
        randSleepSec(5, 15)
Beispiel #8
0
def processSupplies():  # supplies icons
    if not isThereSomethingToCollect():
        randSleepSec(3, 7)
        return

    output = findSupplies()
    if output is not None:
        logging.info("Found supplies %s", output)
        with lock:
            checkIfPaused()
            # get coordinates to click from output
            pressCollect1(output)
            if waitSuppliesCollected(output.left, output.top + ydiff1):
                return

            pressEsc()
            pressCollect2(output)
            if waitSuppliesCollected(output.left,
                                     output.top + ydiff1 + ydiff2):
                return

            pressEsc()
    else:
        randSleepSec(3, 7)
def moveToFirstDesktop():
    with lock:
        checkIfPaused()
        _moveToFirstDesktop()
Beispiel #10
0
def rightDesktop():
    with lock:
        checkIfPaused()
        _rightDesktop()
Beispiel #11
0
def leftDesktop():
    with lock:
        checkIfPaused()
        _leftDesktop()