Skip to content

Commit

Permalink
2.8.0 World Boss (Team) (#62)
Browse files Browse the repository at this point in the history
* edit bot name

* change behavior when defeated on Raid, do not stop ReRun

* add new app World Boss (Team)

* add texture

* enable some flags for World Boss Team + adjust some text+comments

* world boss team ok

* start when not full team + stop when out of xeals

Co-authored-by: 9-9-9-9 <9-9-9-9>
  • Loading branch information
9-9-9-9 authored Dec 8, 2021
1 parent 587bc5d commit 9217a96
Show file tree
Hide file tree
Showing 18 changed files with 587 additions and 30 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
[![Github Open Issues](https://img.shields.io/github/issues/9-9-9-9/Bit-Heroes-bot.svg)](https://github.com/9-9-9-9/Bit-Heroes-bot/issues)
[![Github All Releases](https://img.shields.io/github/downloads/9-9-9-9/Bit-Heroes-bot/total.svg)](https://github.com/9-9-9-9/Bit-Heroes-bot/releases)

Hi, I'm bot, please give this repository a Star, thanks
Hi, I'm the bot, please give this repository a Star, thanks

This project has inspiration from https://github.com/tiemonl/Bit-Heroes-Fishing-Bot

> We play the game, don't let the game play us
> You spend your time for your family and 99bot helps you persuade the Familiars
> You spend your time for your family and me helps you persuade the Familiars
> Eat duck, eat all the bones. With 99bot, you wont waste any minute of your Bitgor also your sleeping time
> Eat duck, eat all the bones. With me, you wont waste any minute of your Bitgor also your sleeping time
___
[Wiki version](https://github.com/9-9-9-9/Bit-Heroes-bot/wiki)
Expand Down Expand Up @@ -55,7 +55,7 @@ And some extra functions support developers on developing this bot
- Mini-client/Web on Windows: `web.bot.bat`
- Linux/MacOS: `./bot.sh`

Tips 1: you can launch app with flags directly via command-line after got familiar with 99bot:
Tips 1: you can launch app with flags directly via command-line after got familiar with this bot:
> java -jar BitHeroes.jar "function_name" "param1" ["param2"] [--flags]
Tips 2: see help
Expand Down
8 changes: 4 additions & 4 deletions README.release.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ ___
Bit Heroes bot
##### on Linux / Windows / ~~MacOS~~

Hi, I'm 99bot, please give this repository a Star, thanks
Hi, I'm the bot, please give this repository a Star, thanks

> We play the game, don't let the game play us
> You spend your time for your family and 99bot helps you persuade the Familiars
> You spend your time for your family and me helps you persuade the Familiars
> Eat duck, eat all the bones. With 99bot, you wont waste any minute of your Bitgor also your sleeping time
> Eat duck, eat all the bones. With me, you wont waste any minute of your Bitgor also your sleeping time
___
[Wiki version](https://github.com/9-9-9-9/Bit-Heroes-bot/wiki)
Expand Down Expand Up @@ -47,7 +47,7 @@ Officially support [Bit Heroes on Steam](https://github.com/9-9-9-9/Bit-Heroes-b
- Mini-client/Web on Windows: `web.bot.bat`
- Linux/MacOS: `./bot.sh`

Tips 1: you can launch app with flags directly via command-line after got familiar with 99bot:
Tips 1: you can launch app with flags directly via command-line after got familiar with this bot:
> java -jar BitHeroes.jar "function_name" "param1" ["param2"] [--flags]
Tips 2: see help
Expand Down
2 changes: 1 addition & 1 deletion _.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@if not exist BitHeroes.jar (
@echo You are using 99bot from source code version which required to run build.bat in order to compile binary first
@echo You are using bot from source code version which required to run build.bat in order to compile binary first
@echo If you are not a developer and you only want to use the bot, please download the zip file with name download-this-file.zip from my website at https://github.com/9-9-9-9/Bit-Heroes-bot/releases/latest
goto L_EXIT1
)
Expand Down
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
<modelVersion>4.0.0</modelVersion>
<groupId>bh.bot</groupId>
<artifactId>99bot</artifactId>
<version>2.7.0</version>
<version>2.8.0</version>

<dependencies>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline</artifactId>
<version>3.21.0</version>
</dependency>
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/bh/bot/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.stream.Collectors;

import bh.bot.app.dev.*;
import bh.bot.app.farming.*;
import bh.bot.common.extensions.Rad;
import bh.bot.common.types.flags.*;
import org.apache.maven.model.Model;
Expand All @@ -27,14 +28,6 @@
import bh.bot.app.GenMiniClient;
import bh.bot.app.ReRunApp;
import bh.bot.app.SettingApp;
import bh.bot.app.farming.ExpeditionApp;
import bh.bot.app.farming.GauntletApp;
import bh.bot.app.farming.GvgApp;
import bh.bot.app.farming.InvasionApp;
import bh.bot.app.farming.PvpApp;
import bh.bot.app.farming.RaidApp;
import bh.bot.app.farming.TrialsApp;
import bh.bot.app.farming.WorldBossApp;
import bh.bot.common.Configuration;
import bh.bot.common.OS;
import bh.bot.common.Telegram;
Expand Down Expand Up @@ -78,6 +71,7 @@ public static void main(String[] args) {
FishingApp.class, //
AfkApp.class, //
WorldBossApp.class, //
WorldBossTeamApp.class, //
RaidApp.class, //
PvpApp.class, //
InvasionApp.class, //
Expand All @@ -92,6 +86,7 @@ public static void main(String[] args) {
//
ScreenCaptureApp.class, //
TestApp.class, //
DualWorldBoss.class, //
GenerateMetaApp.class //
);

Expand Down Expand Up @@ -528,5 +523,6 @@ public static void warningEnergyRefill() {
public static final int EXIT_CODE_WINDOW_DETECTION_ISSUE = 14;
public static final int EXIT_CODE_MULTIPLE_INSTANCE_DETECTED = 15;
public static final int EXIT_CODE_EXTRACT_BOT_VERSION_FAILURE = 16;
public static final int EXIT_CODE_INCORRECT_RUNTIME_CONFIGURATION = 17;
public static final int EXIT_CODE_UNHANDLED_EXCEPTION = -1;
}
2 changes: 1 addition & 1 deletion src/main/java/bh/bot/app/AfkApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected void internalRun(String[] args) {
boolean doExpedition = eventList.contains(AttendablePlaces.expedition);
boolean doPVP = eventList.contains(AttendablePlaces.pvp);
if (doRaid || doWorldBoss || doExpedition || doPVP) {
userConfig = getPredefinedUserConfigFromProfileName("You want to do Raid/World Boss/Expedition/PVP so you have to specific profile name first!\nSelect an existing profile:");
userConfig = getPredefinedUserConfigFromProfileName("You want to do Raid/World Boss (Solo)/Expedition/PVP so you have to specific profile name first!\nSelect an existing profile:");

try {
if (doRaid) {
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/bh/bot/app/ReRunApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ private void detectDefeatedOnRaid(AtomicBoolean masterSwitch) {
continue;
}
if (clickImage(BwMatrixMeta.Metas.Raid.Buttons.town)) {
masterSwitch.set(true);
warn("Detected 'Defeated' state so ReRun gonna stop now");
Telegram.sendMessage("Defeated", true);
warn("Detected 'Defeated' state");
Telegram.sendMessage("Defeated in Raid", true);
}
}
} catch (Exception ex) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/bh/bot/app/SettingApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ protected void internalRun(String[] args) {
info(ColorizeUtil.formatInfo, "You haven't specified Raid mode (Normal/Hard/Heroic)");

if (resultLoadUserConfig._2.isValidWorldBossLevel())
info(ColorizeUtil.formatInfo, "Selected World Boss %s", resultLoadUserConfig._2.getWorldBossLevelDesc());
info(ColorizeUtil.formatInfo, "Selected World Boss (Solo) %s", resultLoadUserConfig._2.getWorldBossLevelDesc());
else
info(ColorizeUtil.formatInfo, "You haven't specified World Boss level");
info(ColorizeUtil.formatInfo, "You haven't specified World Boss level to Solo");

if (resultLoadUserConfig._2.isValidExpeditionPlace())
info(ColorizeUtil.formatInfo, "Selected Expedition door %s", resultLoadUserConfig._2.getExpeditionPlaceDesc());
Expand Down Expand Up @@ -94,7 +94,7 @@ protected void internalRun(String[] args) {
sb = new StringBuilder("All World Boss levels:\n");
for (int rl = woldBossLevelRange._1; rl <= woldBossLevelRange._2; rl++)
sb.append(String.format(" %2d. %s\n", rl, UserConfig.getWorldBossLevelDesc(rl)));
sb.append("Specific World Boss level?");
sb.append("Specific World Boss level to Solo?");
tmp = readIntInput(sb.toString(), woldBossLevelRange._1, woldBossLevelRange._2);
worldBossLevel = tmp == null ? worldBossLevel : tmp;
//
Expand Down Expand Up @@ -124,7 +124,7 @@ protected void internalRun(String[] args) {
sb.append(" raid has not been set");
sb.append('\n');
if (newCfg.isValidWorldBossLevel())
sb.append(String.format(" world boss %s", UserConfig.getWorldBossLevelDesc((byte) worldBossLevel)));
sb.append(String.format(" world boss (solo) %s", UserConfig.getWorldBossLevelDesc((byte) worldBossLevel)));
else
sb.append(" world boss has not been set");
sb.append('\n');
Expand Down Expand Up @@ -189,7 +189,7 @@ protected String getUsage() {

@Override
protected String getDescription() {
return "Do setting raid level, raid mode, world boss level, expedition door to enter,...";
return "Do setting raid level, raid mode, world boss (solo) level, expedition door to enter,...";
}

@Override
Expand Down
173 changes: 173 additions & 0 deletions src/main/java/bh/bot/app/dev/DualWorldBoss.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
package bh.bot.app.dev;

import bh.bot.Main;
import bh.bot.app.AbstractApplication;
import bh.bot.common.Configuration;
import bh.bot.common.exceptions.InvalidDataException;
import bh.bot.common.types.AttendablePlace;
import bh.bot.common.types.AttendablePlaces;
import bh.bot.common.types.annotations.AppMeta;
import bh.bot.common.types.tuples.Tuple2;
import bh.bot.common.types.tuples.Tuple3;
import bh.bot.common.utils.ColorizeUtil;
import bh.bot.common.utils.InteractionUtil;
import bh.bot.common.utils.StringUtil;
import bh.bot.common.utils.TimeUtil;
import com.sun.jna.platform.win32.User32;
import com.sun.jna.platform.win32.Win32Exception;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinDef.RECT;
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;
import org.jline.utils.NonBlockingReader;

import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

import static bh.bot.common.Log.*;
import static bh.bot.common.utils.InteractionUtil.Keyboard.sendEnter;
import static bh.bot.common.utils.InteractionUtil.Keyboard.sendSpaceKey;
import static bh.bot.common.utils.InteractionUtil.Mouse.*;
import static bh.bot.common.utils.InteractionUtil.Mouse.hideCursor;
import static bh.bot.common.utils.StringUtil.isBlank;
import static bh.bot.common.utils.ThreadUtil.sleep;

@SuppressWarnings("unused")
@AppMeta(code = "dwb", name = "Test Code", dev = true)
public class DualWorldBoss extends AbstractApplication {
protected InteractionUtil.Screen.Game gameScreenInteractor = InteractionUtil.Screen.Game.of(this);

private static final int btn1X = 382;
private static final int btn1Y = 527;
private static final int btn2X = 1176;
private static final int btn2Y = 527;
private static final int btnRestoreX = 284;
private static final int btnRestoreY = 857;
private static final Point anchor1 = new Point(btn1X, btn1Y - 400);
private static final Point btn1 = new Point(btn1X, btn1Y);
private static final Point anchor2 = new Point(btn2X, btn2Y - 400);
private static final Point btn2 = new Point(btn2X, btn2Y);
private static final Point btnRestoreMouse = new Point(btnRestoreX, btnRestoreY);

@Override
protected void internalRun(String[] args) {
Terminal terminal = null;
try {
terminal = TerminalBuilder.terminal();
} catch (IOException e) {
e.printStackTrace();
}
terminal.enterRawMode();
NonBlockingReader reader = terminal.reader();
while (true) {
try {
info(";. ReGroup");
info("'. Start");
info(",. ReGroup 1");
info(".. ReGroup 2");
info("/. Start reverse");
BufferedReader br = Main.getBufferedReader();
int opt = reader.read();

if (opt == ';') {
click1();
sleep(1000);
click2();
sleep(500);
restoreMouse();
} else if (opt == ',') {
click1();
sleep(500);
restoreMouse();
} else if (opt == '.') {
click2();
sleep(500);
restoreMouse();
} else if (opt == '\'') {
start(anchor2, btn2, anchor1, btn1);
} else if (opt == '/') {
start(anchor1, btn1, anchor2, btn2);
} else {
System.out.println("Unknown " + opt);
}
} catch (IOException e) {
e.printStackTrace();
continue;
}
}
}

private void click1() {
click(anchor1, btn1);
}

private void click2() {
click(anchor2, btn2);
}

private void click(Point anchor, Point move) {
moveCursor(anchor);
sleep(100);
mouseClick();
sleep(200);
move1();
sleep(300);
moveCursor(move);
sleep(300);
mouseClick();
sleep(200);
mouseClick();
sleep(100);
mouseClick();
}

private void start(Point anchorFirst, Point moveFirst, Point anchorSecond, Point moveSecond) {
click(anchorFirst, moveFirst);
sleep(3000);
click(anchorSecond, moveSecond);
sleep(500);
sendEnter();
sleep(500);
sendEnter();
sleep(500);
sendEnter();
sleep(100);
restoreMouse();
}

private void restoreMouse() {
moveCursor(btnRestoreMouse);
sleep(500);
mouseClick();
sleep(200);
mouseClick();
sleep(200);
mouseClick();
}

private void move1() {
moveCursor(btn1);
}

private void move2() {
moveCursor(btn2);
}

@Override
protected String getUsage() {
return null;
}

@Override
protected String getDescription() {
return "(developers only) run test code";
}

@Override
protected String getLimitationExplain() {
return null;
}
}
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 @@ -25,7 +25,7 @@ public class WorldBossApp extends AbstractDoFarmingApp {

@Override
protected boolean readMoreInput() throws IOException {
userConfig = getPredefinedUserConfigFromProfileName("You want to do World Boss so you have to specific profile name first!\nSelect an existing profile:");
userConfig = getPredefinedUserConfigFromProfileName("You want to do World Boss (Solo) so you have to specific profile name first!\nSelect an existing profile:");

try {
info(ColorizeUtil.formatInfo, "You have selected world boss %s", userConfig.getWorldBossLevelDesc());
Expand Down
Loading

0 comments on commit 9217a96

Please sign in to comment.