|
|
|
@ -5,8 +5,7 @@ import com.example.jmacro.wjdr.JMacro;
|
|
|
|
|
import com.example.jmacro.wjdr.base.ViewPoint;
|
|
|
|
|
import com.example.jmacro.wjdr.base.ViewRect;
|
|
|
|
|
import com.example.jmacro.wjdr.util.Logger;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import com.example.jmacro.wjdr.util.TaskUtil;
|
|
|
|
|
|
|
|
|
|
public class Task_自动采矿 extends BaseTask {
|
|
|
|
|
|
|
|
|
@ -36,31 +35,27 @@ public class Task_自动采矿 extends BaseTask {
|
|
|
|
|
Logger.info("定位野外按钮成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Logger.info("定位资源搜索按钮");
|
|
|
|
|
// 因为搜索按钮透明,不好比对,通过定位其下面的任务图标定位
|
|
|
|
|
ViewRect 野外_任务 = macro.waitAndMatchLegend("野外_任务", 0.9);
|
|
|
|
|
if (野外_任务 == null) {
|
|
|
|
|
Logger.error("未检测到【资源搜索按钮】,采矿终止");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ViewPoint 野外搜索 = new ViewPoint(野外_任务.getCenter()[0], 野外_任务.getCenter()[1] - 125);
|
|
|
|
|
Logger.info("定位资源搜索按钮成功:{}", 野外搜索.toString());
|
|
|
|
|
macro.mouseLeftClick(野外搜索);
|
|
|
|
|
Logger.info("点击资源搜索按钮");
|
|
|
|
|
macro.delayUnstable(1000);
|
|
|
|
|
macro.mouseLeftClick(new ViewPoint(33, 648));
|
|
|
|
|
|
|
|
|
|
// 因为搜索按钮透明,不好比对,通过定位其下面的任务图标定位
|
|
|
|
|
ViewRect 野外_搜索 = macro.waitAndMatchLegend("野外_搜索#L226,879.png", 0.9);
|
|
|
|
|
Logger.info("等待搜索面板");
|
|
|
|
|
ViewRect 野外_搜索 = macro.waitAndMatchLegend("野外_搜索", 0.9);
|
|
|
|
|
if (野外_搜索 == null) {
|
|
|
|
|
Logger.error("未检测到【野外_搜索】,采矿终止");
|
|
|
|
|
Logger.error("未检测到【待搜索面板】,采矿终止");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// todo
|
|
|
|
|
Logger.info("拖动面板");
|
|
|
|
|
macro.mouseLeftDrag(new ViewPoint(433, 679), new ViewPoint(61, 682), true);
|
|
|
|
|
|
|
|
|
|
Logger.info("开始采集资源");
|
|
|
|
|
String[] types = new String[]{
|
|
|
|
|
"生肉", "木材", "煤矿", "铁矿"
|
|
|
|
|
};
|
|
|
|
|
for (String type : types) {
|
|
|
|
|
Logger.info("搜索资源【{}】", type);
|
|
|
|
|
boolean collect = collect(type, 0);
|
|
|
|
|
boolean collect = collect(type, 4);
|
|
|
|
|
if (collect) { // 中断采集
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -88,59 +83,80 @@ public class Task_自动采矿 extends BaseTask {
|
|
|
|
|
* @return 采集是否结束(满队则返回true,接下来的采集也不需要了)
|
|
|
|
|
*/
|
|
|
|
|
private boolean collect(String type, int level) {
|
|
|
|
|
Logger.info("定位【{}】图标", type);
|
|
|
|
|
ViewRect typeRect = macro.waitAndFindPic(viewRect, new File("legend", "野外_" + type + ".png"), 0.9);
|
|
|
|
|
Logger.info("定位【野外_资源搜索_{}】图标", type);
|
|
|
|
|
ViewRect typeRect = macro.waitAndMatchLegend("野外_资源搜索_" + type, 0.9);
|
|
|
|
|
if (typeRect == null) {
|
|
|
|
|
Logger.error("定位【{}】图标失败", type);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
Logger.info("定位【{}】图标成功", type);
|
|
|
|
|
|
|
|
|
|
Logger.info("单击【{}】图标,坐标[{},{}]", type, typeRect.getCenter()[0], typeRect.getCenter()[1]);
|
|
|
|
|
Logger.info("选择【{}】图标,坐标[{},{}]", type, typeRect.getCenter()[0], typeRect.getCenter()[1]);
|
|
|
|
|
macro.mouseLeftClick(typeRect);
|
|
|
|
|
|
|
|
|
|
if (level == 0) {
|
|
|
|
|
ViewRect 等级减 = macro.waitAndFindPic(viewRect, new File("legend", "野外_资源_-.png"), 0.98);
|
|
|
|
|
while (等级减 != null) {
|
|
|
|
|
macro.delayUnstable();
|
|
|
|
|
macro.mouseLeftClick(等级减);
|
|
|
|
|
等级减 = macro.waitAndFindPic(viewRect, new File("legend", "野外_资源_-.png"), 0.98);
|
|
|
|
|
}
|
|
|
|
|
Logger.info("矿等级重置为1");
|
|
|
|
|
level = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Logger.info("搜索{}{}级矿", type, level);
|
|
|
|
|
ViewRect 搜索 = macro.waitAndFindPic(viewRect, new File("legend", "野外_资源_搜索.png"), 0.98);
|
|
|
|
|
macro.mouseLeftClick(搜索);
|
|
|
|
|
ViewRect 采集 = macro.waitAndFindPic(viewRect, new File("legend", "野外_资源_采集.png"), 0.98);
|
|
|
|
|
if (采集 == null) {
|
|
|
|
|
Logger.info("未搜索到{}{}级矿!", type, level);
|
|
|
|
|
ViewRect 等级加 = macro.waitAndFindPic(viewRect, new File("legend", "野外_资源_+.png"), 0.98);
|
|
|
|
|
macro.mouseLeftClick(等级加);
|
|
|
|
|
return collect(type, level + 1);
|
|
|
|
|
int clevel = getLevel();
|
|
|
|
|
if (clevel > level) {
|
|
|
|
|
TaskUtil.execTask(() -> {
|
|
|
|
|
Logger.info("调整等级");
|
|
|
|
|
macro.delayUnstable(700);
|
|
|
|
|
macro.mouseLeftClick(new ViewPoint(51, 777));
|
|
|
|
|
}, clevel - level, 1000);
|
|
|
|
|
}
|
|
|
|
|
Logger.info("搜索到{}{}级矿", type, level);
|
|
|
|
|
Logger.info("采集{}{}级矿", type, level);
|
|
|
|
|
macro.mouseLeftClick(采集);
|
|
|
|
|
|
|
|
|
|
ViewRect 采集队伍满 = macro.waitAndFindPic(viewRect, new File("legend", "野外_资源_采集队伍满.png"), 0.98);
|
|
|
|
|
if (采集队伍满 != null) {
|
|
|
|
|
Logger.info("出征队伍满,取消采集!");
|
|
|
|
|
Logger.info("关闭弹框!");
|
|
|
|
|
macro.mouseLeftClick(new ViewPoint(采集队伍满.getRight() - 17, 采集队伍满.getBottom() - 20));
|
|
|
|
|
Logger.info("退出资源搜索!");
|
|
|
|
|
macro.mouseLeftClick(new ViewPoint(采集队伍满.getRight() - 17, 采集队伍满.getBottom() - 20));
|
|
|
|
|
return true;
|
|
|
|
|
if (clevel < level) {
|
|
|
|
|
TaskUtil.execTask(() -> {
|
|
|
|
|
Logger.info("调整等级");
|
|
|
|
|
macro.delayUnstable(700);
|
|
|
|
|
macro.mouseLeftClick(new ViewPoint(360, 777));
|
|
|
|
|
}, level - clevel, 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ViewRect 出征 = macro.waitAndFindPic(viewRect, new File("legend", "野外_资源_出征.png"), 0.98);
|
|
|
|
|
if (出征 == null) {
|
|
|
|
|
Logger.info("出征{}{}级矿失败!", type, level);
|
|
|
|
|
ViewRect 野外_资源搜索 = macro.matchLegend("野外_资源搜索", 0.9);
|
|
|
|
|
if (野外_资源搜索 == null) {
|
|
|
|
|
Logger.error("定位【野外_资源搜索】失败,采矿终止");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
Logger.info("出征{}{}级矿", type, level);
|
|
|
|
|
macro.mouseLeftClick(出征);
|
|
|
|
|
|
|
|
|
|
Logger.info("点击搜索{}{}级矿", type, level);
|
|
|
|
|
macro.delayUnstable();
|
|
|
|
|
macro.mouseLeftClick(野外_资源搜索);
|
|
|
|
|
|
|
|
|
|
macro.delayUnstable();
|
|
|
|
|
ViewRect 采集 = macro.waitAndMatchLegend("野外_资源采集", 0.98);
|
|
|
|
|
if (采集 != null) {
|
|
|
|
|
macro.mouseLeftClick(采集);
|
|
|
|
|
|
|
|
|
|
macro.delayUnstable(1000);
|
|
|
|
|
|
|
|
|
|
ViewRect[] viewRects = macro.matchLegend("野外_资源出征", "野外_资源无对队列");
|
|
|
|
|
|
|
|
|
|
if (viewRects[0] != null) {
|
|
|
|
|
Logger.info("出征");
|
|
|
|
|
macro.mouseLeftClick(viewRects[0]);
|
|
|
|
|
}
|
|
|
|
|
if (viewRects[1] != null) {
|
|
|
|
|
Logger.info("队列已满,取消采集");
|
|
|
|
|
macro.delayUnstable(1000);
|
|
|
|
|
macro.mouseLeftClick(new ViewPoint(471, 250));
|
|
|
|
|
|
|
|
|
|
Logger.info("队列已满,取消采集");
|
|
|
|
|
macro.delayUnstable(1000);
|
|
|
|
|
macro.mouseLeftClick(new ViewPoint(471, 250));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (level > 1) {
|
|
|
|
|
return collect(type, level - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int getLevel() {
|
|
|
|
|
for (int i = 1; i <= 8; i++) {
|
|
|
|
|
ViewRect 等级 = macro.matchLegend("野外_资源等级" + i, 0.99);
|
|
|
|
|
if (等级 != null) {
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|