自动采集

wjdr
wangbing 1 year ago
parent 192b1f538c
commit 220d5ee1b9

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

@ -137,7 +137,7 @@ public abstract class JMacro {
double absY = Math.abs(startY - endY); double absY = Math.abs(startY - endY);
double absZ = Math.sqrt(Math.pow(absX, 2) + Math.pow(absY, 2)); double absZ = Math.sqrt(Math.pow(absX, 2) + Math.pow(absY, 2));
int times = (int) (absZ / 10 + (absZ % 10 > 0 ? 1 : 0)); int times = (int) (absZ / 10 + (absZ % 10 > 0 ? 1 : 0));
int interval = Math.min(500 / times, 10); int interval = Math.max(500 / times, 10);
times = Math.min(times, 10); times = Math.min(times, 10);
// 分times次移动到指定点 // 分times次移动到指定点
@ -171,7 +171,7 @@ public abstract class JMacro {
* @param rect * @param rect
*/ */
public void mouseLeftClick(ViewRect rect) { public void mouseLeftClick(ViewRect rect) {
mouseLeftClick(new ViewPoint(rect.getCenter()[0], rect.getCenter()[1])); mouseLeftClick(new ViewPoint(rect.getCenter().getX(), rect.getCenter().getY()));
} }
/** /**
@ -235,7 +235,7 @@ public abstract class JMacro {
*/ */
public void mouseWheelClick(ViewRect rect) { public void mouseWheelClick(ViewRect rect) {
delayUnstable(); delayUnstable();
robot.mouseMove(rect.getCenter()[0], rect.getCenter()[1]); robot.mouseMove(rect.getCenter().getX(), rect.getCenter().getY());
delayUnstable(); delayUnstable();
robot.mousePress(InputEvent.BUTTON2_DOWN_MASK); robot.mousePress(InputEvent.BUTTON2_DOWN_MASK);
delayUnstable(); delayUnstable();
@ -249,7 +249,7 @@ public abstract class JMacro {
*/ */
public void mouseRightClick(ViewRect rect) { public void mouseRightClick(ViewRect rect) {
delayUnstable(); delayUnstable();
robot.mouseMove(rect.getCenter()[0], rect.getCenter()[1]); robot.mouseMove(rect.getCenter().getX(), rect.getCenter().getY());
delayUnstable(); delayUnstable();
robot.mousePress(InputEvent.BUTTON3_DOWN_MASK); robot.mousePress(InputEvent.BUTTON3_DOWN_MASK);
delayUnstable(); delayUnstable();
@ -263,7 +263,7 @@ public abstract class JMacro {
*/ */
public void mouseLeftDoubleClick(ViewRect rect) { public void mouseLeftDoubleClick(ViewRect rect) {
delayUnstable(); delayUnstable();
robot.mouseMove(rect.getCenter()[0], rect.getCenter()[1]); robot.mouseMove(rect.getCenter().getX(), rect.getCenter().getY());
delayUnstable(); delayUnstable();
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
delay(100); delay(100);

@ -77,8 +77,20 @@ public class ViewRect {
return this.bottom - this.top + 1; return this.bottom - this.top + 1;
} }
public int[] getCenter() { public ViewPoint getCenter() {
return new int[]{(left + right) / 2, (top + bottom) / 2}; return new ViewPoint((left + right) / 2, (top + bottom) / 2);
}
public ViewRect offset(int offsetX, int offsetY) {
return new ViewRect(this.left + offsetX, this.top + offsetY, this.right + offsetX, this.bottom + offsetY);
}
public ViewRect offsetX(int offsetX) {
return new ViewRect(this.left + offsetX, this.top, this.right + offsetX, this.bottom);
}
public ViewRect offsetY(int offsetY) {
return new ViewRect(this.left, this.top + offsetY, this.right, this.bottom + offsetY);
} }
@Override @Override

@ -25,7 +25,7 @@ public class MacroForWJDR extends JMacro {
/** /**
* *
*/ */
private final String workEnd = "24:00:00"; private final String workEnd = "23:00:00";
/** /**
* (ms) * (ms)
@ -60,6 +60,17 @@ public class MacroForWJDR extends JMacro {
Logger.info("当前时间:{}", currentTime); Logger.info("当前时间:{}", currentTime);
if (!DateUtil.parseTime(currentTime).isIn(DateUtil.parseTime(workStart), DateUtil.parseTime(workEnd))) { if (!DateUtil.parseTime(currentTime).isIn(DateUtil.parseTime(workStart), DateUtil.parseTime(workEnd))) {
Logger.info("当前时间为非工作时间,休眠待命!"); Logger.info("当前时间为非工作时间,休眠待命!");
Logger.info("检测游戏窗口是否关闭!");
ViewRect = findLegend(getFocusRect().offsetY(-30), "无尽", 0.8);
if ( != null) {
Logger.info("游戏窗口存在,关闭窗口!");
mouseMove(.getCenter());
delay(1000);
mouseLeftClick(.getCenter());
}
Logger.info("休眠1分钟");
delay(60 * 1000); delay(60 * 1000);
return; return;
} }

@ -34,26 +34,45 @@ public class Task_仓库奖励领取 extends BaseTask {
Logger.info("滑动到底部"); Logger.info("滑动到底部");
macro.mouseLeftDrag(macro.of(158, 626), macro.of(163, 231), true); macro.mouseLeftDrag(macro.of(158, 626), macro.of(163, 231), true);
macro.delay(1000);
ViewRect _ = macro.matchLegend("仓库_补给完成", 0.9); ViewRect _ = macro.matchLegend("仓库_补给完成", 0.9);
if (_ != null) { if (_ == null) {
Logger.info("仓库补给完成,去领取"); Logger.info("关闭面板");
macro.mouseLeftClick(_); ViewRect rect = macro.matchLegend("城镇_关闭面板", 0.6);
if (rect != null) {
macro.mouseLeftClick(rect);
} else {
Logger.error("关闭面板失败");
}
return;
}
Logger.info("仓库补给完成,去领取");
macro.delay(500);
macro.mouseLeftClick(macro.of(164, 621));
macro.delay(1000);
ViewRect _ = macro.matchLegend("仓库_距离下个包裹", 0.5); Logger.info("点击领取");
macro.mouseLeftClick(macro.of(258, 433));
macro.delay(1000);
if (_ != null) { Logger.info("检测下个包裹提示");
macro.mouseLeftClick(_); ViewRect _ = macro.matchLegend("仓库_距离下个包裹", 0.5);
} if (_ != null) {
return; Logger.info("关闭下个包裹提示");
macro.mouseLeftClick(_);
macro.delay(1000);
} }
Logger.info("关闭面板"); Logger.info("检测体力宝箱");
ViewRect rect = macro.matchLegend("城镇_关闭面板", 0.6); ViewRect _ = macro.matchLegend("仓库_体力宝箱", 0.5);
if (rect == null) { if (_ == null) {
Logger.info("无体力宝箱");
return; return;
} }
macro.mouseLeftClick(rect); Logger.info("领取体力宝箱");
macro.mouseLeftClick(_);
macro.delay(1000);
} }
} }

@ -60,8 +60,20 @@ public class Task_自动练兵 extends BaseTask {
macro.mouseLeftClick(macro.of(355, 632)); macro.mouseLeftClick(macro.of(355, 632));
macro.delay(1000); macro.delay(1000);
Logger.info("检测任意位置继续");
ViewRect _ = macro.waitAndMatchLegend("兵营_任意位置继续", 0.9, 2);
if (_ != null) {
Logger.error("点击继续");
macro.mouseLeftClick(_);
macro.delay(1500);
}
ViewRect _ = macro.waitAndMatchLegend("兵营_训练", 0.9, 2);
if (_ == null) {
Logger.error("训练失败,未检测到兵营训练");
}
Logger.error("确认训练"); Logger.error("确认训练");
macro.mouseLeftClick(macro.of(396, 885)); macro.mouseLeftClick(_);
macro.delay(1000); macro.delay(1000);
ViewRect _ = macro.matchLegend("兵营_返回", 0.9D); ViewRect _ = macro.matchLegend("兵营_返回", 0.9D);
@ -143,6 +155,14 @@ public class Task_自动练兵 extends BaseTask {
macro.mouseLeftClick(macro.of(355, 632)); macro.mouseLeftClick(macro.of(355, 632));
macro.delay(1000); macro.delay(1000);
Logger.info("检测任意位置继续");
ViewRect _ = macro.waitAndMatchLegend("兵营_任意位置继续", 0.9, 2);
if (_ != null) {
Logger.error("点击继续");
macro.mouseLeftClick(_);
macro.delay(1500);
}
ViewRect _ = macro.waitAndMatchLegend("兵营_训练", 0.9, 2); ViewRect _ = macro.waitAndMatchLegend("兵营_训练", 0.9, 2);
if (_ == null) { if (_ == null) {
Logger.error("训练失败,未检测到兵营训练"); Logger.error("训练失败,未检测到兵营训练");
@ -230,6 +250,14 @@ public class Task_自动练兵 extends BaseTask {
macro.mouseLeftClick(macro.of(355, 632)); macro.mouseLeftClick(macro.of(355, 632));
macro.delay(1000); macro.delay(1000);
Logger.info("检测任意位置继续");
ViewRect _ = macro.waitAndMatchLegend("兵营_任意位置继续", 0.9, 2);
if (_ != null) {
Logger.error("点击继续");
macro.mouseLeftClick(_);
macro.delay(1500);
}
ViewRect _ = macro.waitAndMatchLegend("兵营_训练", 0.9, 2); ViewRect _ = macro.waitAndMatchLegend("兵营_训练", 0.9, 2);
if (_ == null) { if (_ == null) {
Logger.error("训练失败,未检测到兵营训练"); Logger.error("训练失败,未检测到兵营训练");

@ -188,7 +188,7 @@ public class Task_自动采矿 extends BaseTask {
return false; return false;
} }
Logger.info("选择【{}】图标,坐标[{},{}]", type, typeRect.getCenter()[0], typeRect.getCenter()[1]); Logger.info("选择【{}】图标,坐标[{},{}]", type, typeRect.getCenter().getX(), typeRect.getCenter().getY());
macro.mouseLeftClick(typeRect); macro.mouseLeftClick(typeRect);
switch (level) { switch (level) {

Loading…
Cancel
Save

Powered by TurnKey Linux.