自动采集

wjdr
wangbing 11 months ago
parent 731683aefa
commit fa1e325e7c

@ -7,11 +7,7 @@ import xyz.wbsite.jmacro.base.Legend;
import xyz.wbsite.jmacro.base.ViewColor; import xyz.wbsite.jmacro.base.ViewColor;
import xyz.wbsite.jmacro.base.ViewPoint; import xyz.wbsite.jmacro.base.ViewPoint;
import xyz.wbsite.jmacro.base.ViewRect; import xyz.wbsite.jmacro.base.ViewRect;
import xyz.wbsite.jmacro.util.ValueUtil; import xyz.wbsite.jmacro.util.*;
import xyz.wbsite.jmacro.util.ColorUtil;
import xyz.wbsite.jmacro.util.ImageUtil;
import xyz.wbsite.jmacro.util.Logger;
import xyz.wbsite.jmacro.util.TaskUtil;
import java.awt.*; import java.awt.*;
import java.awt.event.InputEvent; import java.awt.event.InputEvent;
@ -537,6 +533,82 @@ public abstract class JMacro {
}, seconds, TimeUnit.SECONDS); }, seconds, TimeUnit.SECONDS);
} }
/**
*
*
* @param legend
* @param minSimilar
* @return
*/
public boolean findLegendAndClick(String legend, double minSimilar) {
ViewRect matchLegend = matchLegend(legend, minSimilar);
if (matchLegend != null) {
Logger.info("点击【{}】", legend);
mouseLeftClick(matchLegend);
delay(500);
return true;
} else {
return false;
}
}
/**
*
*
* @param legend
* @param minSimilar
* @return
*/
public boolean findLegendAndClick(Legend legend, double minSimilar) {
ViewRect matchLegend = matchLegend(legend, minSimilar);
if (matchLegend != null) {
Logger.info("点击【{}】", legend);
mouseLeftClick(matchLegend);
delay(500);
return true;
} else {
return false;
}
}
/**
*
*
* @param legend
* @param minSimilar
* @return
*/
public boolean findLegendAndClick(ViewRect rect, String legend, double minSimilar) {
ViewRect matchLegend = findLegend(rect, legend, minSimilar);
if (matchLegend != null) {
Logger.info("点击【{}】", legend);
mouseLeftClick(matchLegend);
delay(500);
return true;
} else {
return false;
}
}
/**
*
*
* @param legend
* @param minSimilar
* @return
*/
public boolean findLegendAndClick(ViewRect rect, Legend legend, double minSimilar) {
ViewRect matchLegend = findLegend(rect, legend, minSimilar);
if (matchLegend != null) {
Logger.info("点击【{}】", legend);
mouseLeftClick(matchLegend);
delay(500);
return true;
} else {
return false;
}
}
/** /**
* *
* *
@ -562,6 +634,7 @@ public abstract class JMacro {
/** /**
* *
* *
* @param rect
* @param legend * @param legend
* @param minSimilar * @param minSimilar
* @return * @return
@ -573,6 +646,7 @@ public abstract class JMacro {
/** /**
* *
* *
* @param rect
* @param legend * @param legend
* @param minSimilar * @param minSimilar
* @return * @return
@ -854,7 +928,7 @@ public abstract class JMacro {
return new ViewRect[0]; return new ViewRect[0];
} }
Logger.info("等待并匹配图例组合:{}", String.join(",", legends)); Logger.info("等待并匹配图例组合:{}", String.join(",", legends));
return TaskUtil.timeTask(() -> { ViewRect[] result = TaskUtil.timeTask(() -> {
while (JMainService.getInstance().run) { while (JMainService.getInstance().run) {
ViewRect[] viewRects = matchLegends(legends, minSimilar); ViewRect[] viewRects = matchLegends(legends, minSimilar);
for (ViewRect viewRect : viewRects) { for (ViewRect viewRect : viewRects) {
@ -865,6 +939,10 @@ public abstract class JMacro {
} }
return new ViewRect[legends.length]; return new ViewRect[legends.length];
}, seconds, TimeUnit.SECONDS); }, seconds, TimeUnit.SECONDS);
if (result == null) {
result = new ViewRect[legends.length];
}
return result;
} }
/** /**

@ -121,7 +121,7 @@ public class JMainService {
// 服务停止 // 服务停止
} else { } else {
e.printStackTrace(); e.printStackTrace();
Logger.error("异常中断"); Logger.info("异常中断");
} }
} }
} }

@ -2,9 +2,11 @@ package xyz.wbsite.jmacro.util;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import xyz.wbsite.jmacro.JMainService;
/** /**
* *
*
* @author wangbing * @author wangbing
* @version 0.0.1 * @version 0.0.1
* @since 1.8 * @since 1.8
@ -19,15 +21,22 @@ public class Logger {
public static void debug(String log, Object... arg) { public static void debug(String log, Object... arg) {
if (isDebug) { if (isDebug) {
System.out.println(DateUtil.date() + " " + StrUtil.format(log, arg)); System.out.println("[DEBUG]" + DateUtil.date() + " " + StrUtil.format(log, arg));
} }
} }
public static void info(String log, Object... arg) { public static void info(String log, Object... arg) {
System.out.println(DateUtil.date() + " " + StrUtil.format(log, arg)); System.out.println("[INFO ]" + DateUtil.date() + " " + StrUtil.format(log, arg));
} }
public static void error(String log, Object... arg) { public static void error(String log, Object... arg) {
System.err.println(DateUtil.date() + " " + StrUtil.format(log, arg)); System.out.println("[ERROR]" + DateUtil.date() + " " + StrUtil.format(log, arg));
while (JMainService.getInstance().run){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
} }
} }

@ -17,11 +17,10 @@ import xyz.wbsite.jmacro.wjdr.task.*;
* @since 1.8 * @since 1.8
*/ */
public class MacroForWJDR extends JMacro { public class MacroForWJDR extends JMacro {
/** /**
* *
*/ */
private final String workStart = "07:00:00"; private final String workStart = "00:00:00";
/** /**
* *

@ -33,10 +33,16 @@ public abstract class BaseTask {
String name = getClass().getSimpleName(); String name = getClass().getSimpleName();
try { try {
Logger.info("》》》任务[{}]开始》》》", name); Logger.info("》》》任务[{}]开始》》》", name);
ViewRect rect;
do {
rect = macro.matchLegend("野外", 0.9);
if (rect == null) {
Logger.info("请返回城镇");
}
} while (rect == null);
this.task(macro, viewRect); this.task(macro, viewRect);
Logger.info("》》》任务[{}]结束》》》", name); Logger.info("》》》任务[{}]结束》》》", name);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
Logger.info("》》》任务[{}]异常中断》》》", name); Logger.info("》》》任务[{}]异常中断》》》", name);
throw e; throw e;
} }

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

@ -298,7 +298,8 @@ public class Task_自动野怪 extends BaseTask {
macro.mouseLeftClick(_); macro.mouseLeftClick(_);
macro.delay(1000); macro.delay(1000);
macro.matchLegendAndClick("野外_攻击平均配置", 0.6); boolean _ = macro.findLegendAndClick(macro.of(110, 842, 282, 909), "野外_攻击平均配置", 0.6);
if (!_) Logger.error("查找点击平均异常");
macro.delay(1000); macro.delay(1000);
boolean = macro.hasColor(macro.of(405, 899, 427, 915), "#f43b3b"); boolean = macro.hasColor(macro.of(405, 899, 427, 915), "#f43b3b");

Loading…
Cancel
Save

Powered by TurnKey Linux.