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) ctr.pause(0.2) print(f"Picking {i + 1}th egg(s)") ctr.A() ctr.pause(1)
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()
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()