Exemplo n.º 1
0
def run(handleOK=False, debug=False):
	"""
	Runs the bot
	"""

	print english.produce_fuel
	coordinate = mapExtractor.getFuelstation()

	if None == coordinate:
		raise ValueError("Map positions are not initialized")

	print english.move_mouse_to_browser
	print english.start_in 
	alphaBotUtility.countDownwards(5)

	infix = datetime.datetime.now().strftime("%d-%m-%y_%H-%M-%S")

	currentRun = 0

	while True:

		currentReport = report.Report()

		if handleOK:
			clickOK()

		backgroundLayerPath = captchaExtractor.extractBackgroundLayer(coordinate[0], coordinate[1], nameInfix=infix)
		currentReport.setBackgroundLayer(backgroundLayerPath)

		# move to factory
		autopy.mouse.smooth_move(coordinate[0], coordinate[1])

		# extract capture
		captchaPath = captchaExtractor.extractCaptcha(coordinate[0], coordinate[1], nameInfix=infix)
		currentReport.setCaptcha(captchaPath)
		
		delta_x = None
		delta_y = None 

		(delta_x, delta_y) = tetragonDetector.findTetragonLineBased(captchaPath, report=currentReport, backgroundLayerPath=backgroundLayerPath, _debug=False)

		if not None == delta_x and not None == delta_y:
			target_x = int(coordinate[0] - 50 + delta_x)
			target_y = int(coordinate[1] + delta_y)

		currentReport.setTargetCoordinates(delta_x, delta_y)

		# move the mouse to prevent the blackening of the screen
		autopy.mouse.smooth_move(coordinate[0]-random.randint(0,100), coordinate[1]-random.randint(0,100))

# move to detected tetragon and click
		if not None == delta_x and not None == delta_y:
			clickCoordinate(target_x, target_y)

		currentReport.save("report_" + str(currentRun) + ".txt")
		currentRun += 1

# wait 60 seconds
		alphaBotUtility.countDownwards(60)
Exemplo n.º 2
0
def initializeFactoryPosition():
	"""
	Contains the in/output of the factory initialization
	"""
	print english.move_mouse_to_browser 

	alphaBotUtility.countDownwards(5)

	alphaBotUtility.showSpinner()

	mapExtractor.initialize()

	alphaBotUtility.hideSpinner()
Exemplo n.º 3
0
def initializeFactoryPosition():
    """
	Contains the in/output of the factory initialization
	"""
    print english.move_mouse_to_browser

    alphaBotUtility.countDownwards(5)

    alphaBotUtility.showSpinner()

    mapExtractor.initialize()

    alphaBotUtility.hideSpinner()
Exemplo n.º 4
0
def initializeOKPosition():
	"""
	Contains the in/output of the OK initialization
	"""
	print english.fallback

	raw_input(english.enter_to_continue)
	print english.move_mouse_to_browser
	alphaBotUtility.countDownwards(5)

	alphaBotUtility.showSpinner()

	mapExtractor.initializeOK()

	alphaBotUtility.hideSpinner()
Exemplo n.º 5
0
def initializeOKPosition():
    """
	Contains the in/output of the OK initialization
	"""
    print english.fallback

    raw_input(english.enter_to_continue)
    print english.move_mouse_to_browser
    alphaBotUtility.countDownwards(5)

    alphaBotUtility.showSpinner()

    mapExtractor.initializeOK()

    alphaBotUtility.hideSpinner()
Exemplo n.º 6
0
def run(handleOK=False, debug=False):
    """
	Runs the bot
	"""

    print english.produce_fuel
    coordinate = mapExtractor.getFuelstation()

    if None == coordinate:
        raise ValueError("Map positions are not initialized")

    print english.move_mouse_to_browser
    print english.start_in
    alphaBotUtility.countDownwards(5)

    infix = datetime.datetime.now().strftime("%d-%m-%y_%H-%M-%S")

    currentRun = 0

    while True:

        currentReport = report.Report()

        if handleOK:
            clickOK()

        backgroundLayerPath = captchaExtractor.extractBackgroundLayer(
            coordinate[0], coordinate[1], nameInfix=infix)
        currentReport.setBackgroundLayer(backgroundLayerPath)

        # move to factory
        autopy.mouse.smooth_move(coordinate[0], coordinate[1])

        # extract capture
        captchaPath = captchaExtractor.extractCaptcha(coordinate[0],
                                                      coordinate[1],
                                                      nameInfix=infix)
        currentReport.setCaptcha(captchaPath)

        delta_x = None
        delta_y = None

        (delta_x, delta_y) = tetragonDetector.findTetragonLineBased(
            captchaPath,
            report=currentReport,
            backgroundLayerPath=backgroundLayerPath,
            _debug=False)

        if not None == delta_x and not None == delta_y:
            target_x = int(coordinate[0] - 50 + delta_x)
            target_y = int(coordinate[1] + delta_y)

        currentReport.setTargetCoordinates(delta_x, delta_y)

        # move the mouse to prevent the blackening of the screen
        autopy.mouse.smooth_move(coordinate[0] - random.randint(0, 100),
                                 coordinate[1] - random.randint(0, 100))

        # move to detected tetragon and click
        if not None == delta_x and not None == delta_y:
            clickCoordinate(target_x, target_y)

        currentReport.save("report_" + str(currentRun) + ".txt")
        currentRun += 1

        # wait 60 seconds
        alphaBotUtility.countDownwards(60)