def run(fox, state, sm, mw, pad, pop, toolbox): pad.reset() mm = p3.menu_manager.MenuManager() while True: last_frame = state.frame res = next(mw) if res is not None: sm.handle(*res) if state.frame > last_frame: if not make_action(state, pad, mm, fox): break return
def restart(self, state, pad): state.players[1].percent = 0 state.players[2].percent = 0 pad.reset() pad.press_button(Button.L) pad.press_button(Button.R) pad.press_button(Button.A) pad.press_button(Button.B) for x in range(0, 30000): pad.press_button(Button.START) pad.release_button(Button.START) pad.reset()
def make_action(state, pad, mm, fox): if state.menu == p3.state.Menu.Game: if fox.advance(state, pad, mm) == c.game['n_agents']: pad.reset() return False elif state.menu == p3.state.Menu.Characters: mm.pick_fox(state, pad) elif state.menu == p3.state.Menu.Stages: mm.press_start_lots(state, pad) elif state.menu == p3.state.Menu.PostGame: mm.press_start_lots(state, pad) return True
def make_action(state, pad, mm, fox): if state.menu == p3.state.Menu.Game: pad.release_button(p3.pad.Button.START) if fox.advance(state, pad, mm) == c.game['n_agents']: pad.reset() return False elif state.menu == p3.state.Menu.Characters: mm.pick_falcon(state, pad) print(state.players[1].character) elif state.menu == p3.state.Menu.Stages: mm.press_start_lots(state, pad) elif state.menu == p3.state.Menu.PostGame: mm.press_start_lots(state, pad) return True
def pick_self(self, state, pad): if self.selected: self.lastState = state pad.release_button(p3.pad.Button.A) else: # Go to falco and press A target_x = -29.5 target_y = 11.5 moved = self.move_stick(state, pad, target_x, target_y) if moved: pad.press_button(p3.pad.Button.A) self.selected = True # the sleep is so that the inputs don't get sent at the same time in which case the reset overrides the button press time.sleep(.02) pad.reset()
def make_action(self, state, pad, mm): if state.menu == p3.state.Menu.Game: pad.reset() return True elif state.menu == p3.state.Menu.Characters: if mm.pick_cpu(state, pad): if mm.pick_fox(state, pad): if mm.set_rules(state, pad): mm.press_start_lots(state, pad) return False elif state.menu == p3.state.Menu.Stages: mm.press_start_lots(state, pad) return False elif state.menu == p3.state.Menu.PostGame: mm.press_start_lots(state, pad) return False
def set_bot_level(self, state, pad, level=9): if self.bot_level_set: self.lastState = state pad.release_button(p3.pad.Button.A) else: target_x = 0.0 target_y = 0.0 if not self.active: # move cursor above player row to activate p2 target_x = -15.0 target_y = 1.5 moved = self.move_stick(state, pad, target_x, target_y) if moved: pad.reset() self.active = True elif not self.is_bot: target_x = -30.0 target_y = -2.2 moved = self.move_stick(state, pad, target_x, target_y) if moved: pad.press_button(p3.pad.Button.A) time.sleep(0.05) pad.reset() self.is_bot = True elif not self.bot_level_selected: # Go to bot level and press A target_x = -30.9 target_y = -15.12 moved = self.move_stick(state, pad, target_x, target_y) if moved: pad.press_button(p3.pad.Button.A) time.sleep(0.05) # pad.release_button(p3.pad.Button.A) pad.reset() self.bot_level_selected = True elif not self.bot_level_set: target_x = -31.9 + float(level)*1.1 target_y = -15.12 moved = self.move_stick(state, pad, target_x, target_y) if moved: pad.press_button(p3.pad.Button.A) time.sleep(.02) pad.reset() self.bot_level_set = True
def change_settings(self, state, pad): if self.changed_settings: pad.reset() self.press_start_lots(state, pad) else: if state.frame % 440 == 0: pad.press_button(p3.pad.Button.D_LEFT) elif state.frame % 442 == 0: pad.release_button(p3.pad.Button.D_LEFT) elif state.frame % 444 == 0: pad.press_button(p3.pad.Button.D_DOWN) elif state.frame % 446 == 0: pad.release_button(p3.pad.Button.D_DOWN) elif state.frame % 448 == 0: pad.press_button(p3.pad.Button.D_LEFT) elif state.frame % 450 == 0: pad.release_button(p3.pad.Button.D_LEFT) elif state.frame % 455 == 0: pad.press_button(p3.pad.Button.D_LEFT) elif state.frame % 460 == 0: pad.release_button(p3.pad.Button.D_LEFT) elif state.frame % 465 == 0: pad.press_button(p3.pad.Button.D_UP) elif state.frame % 470 == 0: pad.release_button(p3.pad.Button.D_UP) elif state.frame % 475 == 0: pad.press_button(p3.pad.Button.D_UP) elif state.frame % 480 == 0: pad.release_button(p3.pad.Button.D_UP) elif state.frame % 485 == 0: pad.press_button(p3.pad.Button.A) elif state.frame % 490 == 0: pad.release_button(p3.pad.Button.A) elif state.frame % 495 == 0: pad.press_button(p3.pad.Button.D_UP) elif state.frame % 500 == 0: pad.release_button(p3.pad.Button.D_UP) elif state.frame % 505 == 0: pad.press_button(p3.pad.Button.A) elif state.frame % 510 == 0: pad.release_button(p3.pad.Button.A) elif state.frame % 515 == 0: pad.press_button(p3.pad.Button.D_DOWN) elif state.frame % 520 == 0: pad.release_button(p3.pad.Button.D_DOWN) elif state.frame % 525 == 0: pad.press_button(p3.pad.Button.D_DOWN) elif state.frame % 530 == 0: pad.release_button(p3.pad.Button.D_DOWN) elif state.frame % 535 == 0: pad.press_button(p3.pad.Button.D_DOWN) elif state.frame % 540 == 0: pad.release_button(p3.pad.Button.D_DOWN) elif state.frame % 545 == 0: pad.press_button(p3.pad.Button.D_DOWN) elif state.frame % 550 == 0: pad.release_button(p3.pad.Button.D_DOWN) elif state.frame % 555 == 0: pad.press_button(p3.pad.Button.D_DOWN) elif state.frame % 560 == 0: pad.release_button(p3.pad.Button.D_DOWN) elif state.frame % 565 == 0: pad.press_button(p3.pad.Button.A) elif state.frame % 570 == 0: pad.release_button(p3.pad.Button.A) elif state.frame % 575 == 0: pad.press_button(p3.pad.Button.D_DOWN) elif state.frame % 580 == 0: pad.release_button(p3.pad.Button.D_DOWN) elif state.frame % 585 == 0: pad.press_button(p3.pad.Button.A) elif state.frame % 590 == 0: pad.release_button(p3.pad.Button.A) elif state.frame % 595 == 0: pad.press_button(p3.pad.Button.D_DOWN) elif state.frame % 600 == 0: pad.release_button(p3.pad.Button.D_DOWN) elif state.frame % 605 == 0: pad.press_button(p3.pad.Button.D_DOWN) elif state.frame % 610 == 0: pad.release_button(p3.pad.Button.D_DOWN) elif state.frame % 615 == 0: pad.press_button(p3.pad.Button.A) elif state.frame % 620 == 0: pad.release_button(p3.pad.Button.A) elif state.frame % 625 == 0: pad.press_button(p3.pad.Button.D_DOWN) elif state.frame % 630 == 0: pad.release_button(p3.pad.Button.D_DOWN) elif state.frame % 635 == 0: pad.press_button(p3.pad.Button.D_DOWN) elif state.frame % 640 == 0: pad.release_button(p3.pad.Button.D_DOWN) elif state.frame % 645 == 0: pad.press_button(p3.pad.Button.D_DOWN) elif state.frame % 650 == 0: pad.release_button(p3.pad.Button.D_DOWN) elif state.frame % 655 == 0: pad.press_button(p3.pad.Button.D_DOWN) elif state.frame % 660 == 0: pad.release_button(p3.pad.Button.D_DOWN) elif state.frame % 665 == 0: pad.press_button(p3.pad.Button.D_DOWN) elif state.frame % 670 == 0: pad.release_button(p3.pad.Button.D_DOWN) elif state.frame % 675 == 0: pad.press_button(p3.pad.Button.A) elif state.frame % 680 == 0: pad.release_button(p3.pad.Button.A) elif state.frame % 685 == 0: pad.press_button(p3.pad.Button.D_DOWN) elif state.frame % 690 == 0: pad.release_button(p3.pad.Button.D_DOWN) elif state.frame % 695 == 0: pad.press_button(p3.pad.Button.A) elif state.frame % 700 == 0: pad.release_button(p3.pad.Button.A) elif state.frame % 705 == 0: pad.press_button(p3.pad.Button.B) elif state.frame % 710 == 0: pad.release_button(p3.pad.Button.B) elif state.frame % 715 == 0: pad.press_button(p3.pad.Button.B) elif state.frame % 720 == 0: pad.release_button(p3.pad.Button.B) elif state.frame % 725 == 0: pad.press_button(p3.pad.Button.B) elif state.frame % 730 == 0: pad.release_button(p3.pad.Button.B) self.changed_settings = True
def pause(self, state, pad): pad.reset() pad.press_button(Button.START) pad.reset()