自动采集

wjdr
wangbing 1 year ago
parent ddc422c658
commit 3ef4d911b6

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 972 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 974 B

@ -370,7 +370,7 @@ public abstract class JMacro {
}
Logger.info("查找图片:{}", pic.getAbsolutePath());
BufferedImage bufferedImage = ImageUtil.load(pic);
return findPic(viewRect, bufferedImage, minSimilar);
return findPic(viewRect, bufferedImage, minSimilar, true);
}
/**
@ -379,9 +379,10 @@ public abstract class JMacro {
* @param viewRect
* @param pic
* @param minSimilar
* @param fast
* @return
*/
public ViewRect findPic(ViewRect viewRect, BufferedImage pic, double minSimilar) {
public ViewRect findPic(ViewRect viewRect, BufferedImage pic, double minSimilar, boolean fast) {
// 当聚焦区域为null时默认全屏查找
if (viewRect == null) {
viewRect = getFocusRect() != null ? getFocusRect() : getScreenRect();
@ -412,37 +413,44 @@ public abstract class JMacro {
double maxSimilar = 0;
for (int y = yMin; y <= yMax; y++) {
for (int x = xMin; x <= xMax; x++) {
// 对关键点进行先期匹配,降低运算复杂度。如果关键点本身就不匹配,就没必要再去匹配小图的每一个像素点
// 左上角
boolean lt = ColorUtil.isSimilar(screenData[x - xMin][y - yMin], picData[0][0]);
// 右上角
boolean rt = ColorUtil.isSimilar(screenData[x - xMin + pic.getWidth() - 1][y - yMin], picData[pic.getWidth() - 1][0]);
// 左下角
boolean lb = ColorUtil.isSimilar(screenData[x - xMin][y - yMin + pic.getHeight() - 1], picData[0][pic.getHeight() - 1]);
// 右下角
boolean rb = ColorUtil.isSimilar(screenData[x - xMin + pic.getWidth() - 1][y - yMin + pic.getHeight() - 1], picData[pic.getWidth() - 1][pic.getHeight() - 1]);
//中心点
boolean cc = ColorUtil.isSimilar(screenData[x - xMin + pic.getWidth() / 2][y - yMin + pic.getHeight() / 2], picData[pic.getWidth() / 2][pic.getHeight() / 2]);
if (lt && rt && lb && rb && cc) {
// 统计相似点数
int samePixels = 0;
for (int smallY = 0; smallY < pic.getHeight(); smallY++) {
for (int smallX = 0; smallX < pic.getWidth(); smallX++) {
if (ColorUtil.isSimilar(screenData[x + smallX - xMin][y + smallY - yMin], picData[smallX][smallY])) {
samePixels++;
}
}
if (fast) {
// 对关键点进行先期匹配,降低运算复杂度。如果关键点本身就不匹配,就没必要再去匹配小图的每一个像素点
// 左上角
boolean lt = ColorUtil.isSimilar(screenData[x - xMin][y - yMin], picData[0][0]);
// 右上角
boolean rt = ColorUtil.isSimilar(screenData[x - xMin + pic.getWidth() - 1][y - yMin], picData[pic.getWidth() - 1][0]);
// 左下角
boolean lb = ColorUtil.isSimilar(screenData[x - xMin][y - yMin + pic.getHeight() - 1], picData[0][pic.getHeight() - 1]);
// 右下角
boolean rb = ColorUtil.isSimilar(screenData[x - xMin + pic.getWidth() - 1][y - yMin + pic.getHeight() - 1], picData[pic.getWidth() - 1][pic.getHeight() - 1]);
//中心点
boolean cc = ColorUtil.isSimilar(screenData[x - xMin + pic.getWidth() / 2][y - yMin + pic.getHeight() / 2], picData[pic.getWidth() / 2][pic.getHeight() / 2]);
// 五个关键点不一致,则没必要继续比下去
// 但要注意四个顶点和中心存在半透明情况,会导致关键点定位不准
if (!lt || !rt || !lb || !rb || !cc) {
continue;
}
// 计算相似度
double similar = (double) samePixels / (pic.getWidth() * pic.getHeight());
maxSimilar = Math.max(maxSimilar, similar);
if (similar >= minSimilar) {
return new ViewRect(x, y, x + pic.getWidth(), y + pic.getHeight(), similar);
}
// 统计相似点数
int samePixels = 0;
for (int smallY = 0; smallY < pic.getHeight(); smallY++) {
for (int smallX = 0; smallX < pic.getWidth(); smallX++) {
if (ColorUtil.isSimilar(screenData[x + smallX - xMin][y + smallY - yMin], picData[smallX][smallY])) {
samePixels++;
}
}
}
// 计算相似度
double similar = (double) samePixels / (pic.getWidth() * pic.getHeight());
maxSimilar = Math.max(maxSimilar, similar);
if (similar >= minSimilar) {
return new ViewRect(x, y, x + pic.getWidth(), y + pic.getHeight(), similar);
}
}
}
if (maxSimilar > 0.1D) {
if (maxSimilar > 0.5D) {
ImageUtil.show(viewRect);
Logger.info("最大相似度{}", NumberUtil.formatPercent(maxSimilar, 0));
}
return null;
@ -497,7 +505,7 @@ public abstract class JMacro {
BufferedImage pic = ImageUtil.load(picFile);
return TaskUtil.timeTask(() -> {
while (JMainService.getInstance().run) {
ViewRect result = findPic(rect, pic, minSimilar);
ViewRect result = findPic(rect, pic, minSimilar, true);
if (result != null) {
return result;
}
@ -548,7 +556,7 @@ public abstract class JMacro {
*/
public ViewRect findLegend(ViewRect rect, Legend legend, double minSimilar) {
Logger.info("查找图例:{}", legend.getName());
return findPic(rect, legend.getImage(), minSimilar);
return findPic(rect, legend.getImage(), minSimilar, true);
}
/**
@ -562,7 +570,7 @@ public abstract class JMacro {
Logger.info("等待并查找图例:{}", legend.getName());
return TaskUtil.timeTask(() -> {
while (JMainService.getInstance().run) {
ViewRect result = findPic(rect, legend.getImage(), minSimilar);
ViewRect result = findPic(rect, legend.getImage(), minSimilar, true);
if (result != null) {
return result;
}
@ -645,7 +653,7 @@ public abstract class JMacro {
viewRect.setRight(viewRect.getLeft() + image.getWidth());
viewRect.setBottom(viewRect.getTop() + image.getHeight());
Logger.info("匹配图例:{},区域:{}", legend.getName(), viewRect);
return findPic(viewRect, image, minSimilar);
return findPic(viewRect, image, minSimilar, false);
}
/**
@ -681,7 +689,7 @@ public abstract class JMacro {
Logger.info("等待并匹配图例:{},区域:{}", legend.getName(), viewRect);
return TaskUtil.timeTask(() -> {
while (JMainService.getInstance().run) {
ViewRect result = findPic(viewRect, image, minSimilar);
ViewRect result = findPic(viewRect, image, minSimilar, false);
if (result != null) {
return result;
}
@ -827,12 +835,29 @@ public abstract class JMacro {
* @return
*/
public boolean matchColor(ViewColor color) {
ViewRect of = of(color.getX(), color.getY(), color.getX(), color.getY());
ViewRect rect = new ViewRect(color.getX(), color.getY(), color.getX(), color.getY());
// 获取实时屏幕
BufferedImage pointImage = capture(robot, rect);
ImageUtil.show(pointImage);
int[][] pointData = ImageUtil.getImageRGB(pointImage);
boolean similar = ColorUtil.isSimilar(pointData[0][0], color.getColor());
Logger.info("比较色值:{},{} ==> {}", Integer.toHexString(pointData[0][0]), Integer.toHexString(color.getColor()), similar ? "相似" : "不同");
return similar;
}
/**
*
*
* @param point
* @return
*/
public String takeColor(ViewPoint point) {
ViewRect of = of(point.getX(), point.getY(), point.getX(), point.getY());
// 获取实时屏幕
BufferedImage pointImage = capture(robot, of);
ImageUtil.show(pointImage);
int[][] pointData = ImageUtil.getImageRGB(pointImage);
return ColorUtil.isSimilar(pointData[0][0], color.getColor());
return "#" + Integer.toHexString(pointData[0][0]);
}
/**

@ -19,7 +19,7 @@ public class ViewColor extends ViewPoint {
/**
* @param x
* @param y
* @param hexColor argb #FFFFFF
* @param hexColor rgb #FFFFFF
*/
public ViewColor(int x, int y, String hexColor) {
super(x, y);

@ -11,13 +11,7 @@ import xyz.wbsite.jmacro.util.Logger;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.List;
@ -219,16 +213,19 @@ public class PickLegend extends JFrame {
if (returnVal == JFileChooser.APPROVE_OPTION) {
// 默认文件
File file = jFileChooser.getSelectedFile();
String name = file.getName().replaceAll("\\.png","");
String name = file.getName().replaceAll("\\.png", "");
String legendName = name.split("#")[0];
String prefix = legendName + "#";
List<File> files = FileUtil.loopFiles(Legend.getDefaultBase(), pathname -> pathname.getName().startsWith(prefix));
List<File> files = FileUtil.loopFiles(Legend.getDefaultBase(), pathname -> pathname.getName().startsWith(legendName));
if (files.size() > 0) {
DialogUtil.confirm("提示", "存在相同图例,是否旧的删除?", result -> {
if (result) {
for (File file1 : files) {
file1.deleteOnExit();
boolean delete = file1.delete();
if (!delete) {
Logger.error("删除失败,{}", file1.getAbsolutePath());
}
}
}
});

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

@ -1,5 +1,8 @@
package xyz.wbsite.jmacro.util;
import java.awt.image.BufferedImage;
import java.io.File;
/**
*
*
@ -45,14 +48,15 @@ public class ColorUtil {
* @return
*/
public static boolean isSimilar(int colorInt1, int colorInt2) {
// 透明色认为相似
if ((colorInt1 >> 24 & 0xff) == 0) {
return true;
}
// 图例中的透明色认为相似
if ((colorInt2 >> 24 & 0xff) == 0) {
return true;
}
return calculateSimilarity(colorInt1, colorInt2) > THRESHOLD_OF_SIMILARITY;
}
public static void main(String[] args) {
int color1 = 0xf6fbff; // 白色
int color2 = 0xfefefe; // 非常接近白色的颜色
double similarity = calculateSimilarity(color1, color2);
System.out.println("Similarity: " + similarity); // 输出相似度
}
}

@ -201,11 +201,18 @@ public class TaskUtil extends CronUtil {
* @param time
*/
public static <T> T timeTask(Callable<T> callable, long time, TimeUnit unit) {
Future<T> submit = null;
try {
CompletionService<T> completionService = ThreadUtil.newCompletionService();
Future<T> submit = completionService.submit(callable);
submit = completionService.submit(callable);
return submit.get(time, unit);
} catch (Exception e) {
} catch (InterruptedException e) {
return null;
} catch (ExecutionException e) {
e.printStackTrace();
return null;
} catch (TimeoutException e) {
submit.cancel(true);
return null;
}
}

@ -80,6 +80,10 @@ public class MacroForWJDR extends JMacro {
// 任意界面优先返回城镇
new Task_(this, focusRect).run();
// 检测状态
Task_ task_ = new Task_(this, focusRect);
task_.run();
// 可按优先级排序以下任务
{
// 矿场攻击检测任务
@ -89,14 +93,26 @@ public class MacroForWJDR extends JMacro {
new Task_(this, focusRect).run();
// 邮箱礼包领取
new Task_(this, focusRect).run();
if (task_.) {
new Task_(this, focusRect).run();
}
// 探险领取
new Task_(this, focusRect).run();
if (task_.) {
new Task_(this, focusRect).run();
}
// 自动练兵
new Task_(this, focusRect).run();
// 自动采矿任务
new Task_(this, focusRect).run();
if (task_.()) {
new Task_(this, focusRect).run();
}
}
Logger.info("休眠1分钟...");
delay(60 * 1000);
}
}
}

@ -21,6 +21,13 @@ public class Task_定位城镇 extends BaseTask {
return;
}
}
{// 探险返回
ViewRect rect = macro.matchLegend("探险_返回", 0.9);
if (rect != null) {
macro.mouseLeftClick(rect);
Logger.info("返回城镇");
}
}
{// 野外返回
ViewRect rect = macro.matchLegend("城镇", 0.9);
if (rect != null) {
@ -29,12 +36,19 @@ public class Task_定位城镇 extends BaseTask {
}
}
{// 其他页面返回
ViewRect rect = macro.matchLegend("返回", 0.9);
ViewRect rect = macro.matchLegend("返回", 0.5);
if (rect != null) {
macro.mouseLeftClick(rect);
Logger.info("返回城镇");
}
}
{// 侧边面板关闭
ViewRect rect = macro.matchLegend("城镇_关闭面板", 0.6);
if (rect != null) {
macro.mouseLeftClick(rect);
Logger.info("关闭侧面板");
}
}
{ // 定位弹框,关闭弹框
ViewRect rect = macro.findLegend(macro.of(437, 28, 491, 106), "城镇_礼包", 0.7);
if (rect != null) {
@ -73,7 +87,7 @@ public class Task_定位城镇 extends BaseTask {
}
}
{// 点击任务位置退出
ViewRect rect = macro.matchLegend("点击任意位置退出", 0.9);
ViewRect rect = macro.matchLegend("点击任意位置退出", 0.5);
if (rect != null) {
macro.mouseLeftClick(rect);
Logger.info("点击任意位置退出");

@ -12,21 +12,13 @@ public class Task_探险领取 extends BaseTask {
@Override
public void task(JMacro macro, ViewRect viewRect) {
Logger.info("定位【探险】按钮");
ViewRect _ = macro.waitAndMatchLegend("城镇_探险", 0.9);
if (_ == null) {
boolean = macro.matchColor(macro.of(71, 877, "#ff1e1f"));
if (!) {
Logger.info("探险奖励未满,跳过");
return;
}
Logger.info("点击【探险】按钮");
macro.mouseLeftClick(_);
ViewRect _ = macro.waitAndMatchLegend("探险_按钮", 0.9);
if (_ == null) {
Logger.info("进入探险界面失败");
return;
}
Logger.info("进入探险界面成功");
Logger.info("进入探险页面,领取奖励");
macro.mouseLeftClick(macro.of(71, 877));
ViewRect[] viewRects = macro.waitAndMatchLegends(0.9, 5, "探险_领取", "探险_不可领取");
if (viewRects[0] != null) { // 可以领取

@ -0,0 +1,108 @@
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 boolean 1;
public boolean 2;
public boolean 3;
public boolean 4;
public boolean 5;
public boolean 6;
public boolean ;
public boolean ;
public boolean ;
public boolean ;
public Task_(JMacro macro, ViewRect viewRect) {
super(macro, viewRect);
}
@Override
public void task(JMacro macro, ViewRect viewRect) {
Logger.info("读取行军状态");
{
Logger.info("检测面板状态");
ViewRect[] viewRects = macro.matchLegends(0.6, "城镇_打开面板", "城镇_关闭面板");
if (viewRects[0] == null && viewRects[1] == null) {
Logger.info("检测面板状态失败");
return;
}
if (viewRects[0] != null) {
Logger.info("打开面板");
macro.mouseLeftClick(viewRects[0]);
macro.delay(1000);
}
Logger.info("选中城镇");
macro.mouseLeftClick(macro.of(85,200));
macro.delay(1000);
// todo
Logger.info("选中野外");
macro.mouseLeftClick(macro.of(245,200));
macro.delay(1000);
ViewRect[] viewRects1 = macro.matchLegends(0.6D,
"城镇_面板_空闲1",
"城镇_面板_空闲2",
"城镇_面板_空闲3",
"城镇_面板_空闲4",
"城镇_面板_空闲5",
"城镇_面板_空闲6"
);
if (null != macro.matchLegend("城镇_面板_空闲1", 0.6D)) {
1 = true;
Logger.info("队列1空闲");
}
if (null != macro.matchLegend("城镇_面板_空闲2", 0.6D)) {
2 = true;
Logger.info("队列2空闲");
}
if (null != macro.matchLegend("城镇_面板_空闲3", 0.6D)) {
3 = true;
Logger.info("队列3空闲");
}
if (null != macro.matchLegend("城镇_面板_空闲4", 0.6D)) {
4 = true;
Logger.info("队列4空闲");
}
if (null != macro.matchLegend("城镇_面板_空闲5", 0.6D)) {
5 = true;
Logger.info("队列5空闲");
}
if (null != macro.matchLegend("城镇_面板_空闲6", 0.6D)) {
6 = true;
Logger.info("队列6空闲");
}
}
ViewRect _ = macro.matchLegend("城镇_关闭面板", 0.6);
if (_ == null) {
Logger.info("关闭面板异常");
return;
}
Logger.info("关闭面板");
macro.mouseLeftClick(_);
{// 任务奖励
= macro.matchColor(macro.of(43, 759, "#ff3939"));
}
{// 邮件奖励
= macro.matchColor(macro.of(506, 751, "#fe3939"));
}
{// 探险奖励
= macro.matchColor(macro.of(71,877,"#ff1e1f"));
}
}
public boolean () {
return 1 || 2 || 3 || 4 || 5 || 6;
}
}

@ -0,0 +1,276 @@
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) {
(macro, viewRect);
(macro, viewRect);
(macro, viewRect);
}
private void (JMacro macro, ViewRect viewRect) {
Logger.info("检测面板状态");
ViewRect[] viewRects = macro.matchLegends(0.6, "城镇_打开面板", "城镇_关闭面板");
if (viewRects == null) {
Logger.info("检测面板状态检测失败");
return;
}
if (viewRects[0] != null) {
Logger.info("打开面板");
macro.mouseLeftClick(viewRects[0]);
macro.delay(1000);
}
if (viewRects[1] != null) {
Logger.info("面板已打开");
}
Logger.info("选中城镇");
macro.mouseLeftClick(macro.of(85, 200));
macro.delay(1000);
Logger.info("检测盾兵");
ViewRect[] viewRects2 = macro.waitAndMatchLegends(0.9D, 3, "城镇_完成盾兵", "城镇_空闲盾兵");
if (viewRects2 == null) {
Logger.info("检测失败");
return;
}
if (viewRects2[0] != null) {
Logger.info("训练完成,去领取");
macro.mouseLeftClick(viewRects2[0]);
macro.delay(1000);
Logger.info("点击领取");
macro.mouseLeftClick(macro.of(268, 431));
macro.delay(1000);
Logger.info("点击兵营");
macro.mouseLeftClick(macro.of(268, 431));
macro.delay(1000);
Logger.info("点击训练");
macro.mouseLeftClick(macro.of(355, 632));
macro.delay(1000);
Logger.error("确认训练");
macro.mouseLeftClick(macro.of(396, 885));
macro.delay(1000);
ViewRect _ = macro.matchLegend("兵营_返回", 0.9D);
if (_ == null) {
Logger.error("兵营返回失败");
}
macro.mouseLeftClick(_);
macro.delay(1000);
}
if (viewRects2[1] != null) {
Logger.info("兵营空闲,去练兵");
macro.mouseLeftClick(viewRects2[1]);
Logger.info("点击训练");
macro.mouseLeftClick(macro.of(355, 632));
macro.delay(1000);
Logger.error("确认训练");
macro.mouseLeftClick(macro.of(396, 885));
macro.delay(1000);
ViewRect _ = macro.matchLegend("兵营_返回", 0.9D);
if (_ == null) {
Logger.error("兵营返回失败");
}
macro.mouseLeftClick(_);
macro.delay(1000);
}
if (viewRects2[0] != null && viewRects2[1] != null) {
Logger.info("关闭面板");
ViewRect rect = macro.matchLegend("城镇_关闭面板", 0.6);
if (rect == null) {
return;
}
macro.mouseLeftClick(rect);
}
}
private void (JMacro macro, ViewRect viewRect) {
Logger.info("检测面板状态");
ViewRect[] viewRects = macro.matchLegends(0.6, "城镇_打开面板", "城镇_关闭面板");
if (viewRects == null) {
Logger.info("检测面板状态检测失败");
return;
}
if (viewRects[0] != null) {
Logger.info("打开面板");
macro.mouseLeftClick(viewRects[0]);
macro.delay(1000);
}
if (viewRects[1] != null) {
Logger.info("面板已打开");
}
Logger.info("选中城镇");
macro.mouseLeftClick(macro.of(85, 200));
macro.delay(1000);
Logger.info("检测矛兵");
ViewRect[] viewRects2 = macro.waitAndMatchLegends(0.9D, 3, "城镇_完成矛兵", "城镇_空闲矛兵");
if (viewRects2 == null) {
Logger.info("检测失败");
return;
}
if (viewRects2[0] != null) {
Logger.info("训练完成,去领取");
macro.mouseLeftClick(viewRects2[0]);
macro.delay(1000);
Logger.info("点击领取");
macro.mouseLeftClick(macro.of(268, 431));
macro.delay(1000);
Logger.info("点击兵营");
macro.mouseLeftClick(macro.of(268, 431));
macro.delay(1000);
Logger.info("点击训练");
macro.mouseLeftClick(macro.of(355, 632));
macro.delay(1000);
ViewRect _ = macro.waitAndMatchLegend("兵营_训练", 0.9, 2);
if (_ == null) {
Logger.error("训练失败,未检测到兵营训练");
}
Logger.error("确认训练");
macro.mouseLeftClick(_);
macro.delay(1000);
ViewRect _ = macro.matchLegend("兵营_返回", 0.9D);
if (_ == null) {
Logger.error("兵营返回失败");
}
macro.mouseLeftClick(_);
macro.delay(1000);
}
if (viewRects2[1] != null) {
Logger.info("兵营空闲,去练兵");
macro.mouseLeftClick(viewRects2[1]);
Logger.info("点击训练");
macro.mouseLeftClick(macro.of(355, 632));
macro.delay(1000);
Logger.error("确认训练");
macro.mouseLeftClick(macro.of(396, 885));
macro.delay(1000);
ViewRect _ = macro.matchLegend("兵营_返回", 0.9D);
if (_ == null) {
Logger.error("兵营返回失败");
}
macro.mouseLeftClick(_);
macro.delay(1000);
}
if (viewRects2[0] != null && viewRects2[1] != null) {
Logger.info("关闭面板");
ViewRect rect = macro.matchLegend("城镇_关闭面板", 0.6);
if (rect == null) {
return;
}
macro.mouseLeftClick(rect);
}
}
private void (JMacro macro, ViewRect viewRect) {
Logger.info("检测面板状态");
ViewRect[] viewRects = macro.matchLegends(0.6, "城镇_打开面板", "城镇_关闭面板");
if (viewRects == null) {
Logger.info("检测面板状态检测失败");
return;
}
if (viewRects[0] != null) {
Logger.info("打开面板");
macro.mouseLeftClick(viewRects[0]);
macro.delay(1000);
}
if (viewRects[1] != null) {
Logger.info("面板已打开");
}
Logger.info("选中城镇");
macro.mouseLeftClick(macro.of(85, 200));
macro.delay(1000);
Logger.info("检测矛兵");
ViewRect[] viewRects2 = macro.waitAndMatchLegends(0.9D, 3, "城镇_完成射手", "城镇_空闲射手");
if (viewRects2 == null) {
Logger.info("检测失败");
return;
}
if (viewRects2[0] != null) {
Logger.info("训练完成,去领取");
macro.mouseLeftClick(viewRects2[0]);
macro.delay(1000);
Logger.info("点击领取");
macro.mouseLeftClick(macro.of(268, 431));
macro.delay(1000);
Logger.info("点击兵营");
macro.mouseLeftClick(macro.of(268, 431));
macro.delay(1000);
Logger.info("点击训练");
macro.mouseLeftClick(macro.of(355, 632));
macro.delay(1000);
ViewRect _ = macro.waitAndMatchLegend("兵营_训练", 0.9, 2);
if (_ == null) {
Logger.error("训练失败,未检测到兵营训练");
}
Logger.error("确认训练");
macro.mouseLeftClick(_);
macro.delay(1000);
ViewRect _ = macro.matchLegend("兵营_返回", 0.9D);
if (_ == null) {
Logger.error("兵营返回失败");
}
macro.mouseLeftClick(_);
macro.delay(1000);
}
if (viewRects2[1] != null) {
Logger.info("兵营空闲,去练兵");
macro.mouseLeftClick(viewRects2[1]);
Logger.info("点击训练");
macro.mouseLeftClick(macro.of(355, 632));
macro.delay(1000);
Logger.error("确认训练");
macro.mouseLeftClick(macro.of(396, 885));
macro.delay(1000);
ViewRect _ = macro.matchLegend("兵营_返回", 0.9D);
if (_ == null) {
Logger.error("兵营返回失败");
}
macro.mouseLeftClick(_);
macro.delay(1000);
}
if (viewRects2[0] != null && viewRects2[1] != null) {
Logger.info("关闭面板");
ViewRect rect = macro.matchLegend("城镇_关闭面板", 0.6);
if (rect == null) {
return;
}
macro.mouseLeftClick(rect);
}
}
}

@ -4,7 +4,6 @@ import cn.hutool.json.JSONUtil;
import xyz.wbsite.jmacro.JMacro;
import xyz.wbsite.jmacro.base.ViewRect;
import xyz.wbsite.jmacro.util.Logger;
import xyz.wbsite.jmacro.util.TaskUtil;
public class Task_ extends BaseTask {
@ -34,20 +33,6 @@ public class Task_自动采矿 extends BaseTask {
Logger.info("定位野外按钮成功");
}
Logger.info("点击资源搜索按钮");
macro.delayUnstable(1000);
macro.mouseLeftClick(macro.of(33, 648));
Logger.info("等待搜索面板");
ViewRect _ = macro.waitAndMatchLegend("野外_搜索", 0.9);
if (_ == null) {
Logger.error("未检测到【待搜索面板】,采矿终止");
return;
}
Logger.info("拖动面板");
macro.mouseLeftDrag(macro.of(433, 679), macro.of(61, 682), true);
Logger.info("开始采集资源");
String[] types = new String[]{
"生肉", "木材", "煤矿", "铁矿"
@ -81,8 +66,28 @@ public class Task_自动采矿 extends BaseTask {
* @return true,
*/
private boolean collect(String type, int level) {
Logger.info("查看放大镜搜索");
ViewRect _ = macro.waitAndMatchLegend("野外_放大镜搜索", 0.4);
if (_ == null) {
Logger.error("未检测到【放大镜搜索】,采矿终止");
return false;
}
Logger.info("点击放大镜搜索按钮");
macro.mouseLeftClick(_);
Logger.info("等待搜索面板");
ViewRect __ = macro.waitAndMatchLegend("野外_搜索面板_搜索按钮", 0.9);
if (__ == null) {
Logger.error("未检测到【待搜索面板】,采矿终止");
return false;
}
Logger.info("拖动面板");
macro.mouseLeftDrag(macro.of(433, 679), macro.of(61, 682), true);
Logger.info("定位【野外_资源搜索_{}】图标", type);
ViewRect typeRect = macro.waitAndMatchLegend("野外_资源搜索_" + type, 0.9);
ViewRect typeRect = macro.waitAndMatchLegend("野外_资源搜索_" + type, 0.9, 2);
if (typeRect == null) {
Logger.error("定位【{}】图标失败", type);
return false;
@ -91,18 +96,31 @@ public class Task_自动采矿 extends BaseTask {
Logger.info("选择【{}】图标,坐标[{},{}]", type, typeRect.getCenter()[0], typeRect.getCenter()[1]);
macro.mouseLeftClick(typeRect);
int clevel = getLevel();
if (clevel > level) {
TaskUtil.execTask(() -> {
Logger.info("调整等级");
macro.mouseLeftClick(macro.of(51, 777));
}, clevel - level, 1000);
}
if (clevel < level) {
TaskUtil.execTask(() -> {
Logger.info("调整等级");
macro.mouseLeftClick(macro.of(360, 777));
}, level - clevel, 1000);
switch (level) {
case 1:
macro.mouseLeftClick(macro.of(93, 777));
break;
case 2:
macro.mouseLeftClick(macro.of(125, 777));
break;
case 3:
macro.mouseLeftClick(macro.of(158, 777));
break;
case 4:
macro.mouseLeftClick(macro.of(192, 777));
break;
case 5:
macro.mouseLeftClick(macro.of(223, 777));
break;
case 6:
macro.mouseLeftClick(macro.of(256, 777));
break;
case 7:
macro.mouseLeftClick(macro.of(288, 777));
break;
case 8:
macro.mouseLeftClick(macro.of(321, 777));
break;
}
ViewRect _ = macro.matchLegend("野外_资源搜索", 0.9);
@ -141,14 +159,4 @@ public class Task_自动采矿 extends BaseTask {
return true;
}
private int getLevel() {
for (int i = 1; i <= 8; i++) {
ViewRect = macro.matchLegend("野外_资源等级" + i, 0.99);
if ( != null) {
return i;
}
}
return 0;
}
}

@ -13,7 +13,7 @@ public class Task_邮箱礼包领取 extends BaseTask {
@Override
public void task(JMacro macro, ViewRect viewRect) {
Logger.info("检测邮箱待领取礼包");
boolean b = macro.matchColor(macro.of(505, 750, "#fd3939"));
boolean b = macro.matchColor(macro.of(506, 751, "#fe3939"));
if (!b) {
Logger.info("邮箱无待领取礼包");
return;
@ -25,10 +25,28 @@ public class Task_邮箱礼包领取 extends BaseTask {
// todo 战争
// todo 联盟
// todo 系统
// 系统
if (macro.matchColor(macro.of(297, 70, "#fe3939"))) {
macro.mouseLeftClick(macro.of(297, 70));
macro.delay(500);
ViewRect = macro.waitAndMatchLegend("一键已读领取", 0.9, 2);
if ( == null) {
Logger.info("异常结束");
return;
}
macro.mouseLeftClick();
ViewRect 退 = macro.waitAndMatchLegend("点击任意位置退出", 0.5, 2);
if (退 != null) {
Logger.info("点击任意位置退出");
macro.mouseLeftClick(退);
macro.delay(500);
}
}
// 报告
if (macro.matchColor(macro.of(398,71,"#ff3a3a"))){
if (macro.matchColor(macro.of(398, 71, "#fe3939"))) {
macro.mouseLeftClick(macro.of(398, 71));
macro.delay(500);
@ -39,16 +57,15 @@ public class Task_邮箱礼包领取 extends BaseTask {
}
macro.mouseLeftClick();
ViewRect 退 = macro.waitAndMatchLegend("点击任意位置退出", 0.9);
if (退 == null) {
Logger.info("异常结束");
return;
ViewRect 退 = macro.waitAndMatchLegend("点击任意位置退出", 0.5, 2);
if (退 != null) {
Logger.info("点击任意位置退出");
macro.mouseLeftClick(退);
macro.delay(500);
}
macro.mouseLeftClick(退);
}
ViewRect rect = macro.matchLegend("返回", 0.9);
ViewRect rect = macro.matchLegend("邮件_返回", 0.9);
if (rect != null) {
macro.mouseLeftClick(rect);
Logger.info("返回城镇");

Loading…
Cancel
Save

Powered by TurnKey Linux.