Advertisement
Guest User

Ugly java code

a guest
Apr 12th, 2018
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.27 KB | None | 0 0
  1. import java.awt.AWTException;
  2. import java.awt.MouseInfo;
  3. import java.awt.Robot;
  4. import java.awt.Toolkit;
  5. import java.awt.event.InputEvent;
  6. import java.awt.event.KeyEvent;
  7. import java.awt.event.MouseEvent;
  8. import java.util.Arrays;
  9. import java.util.Random;
  10.  
  11. public class A {
  12.    
  13.     private static Robot bot;
  14.    
  15.    
  16.    
  17.     private static int[][] clickList = new int[][]{
  18.             {691, 308, 100}, //tutorial
  19.             {1176, 843, 100}, //play tutorial
  20.             {934, 202, 5500},
  21.             {1266, 942},
  22.             {1229, 764},
  23.             {948, 930},
  24.             {942, 202},
  25.             {724, 471},
  26.             {970, 205},
  27.             {730, 477},
  28.             {958, 203, 100},
  29.             {955, 203},
  30.             {955, 203},
  31.             {226, 1002},
  32.             {961, 208, 3500},
  33.             {1157, 923},
  34.             {1130, 753},
  35.             {1077, 940},
  36.             {632, 572},
  37.             {225, 996},
  38.             {954, 212, 3500},
  39.             {951, 209},
  40.             //{955, 209},
  41.             {732, 470},
  42.             {804, 372},
  43.             {1057, 942},
  44.             {789, 570},
  45.             {221, 1003},
  46.             {940, 1001, 4500}};
  47.    
  48.     private static Times[] timeList = new Times[]{
  49.         Times.CLICKTHROUGH,//Tutorial
  50.         Times.CLICKTHROUGH,//play tutorial
  51.         Times.TURN,//wait for turn to start, then click dialogue
  52.         Times.CLICKTHROUGH,//no need to wait before first card action - clicking ranger
  53.         Times.CARD,//should wait a sec before saccing
  54.         Times.CARD,//wait before rat
  55.         Times.CLICKTHROUGH,//click dialogue
  56.         Times.CLICKTHROUGH, //click dialogue provided enough pause for play rat
  57.         Times.CARD,//dialogue after summon should wait a sec
  58.         Times.CLICKTHROUGH, //click on rat
  59.         Times.CLICKTHROUGH,//click on dialogue
  60.         Times.CLICKTHROUGH,//click on dialogue
  61.         Times.CLICKTHROUGH,//click on dialogue
  62.         Times.CLICKTHROUGH,//click on end turn button
  63.         Times.TURN, //wait for short turn by tootsie to click dialogue
  64.         Times.CLICKTHROUGH, //click sacranger
  65.         Times.CARD, //wait for sac
  66.         Times.CARD,//select ranger
  67.         Times.CARD, //play ranger
  68.         Times.CARD, //end turn
  69.         Times.TURN, //wait for short tootsie turn
  70.         Times.CLICKTHROUGH, //dialogue select
  71.         Times.CLICKTHROUGH, //rat click
  72.         Times.CARD, //rat move
  73.         Times.CARD, //wolf click
  74.         Times.CARD, //wolf play
  75.         Times.CARD, //end turn
  76.         Times.TURN //end game
  77.     };
  78.    
  79.     public enum Times{
  80.        
  81.        
  82.         CLICKTHROUGH(100), SHORTTURN(3000), TURN(6000), CARD(1000);
  83.        
  84.         private int time = 0;
  85.        
  86.         private Times(int time){
  87.             this.time = time;
  88.         }
  89.        
  90.         public int getTime(){
  91.             return time;
  92.         }
  93.        
  94.     }
  95.    
  96.     public static void main(String[] args) throws AWTException, InterruptedException{
  97.         System.out.println(timeList.length +" " + clickList.length);
  98.         bot = new Robot();
  99.         Random r = new Random();
  100.        
  101.        
  102.         int i = -1;
  103.        
  104.         Thread.sleep(7000);
  105.         while(true){
  106.            
  107.             i++;
  108.             if(i==clickList.length){
  109.                 i = 0;
  110.                 System.out.println("Objective completed");
  111.                
  112.                 Thread.sleep(r.nextInt(5000));
  113.                 click(1288, 367);
  114.             }
  115.             //if(i>12)Thread.sleep(3000);
  116.             Thread.sleep((int) (timeList[i].getTime() * ((r.nextFloat()/2)+1)));
  117.             Toolkit.getDefaultToolkit().beep();
  118.             /*if(clickList[i].length == 3){
  119.                 Thread.sleep(clickList[i][2]);
  120.                 //((Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.start")).run();;
  121.             }else{
  122.                 Thread.sleep(1000);
  123.                 //Toolkit.getDefaultToolkit().beep();
  124.             }*/
  125.             //Thread.sleep(r.nextInt(100));
  126.            
  127.             if(MouseInfo.getPointerInfo().getLocation().x < 10) break;
  128.             System.out.println("Click number " + i + " at coords " + clickList[i][0] + ", " + clickList[i][1] + " after delay " + timeList[i].name());
  129.            
  130.             click(clickList[i][0], clickList[i][1]);
  131.            
  132.         }
  133.        
  134.        
  135.         /*while(true){
  136.             Thread.sleep(5000);
  137.             if(true){
  138.                 Toolkit.getDefaultToolkit().beep();
  139.                 //int offset = r.nextInt(11) - 5;
  140.                 System.out.println("{" + (MouseInfo.getPointerInfo().getLocation().x) + ", " + (MouseInfo.getPointerInfo().getLocation().y) + "}" +", ");
  141.                 Thread.sleep(5000);
  142.             }
  143.         }*/
  144.        
  145.     }
  146.    
  147.     private static boolean mouseDown = false;
  148.    
  149.     public void mousePressed(MouseEvent e) {
  150.         if (e.getButton() == MouseEvent.BUTTON1) {
  151.             mouseDown = true;
  152.         }
  153.     }
  154.  
  155.     public void mouseReleased(MouseEvent e) {
  156.         if (e.getButton() == MouseEvent.BUTTON1) {
  157.             mouseDown = false;
  158.         }
  159.     }
  160.  
  161.    
  162.     public static void click(int x, int y){
  163.         int mask = InputEvent.BUTTON1_DOWN_MASK;
  164.         bot.mouseMove(x, y);
  165.         bot.mousePress(mask);
  166.         bot.mouseRelease(mask);
  167.     }
  168. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement