Esempio n. 1
0
 def withdraw(self, grid=None):
     m = self.scripts['fight']
     if grid:
         m.forceRun('g' + str(grid))
         util.wait(0.12, 0.04)
     m.forceRun('withdraw')
     util.wait(0.1, 0.04)
Esempio n. 2
0
 def login(self):
     m = self.scripts['login']
     m.run('app')
     util.wait(1)
     keyboard.write(Config.i.data['pass'])
     util.wait(1)
     m.run('press login')
Esempio n. 3
0
 def clickAway(self, toMain=False):
     mEnd = self.scripts['end']
     ri = random.randint(0, 9)
     clickSafety = 80
     clickDone = 0
     while not mEnd.checkState('loading') and not mEnd.checkState('partial main') and clickDone < clickSafety:
         if not Machine.blocked:
             if toMain:
                 mEnd.forceRun('end big loop')
             else:
                 mEnd.forceRun('rc' + str(ri))
             clickDone += 1
             if clickDone >= clickSafety:
                 util.alert()
         util.wait(0.4)
Esempio n. 4
0
    def playThread(self):
        # do the big loops
        Controller.state['bigLoopComplete'] = 0
        Controller.state['repairLoopComplete'] = 0
        while Controller.state['bigLoopComplete'] < Controller.state['bigLoop']:
            # initial check logistics
            self.getLogisticTimer()
            if min(Controller.state['logistic']) - time.time() > 90:
                self.runner.restart()
            if Controller.state['waiting'] > 0:
                while Controller.state['waiting'] > 0:
                    util.wait(1)
                util.wait(1)
                self.getLogisticTimer()
            Controller.state['runtime'] = time.time()
            self.runner.play()
            t = time.time() - Controller.state['runtime']
            print('RUNTIME: ' + str(round(t, 1)) + 's (' + str(round(t / 60, 1)) + ' min)')
            Controller.state['bigLoopComplete'] += 1
            util.wait(1)

            # does enhancement and dumps and conditional repair
            m = self.scripts['manage']
            m.run('main')
            if Controller.state['repairLoopComplete'] < Controller.state['repairLoop']:
                Controller.state['repairLoopComplete'] += 1
            else:
                m.run('main repair')
                Controller.state['repairLoopComplete'] = 0

        util.alert()
Esempio n. 5
0
    def execute(self):
        if Machine.blocked:
            return
        elif Machine.dead:
            sys.exit()

        cur = self.state[self.cur]

        # if screen has changed, check if new state has been reached
        if not cur.pixelCheck():
            util.wait(0)
            self.checkNext()
            return

        cur.run()

        # check if new state has been entered
        functionData = cur.function['data']
        util.wait(functionData['wait'], 0.15)
        if self.checkNext():
            return

        # retry loop, otherwise notify
        while cur.pixelCheck():
            cur.run()
            util.wait(functionData['retry'], 0.15)
            if self.checkNext():
                return
Esempio n. 6
0
def wheelScroll(d, t, mod=None):
    # mouse wheel scrolling
    p = ((Context.i.x2 - Context.i.x) / 2, (Context.i.y2 - Context.i.y) * 0.25)
    mouseTo(p)
    if mod:
        gui.keyDown(mod)
        util.wait(0.1)
        for _ in range(t):
            gui.scroll(d, x=p[0], y=p[1])
            util.wait(0.05)
        util.wait(0.1)
        gui.keyUp(mod)
    else:
        for _ in range(t):
            gui.scroll(d, x=p[0], y=p[1])
            util.wait(0.05)
Esempio n. 7
0
    def run(self, starter=None):
        if starter:
            self.cur = starter
        else:
            self.cur = self.start

        cur = self.state[self.cur]
        curState = self.cur
        curTime = time.time()
        while cur.next or cur.pixelCheck():
            # check if the loop is potentially stuck
            if curState != self.cur:
                curState = self.cur
                curTime = time.time()
            elif time.time() - curTime > Config.i.data['stuck_timer']:
                print('STUCK?\nCur: <' + self.cur + '> Prev: <' + self.pre + '>\n')
                util.alert()
                util.wait(Config.i.data['stuck_timer'])

            if not cur.function:
                return
            self.execute()
            cur = self.state[self.cur]
Esempio n. 8
0
def rDrag(p1a, p1b, p4a, p4b, delay=0.3, hold=0.05):
    p1, p2, p3, p4 = util.cubicRandomPoints(p1a, p1b, p4a, p4b)
    mouseTo(p1)
    mouseDown()
    util.wait(hold, 0)
    t = 0
    while t < delay:
        util.wait(DRAG_TIME_STEP, 0)
        t = min(t + util.normalRange(DRAG_TIME_STEP, DRAG_TIME_STEP / 2),
                delay)
        mouseMove(util.cubicBezier(p1, p2, p3, p4, t / delay))
    util.wait(hold, 0)
    mouseUp()
Esempio n. 9
0
    def loopLogi(self):
        m = self.scripts['logi']
        while True:
            if Machine.dead:
                sys.exit()

            if m.checkState('logi1') or m.checkState('logi2'):
                Controller.state['waiting'] = max(0, Controller.state['waiting'] - 1)
                while m.checkState('logi1') or m.checkState('logi2'):
                    m.forceRun('logi2')
                    if m.checkState('logi1'):
                        util.wait(0.4)
                    elif m.checkState('logi2'):
                        util.wait(0.2)
            util.wait(0.4)
Esempio n. 10
0
 def swap(self, gFrom, gTo, wait=0.1):
     m = self.scripts['fight']
     pFrom = m.state['g' + str(gFrom)].function['data']['points']
     pTo = m.state['g' + str(gTo)].function['data']['points']
     mouse.rDrag(*pFrom, *pTo, delay=0.12)
     util.wait(wait)
Esempio n. 11
0
 def closeLogi(self):
     m = self.scripts['common']
     while not m.checkState('home'):
         m.forceRun('logi opened')
         util.wait(2)
Esempio n. 12
0
 def openLogi(self):
     m = self.scripts['common']
     while not m.checkState('logi opened'):
         m.forceRun('open logi')
         util.wait(2)
Esempio n. 13
0
 def waitState(self, name, inverse=False, delay=0.1, some=False, fn=None):
     while not (self.checkState(name, some, fn) ^ inverse):
         util.wait(delay)
Esempio n. 14
0
 def test_wait(self):
     print(sum([util.wait(0) for _ in range(TRIALS_SHORT)]) / TRIALS_SHORT)