2018-01-31 00:04:07 -05:00
|
|
|
import java.awt.AWTException;
|
2018-02-02 06:27:29 -05:00
|
|
|
import java.awt.Point;
|
2018-01-31 00:04:07 -05:00
|
|
|
|
2018-02-02 06:27:29 -05:00
|
|
|
public class CursorTask {
|
2018-01-31 00:04:07 -05:00
|
|
|
|
2018-02-02 06:27:29 -05:00
|
|
|
public static final int DROP_OFFSET = 40;
|
2018-02-02 12:17:47 -05:00
|
|
|
public static final int DROP_BOTTOM_ROW = 539;
|
2018-02-02 06:27:29 -05:00
|
|
|
|
2018-02-02 12:56:34 -05:00
|
|
|
|
|
|
|
// Human drop time: 29 seconds
|
2018-02-19 16:12:25 -05:00
|
|
|
// Measured: 30 seconds, 29 seconds, 28
|
|
|
|
public void optimizedDropAllItemsInInventory(Cursor cursor, Inventory inventory) throws Exception {
|
2018-02-02 12:56:34 -05:00
|
|
|
for (int row = 0; row < 4; row++) {
|
|
|
|
Point coordinatesToClick = dropItem(cursor, inventory, row, 0);
|
|
|
|
for (int column = 1; column < 7; column++) {
|
2018-02-19 16:12:25 -05:00
|
|
|
if (distanceBetweenPoints(coordinatesToClick, inventory.getClickCoordinatesForInventorySlot(row, column)) > 12) {
|
|
|
|
coordinatesToClick = inventory.getClickCoordinatesForInventorySlot(row, column);
|
2018-02-02 12:56:34 -05:00
|
|
|
}
|
|
|
|
rightClickItemSlot(cursor, coordinatesToClick);
|
|
|
|
coordinatesToClick = leftClickDropOption(cursor, coordinatesToClick, column);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private int distanceBetweenPoints(Point a, Point b) {
|
|
|
|
return (int) (Math.hypot(a.x - b.x, a.y - b.y));
|
|
|
|
}
|
|
|
|
|
2018-03-13 06:43:04 -04:00
|
|
|
public void dropOre(Cursor cursor, Inventory inventory) throws Exception {
|
|
|
|
dropItem(cursor, inventory, 0, 0);
|
|
|
|
}
|
|
|
|
|
2018-02-19 16:12:25 -05:00
|
|
|
public void dropAllItemsInInventory(Cursor cursor, Inventory inventory) throws Exception {
|
2018-02-02 06:27:29 -05:00
|
|
|
for (int row = 0; row < 4; row++) {
|
|
|
|
for (int column = 0; column < 7; column++) {
|
|
|
|
dropItem(cursor, inventory, row, column);
|
2018-01-31 00:04:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-01-31 00:45:08 -05:00
|
|
|
|
2018-02-02 12:17:47 -05:00
|
|
|
|
2018-02-19 16:12:25 -05:00
|
|
|
public Point dropItem(Cursor cursor, Inventory inventory, int row, int column) throws Exception {
|
|
|
|
Point coordinatesToRightClick = inventory.getClickCoordinatesForInventorySlot(row, column);
|
2018-02-02 12:56:34 -05:00
|
|
|
Point clickedCoordinates = rightClickItemSlotWithRandomness(cursor, coordinatesToRightClick);
|
|
|
|
return leftClickDropOption(cursor, clickedCoordinates, column);
|
|
|
|
}
|
|
|
|
|
2018-02-19 16:12:25 -05:00
|
|
|
public void rightClickItemSlot(Cursor cursor, Point coordinatesToRightClick) throws Exception {
|
2018-02-02 12:56:34 -05:00
|
|
|
cursor.moveAndRightClickAtCoordinates(coordinatesToRightClick);
|
2018-02-02 06:27:29 -05:00
|
|
|
}
|
|
|
|
|
2018-02-19 16:12:25 -05:00
|
|
|
public Point rightClickItemSlotWithRandomness(Cursor cursor, Point coordinatesToRightClick) throws Exception {
|
2018-02-02 12:56:34 -05:00
|
|
|
Point clickedCoordinates = cursor.moveAndRightlickAtCoordinatesWithRandomness(coordinatesToRightClick, 6, 6);
|
2018-02-02 12:17:47 -05:00
|
|
|
return clickedCoordinates;
|
2018-02-02 06:27:29 -05:00
|
|
|
}
|
|
|
|
|
2018-02-19 16:12:25 -05:00
|
|
|
private Point leftClickDropOption(Cursor cursor, Point coordinatesToLeftClick, int column) throws Exception {
|
2018-02-02 06:27:29 -05:00
|
|
|
Point offsetCoordinatesToLeftClick = coordinatesToLeftClick;
|
2018-02-02 12:17:47 -05:00
|
|
|
if (column < 6) {
|
2018-02-02 06:27:29 -05:00
|
|
|
offsetCoordinatesToLeftClick.y += DROP_OFFSET;
|
|
|
|
}
|
|
|
|
else {
|
2018-02-02 12:17:47 -05:00
|
|
|
offsetCoordinatesToLeftClick.y = DROP_BOTTOM_ROW;
|
2018-02-02 06:27:29 -05:00
|
|
|
}
|
2018-02-19 16:12:25 -05:00
|
|
|
System.out.println("foudn where to click...");
|
|
|
|
return cursor.moveAndLeftClickAtCoordinatesWithRandomness(offsetCoordinatesToLeftClick, 13, 10, 6);
|
2018-01-31 00:45:08 -05:00
|
|
|
}
|
2018-01-31 00:04:07 -05:00
|
|
|
}
|