自动采集

wjdr
wangbing 1 year ago
parent 7a029ee49c
commit ddc422c658

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 570 KiB

@ -442,7 +442,7 @@ public abstract class JMacro {
} }
} }
} }
if (maxSimilar > 0.5D) { if (maxSimilar > 0.1D) {
Logger.info("最大相似度{}", NumberUtil.formatPercent(maxSimilar, 0)); Logger.info("最大相似度{}", NumberUtil.formatPercent(maxSimilar, 0));
} }
return null; return null;
@ -668,10 +668,20 @@ public abstract class JMacro {
* @return * @return
*/ */
public ViewRect waitAndMatchLegend(Legend legend, double minSimilar, long seconds) { public ViewRect waitAndMatchLegend(Legend legend, double minSimilar, long seconds) {
Logger.info("等待并匹配图例:{}", legend.getName()); BufferedImage image = ImageUtil.load(legend.getFile());
// 获取图例相对坐标
int offsetX = legend.getLocation().getX();
int offsetY = legend.getLocation().getY();
// 根据原点计算图例绝对坐标
ViewRect viewRect = new ViewRect();
viewRect.setLeft(getFocusRect().getLeft() + offsetX);
viewRect.setTop(getFocusRect().getTop() + offsetY);
viewRect.setRight(viewRect.getLeft() + image.getWidth());
viewRect.setBottom(viewRect.getTop() + image.getHeight());
Logger.info("等待并匹配图例:{},区域:{}", legend.getName(), viewRect);
return TaskUtil.timeTask(() -> { return TaskUtil.timeTask(() -> {
while (JMainService.getInstance().run) { while (JMainService.getInstance().run) {
ViewRect result = findPic(getFocusRect(), legend.getImage(), minSimilar); ViewRect result = findPic(viewRect, image, minSimilar);
if (result != null) { if (result != null) {
return result; return result;
} }

@ -70,11 +70,11 @@ public class ViewRect {
} }
public int getWidth() { public int getWidth() {
return this.right - this.left; return this.right - this.left + 1;
} }
public int getHeight() { public int getHeight() {
return this.bottom - this.top; return this.bottom - this.top + 1;
} }
public int[] getCenter() { public int[] getCenter() {

@ -107,7 +107,7 @@ public class PickPoint extends JFrame {
Logger.info("用法示例:"); Logger.info("用法示例:");
Logger.info("1、点击坐标mouseLeftClick(of({},{}));", x - originX, y - originY); Logger.info("1、点击坐标mouseLeftClick(of({},{}));", x - originX, y - originY);
Logger.info("2、色值比对matchColor(of({},{},{}));", x - originX, y - originY, hexColor); Logger.info("2、色值比对matchColor(of({},{},\"#{}\"));", x - originX, y - originY, hexColor);
Logger.info("=========================坐标采集========================="); Logger.info("=========================坐标采集=========================");
close(); close();

@ -6,10 +6,7 @@ import xyz.wbsite.jmacro.JMacro;
import xyz.wbsite.jmacro.JMainService; import xyz.wbsite.jmacro.JMainService;
import xyz.wbsite.jmacro.base.ViewRect; import xyz.wbsite.jmacro.base.ViewRect;
import xyz.wbsite.jmacro.util.Logger; import xyz.wbsite.jmacro.util.Logger;
import xyz.wbsite.jmacro.wjdr.task.Task_; import xyz.wbsite.jmacro.wjdr.task.*;
import xyz.wbsite.jmacro.wjdr.task.Task_;
import xyz.wbsite.jmacro.wjdr.task.Task_;
import xyz.wbsite.jmacro.wjdr.task.Task_;
/** /**
* *
@ -91,6 +88,12 @@ public class MacroForWJDR extends JMacro {
// 避难者 // 避难者
new Task_(this, focusRect).run(); new Task_(this, focusRect).run();
// 邮箱礼包领取
new Task_(this, focusRect).run();
// 探险领取
new Task_(this, focusRect).run();
// 自动采矿任务 // 自动采矿任务
new Task_(this, focusRect).run(); new Task_(this, focusRect).run();
} }

@ -16,8 +16,8 @@ public class Task_定位城镇 extends BaseTask {
{// 野外返回 {// 野外返回
ViewRect rect = macro.matchLegend("野外", 0.9); ViewRect rect = macro.matchLegend("野外", 0.9);
if (rect != null) { if (rect != null) {
macro.mouseLeftClick(rect);
Logger.info("当前位置:城镇"); Logger.info("当前位置:城镇");
macro.delay(1000);
return; return;
} }
} }

@ -21,7 +21,7 @@ public class Task_收留避难者 extends BaseTask {
Logger.info("收留避难者"); Logger.info("收留避难者");
macro.mouseLeftClick(rect); macro.mouseLeftClick(rect);
ViewRect rect1 = macro.waitAndMatchLegend("城镇_欢迎新成员", 0.9, 2000); ViewRect rect1 = macro.waitAndMatchLegend("城镇_欢迎新成员", 0.9, 2);
if (rect1 == null) { if (rect1 == null) {
Logger.info("收留避难者异常"); Logger.info("收留避难者异常");
return; return;

@ -0,0 +1,57 @@
package xyz.wbsite.jmacro.wjdr.task;
import xyz.wbsite.jmacro.JMacro;
import xyz.wbsite.jmacro.base.ViewRect;
import xyz.wbsite.jmacro.util.Logger;
public class Task_ extends BaseTask {
public Task_(JMacro macro, ViewRect viewRect) {
super(macro, viewRect);
}
@Override
public void task(JMacro macro, ViewRect viewRect) {
Logger.info("检测邮箱待领取礼包");
boolean b = macro.matchColor(macro.of(505, 750, "#fd3939"));
if (!b) {
Logger.info("邮箱无待领取礼包");
return;
}
Logger.info("点击邮箱");
macro.mouseLeftClick(macro.of(505, 750));
macro.delay(1000);
// todo 战争
// todo 联盟
// todo 系统
// 报告
if (macro.matchColor(macro.of(398,71,"#ff3a3a"))){
macro.mouseLeftClick(macro.of(398, 71));
macro.delay(500);
ViewRect = macro.waitAndMatchLegend("一键已读领取", 0.9);
if ( == null) {
Logger.info("异常结束");
return;
}
macro.mouseLeftClick();
ViewRect 退 = macro.waitAndMatchLegend("点击任意位置退出", 0.9);
if (退 == null) {
Logger.info("异常结束");
return;
}
macro.mouseLeftClick(退);
}
ViewRect rect = macro.matchLegend("返回", 0.9);
if (rect != null) {
macro.mouseLeftClick(rect);
Logger.info("返回城镇");
}
}
}
Loading…
Cancel
Save

Powered by TurnKey Linux.