def __init__(self, cycle): super(EggHatcher, self).__init__() self.m_Cycle = cycle self.m_CurCol = 0 self.m_nxCtrl = Controller(printout=True) self.m_nxCtrl.LS() self.m_nxCtrl.pause(2)
def __init__(self, startDate, skipFrameNum): super(TimeSkipper, self).__init__() self.m_curDate = startDate self.m_skipFrameNum = skipFrameNum self.m_nxCtrl = Controller(printout=True) self.m_nxCtrl.LS() self.m_nxCtrl.pause(2) self.m_timeClickDuration = 0.005 self.m_nxCtrl.buttondelay = 0.02
def save(ctrl: Controller): ctrl.X() ctrl.pause(0.5) ctrl.R() ctrl.pause(1.5) ctrl.A() ctrl.pause(4)
from NXController import Controller ctr = Controller() N = 90 # Number of Pokemon for ii in range(N): print(f'{ii+1}/{N} released') ctr.A() ctr.pause(0.1) ctr.u() ctr.u() ctr.A() ctr.pause(0.7) ctr.u() ctr.A() ctr.pause(1.3) ctr.A() # Move to next ctr.r() # Change row if ii % 6 == 5: ctr.r() ctr.d() # Change boxs if ii % 30 == 29: ctr.R() ctr.d() ctr.d()
class TimeSkipper(object): """ 过帧控制,起始状态要在坑前定位 """ def __init__(self, startDate, skipFrameNum): super(TimeSkipper, self).__init__() self.m_curDate = startDate self.m_skipFrameNum = skipFrameNum self.m_nxCtrl = Controller(printout=True) self.m_nxCtrl.LS() self.m_nxCtrl.pause(2) self.m_timeClickDuration = 0.005 self.m_nxCtrl.buttondelay = 0.02 def start_skip_frame(self): self.save(collectWatt=False) firstOpenTime = True for i in range(self.m_skipFrameNum): print("Current Skip = %s, Date = %s" % (i, self.m_curDate)) self.skip_one_frame(firstOpenTime) firstOpenTime = False self.m_curDate = self.m_curDate + datetime.timedelta(days=1) # 1.1/4.1/8.1各保存一次,防崩溃 if self.m_curDate.day == 1 and (self.m_curDate.month == 1 or self.m_curDate.month == 4 or self.m_curDate.month == 8): print("Save Date = %s" % self.m_curDate) self.save() firstOpenTime = True self.save() print("Skip Frame Finished!!!") def close_controller(self): self.m_nxCtrl.release() self.m_nxCtrl.close() def skip_one_frame(self, firstOpenTime=False): self.m_nxCtrl.A(0.15) self.m_nxCtrl.pause(0.1) self.skip_time_from_year(firstOpenTime) def skip_time_from_year(self, firstOpenTime=False): tmpDate = self.m_curDate + datetime.timedelta(days=1) # 跨年,年跳1 if tmpDate.year > self.m_curDate.year: # 不是首次点开时间,要回退到年位置 if not firstOpenTime: for i in range(5): self.m_nxCtrl.l() self.pause_skip_time() firstOpenTime = True self.m_nxCtrl.u() self.pause_skip_time() if firstOpenTime: self.m_nxCtrl.r() self.pause_skip_time() self.skip_time_from_month(firstOpenTime) def skip_time_from_month(self, firstOpenTime=False): # 跨月,月跳1 lastMonthDay = self.last_day_of_month(self.m_curDate) if self.m_curDate.day == lastMonthDay.day: # 不是首次点开时间,回退到月位置 if not firstOpenTime: for i in range(4): self.m_nxCtrl.l() self.pause_skip_time() firstOpenTime = True self.m_nxCtrl.u() self.pause_skip_time() # 补全由于月份跳动没有加到的日 appendDay = 0 if self.m_curDate.day == 28: appendDay = 3 elif self.m_curDate.day == 29: appendDay = 2 elif self.m_curDate.day == 30: appendDay = 1 # 回到日位置 if appendDay > 0: self.m_nxCtrl.r() self.pause_skip_time() # 日修正 for i in range(appendDay): self.m_nxCtrl.u() self.pause_skip_time() # 回月位置 if appendDay > 0: self.m_nxCtrl.l() self.pause_skip_time() if firstOpenTime: self.m_nxCtrl.r() self.pause_skip_time() self.skip_time_from_day(firstOpenTime) def skip_time_from_day(self, firstOpenTime=False): # 不是首次点开时间,要回退到月位置 if not firstOpenTime: for i in range(3): self.m_nxCtrl.l() self.pause_skip_time() firstOpenTime = True # 日跳1 self.m_nxCtrl.u() self.pause_skip_time() for i in range(3): self.m_nxCtrl.r() self.pause_skip_time() self.m_nxCtrl.A(0.15) self.m_nxCtrl.pause(0.1) def pause_skip_time(self): self.m_nxCtrl.pause(self.m_timeClickDuration) def save(self, collectWatt=True): # 回桌面进游戏 self.m_nxCtrl.h(0.1) self.m_nxCtrl.pause(1) self.m_nxCtrl.A(0.1) self.m_nxCtrl.pause(2) # 收瓦特 if collectWatt: self.collect_watt() # 保存 self.m_nxCtrl.X(0.5) self.m_nxCtrl.pause(2) self.m_nxCtrl.R(0.5) self.m_nxCtrl.pause(2) self.m_nxCtrl.A(0.5) self.m_nxCtrl.pause(3) print("Save!!!") # 回桌面进时间界面 self.m_nxCtrl.h(0.1) self.m_nxCtrl.pause(0.5) self.m_nxCtrl.d(0.1) self.m_nxCtrl.pause(0.5) for i in range(4): self.m_nxCtrl.r(0.1) self.m_nxCtrl.pause(0.05) self.m_nxCtrl.A(0.1) self.m_nxCtrl.pause(1) self.m_nxCtrl.d(-1) self.m_nxCtrl.pause(2) self.m_nxCtrl.release() self.m_nxCtrl.r(0.1) self.m_nxCtrl.pause(0.05) # 定位到时间上 for i in range(4): self.m_nxCtrl.d(0.1) self.m_nxCtrl.pause(0.05) self.m_nxCtrl.A(0.1) self.m_nxCtrl.pause(0.5) for i in range(2): self.m_nxCtrl.d(0.1) self.m_nxCtrl.pause(0.05) def collect_watt(self): self.m_nxCtrl.A(0.1) self.m_nxCtrl.pause(2) for i in range(5): self.m_nxCtrl.B(0.1) self.m_nxCtrl.pause(1) def last_day_of_month(self, any_day): next_month = any_day.replace(day=28) + datetime.timedelta( days=4) # this will never fail return next_month - datetime.timedelta(days=next_month.day)
from NXController import Controller ctr = Controller() ## Or use your serial port if you have many # ctr = Controller('/dev/tty.usbserial-AO0099VT'); ctr.A() ctr.B() ctr.X() ctr.Y() ctr.L() ctr.R() ctr.ZL() ctr.ZR() ctr.LS() ctr.RS() ctr.PLUS() ctr.MINUS() ## long press to quit ctr.B(5) ctr.close()
from NXController import Controller ctr = Controller() for i in range(30): ctr.A() if i == 0: ctr.r() ctr.r() else: ctr.l() ctr.l() ctr.l() ctr.u() ctr.r(0.4) ctr.A() ctr.close()
from NXController import Controller # Full party lead with flame body, on your bike, egg is ready to pick # Text speed fast. No animation. cycle = 20 # Egg cycles hatchingtime = 9 # Unfreeze the game before fly, egg hatching time in seconds. 18 is safest slot = 1 # The first party slot to be replaced (1~5) N = 210 # Number of eggs to receive ctr = Controller() ctr.LS() ctr.buttondelay = 0 for i in range(N): # Fly to Day Care in Wild Area ctr.X() ctr.pause(1) if i == 0: # Select map ctr.ls_d(0.5) ctr.ls_l(0.7) ctr.A() ctr.pause(2.5) ctr.A() ctr.pause(0.5) ctr.A() ctr.pause(2.8) # Go back to Day Care ctr.ls_d(0.7) ctr.ls_r(0.2)
from NXController import Controller from tqdm_helpers import trange start_index = 1 N = 16 * 30 - 9 # Number of Pokemon with Controller() as ctr: for ii in trange(start_index - 1, N, desc="Releasing", unit="egg"): ctr.A() ctr.pause(0.5) ctr.UP() ctr.UP() ctr.A() ctr.pause(0.7) ctr.UP() ctr.A() ctr.pause(1.3) ctr.A() ctr.pause(0.3) # Move to next ctr.RIGHT() # Change row if ii % 6 == 5: ctr.RIGHT() ctr.DOWN() # Change boxs if ii % 30 == 29: ctr.R() ctr.pause(0.5)
from NXController import Controller ctr = Controller() ## Or use your serial port if you have many # ctr = Controller('/dev/tty.usbserial-AO0099VT'); # Hold two stick in the oppsite direction ctr.ls_r(-1) ctr.rs_l(-1) ctr.pause(5) ctr.release() # Backwards ctr.ls_l(-1) ctr.rs_r(-1) ctr.pause(5) ctr.release() ctr.close()
from NXController import Controller ctr = Controller() ## Or use your serial port if you have many # ctr = Controller('/dev/tty.usbserial-AO0099VT'); ctr.A() ctr.B() ctr.X() ctr.Y() ctr.L() ctr.R() ctr.ZL() ctr.ZR() ctr.LS() ctr.RS() ctr.p() ctr.m() ## long press to quit ctr.B(5) ctr.close()
class EggGetter(object): """ 起始位置定在npc左边,背包pm要全满 """ def __init__(self, eggCount): super(EggGetter, self).__init__() self.m_EggCount = eggCount self.m_nxCtrl = Controller(printout=True) self.m_nxCtrl.LS() self.m_nxCtrl.pause(2) def start_get_egg(self): for i in range(self.m_EggCount): print("Current Egg: %s" % (i + 1)) for j in range(4): self.ls_left_up(2.8) self.ls_right_up(2.83) self.m_nxCtrl.release() self.ask_egg() print("Get Egg Finished!!!") def ask_egg(self): self.m_nxCtrl.pause(1.5) self.m_nxCtrl.A() self.m_nxCtrl.pause(0.5) self.m_nxCtrl.A() self.m_nxCtrl.pause(3.5) self.m_nxCtrl.B() self.m_nxCtrl.pause(1.5) self.m_nxCtrl.B() self.m_nxCtrl.pause(1.5) self.m_nxCtrl.B() self.m_nxCtrl.pause(0.5) def ls_left_up(self, duration=0.1): self.m_nxCtrl.send('LX MIN\r\nLY MIN', duration) def ls_right_up(self, duration=0.1): self.m_nxCtrl.send('LX MAX\r\nLY MIN', duration) def close_controller(self): self.m_nxCtrl.release() self.m_nxCtrl.close()
def __init__(self, eggCount): super(EggGetter, self).__init__() self.m_EggCount = eggCount self.m_nxCtrl = Controller(printout=True) self.m_nxCtrl.LS() self.m_nxCtrl.pause(2)
from NXController import Controller ctr = Controller() for i in range(30): ctr.A() if i == 0: ctr.RIGHT() ctr.RIGHT() else: ctr.LEFT() ctr.LEFT() ctr.LEFT() ctr.UP() ctr.RIGHT(0.4) ctr.A() ctr.close()
# Text speed fast. No animation. #cycle = 20 # Egg cycles #hatchingtime = 9 # Unfreeze the game before fly, egg hatching time in seconds. 18 is safest #slot = 1 # The first party slot to be replaced (1~5) #N = 210 # Number of eggs to receive #利用5号道路长直线的原理进行孵蛋。 #使用方法:队首带一个特性为【火焰之躯】的宝可梦(例如巨碳山)。剩下五个位置全部是空的。 #然后保证当前所在的电脑箱子开始往后,全部是蛋(虽然没有应该也不会触发问题) #原理: 【根据需要孵蛋的数量N,逐次往后一箱子一箱子孵【根据箱子特征,竖排往后逐次孵完一箱【根据孵蛋周期,确定单轮5个蛋的孵化小周期】】】 #单次Hatch_time完成后,必须进行全力往右的行进,从而可以被黑色西装男挡住,进行步长偏移的消除。回归单个小周期的初始态。 Hatch_time = 20 #此处请参考宝可梦百科中的 孵化周期,必定为 15 20 25 30 35 40其中的值。。 ctr = Controller() for i in range(Hatch_time // 5): # Backwards # Hold two stick in the oppsite direction for ii in range(2): ctr.rs_l(-1) ctr.ls_r(-1) ctr.pause(4.5) ctr.release() ctr.pause(0.3) # Backwards ctr.rs_r(-1) ctr.ls_l(-1) ctr.pause(4.7) ctr.release()
from NXController import Controller ctr = Controller() ## Or use your serial port if you have many # ctr = Controller('/dev/tty.usbserial-AO0099VT'); ctr.LS() # Advance raid seed FrameCycle times FrameCycle = 5 ReturntoStartDate = True N = FrameCycle + 1 if ReturntoStartDate else FrameCycle for ii in range(N): # enter the raid ctr.A() ctr.pause(2) # quit the game and go to settings ctr.h() ctr.pause(1) ctr.d() for jj in range(4): ctr.r() ctr.A() ctr.d(2) ctr.r() for jj in range(4): ctr.d() ctr.A() # change the date ctr.d(0.4) # Scroll down to bottom
from NXController import Controller import time ctr = Controller() count = 0 goal = int(input("目標幾隻:")) print("{}開始{}".format("=" * 10, "=" * 10)) while count < goal: count += 1 print("目前第{}隻,剩餘{}隻達到目標。".format(count, goal - count)) Fossil() print("已達目標數量,共{}隻。".format(goal)) #復活化石 def Fossil(): ctr.A(1) # print("1. click A") ctr.A(1) # print("2. click A") ctr.A(1) # print("3. click A") ctr.A(1) # print("4. click A") ctr.A(1) # print("5. click A") ctr.A(5) # print("6. click A") ctr.A(1)
class EggHatcher(object): """ 初始化需要背包队伍为空,蛋箱满 """ def __init__(self, cycle): super(EggHatcher, self).__init__() self.m_Cycle = cycle self.m_CurCol = 0 self.m_nxCtrl = Controller(printout=True) self.m_nxCtrl.LS() self.m_nxCtrl.pause(2) def start_hatch_egg(self): while self.m_CurCol <= 6: print("Cur Round: %s" % self.m_CurCol) # 取蛋 self.pick_egg() if self.m_CurCol == 6: break # 孵蛋 all_range = int(self.m_Cycle / 10) for i in range(all_range): # 5rang=10周期 for j in range(5): print("周期: %s" % (i * 10 + j * 2)) self.run_round() self.m_nxCtrl.ls_r(-1) self.m_nxCtrl.ls_u(-1) for cnt in range(20 * 5): self.m_nxCtrl.B() self.m_nxCtrl.pause(0.8) self.m_nxCtrl.ls_r(-1) self.m_nxCtrl.ls_u(-1) self.m_nxCtrl.pause(6.5) self.m_nxCtrl.release() # 列数+1 self.m_CurCol = self.m_CurCol + 1 print("Patch Egg Finished!!!") def run_round(self): self.m_nxCtrl.ls_l(-1) self.m_nxCtrl.ls_u(-1) self.m_nxCtrl.pause(5.6) self.m_nxCtrl.release() # back self.m_nxCtrl.ls_r(-1) self.m_nxCtrl.ls_u(-1) self.m_nxCtrl.pause(6.3) self.m_nxCtrl.release() def switch_2_box(self): self.m_nxCtrl.X() self.m_nxCtrl.pause(1) self.m_nxCtrl.A() self.m_nxCtrl.pause(2) self.m_nxCtrl.R() self.m_nxCtrl.pause(2) self.m_nxCtrl.Y() self.m_nxCtrl.pause(0.1) self.m_nxCtrl.Y() self.m_nxCtrl.pause(0.1) self.m_nxCtrl.l() self.m_nxCtrl.pause(0.1) def back_2_road(self): for i in range(3): self.m_nxCtrl.B(2) self.m_nxCtrl.pause(0.1) def move_2_follow(self): self.m_nxCtrl.r() self.m_nxCtrl.pause(0.01) self.m_nxCtrl.A() self.m_nxCtrl.pause(0.01) self.m_nxCtrl.u() self.m_nxCtrl.pause(0.01) self.m_nxCtrl.A() self.m_nxCtrl.pause(0.01) for i in range(self.m_CurCol + 1): self.m_nxCtrl.l() self.m_nxCtrl.pause(0.01) self.m_nxCtrl.d() self.m_nxCtrl.pause(0.01) self.m_nxCtrl.A() self.m_nxCtrl.pause(0.01) def move_2_box(self): self.m_nxCtrl.d() self.m_nxCtrl.pause(0.01) self.m_nxCtrl.A() self.m_nxCtrl.pause(0.01) for i in range(2): self.m_nxCtrl.u() self.m_nxCtrl.pause(0.01) self.m_nxCtrl.A() self.m_nxCtrl.pause(0.01) for i in range(self.m_CurCol): self.m_nxCtrl.r() self.m_nxCtrl.pause(0.01) self.m_nxCtrl.u() self.m_nxCtrl.pause(0.01) self.m_nxCtrl.A() self.m_nxCtrl.pause(0.01) def pick_egg(self): print(f"Picking {self.m_CurCol + 1}th egg(s)") self.switch_2_box() if self.m_CurCol != 0: self.move_2_box() if self.m_CurCol != 6: self.move_2_follow() self.back_2_road() def close_controller(self): self.m_nxCtrl.release() self.m_nxCtrl.close()
print("存檔中...") ctr.B() time.sleep(1.5) ctr.X() time.sleep(0.6) ctr.R() time.sleep(1) ctr.A() time.sleep(3.2) print("存檔完畢") ctr.A() time.sleep(1) if __name__ == "__main__": ctr = Controller() print("{}搜尋控制器{}".format("=" * 5, "=" * 5)) ctr.LR() year, month, day = [ int(i) for i in input("輸入目前日期 (YYYY.MM.DD):").split('.') ] count, goal = 0, int(input("輸入次數:")) # 當前日期轉為datetime格式 current_date = datetime.datetime(year, month, day) isSaved = True print("{}開始執行程式{}".format("=" * 5, "=" * 5)) while count < goal: count += 1
from NXController import Controller ctr = Controller() N = 30 # Number of Pokemon in the box ctr.buttondelay = 0.2 for i in range(N): print(f'{i+1}/{N}') ctr.A() ctr.d(0.7) ctr.r(0.7) ctr.A() ctr.R() ctr.R() ctr.A() ctr.L() ctr.L() ctr.L() #ctr.p() ctr.close()
from NXController import Controller ctr = Controller() ctr.LS() ctr.A() ctr.pause(1) ctr.A() ctr.pause(1) ctr.A() ctr.pause(0.3) ctr.HOME() response = input("Restart(y/n): ") while response == 'y': ctr.X() ctr.A() ctr.pause(3) ctr.A() ctr.pause(1) ctr.A() ctr.pause(15) ctr.A() ctr.pause(7) ctr.A() ctr.pause(1) ctr.A() ctr.pause(1) ctr.A()
from NXController import Controller ctr = Controller() N = 30 # Number of Pokemon in the box ctr.buttondelay = 0.2 for i in range(N): print(f'{i+1}/{N}') ctr.A() ctr.DOWN(0.7) ctr.RIGHT(0.7) ctr.A() ctr.R() ctr.R() ctr.A() ctr.L() ctr.L() ctr.L() #ctr.p() ctr.close()
from NXController import Controller ctr = Controller() ## Or use your serial port if you have many # ctr = Controller('/dev/tty.usbserial-AO0099VT'); #for i in range(10): # ctr.ls_r(1) # ctr.pause(0.2) # ctr.ls_l(1) # ctr.pause(0.2) ctr.A()
from NXController import Controller ctr = Controller() ## Or use your serial port if you have many # ctr = Controller('/dev/tty.usbserial-AO0099VT'); # Hold two stick in the oppsite direction ctr.LS_RIGHT(-1) ctr.RS_LEFT(-1) ctr.pause(5) ctr.release() # Backwards ctr.LS_LEFT(-1) ctr.RS_RIGHT(-1) ctr.pause(5) ctr.release() ctr.close()
from NXController import Controller ctr = Controller() ## Or use your serial port if you have many # ctr = Controller('/dev/tty.usbserial-AO0099VT'); for x in range(300): for i in range(2): # Hold two stick in the oppsite direction ctr.ls_l(-1) ctr.rs_r(-1) ctr.pause(1.8) ctr.release() # Backwards ctr.ls_r(-1) ctr.rs_l(-1) ctr.pause(1.76) ctr.release() ctr.pause(0.5) ctr.A() ctr.pause(0.5) ctr.A() ctr.pause(4) ctr.B() ctr.pause(2) ctr.B() ctr.pause(1.4) ctr.B() ctr.pause(0.1) ctr.release()
ctr.A() def ChooseColor(last_hsv, hsv): Diff = int(last_hsv[4] - hsv[4]) if Diff > 0: for jj in range(Diff): ctr.R() else: for jj in range(-Diff): ctr.L() # # Reset from NXController import Controller ctr = Controller() ctr.LS() ResetCanvas() SetPalette() # Print direction = +1 last_hsv = [0, 0, 0, 255, 0] for r in range(h): if not hsv_array[r, :, 3].any(): # Skip transparent row Move2NextRow() continue for c in range(w): if direction < 0: c = w - c - 1 hsv = hsv_array[r, c]
from NXController import Controller import time ctr = Controller() ## Or use your serial port if you have many # ctr = Controller('/dev/tty.usbserial-AO0099VT'); #連續按 10次 A鍵 for i in range(10): ctr.A() ctr.close()
from NXController import Controller ctr = Controller() ## Or use your serial port if you have many # ctr = Controller('/dev/tty.usbserial-AO0099VT'); ctr.LS() # Advance raid seed FrameCycle times FrameCycle = 5 ReturntoStartDate = True N = FrameCycle + 1 if ReturntoStartDate else FrameCycle for ii in range(N): # enter the raid ctr.A() ctr.pause(2) # quit the game and go to settings ctr.HOME() ctr.pause(1) ctr.DOWN() for jj in range(4): ctr.RIGHT() ctr.A() ctr.DOWN(2) ctr.RIGHT() for jj in range(4): ctr.DOWN() ctr.A() # change the date ctr.DOWN(0.4) # Scroll down to bottom