Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ FROM python:3.13.6-bullseye
RUN apt-get update && apt-get upgrade -y

# Unit testing
RUN pip3 install --upgrade pytest
RUN pip3 install --upgrade pytest pyyaml

# Set working directory
WORKDIR /app
Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
PokemonGo Bot via screen mirroring

### About
Using [screen mirroring](https://support.apple.com/en-us/120421), click on repeatable locations with random delays and random click accuracy.
Using iPhone/Mac [screen mirroring](https://support.apple.com/en-us/120421), click on repeatable locations with random delays and random click accuracy in order to automate repetitive PokemonGo Tasks.

### Configuration
Edit the coordinates for your system in [`config.py`](config.py). I'd recommend placing the screen mirroring application in an easily repeatable location (Ex. bottom right of screen).
Edit the `anchor` point for your system in one of the `.yaml` files in [`configs/`](/configs). I'd recommend placing the screen mirroring application in an easily repeatable location (Ex. bottom right of screen). The anchor point should be the center of the red 'x' on the top left of the screen mirroring window.

The coordinates of the current mouse position can be easily obtained via `cmd` + `shift` + `4`.
<!--
Expand All @@ -17,7 +17,18 @@ The easiest way to find out the color at a certain location is by using macOS's

### Dependencies
* Python
* [cliclick](https://github.com/BlueM/cliclick)
* [cliclick](https://github.com/BlueM/cliclick) ([`brew install cliclick`](https://formulae.brew.sh/formula/cliclick))
* [pyyaml](https://pypi.org/project/PyYAML/)
* ```shell
python3 -m venv myenv
source myenv/bin/activate
pip3 install pyyaml
```

### Examples
* `CONFIG=iPhone11.yaml python3 trader.py`
* `CONFIG=iPhoneMax.yaml python3 modifyFavorite.py`
* `python3 battler.py --master --lose` and `python3 battler.py --win`

### Supported bot actions
* Trading
Expand Down
2 changes: 1 addition & 1 deletion battler.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import sys

# Custom imports
from configs.iPhone11 import coordinates
from configs import coordinates
from functions.cliclick import Cliclick
import functions.utils as utils

Expand Down
93 changes: 93 additions & 0 deletions configs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import yaml
import os
from pathlib import Path

# Default config file name if none is specified
DEFAULT_CONFIG_NAME = "iPhoneMax.yaml"

# The directory containing the config files (this package's directory)
CONFIG_DIR = Path(__file__).parent


def load_config(config_name: str | None = None) -> dict:
"""
Load a config YAML file and return the computed coordinates dictionary.

Args:
config_name: Name of the YAML file (without path).
If None, uses CONFIG environment variable
If no CONFIG environment variable, uses DEFAULT_CONFIG_NAME

Returns:
Dictionary of coordinates with the anchor added to them
"""
if config_name is None:
config_name = os.getenv("CONFIG")
if config_name is None:
print(
f"No CONFIG environment variable set, using the default of CONFIG={DEFAULT_CONFIG_NAME}"
)
config_name = DEFAULT_CONFIG_NAME

config_path = CONFIG_DIR / config_name

if not config_path.exists():
raise FileNotFoundError(f"Config file not found: {config_name}")

with open(config_path, "r") as f:
config = yaml.safe_load(f)

anchor_x = config["anchor"]["x"]
anchor_y = config["anchor"]["y"]
offsets = config["offsets"]

def get_coordinate_plus_anchor(offset_key: str) -> list[int]:
"""
Get coordinates of offset_key, add the anchor, and return
"""
offset = offsets[offset_key]
return [anchor_x + offset["x"], anchor_y + offset["y"]]

# coordinate key : yaml key
key_mapping = {
"start_battle_coordinates": "start_battle",
"start_trade_coordinates": "start_trade",
"first_trade_pokemon_coordinates": "first_trade_pokemon",
"between_first_second_pokemon": "between_first_second_pokemon",
"next_button_coordinates": "next_button",
"confirm_button_coordinates": "confirm_button",
"pokemon_details_left_health_white": "pokemon_details_left_health_white",
"x_button_coordinates": "x_button",
"start_drag_next_poke": "start_drag_next_poke",
"end_drag_next_poke": "end_drag_next_poke",
"modify_favorite": "modify_favorite",
"lets_do_it_coordinates": "lets_do_it",
"great_league_coordinates": "great_league",
"ultra_league_coordinates": "ultra_league",
"master_league_coordinates": "master_league",
"lets_battle_coordinates": "lets_battle",
"first_pokemon_in_party_coordinates": "first_pokemon_in_party",
"use_party_coordinates": "use_party",
"rematch_coordinates": "rematch",
"sort_button_coordinates": "sort_button",
"first_pokemon_coordinates": "first_pokemon",
"second_pokemon_coordinates": "second_pokemon",
"third_pokemon_coordinates": "third_pokemon",
"done_button_coordinates": "done_button",
}

coordinates = {
coordinate_key: get_coordinate_plus_anchor(yaml_key)
for coordinate_key, yaml_key in key_mapping.items()
}

# Add everything else from the YAML that is NOT 'anchor' or 'offsets'
for key, value in config.items():
if key not in {"anchor", "offsets"}:
coordinates[key] = value

return coordinates


# Load config
coordinates = load_config()
131 changes: 0 additions & 131 deletions configs/iPhone11.py

This file was deleted.

87 changes: 87 additions & 0 deletions configs/iPhone11.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# This is a config file for screen mirroring with an iPhone 11 with a "Larger"
# view window. To use this with an iPhone 11, the only thing you should modify
# is the `anchor` variable.

# Red 'x' in the top left of the mirroring window
anchor:
# MacBook Air
x: 1311
y: 213

# Individual offset values with a "larger" view
# iPhone Mirroring -> View -> Larger
offsets:
start_battle:
x: 286
y: 633
start_trade:
x: 129
y: 636
first_trade_pokemon:
x: 55
y: 276
between_first_second_pokemon: # unused
x: 109
y: 275
next_button:
x: 176
y: 704
confirm_button:
x: 36
y: 437
pokemon_details_left_health_white: # unused
x: 39
y: 366
x_button:
x: 175
y: 782
start_drag_next_poke:
x: 322
y: 497
end_drag_next_poke:
x: 29
y: 497
modify_favorite:
x: 325
y: 81
lets_do_it:
x: 172
y: 515
great_league:
x: 174
y: 391
ultra_league:
x: 175
y: 507
master_league:
x: 176
y: 628
lets_battle:
x: 171
y: 506
first_pokemon_in_party:
x: 73
y: 615
use_party:
x: 188
y: 746
rematch:
x: 171
y: 537
sort_button: # unused
x: 310
y: 702
first_pokemon:
x: 56
y: 353
second_pokemon:
x: 174
y: 353
third_pokemon:
x: 291
y: 353
done_button:
x: 260
y: 796

change_prng: False
Loading