diff --git a/pgo-automat-settings.properties b/pgo-automat-settings.properties index 3cc2b0b..bbdb5f3 100644 --- a/pgo-automat-settings.properties +++ b/pgo-automat-settings.properties @@ -1,12 +1,12 @@ #Pokmon GO Automatizace - Nastaven -#Mon Dec 08 13:05:40 CET 2025 +#Fri Dec 12 11:08:56 CET 2025 autoklik.count=500 window.width=807 transfer.delay=0 window.height=743 autoklik.x=2380 autoklik.y=1124 -transfer.count=12 +transfer.count=48 window.x=866 autoklik.interval=100 window.y=237 diff --git a/src/main/java/com/pokemongo/PokemonGoAutomation.java b/src/main/java/com/pokemongo/PokemonGoAutomation.java index b2b9958..02a04ff 100644 --- a/src/main/java/com/pokemongo/PokemonGoAutomation.java +++ b/src/main/java/com/pokemongo/PokemonGoAutomation.java @@ -24,6 +24,7 @@ public class PokemonGoAutomation { private Rectangle windowBounds; private BufferedImage t1Template; // TRANSFER button template private BufferedImage t2Template; // Confirmation button template + private BufferedImage t3Template; private BufferedImage pok1Template; // Pokemon detection template private BufferedImage includeTemplate; // Include button template private static final int DELAY_BETWEEN_CLICKS = 100; // ms @@ -73,6 +74,11 @@ public class PokemonGoAutomation { t2Template = ImageIO.read(getClass().getResourceAsStream(t2Paths)); System.out.println("✅ Template Potvrzení načten z: " + t2Paths); + String t3Paths = "/t3.png"; + + t3Template = ImageIO.read(getClass().getResourceAsStream(t3Paths)); + System.out.println("✅ Template Potvrzení načten z: " + t3Paths); + String pok1Paths = "/pok1.png"; pok1Template = ImageIO.read(getClass().getResourceAsStream(pok1Paths)); @@ -104,7 +110,8 @@ public class PokemonGoAutomation { * Porovnává template s oblastí v obrázku - jednoduché pixelové porovnání s * optimalizací */ - private double templateMatch(BufferedImage screenshot, int startX, int startY, BufferedImage template, int tolerance) { + private double templateMatch(BufferedImage screenshot, int startX, int startY, BufferedImage template, + int tolerance) { if (template == null) return 0.0; @@ -234,7 +241,6 @@ public class PokemonGoAutomation { return positions; } - /** * Najde a vrátí pozici transferu tlačítka bez kliknutí */ @@ -285,13 +291,13 @@ public class PokemonGoAutomation { /** * Najde a vrátí pozici potvrzovacího tlačítka bez kliknutí */ - private Point findConfirmTransferButtonPosition() { - System.out.println("Hledám potvrzovací TRANSFER tlačítko pomocí template matchingu (t2.png)..."); + private Point findConfirmTransferButtonPosition(BufferedImage template, int tolerance) { + System.out.println("Hledám potvrzovací TRANSFER tlačítko pomocí template matchingu..."); BufferedImage screenshot = captureScreen(windowBounds); - int tWidth = t2Template.getWidth(); - int tHeight = t2Template.getHeight(); + int tWidth = template.getWidth(); + int tHeight = template.getHeight(); // Dialog je obvykle v horní polovině po TRANSFER kliknutí int searchStartY = (int) (windowBounds.height * 0.40); @@ -305,7 +311,7 @@ public class PokemonGoAutomation { for (int y = searchStartY; y <= searchEndY - tHeight; y += 15) { // Skenovat také X pozice pro nalezení středu shody for (int x = 0; x <= windowBounds.width - tWidth; x += 30) { - double score = templateMatch(screenshot, x, y, t2Template, 90); + double score = templateMatch(screenshot, x, y, template, tolerance); if (score > bestScore) { bestScore = score; @@ -328,7 +334,7 @@ public class PokemonGoAutomation { return null; } - private Point findIncludeButtonPosition() { + private Point findIncludeButtonPosition(int tolerance) { System.out.println("Hledám tlačítko INCLUDE pomocí template matchingu (include.png)..."); BufferedImage screenshot = captureScreen(windowBounds); @@ -348,7 +354,7 @@ public class PokemonGoAutomation { for (int y = searchStartY; y <= searchEndY - tHeight; y += 15) { // Skenovat také X pozice pro nalezení středu shody for (int x = 0; x <= windowBounds.width - tWidth; x += 30) { - double score = templateMatch(screenshot, x, y, includeTemplate, 90); + double score = templateMatch(screenshot, x, y, includeTemplate, tolerance); if (score > bestScore) { bestScore = score; @@ -467,8 +473,9 @@ public class PokemonGoAutomation { */ public void clickTransferButton() { // Použít detekci tlačítka - Point buttonPos = findTransferButtonPosition(); - + // Point buttonPos = findTransferButtonPosition(); + Point buttonPos = getAbsolutePoint(307, 1100); + if (buttonPos == null) { System.err.println("Tlačítko TRANSFER nebylo nalezeno!"); return; @@ -487,13 +494,13 @@ public class PokemonGoAutomation { /** * Potvrdí transfer (pokud je potřeba potvrzovací dialog) */ - public void clickConfirmTransferButton() { - System.out.println("Potvrzuji transfer - hledám t2.png (confirmation button)..."); - + public void clickConfirmTransferButton(BufferedImage template, int tolerance) { + System.out.println("Potvrzuji transfer - hledám confirmation button..."); + robot.delay(100); // Počkat na zobrazení dialogu // Najít zelené TRANSFER tlačítko v potvrzovacím dialogu - Point buttonPos = findConfirmTransferButtonPosition(); + Point buttonPos = findConfirmTransferButtonPosition(template, tolerance); if (buttonPos == null) { System.out.println("Potvrzovací tlačítko nebylo nalezeno, přeskočím potvrzení."); return; @@ -509,16 +516,16 @@ public class PokemonGoAutomation { robot.delay(DELAY_AFTER_ACTION); } - public void clickIncludeButton() { + public boolean clickIncludeButton(int tolerance) { System.out.println("Potvrzuji transfer - hledám include.png (confirmation button)..."); - + robot.delay(100); // Počkat na zobrazení dialogu // Najít zelené INCLUDE tlačítko v potvrzovacím dialogu - Point buttonPos = findIncludeButtonPosition(); + Point buttonPos = findIncludeButtonPosition(tolerance); if (buttonPos == null) { System.out.println("INCLUDE tlačítko nebylo nalezeno, přeskočím potvrzení."); - return; + return false; } robot.mouseMove(buttonPos.x, buttonPos.y); @@ -529,6 +536,7 @@ public class PokemonGoAutomation { System.out.println("Transfer finálně potvrzen!"); robot.delay(DELAY_AFTER_ACTION); + return true; } /** @@ -563,8 +571,9 @@ public class PokemonGoAutomation { int pokemonThisRound = Math.min(12, totalPokemonCount - transferredCount); - System.out.println("\n=== Iterace " + (transferredCount / 9 + 1) + " - Transferuji maximálně " + pokemonThisRound - + " pokémonů ==="); + System.out.println( + "\n=== Iterace " + (transferredCount / 9 + 1) + " - Transferuji maximálně " + pokemonThisRound + + " pokémonů ==="); // Vybrat pokémony a získat skutečný počet vybraných int actualTransferredCount = selectAllPokemonCount(pokemonThisRound); @@ -574,16 +583,21 @@ public class PokemonGoAutomation { System.out.println("Čekám na INCLUDE dialog..."); robot.delay(100); - clickIncludeButton(); - - System.out.println("Čekám na potvrzovací dialog..."); - robot.delay(100); - clickConfirmTransferButton(); + if (clickIncludeButton(70)) { + System.out.println("Čekám na potvrzovací dialog t3..."); + robot.delay(100); + clickConfirmTransferButton(t3Template, 70); + } else { + System.out.println("Čekám na potvrzovací dialog t2..."); + robot.delay(100); + clickConfirmTransferButton(t2Template, 70); + } transferredCount += actualTransferredCount; transferredPokemonCount += actualTransferredCount; - System.out.println("Transferováno v této iteraci: " + actualTransferredCount + " pokémonů (celkem: " + transferredCount + ")"); + System.out.println("Transferováno v této iteraci: " + actualTransferredCount + " pokémonů (celkem: " + + transferredCount + ")"); // Pokud ještě zbývá co transferovat, počkat if (transferredCount < totalPokemonCount) { @@ -605,6 +619,7 @@ public class PokemonGoAutomation { /** * Označí konkrétní počet pokémonů + * * @return Skutečný počet vybraných pokémonů */ private int selectAllPokemonCount(int count) { @@ -624,7 +639,7 @@ public class PokemonGoAutomation { if (i == 0) { System.out.println(" -> Dlouhé podržení (aktivace multi-select)"); robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - robot.delay(600); + robot.delay(700); robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); robot.delay(DELAY_AFTER_ACTION); } else { @@ -639,7 +654,7 @@ public class PokemonGoAutomation { System.out.println("Označeno " + maxPokemon + " pokémonů!"); System.out.println("Čekám před kliknutím na TRANSFER..."); robot.delay(800); - + return maxPokemon; } @@ -666,6 +681,7 @@ public class PokemonGoAutomation { /** * Převede relativní pozici v okně (0.0-1.0) na absolutní souřadnice obrazovky + * * @param relativeX Relativní X pozice (0.0 = levý okraj, 1.0 = pravý okraj) * @param relativeY Relativní Y pozice (0.0 = horní okraj, 1.0 = dolní okraj) * @return Absolutní pozice na obrazovce diff --git a/src/main/resources/include.png b/src/main/resources/include.png index c86caa4..045b95d 100644 Binary files a/src/main/resources/include.png and b/src/main/resources/include.png differ diff --git a/src/main/resources/t1.png b/src/main/resources/t1.png index c34f2ec..84e8d83 100644 Binary files a/src/main/resources/t1.png and b/src/main/resources/t1.png differ diff --git a/src/main/resources/t2.png b/src/main/resources/t2.png index 72041a1..1193491 100644 Binary files a/src/main/resources/t2.png and b/src/main/resources/t2.png differ diff --git a/src/main/resources/t3.png b/src/main/resources/t3.png new file mode 100644 index 0000000..6de8510 Binary files /dev/null and b/src/main/resources/t3.png differ