Skip to content

Commit

Permalink
fixed Raid selection
Browse files Browse the repository at this point in the history
  • Loading branch information
9-9-9-9 committed Nov 30, 2022
1 parent 7ef333a commit 43aef39
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/main/java/bh/bot/app/AbstractApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,9 @@ protected Tuple2<Point[], Byte> detectRadioButtons(Rectangle scanRect) {

try (ScreenCapturedResult screenCapturedResult = captureElementInEstimatedArea(
new Offset(Math.max(0, scanRect.x - positionTolerant), Math.max(0, scanRect.y - positionTolerant)),
scanRect.width + positionTolerant * 2, scanRect.height + positionTolerant * 2)) {
scanRect.width + positionTolerant * 2,
scanRect.height + positionTolerant * 2
)) {
BufferedImage sc = screenCapturedResult.image;
saveDebugImage(sc, "detectRadioButtons");

Expand Down Expand Up @@ -675,7 +677,7 @@ protected Tuple2<Point[], Byte> detectRadioButtons(Rectangle scanRect) {
else {
if (selectedRadioButtonIndex != curRadioButtonIndex)
throw new InvalidDataException(
"Found more than one selected radio button which is absolutely wrong!"
String.format("Found more than one selected radio button which is absolutely wrong! (no.%d conflicts with no.%d)", curRadioButtonIndex + 1, selectedRadioButtonIndex + 1)
);
}
break;
Expand All @@ -687,6 +689,7 @@ protected Tuple2<Point[], Byte> detectRadioButtons(Rectangle scanRect) {
x, y
);
startingCoords.add(new Point(x, y));
x += Math.max(0, im.getWidth() - 2);
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/main/java/bh/bot/app/dev/TestApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@ protected void internalRun(String[] args) {
adjustScreenOffset();

//
findAttendablePlaces();
Tuple2<Point[], Byte> result = detectRadioButtons(
Configuration.screenResolutionProfile.getRectangleRadioButtonsOfRaid()
);
Point[] points = result._1;
int selectedLevel = result._2 + 1;
info("Selected %d", selectedLevel);
for (int i = 0; i < points.length; i++) {
Point p = points[i];
info("[%d] %d,%d", i + 1, p.x - Configuration.gameScreenOffset.X.get(), p.y - Configuration.gameScreenOffset.Y.get());
}
}

private static void testParseTime() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/bh/bot/common/types/images/BwMatrixMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ public static void load() throws IOException {
0xFFFFFF
);
Metas.Globally.Buttons.radioButton = BwMatrixMeta.from(//
"buttons/globally.radio-button2?",
"buttons/globally.radio-button3?",
Offset.none(), //
0x000000
);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/bh/bot/common/utils/InteractionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static void hideCursor() {
public static void clickRadioButton(int level, Point[] points, String evName) {
if (level < 1 || level > points.length)
throw new InvalidDataException(
"Can not select level %d of %s because it's not exists, do you setup wrongly?", level, evName
"Can not select level %d/%d of %s because it's not exists, do you setup wrongly?", level, points.length, evName
);
Point p = points[level - 1];
moveCursor(new Point(p.x + 7, p.y + 7));
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit 43aef39

Please sign in to comment.