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

Commit

Permalink
Merge pull request #1038 from farkam135/fixCandyEvolutionScanOnNewMov…
Browse files Browse the repository at this point in the history
…eProblem

Checks if wrongly scanning new attack button before parsing
  • Loading branch information
nahojjjen authored Feb 27, 2019
2 parents 1acd78a + f46143d commit 8215c8c
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,45 @@ private static Optional<Integer> getPokemonEvolutionCostFromImgUncached(@NonNull
* @return the evolution cost (or -1 if absent) wrapped in Optional.of(), or Optional.absent() on scan failure
*/
private static Optional<Integer> getPokemonEvolutionCostFromImg(@NonNull Bitmap pokemonImage,

@Nullable ScanArea evolutionCostArea) {
Bitmap evolutionCostImage = null;

//Since 'new attack' button is at the same place as "evolve" on max evolutions, we need to make sure
//We're not wrongly reading a 'new attack' button. Check this by scanning left of evolutionCostImage, and
//looking for a specific color that evolve button doesnt have.
Bitmap leftOfEvolutionCostImage = null;
if (evolutionCostArea != null) {
evolutionCostImage = getImageCrop(pokemonImage, evolutionCostArea);

leftOfEvolutionCostImage = Bitmap.createBitmap(pokemonImage,
evolutionCostArea.xPoint-evolutionCostArea.width,//-evolutionCostArea.width,
evolutionCostArea.yPoint,
evolutionCostArea.width,
evolutionCostArea.height);
//xstart,ystart,xwidth,
// ywidth)

}
if (evolutionCostImage == null) {
evolutionCostImage = getImageCrop(pokemonImage, 0.625, 0.815, 0.2, 0.03);
}

boolean isNewAttackButton = false;
if (leftOfEvolutionCostImage != null){
int middle = leftOfEvolutionCostImage.getHeight()/2;
for (int i = 0; i < leftOfEvolutionCostImage.getWidth(); i++){
System.out.println("color is: " + leftOfEvolutionCostImage.getPixel(i, middle));
if (leftOfEvolutionCostImage.getPixel(i, middle) == Color.rgb(68,105,108)){
isNewAttackButton = true;
}
}
}
if (isNewAttackButton){
return Optional.of(-1);
}


String hash = "candyCost" + hashBitmap(evolutionCostImage);

if (ocrCache != null) {
Expand Down

0 comments on commit 8215c8c

Please sign in to comment.