Skip to content

Commit

Permalink
Merge pull request #7 from PokemonGoF/dev
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
Reaver01 authored Jul 23, 2016
2 parents 55a2107 + 3937b50 commit 8578372
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 27 deletions.
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ var/
*.manifest
*.spec

# Eclipse Users
.project
.pydevproject
.settings/


# Installer logs
pip-log.txt
pip-delete-this-directory.txt
Expand Down Expand Up @@ -90,15 +96,17 @@ ENV/

# Personal load details
config.json
location.json
src/
info.json
inventory.json
pokedex.json
web/catchable.json
data/catch-ignore.yml
web/catchable-*.json
web/location-*.json
web/location.json
web/userdata.js
data/last-location*.json
data/catch-ignore.yml

# ignore Pycharm config
.idea
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ This project uses Google Maps. There's one map coupled with the project, but as
-u USERNAME, --username USERNAME Username
-p PASSWORD, --password PASSWORD Password
-l LOCATION, --location LOCATION Location (Address or 'xx.yyyy,zz.ttttt')
-lc, --use-location-cache Bot will start at last known location
-lc, --location_cache Bot will start at last known location
-c CP, --cp Set the CP to transfer or lower (eg. 100 will transfer CP0-99)
-m MODE, --mode MODE Set farming Mode for the bot ('all', 'poke', 'farm')
-w SPEED, --walk SPEED Walk instead of teleport with given speed (meters per second max 4.16 because of walking end on 15km/h)
--distance_unit UNIT Set the unit to display distance in (e.g, km for kilometers, mi for miles, ft for feet)
--initial-transfer Start the bot with a pokemon clean up, keeping only the higher CP of each pokemon. It respects -c as upper limit to release.
--maxsteps MAX_STEP Set the steps around your initial location (DEFAULT 5 mean 25 cells around your location)
-du, --distance_unit UNIT Set the unit to display distance in (e.g, km for kilometers, mi for miles, ft for feet)
-it, --initial_transfer Start the bot with a pokemon clean up, keeping only the higher CP of each pokemon. It respects -c as upper limit to release.
-ms, --max_steps MAX_STEP Set the steps around your initial location (DEFAULT 5 mean 25 cells around your location)
-iv IV, --pokemon_potential Set the ratio for the IV values to transfer (eg. 0.8 will transfer a pokemon with IV 0.5)
-d, --debug Debug Mode
-t, --test Only parse the specified location
Expand Down Expand Up @@ -260,6 +260,7 @@ To install the pgoapi use `pip install -e git://github.com/tejado/pgoapi.git#egg
* luizperes
* brantje
* VirtualSatai
* dmateusp

## Credits
[tejado](https://github.com/tejado) many thanks for the API
Expand Down
19 changes: 11 additions & 8 deletions config.json.example
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
"auth_service": "google",
"username": "example@gmail.com",
"password": "password11!!",
"location": "New York",
"username": "YOURACCOUNT@gmail.com",
"password": "YOURPASSWORD",
"location": "SOME LOCATION",
"cp": 100,
"gmapkey": "CHANGME",
"maxsteps": 100,
"gmapkey": "AGMAPAPIKEY",
"max_steps": 50,
"mode": "all",
"walk": 4.16,
"debug": true,
"test": false
"debug": false,
"test": false,
"initial_transfer": false,
"pokemon_potential": 0.70,
"location_cache": true,
"distance_unit": "km"
}

18 changes: 8 additions & 10 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,18 @@ def init_config():
parser.add_argument("-u", "--username", help="Username")
parser.add_argument("-p", "--password", help="Password")
parser.add_argument("-l", "--location", help="Location")
parser.add_argument("-lc", "--use-location-cache", help="Bot will start at last known location", action='store_true', default=False, dest='location_cache')
parser.add_argument("-lc", "--location_cache", help="Bot will start at last known location", type=bool, default=False)
parser.add_argument("-m", "--mode", help="Farming Mode", type=str, default="all")
parser.add_argument("-w", "--walk", help="Walk instead of teleport with given speed (meters per second, e.g. 2.5)", type=float, default=2.5)
parser.add_argument("-c", "--cp",help="Set CP less than to transfer(DEFAULT 100)",type=int,default=100)
parser.add_argument("-iv", "--pokemon_potential",help="Set IV ratio less than to transfer(DEFAULT 0.80)",type=float,default=0.80)
parser.add_argument("-k", "--gmapkey",help="Set Google Maps API KEY",type=str,default=None)
parser.add_argument("--maxsteps",help="Set the steps around your initial location(DEFAULT 5 mean 25 cells around your location)",type=int,default=5)
parser.add_argument("--initial-transfer", help="Transfer all pokemon with same ID on bot start, except pokemon with highest CP. It works with -c", action='store_true', dest='initial_transfer')
parser.add_argument("-d", "--debug", help="Debug Mode", action='store_true')
parser.add_argument("-t", "--test", help="Only parse the specified location", action='store_true')
parser.add_argument("--distance_unit", help="Set the unit to display distance in (e.g, km for kilometers, mi for miles, ft for feet)", type=str, default="m")
parser.set_defaults(DEBUG=False, TEST=False)
parser.add_argument("-k", "--gmapkey",help="Set Google Maps API KEY",type=str, default=None)
parser.add_argument("-ms","--max_steps",help="Set the steps around your initial location(DEFAULT 5 mean 25 cells around your location)",type=int,default=50)
parser.add_argument("-it", "--initial_transfer", help="Transfer all pokemon with same ID on bot start, except pokemon with highest CP. It works with -c", type=bool, default=False)
parser.add_argument("-d", "--debug", help="Debug Mode", type=bool, default=False)
parser.add_argument("-t", "--test", help="Only parse the specified location", type=bool, default=False)
parser.add_argument("-du","--distance_unit", help="Set the unit to display distance in (e.g, km for kilometers, mi for miles, ft for feet)", type=str, default="km")
config = parser.parse_args()

if not config.username and not 'username' in load:
config.username = raw_input("Username: ")
if not config.password and not 'password' in load:
Expand All @@ -91,7 +89,7 @@ def init_config():
if not config.location and not config.location_cache in load:
logging.error("Needs either --use-location-cache or --location.")
return None

print(config)
return config

def main():
Expand Down
4 changes: 2 additions & 2 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def _set_starting_position(self):
try:
#
# save location flag used to pull the last known location from the location.json
with open('location.json') as f:
with open('data/last-location-%s.json' % (self.config.username)) as f:
location_json = json.load(f)

self.position = (location_json['lat'], location_json['lng'], 0.0)
Expand Down Expand Up @@ -310,7 +310,7 @@ def _set_starting_position(self):

def _get_pos_by_name(self, location_name):
geolocator = GoogleV3(api_key=self.config.gmapkey)
loc = geolocator.geocode(location_name)
loc = geolocator.geocode(location_name, timeout=10)

#self.log.info('Your given location: %s', loc.address.encode('utf-8'))
#self.log.info('lat/long/alt: %s %s %s', loc.latitude, loc.longitude, loc.altitude)
Expand Down
5 changes: 4 additions & 1 deletion pokemongo_bot/stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, bot):
self.y = 0
self.dx = 0
self.dy = -1
self.steplimit=self.config.maxsteps
self.steplimit=self.config.max_steps
self.steplimit2 = self.steplimit**2
self.origin_lat = self.bot.position[0]
self.origin_lon = self.bot.position[1]
Expand Down Expand Up @@ -92,6 +92,9 @@ def _work_at_position(self, lat, lng, alt, pokemon_only=False):
if 'map_cells' in response_dict['responses']['GET_MAP_OBJECTS']:
with open('web/location-%s.json' % (self.config.username), 'w') as outfile:
json.dump({'lat': lat, 'lng': lng,'cells':response_dict['responses']['GET_MAP_OBJECTS']['map_cells']}, outfile)
with open('data/last-location-%s.json' % (self.config.username), 'w') as outfile:
outfile.truncate()
json.dump({'lat': lat, 'lng' : lng},outfile)
if response_dict and 'responses' in response_dict:
if 'GET_MAP_OBJECTS' in response_dict['responses']:
if 'status' in response_dict['responses']['GET_MAP_OBJECTS']:
Expand Down
3 changes: 3 additions & 0 deletions web/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ var trainerFunc = function(data, user_index) {
/* var z = 0;
for (var i = 0; i < data.cells.length; i++) {
cell = data.cells[i];
if (!cell.hasOwnProperty(forts)) {
continue;
}
for (var x = 0; x < data.cells[i].forts.length; x++) {
var fort = cell.forts[x];
if (!forts[fort.id]) {
Expand Down

0 comments on commit 8578372

Please sign in to comment.