Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

Commit

Permalink
Revisited familiar contribution logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ilpersi committed Oct 27, 2020
1 parent 0290c67 commit 3281f3c
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions src/main/java/com/github/ilpersi/BHBot/EncounterManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void processFamiliarEncounter() {
familiarLevel = FamiliarType.ERROR; // error
}

DungeonThread.PersuationType persuasion;
PersuationType persuasion;
BribeSettings bribeInfo = new BribeSettings();

// Checking familiars setting takes time and a lot of cues verifications. We try to minimize the number of times
Expand Down Expand Up @@ -131,11 +131,25 @@ void processFamiliarEncounter() {
// We save all the errors and persuasions based on settings
if ((familiarLevel.getValue() >= bot.settings.familiarScreenshot) || familiarLevel == FamiliarType.ERROR) {
bot.saveGameScreen(persuasionLog.toString(), "familiars");
}

if (bot.settings.contributeFamiliars) {
contributeFamiliarShoot(persuasionLog.toString(), familiarLevel);
}
// if (bot.settings.contributeFamiliars) {

// We build the MD5 string for the current encounter
BufferedImage famNameImg = EncounterManager.getFamiliarNameImg(bot.browser.getImg(), familiarLevel, new Bounds(105, 60, 640, 105));
String famNameMD5 = Misc.imgToMD5(famNameImg);

// We check if the familiar is known
FamiliarDetails encounterDetails = EncounterManager.famMD5Table.getOrDefault(famNameMD5, null);
if (encounterDetails == null) {
// String unkMD5 = bot.saveGameScreen(familiarLevel.toString() + "-unknown-familiar", "unknown-familiars", famNameImg);
// BHBot.logger.debug("MD5 familiar unknown: '" + famNameMD5 + "' saved as " + unkMD5);
// we contribute unknown familiars
Misc.contributeImage(famNameImg, persuasionLog.toString(), null);
} else {
BHBot.logger.debug("MD5 familiar detected: " + encounterDetails.name);
}
// }

// We attempt persuasion or bribe based on settings
if (persuasion == PersuationType.BRIBE) {
Expand Down Expand Up @@ -267,7 +281,7 @@ private boolean bribeFamiliar() {
* Bot will attempt to persuade the current encountered familiar.
* For this to work, the familiar window must be opened!
*
* @return true if persuasion is successfully peformed, false otherwise
* @return true if persuasion is successfully performed, false otherwise
*/
private boolean persuadeFamiliar() {

Expand All @@ -288,21 +302,6 @@ private boolean persuadeFamiliar() {
return false;
}

/**
* This method is contributing familiar cues to the project. Before contributing the familiar image,
* the method is taking care of stripping all the unnecessary pixels
*
* @param shootName Name of the image containing the familiar screenshot
* @param familiarType The familiar type: COMMON|RARE|EPIC|LEGENDARY
*/
private void contributeFamiliarShoot(String shootName, FamiliarType familiarType) {

BufferedImage famNameImg = EncounterManager.getFamiliarNameImg(bot.browser.getImg(), familiarType, new Bounds(105, 60, 640, 105));

Misc.contributeImage(famNameImg, shootName, null);

}

private void updateFamiliarCounter(String fam) {
String familiarToUpdate = "";
String updatedFamiliar = "";
Expand Down

0 comments on commit 3281f3c

Please sign in to comment.