Skip to content

Commit

Permalink
Merge pull request #92 from 9-9-9-9/refactor/v3.5.0
Browse files Browse the repository at this point in the history
refactor: new app `character` v3.5.0, change app code into `change-character`
  • Loading branch information
9-9-9-9 authored Jan 27, 2023
2 parents 6029953 + a8d0366 commit 11d2896
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
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>3.5.0</version>
<version>3.5.1</version>

<dependencies>
<dependency>
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/bh/bot/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

import bh.bot.app.*;
import bh.bot.app.dev.*;
import bh.bot.app.farming.*;
import bh.bot.common.extensions.Rad;
Expand All @@ -22,12 +23,6 @@
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.fusesource.jansi.AnsiConsole;

import bh.bot.app.AbstractApplication;
import bh.bot.app.AfkApp;
import bh.bot.app.FishingApp;
import bh.bot.app.GenMiniClient;
import bh.bot.app.ReRunApp;
import bh.bot.app.SettingApp;
import bh.bot.common.Configuration;
import bh.bot.common.OS;
import bh.bot.common.Telegram;
Expand Down Expand Up @@ -79,7 +74,8 @@ public static void main(String[] args) {
TrialsApp.class, //
GvgApp.class, //
GauntletApp.class, //
GenMiniClient.class,
GenMiniClient.class, //
ChangeCharacterApp.class,
// Dev functions
ExtractMatrixApp.class, //
ImportTpImageApp.class, //
Expand Down
33 changes: 18 additions & 15 deletions src/main/java/bh/bot/app/ChangeCharacterApp.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package bh.bot.app;

import static bh.bot.common.Log.info;
import static bh.bot.common.Log.debug;
import static bh.bot.common.Log.*;
import static bh.bot.common.utils.InteractionUtil.Mouse.moveCursor;
import static bh.bot.common.utils.ThreadUtil.sleep;

Expand All @@ -20,10 +19,16 @@
import bh.bot.common.utils.InteractionUtil;
import bh.bot.common.utils.ThreadUtil;

@AppMeta(code = "character", name = "Change Character", displayOrder = 1, argType = "number", argAsk = "What character slot do you want to pick?", argDefault = "1", argRequired = true)
@AppMeta(code = "change-character", name = "Change Character", displayOrder = 1, argType = "number", argAsk = "What character slot do you want to pick?", argDefault = "1", argRequired = true)
@RequireSingleInstance
public class ChangeCharacterApp extends AbstractApplication {

private static final Offset[] characterSelectionButtonOffsets = new Offset[]{
new Offset(250, 200), // # 1
new Offset(375, 200), // # 2
new Offset(500, 200), // # 3
};

@Override
protected void internalRun(String[] args) {
int arg;
Expand All @@ -35,7 +40,13 @@ protected void internalRun(String[] args) {
}

final int characterSlot = arg;
info("Character in slot %3d ", characterSlot);

if (characterSlot < 1 || characterSlot > characterSelectionButtonOffsets.length) {
err("Invalid character slot, must be in range 1 to %d", characterSelectionButtonOffsets.length);
System.exit(1);
}

info("Character in slot %d", characterSlot);
AtomicBoolean masterSwitch = new AtomicBoolean(false);
ThreadUtil.waitDone(
() -> doLoopClickImage(characterSlot, masterSwitch),
Expand All @@ -45,7 +56,6 @@ protected void internalRun(String[] args) {
.builder() //
.clickTalk() //
.clickDisconnect() //
.reactiveAuto() //
.autoExit() //
.detectChatboxDirectMessage() //
.build() //
Expand Down Expand Up @@ -89,15 +99,8 @@ private void doLoopClickImage(int characterSlot, AtomicBoolean masterSwitch) {
}
} else {
debug("Selecting Character in Slot #" + characterSlot);
if (characterSlot == 1) {
InteractionUtil.Mouse.mouseMoveAndClickAndHide(new Offset(250, 200).toScreenCoordinate());
} else if (characterSlot == 2) {
InteractionUtil.Mouse.mouseMoveAndClickAndHide(new Offset(375, 200).toScreenCoordinate());
} else if (characterSlot == 3) {
InteractionUtil.Mouse.mouseMoveAndClickAndHide(new Offset(500, 200).toScreenCoordinate());
} else {
throw new NotSupportedException("Cannot select character in this slot.");
}

InteractionUtil.Mouse.mouseMoveAndClickAndHide(characterSelectionButtonOffsets[characterSlot-1].toScreenCoordinate());
sleep(mainLoopInterval);
if (clickImage(BwMatrixMeta.Metas.Character.Buttons.confirm)) {
info(ColorizeUtil.formatInfo, "\n\nCharacter Changed to Slot #" + characterSlot);
Expand Down Expand Up @@ -139,4 +142,4 @@ protected String getLimitationExplain() {
protected int getDefaultMainLoopInterval() {
return 2_000;
}
}
}

0 comments on commit 11d2896

Please sign in to comment.