Skip to content

Commit

Permalink
Dispatch to secret main methods
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaRGB committed May 21, 2021
1 parent e6251b9 commit 97d735c
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 26 deletions.
30 changes: 23 additions & 7 deletions java/AnimalPrints/src/com/kreative/acpattern/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import java.util.Arrays;
import java.util.List;
import com.kreative.acpattern.robot.PatternBot;
import com.kreative.acpattern.robot.SwitchControl;
import com.kreative.acpattern.robot.WishBot;

public class Main {
public static void main(String[] args) {
Expand All @@ -10,13 +13,26 @@ public static void main(String[] args) {
return;
}
String verb = args[0].trim().toLowerCase();
if (verb.equals("convert")) {
ACConvert.main(subarray(args, 1));
} else if (verb.equals("view")) {
ACView.main(subarray(args, 1));
} else {
ACView.main(args);
}
if (verb.equals("help") || verb.equals("--help")) help();
else if (verb.equals("convert")) ACConvert.main(subarray(args, 1));
else if (verb.equals("view")) ACView.main(subarray(args, 1));
else if (verb.equals("acnhdebug")) ACNHDebug.main(subarray(args, 1));
else if (verb.equals("acnldebug")) ACNLDebug.main(subarray(args, 1));
else if (verb.equals("acqrdebug")) ACQRDebug.main(subarray(args, 1));
else if (verb.equals("acwwdebug")) ACWWDebug.main(subarray(args, 1));
else if (verb.equals("switchcontrol")) SwitchControl.main(subarray(args, 1));
else if (verb.equals("patternbot")) PatternBot.main(subarray(args, 1));
else if (verb.equals("wishbot")) WishBot.main(subarray(args, 1));
else ACView.main(args);
}

private static void help() {
System.out.println();
System.out.println("Animal Prints - View and convert Animal Crossing design patterns.");
System.out.println();
System.out.println("animalprints convert <options> <files>");
System.out.println("animalprints view <files>");
System.out.println();
}

private static String[] subarray(String[] a, int i) {
Expand Down
61 changes: 42 additions & 19 deletions java/AnimalPrints/src/com/kreative/acpattern/robot/WishBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.io.IOException;
import java.util.List;

import java.util.Scanner;
import com.kreative.acpattern.robot.SwitchController.Button;
import com.kreative.acpattern.robot.SwitchController.DPad;

Expand Down Expand Up @@ -39,30 +39,53 @@ public static void main(String[] args) {
SwitchController ctrl = new SwitchController(port.getOutputStream());
ctrl.sleep(1000);

// Deselect tool
ctrl.clickDPad(DPad.DOWN);
ctrl.clickDPad(DPad.DOWN);
ctrl.clickDPad(DPad.DOWN);
ctrl.clickDPad(DPad.DOWN);

// Highest camera angle
ctrl.nudgeRightStick(0, -1);
ctrl.nudgeRightStick(0, -1);
ctrl.nudgeRightStick(0, -1);
ctrl.nudgeRightStick(0, -1);

// Mash A
while (!Thread.interrupted()) {
ctrl.pressButton(Button.A);
ctrl.sleep(500);
ctrl.releaseButton(Button.A);
ctrl.sleep(500);
// Control loop
Scanner scan = new Scanner(System.in);
WishThread thread = null;
for (;;) {
System.out.println("Press enter to start wishing or ^D to exit.");
if (scan.hasNextLine()) scan.nextLine(); else break;
thread = new WishThread(ctrl); thread.start();
System.out.println("Press enter to stop wishing or ^D to exit.");
if (scan.hasNextLine()) scan.nextLine(); else break;
thread.interrupt(); thread = null;
}
if (thread != null) thread.interrupt();
scan.close();

// Close the serial port
ctrl.sleep(1000);
try { port.close(); }
catch (IOException e) {}
System.exit(0);
}

public static final class WishThread extends Thread {
private final SwitchController ctrl;
public WishThread(SwitchController ctrl) {
this.ctrl = ctrl;
}
@Override
public void run() {
// Deselect tool
ctrl.clickDPad(DPad.DOWN);
ctrl.clickDPad(DPad.DOWN);
ctrl.clickDPad(DPad.DOWN);
ctrl.clickDPad(DPad.DOWN);

// Highest camera angle
ctrl.nudgeRightStick(0, -1);
ctrl.nudgeRightStick(0, -1);
ctrl.nudgeRightStick(0, -1);
ctrl.nudgeRightStick(0, -1);

// Mash A
while (!Thread.interrupted()) {
ctrl.pressButton(Button.A);
ctrl.sleep(500);
ctrl.releaseButton(Button.A);
ctrl.sleep(500);
}
}
}
}

0 comments on commit 97d735c

Please sign in to comment.