Skip to content

Commit

Permalink
1.6.0 support Invasion on Steam (#36)
Browse files Browse the repository at this point in the history
* prepare for other Dimentions of Expedition

* update desc of some functions

* support Invasion on Steam

* 1.6.0

Co-authored-by: 9-9-9-9 <9-9-9-9>
  • Loading branch information
9-9-9-9 authored Sep 9, 2021
1 parent d902ff6 commit 814910a
Show file tree
Hide file tree
Showing 21 changed files with 326 additions and 55 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Tips 2: see help
- Linux/MacOS: run script `./help.sh`

##### Optional configuration:
- [Configure Raid/World Boss](https://github.com/9-9-9-9/Bit-Heroes-bot/wiki/Select-Raid-World-Boss-level,-mode,..-using-%60setting%60-function):
- [Configure Raid/World Boss/Expedition](https://github.com/9-9-9-9/Bit-Heroes-bot/wiki/Select-Raid-World-Boss-level,-mode,..-using-%60setting%60-function):
- Windows: run file `setting.bat`
- Linux/MacOS: run script `./setting.sh`
- [push notification via Telegram](https://github.com/9-9-9-9/Bit-Heroes-bot/wiki/Configure-Telegram-in-able-to-receive-notification)
Expand Down
2 changes: 1 addition & 1 deletion README.release.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Tips 2: see help
- Linux/MacOS: run script `./help.sh`

##### Optional configuration:
- [Configure Raid/World Boss](https://github.com/9-9-9-9/Bit-Heroes-bot/wiki/Select-Raid-World-Boss-level,-mode,..-using-%60setting%60-function):
- [Configure Raid/World Boss/Expedition](https://github.com/9-9-9-9/Bit-Heroes-bot/wiki/Select-Raid-World-Boss-level,-mode,..-using-%60setting%60-function):
- Windows: run file `setting.bat`
- Linux/MacOS: run script `./setting.sh`
- [push notification via Telegram](https://github.com/9-9-9-9/Bit-Heroes-bot/wiki/Configure-Telegram-in-able-to-receive-notification)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>bh.bot</groupId>
<artifactId>99bot</artifactId>
<version>1.5.8</version>
<version>1.6.0</version>

<dependencies>
<dependency>
Expand Down
84 changes: 58 additions & 26 deletions src/main/java/bh/bot/app/AbstractApplication.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package bh.bot.app;

import bh.bot.Main;
import bh.bot.app.farming.ExpeditionApp;
import bh.bot.common.Configuration;
import bh.bot.common.OS;
import bh.bot.common.Telegram;
Expand All @@ -27,8 +28,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.*;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
Expand Down Expand Up @@ -659,30 +659,63 @@ protected void autoExit(int exitAfterXSecs, AtomicBoolean masterSwitch) {
}
}

private final HashMap<BwMatrixMeta, Offset[]> expeditionMap =
this instanceof AfkApp || this instanceof ExpeditionApp
? new HashMap<BwMatrixMeta, Offset[]>() {{
/*
put(BwMatrixMeta.Metas.Expedition.Labels.infernoDimension, new Offset[]{
Configuration.screenResolutionProfile.getOffsetEnterInfernoDimensionRaleib(),
Configuration.screenResolutionProfile.getOffsetEnterInfernoDimensionBlemo(),
Configuration.screenResolutionProfile.getOffsetEnterInfernoDimensionGummy(),
Configuration.screenResolutionProfile.getOffsetEnterInfernoDimensionZarlock(),
});
put(BwMatrixMeta.Metas.Expedition.Labels.hallowedDimension, new Offset[]{
Configuration.screenResolutionProfile.getOffsetEnterHallowedDimensionGooGarum(),
Configuration.screenResolutionProfile.getOffsetEnterHallowedDimensionSvord(),
Configuration.screenResolutionProfile.getOffsetEnterHallowedDimensionTwimbo(),
Configuration.screenResolutionProfile.getOffsetEnterHallowedDimensionX5T34M(),
});
put(BwMatrixMeta.Metas.Expedition.Labels.jammieDimension, new Offset[]{
Configuration.screenResolutionProfile.getOffsetEnterJammieDimensionZorgo(),
Configuration.screenResolutionProfile.getOffsetEnterJammieDimensionYackerz(),
Configuration.screenResolutionProfile.getOffsetEnterJammieDimensionVionot(),
Configuration.screenResolutionProfile.getOffsetEnterJammieDimensionGrampa(),
});
*/
put(BwMatrixMeta.Metas.Expedition.Labels.idolDimension, new Offset[]{
Configuration.screenResolutionProfile.getOffsetEnterIdolDimensionBlubLix(),
Configuration.screenResolutionProfile.getOffsetEnterIdolDimensionMowhi(),
Configuration.screenResolutionProfile.getOffsetEnterIdolDimensionWizBot(),
Configuration.screenResolutionProfile.getOffsetEnterIdolDimensionAstamus(),
});
/*
put(BwMatrixMeta.Metas.Expedition.Labels.battleBards, new Offset[]{
Configuration.screenResolutionProfile.getOffsetEnterBattleBardsHero(),
Configuration.screenResolutionProfile.getOffsetEnterBattleBardsBurning(),
Configuration.screenResolutionProfile.getOffsetEnterBattleBardsMelvapaloozo(),
Configuration.screenResolutionProfile.getOffsetEnterBattleBardsBitstock(),
});
*/
}}
: null;

protected boolean tryEnterExpedition(boolean doExpedition, byte place) {
if (doExpedition && clickImage(BwMatrixMeta.Metas.Expedition.Labels.idolDimension)) {
Point p;
switch (place) {
case 1:
p = Configuration.screenResolutionProfile.getOffsetEnterIdolDimensionBlubLix().toScreenCoordinate();
break;
case 2:
p = Configuration.screenResolutionProfile.getOffsetEnterIdolDimensionMowhi().toScreenCoordinate();
break;
case 3:
p = Configuration.screenResolutionProfile.getOffsetEnterIdolDimensionWizBot().toScreenCoordinate();
break;
case 4:
p = Configuration.screenResolutionProfile.getOffsetEnterIdolDimensionAstamus().toScreenCoordinate();
break;
default:
return false;
if (!doExpedition)
return false;

for (Map.Entry<BwMatrixMeta, Offset[]> entry : expeditionMap.entrySet()) {
if (entry.getKey() == null)
continue;

if (clickImage(entry.getKey())) {
Point p = entry.getValue()[place - 1].toScreenCoordinate();
mouseMoveAndClickAndHide(p);
sleep(5_000);
hideCursor();
return true;
}
mouseMoveAndClickAndHide(p);
sleep(5_000);
hideCursor();
return true;
}

return false;
}

Expand Down Expand Up @@ -781,7 +814,6 @@ private Point fromRelativeToAbsoluteBasedOnPreviousResult(BwMatrixMeta sampleImg
}

protected byte selectExpeditionPlace() {
//noinspection StringBufferReplaceableByString
StringBuilder sb = new StringBuilder("Select a place to do Expedition:\n");
final Tuple2<Byte, Byte> expeditionPlaceRange = UserConfig.getExpeditionPlaceRange();
for (int i = expeditionPlaceRange._1; i <= expeditionPlaceRange._2; i++)
Expand Down Expand Up @@ -916,8 +948,8 @@ protected String readCfgProfileName(String ask, String desc) {
final String prefix = "readonly.";
final String suffix = ".user-config.properties";
boolean foundAny = false;
for (File file : Arrays.stream(new File(".").listFiles())
.filter(x -> x.isFile())
for (File file : Arrays.stream(Objects.requireNonNull(new File(".").listFiles()))
.filter(File::isFile)
.sorted().collect(Collectors.toList())) {
String name = file.getName();
if (!name.startsWith(prefix) || !name.endsWith(suffix))
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/bh/bot/app/AfkApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ private void doLoop(//
boolean doGauntlet //
) {
try {

if (doInvasion && Configuration.isSteamProfile)
throw new NotSupportedException("Invasion has not been supported on Steam mode");

info(ColorizeUtil.formatInfo, "\n\nStarting AFK");
boolean isUnknownGvgOrInvasionOrExpedition = (doGvg && doInvasion) || (doGvg && doExpedition)
|| (doInvasion && doExpedition);
Expand Down Expand Up @@ -460,7 +456,7 @@ private ArrayList<AttendablePlace> getAttendablePlaces() {
MenuItem.from("Trials/Gauntlet", AttendablePlaces.trials, AttendablePlaces.gauntlet),
MenuItem.from(AttendablePlaces.pvp, AttendablePlaces.worldBoss, AttendablePlaces.raid),
MenuItem.from(AttendablePlaces.pvp, AttendablePlaces.worldBoss, AttendablePlaces.raid,
AttendablePlaces.expedition, AttendablePlaces.trials),
AttendablePlaces.invasion, AttendablePlaces.gauntlet),
MenuItem.from("All", allAttendablePlaces.toArray(new AttendablePlace[0]))
).collect(Collectors.toList());

Expand Down Expand Up @@ -521,7 +517,7 @@ protected String getUsage() {

@Override
protected String getDescription() {
return "It helps you AFK by automatically consume PVP/World Boss/GVG/Invasion/Trials/Gauntlet turns";
return "AFK automatically consume PVP/World Boss/GVG/Invasion/Trials/Gauntlet turns, thus you can away from keyboard";
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/bh/bot/app/farming/ExpeditionApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static List<NextAction> getPredefinedImageActions() {

@Override
protected String getLimitationExplain() {
return "This function does not support select badge cost, so choose it before turn this on";
return "Expedition does not support select badge cost, so choose it before turn this on";
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/bh/bot/app/farming/GauntletApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public static List<NextAction> getPredefinedImageActions() {

@Override
protected String getLimitationExplain() {
return "This function does not support select difficulty and token cost, so choose it before turn this on";
return "Gauntlet does not support select difficulty and token cost, so choose it before turn this on";
}
}
2 changes: 1 addition & 1 deletion src/main/java/bh/bot/app/farming/GvgApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public static List<NextAction> getPredefinedImageActions() {

@Override
protected String getLimitationExplain() {
return "This function does not support select badge cost, so choose it before turn this on";
return "GVG does not support select badge cost, so choose it before turn this on";
}
}
2 changes: 1 addition & 1 deletion src/main/java/bh/bot/app/farming/InvasionApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public static List<NextAction> getPredefinedImageActions() {

@Override
protected String getLimitationExplain() {
return "This function does not support select badge cost, so choose it before turn this on";
return "Invasion does not support select badge cost, so choose it before turn this on";
}
}
4 changes: 2 additions & 2 deletions src/main/java/bh/bot/app/farming/PvpApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public static List<NextAction> getPredefinedImageActions() {

@Override
protected String getLimitationExplain() {
return "This function only hit first opponent and does not support select PVP ticket cost, so choose it before turn this on";
return "PVP only hit first opponent and does not support select PVP ticket cost, so choose it before turn this on";
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/bh/bot/app/farming/TrialsApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public static List<NextAction> getPredefinedImageActions() {

@Override
protected String getLimitationExplain() {
return "This function does not support select difficulty and token cost, so choose it before turn this on";
return "Trials does not support select difficulty and token cost, so choose it before turn this on";
}
}
2 changes: 1 addition & 1 deletion src/main/java/bh/bot/app/farming/WorldBossApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ public static List<NextAction> getPredefinedImageActions() {

@Override
protected String getLimitationExplain() {
return "This function is solo only and does not support select mode of World Boss (Normal/Hard/Heroic), only select by default So which boss do you want to hit? Choose it before turn this on";
return "World Boss is solo only and does not support select mode of World Boss (Normal/Hard/Heroic), only select by default So which boss do you want to hit? Choose it before turn this on";
}
}
2 changes: 1 addition & 1 deletion src/main/java/bh/bot/common/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static void loadSystemConfig(final ParseArgumentsResult parseArgumentsRes
if (isBlank(profileName))
throw new InvalidDataException("profileName");

warn("You must move the Bit Heroes game's window to top left corner of your screen or provide exactly screen offset into the 'offset.screen.x & y' keys");
warn("You must move the Bit Heroes game's window to top left corner of your screen or provide exactly screen offset into the 'offset.screen.x & y' keys. See more: https://github.com/9-9-9-9/Bit-Heroes-bot/wiki/Manually-setting-game-screen-coordinate");
if (isSteamProfile)
warn("Your Bit Heroes game window must be 800x480. You can check it by open Settings, see the Windowed option");

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/bh/bot/common/jna/MiniClientLinuxJna.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ public void internalTryToCloseGameWindow() throws Exception {
debug("internalTryToCloseGameWindow: Output of ps command has invalid format: %s", psOutput);
continue;
}
int pid = Integer.parseInt(spl[0]);
startProcess("kill", "-9", String.valueOf(pid));

int pid = Integer.parseInt(spl[0]);
new ProcessBuilder(new String[]{
"kill", "-9", String.valueOf(pid)
}).start().waitFor();
Expand Down
Loading

0 comments on commit 814910a

Please sign in to comment.