Skip to content

Commit

Permalink
Merge pull request #3 from PokemonGoF/dev
Browse files Browse the repository at this point in the history
Merge Main into my project
  • Loading branch information
Reaver01 authored Jul 22, 2016
2 parents 68d0df8 + c80ab0d commit 3a4d004
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 12 deletions.
1 change: 1 addition & 0 deletions pokecli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
pgoapi - Pokemon Go API
Copyright (c) 2016 tjado <https://github.com/tejado>
Expand Down
2 changes: 2 additions & 0 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

import logging
import googlemaps
import json
Expand Down
2 changes: 2 additions & 0 deletions pokemongo_bot/cell_workers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# -*- coding: utf-8 -*-

from pokemon_catch_worker import PokemonCatchWorker
from seen_fort_worker import SeenFortWorker
16 changes: 9 additions & 7 deletions pokemongo_bot/cell_workers/pokemon_catch_worker.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

import time
from sets import Set
from utils import distance, print_green, print_yellow, print_red
Expand Down Expand Up @@ -33,7 +35,7 @@ def work(self):
cp=pokemon['pokemon_data']['cp']
pokemon_num=int(pokemon['pokemon_data']['pokemon_id'])-1
pokemon_name=self.pokemon_list[int(pokemon_num)]['Name']
print_yellow('[#] A Wild ' + str(pokemon_name) + ' appeared! [CP' + str(cp) + ']')
print_yellow('[#] A Wild {} appeared! [CP {}]'.format(pokemon_name, cp))
#Simulate app
sleep(3)
while(True):
Expand All @@ -52,7 +54,7 @@ def work(self):
print_red('[x] Out of pokeballs...')
# TODO: Begin searching for pokestops.
break
print('[x] Using ' + self.item_list[str(pokeball)] + '...')
print('[x] Using {}...'.format(self.item_list[str(pokeball)]))
self.api.catch_pokemon(encounter_id = encounter_id,
pokeball = pokeball,
normalized_reticle_size = 1.950,
Expand All @@ -68,22 +70,22 @@ def work(self):
'status' in response_dict['responses']['CATCH_POKEMON']:
status = response_dict['responses']['CATCH_POKEMON']['status']
if status is 2:
print_red('[-] Attempted to capture ' + str(pokemon_name) + ' - failed.. trying again!')
print_red('[-] Attempted to capture {} - failed.. trying again!'.format(pokemon_name))
sleep(2)
continue
if status is 3:
print_red('[x] Oh no! ' + str(pokemon_name) + ' vanished! :(')
print_red('[x] Oh no! {} vanished! :('.format(pokemon_name))
if status is 1:
if cp < self.config.cp:
print_green('[x] Captured ' + str(pokemon_name) + '! [CP' + str(cp) + '] - exchanging for candy')
print_green('[x] Captured {}! [CP {}] - exchanging for candy'.format(pokemon_name, cp))
id_list2 = self.count_pokemon_inventory()
# Transfering Pokemon

## TODO - FIX TRANSFERRING OF POKEMON
self.transfer_pokemon(list(Set(id_list2) - Set(id_list1)))
print_green('[#] ' + str(pokemon_name) + ' has been exchanged for candy!')
print_green('[#] {} has been exchanged for candy!'.format(pokemon_name))
else:
print_green('[x] Captured ' + str(pokemon_name) + '! [CP' + str(cp) + ']')
print_green('[x] Captured {}! [CP {}]'.format(pokemon_name, cp))
break
time.sleep(5)

Expand Down
2 changes: 2 additions & 0 deletions pokemongo_bot/cell_workers/seen_fort_worker.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

import json
import time
from math import radians, sqrt, sin, cos, atan2
Expand Down
8 changes: 5 additions & 3 deletions pokemongo_bot/cell_workers/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

import struct
from math import cos, asin, sqrt

Expand All @@ -10,10 +12,10 @@ def i2f(int):
return struct.unpack('<d', struct.pack('<Q', int))[0]

def print_green(message):
print('\033[92m' + message + '\033[0m');
print(u'\033[92m' + message.decode('utf-8') + '\033[0m');

def print_yellow(message):
print('\033[93m' + message + '\033[0m');
print(u'\033[93m' + message.decode('utf-8') + '\033[0m');

def print_red(message):
print('\033[91m' + message + '\033[0m');
print(u'\033[91m' + message.decode('utf-8') + '\033[0m');
2 changes: 2 additions & 0 deletions pokemongo_bot/human_behaviour.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

import time
from math import ceil
from random import random, randint
Expand Down
2 changes: 2 additions & 0 deletions pokemongo_bot/stepper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

import json
import time

Expand Down
7 changes: 5 additions & 2 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<script>
var map;
var marker;
var loc = {};
var loc = {}, cachedLoc = {};
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 50.0830986, lng: 6.7613762},
Expand Down Expand Up @@ -51,6 +51,9 @@
function(data) { loc = data; map.panTo({lat: parseFloat(loc.lat), lng: parseFloat(loc.lng)}); },
function(xhr) { console.error(xhr);}
);

if (loc.lat === cachedLoc.lat && loc.lng === cachedLoc.lng) return;
cachedLoc = loc;
console.log("Move Marker: Trainer - " + loc.lat + ", " + loc.lng);
marker.setPosition({lat: parseFloat(loc.lat), lng: parseFloat(loc.lng)});
}
Expand All @@ -74,4 +77,4 @@
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBWa0ZYeH6RBZnNTAIj30FyDIVnXV74D9o&callback=initMap"
async defer></script>
</body>
</html>
</html>

0 comments on commit 3a4d004

Please sign in to comment.