Esempio n. 1
0
def processSocial():
    global socialProcesses
    initSocialProcesses()
    random.shuffle(socialProcesses)
    while socialProcesses:
        process = socialProcesses.pop()
        process()
    randSleepSec(300, 600)
Esempio n. 2
0
def processGoods():  # goods boxes icons
    if not isThereSomethingToCollect():
        randSleepSec(5, 15)
        return

    output = findGoods()
    if output is not None:
        logging.info("Found good %s", output)
        processGoodsOutput(output)
    else:
        randSleepSec(3, 7)
Esempio n. 3
0
def processIdleBuildings():  # idle building icons
    if not isThereSomethingSleeps():
        randSleepSec(3, 7)
        return

    output = findIdle()
    if output is not None:
        logging.info("Found idle %s", output)
        processIdleOutput(output)
    else:
        randSleepSec(3, 7)
Esempio n. 4
0
def findLoot():
    pics = []
    for file in glob.glob("resources/loot/*.png"):
        name = Path(file).stem
        pic = f"loot/{name}"
        pics.append(pic)
    for i in range(0, 3):
        found = execInPool(findPic, pics)
        found = [pic for pic in found if pic is not None]
        if found:
            return found[0]
        randSleepSec()
Esempio n. 5
0
def lootCollector2():
    randSleepSec(90, 180)
    with lock:
        moveTo(lambda: right() or up(), findUpRightCorner)
        collectLoot()
        moveTo(lambda: right() or down(), findDownRightCorner)
        collectLoot()
        moveTo(lambda: left() or down(), findDownLeftCorner)
        collectLoot()
        moveTo(lambda: left() or up(), findUpLeftCorner)
        collectLoot()
        moveTo(lambda: right(), findCoastOnTheRight)
Esempio n. 6
0
def unstuck():
    if findPic('sessionExpired') is not None:
        pressButton(findPic('rebootNow'), True)
        randSleepSec(5, 10)

    playBtn = findPic('play')
    if playBtn is not None:
        pressButton(playBtn, True)

    worldBtn = findPic('world')
    if worldBtn is not None:
        pressButton(worldBtn, True)
        randSleepSec(5, 10)

    eventsPanel = findPic('events')
    if eventsPanel is not None:
        pressEsc()
        randSleepSec(5, 10)

    if findPic('visitUnavailable') is not None:
        pressButton(findPic('ok'), True)

    returnToCity = findPic('returnToCity')
    if returnToCity is not None:
        pressButton(returnToCity, False)

    if findPic('cannotHelp') is not None:
        reboot()

    randSleepSec(5, 15)
Esempio n. 7
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)
Esempio n. 8
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)
Esempio n. 9
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)
Esempio n. 10
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)
Esempio n. 11
0
def processArmy():
    output = findArmy()
    if output is not None:
        logging.info("Found army %s", output)
        processOutput(output)
    randSleepSec(5, 10)