Code readability improved

This commit is contained in:
mrbesen 2017-10-26 14:07:45 +02:00
parent 963af8b78e
commit da8216d521
1 changed files with 16 additions and 8 deletions

View File

@ -51,7 +51,7 @@ public class Clicker implements Runnable{
return; return;
try { try {
if(ms > 1000) { if(ms > 1000) {
Thread.sleep(1000); Thread.sleep(1000);//split the sleep time.
sleep(ms-1000); sleep(ms-1000);
} else } else
Thread.sleep(ms); Thread.sleep(ms);
@ -163,13 +163,13 @@ public class Clicker implements Runnable{
clickL(rob, end);//ok button clickL(rob, end);//ok button
backfocus(rob); backfocus(rob);
Main.get().ui.info("Battle ended."); Main.get().ui.info("Battle ended.");
sleep(9000);//9 sec-loading screen sleep(7000);//7 sec-loading screen
//checken, ob Arena wechsel pop-up //checken, ob Arena wechsel pop-up
while(checkOK(arena_switch, rob,arena_view) & should_run) { while(checkOK(arena_switch, rob,arena_view) & should_run) {
System.out.println("Arena found, clicking"); System.out.println("Arena found, clicking");
clickL(rob, arena_switch); clickL(rob, arena_switch);
backfocus(rob); backfocus(rob);
sleep(2000); sleep(2000);//wait 2 seconds
} }
} }
} catch (AWTException e) { } catch (AWTException e) {
@ -276,18 +276,26 @@ public class Clicker implements Runnable{
return (end != null & battle != null); return (end != null & battle != null);
} }
/**
* Perform a Leftclick.
* @param b the Robot to use
* @param a the Position to click
*/
private void clickL(Robot b, Point a) { private void clickL(Robot b, Point a) {
if(!should_run) if(!should_run)
return; return;
Point old = getMouse(); Point old = getMouse();
b.mouseMove(a.x, a.y); b.mouseMove(a.x, a.y);
sleep(50); sleep(waittime);
clickL(b); clickL(b);
sleep(50);
b.mouseMove(old.x, old.y); b.mouseMove(old.x, old.y);
sleep(50); sleep(waittime);
} }
/**
* Perform a Leftclick
* @param b
*/
private void clickL(Robot b) {//40 ms delay private void clickL(Robot b) {//40 ms delay
b.mousePress(InputEvent.BUTTON1_MASK); b.mousePress(InputEvent.BUTTON1_MASK);
sleep(waittime); sleep(waittime);
@ -327,7 +335,7 @@ public class Clicker implements Runnable{
} }
} }
// System.out.println("counts: " + count);//some performance checking System.out.println("counts: " + count);//some performance checking
return count > 4;//engough pixel have the right color return count > 4;//engough pixel have the right color
} }
@ -364,7 +372,7 @@ public class Clicker implements Runnable{
arena_view = c; arena_view = c;
break; break;
} }
if(mincolordistance < minimumdistance)//enlarging min distance required if(mincolordistance < minimumdistance)//enlarging mindistance
mincolordistance = minimumdistance; mincolordistance = minimumdistance;
System.out.println(colornum + ": "+c.getRed() + " " + c.getGreen() + " " + c.getBlue()); System.out.println(colornum + ": "+c.getRed() + " " + c.getGreen() + " " + c.getBlue());
} }