Ejemplo n.º 1
0
 def scout_lure(self):
     args = get_args()
     if args.lure_url:
         lat = request.args.get('latitude')
         lng = request.args.get('longitude')
         log.info(
         u"On demand luring a stop at lat = {}, long = {}.".format(lat,
                                           lng))
         stops = Pokestop.get_stop_by_cord(lat, lng)
         if len(stops) > 1:
             log.info("Error, more than one stop returned")
             return None
         else:
             p = stops[0]
         log.info(
             u"On demand luring a stop {} at {}, {}.".format(p["pokestop_id"],
                                                           p["latitude"],
                                                           p["longitude"]))
         scout_result = perform_lure(p)
         if scout_result['success']:
             log.info(
                 u"Successfully lured pokestop_id {} at {}, {}".format(
                     p["pokestop_id"], p["latitude"],
                     p["longitude"]))
         else:
             log.warning(u"Failed luring {} at {},{}".format(p["pokestop_id"], p["latitude"], p["longitude"]))
     else:
         scout_result = scout_error("URL not configured.")
     return jsonify(scout_result)
Ejemplo n.º 2
0
 def scout_pokemon(self):
     args = get_args()
     if args.pgscout_url:
         encounterId = request.args.get('encounter_id')
         p = Pokemon.get(Pokemon.encounter_id == encounterId)
         pokemon_name = get_pokemon_name(p.pokemon_id)
         save_encounter_id = p.encounter_id
         save_spawnpoint_id = p.spawnpoint_id
         p.encounter_id = b64encode(str(p.encounter_id))
         p.spawnpoint_id = format(p.spawnpoint_id, 'x')
         log.info(
             u"On demand PGScouting a {} at {}, {} with ID {} and spawn {}.".format(pokemon_name,
                                                           p.latitude,
                                                           p.longitude, encounterId, p.spawnpoint_id))
         scout_result = pgscout_encounter(p, 1)
         if scout_result['success']:
             p.encounter_id  = save_encounter_id
             p.spawnpoint_id = save_spawnpoint_id
             
             self.update_scouted_pokemon(p, scout_result)
             log.info(
                 u"Successfully PGScouted a {:.1f}% lvl {} {} with {} CP"
                 u" (scout level {}).".format(
                     scout_result['iv_percent'], scout_result['level'],
                     pokemon_name, scout_result['cp'],
                     scout_result['scout_level']))
         else:
             log.warning(u"Failed PGScouting {}: {}".format(pokemon_name,
                                                            scout_result[
                                                                'error']))
     else:
         scout_result = scout_error("Check IV URL not configured.")
     return jsonify(scout_result)
Ejemplo n.º 3
0
 def scout_pokemon(self):
     args = get_args()
     if args.pgscout_url:
         encounterId = request.args.get('encounter_id')
         p = Pokemon.get(Pokemon.encounter_id == encounterId)
         pokemon_name = get_pokemon_name(p.pokemon_id)
         log.info(
             u"On demand PGScouting a {} at {}, {}.".format(pokemon_name,
                                                           p.latitude,
                                                           p.longitude))
         scout_result = pgscout_encounter(p, forced=1)
         if scout_result['success']:
             self.update_scouted_pokemon(p, scout_result)
             if scout_result['weather_id'] == None:
                 scout_result['weather_id'] = 0
             log.info(
                 u"Successfully PGScouted a {:.1f}% lvl {} {} with {} CP {} Bonus"
                 u" (scout level {}).".format(
                     scout_result['iv_percent'], scout_result['level'],
                     pokemon_name, scout_result['cp'],
                     GameplayWeather.WeatherCondition.Name(scout_result['weather_id']),
                     scout_result['scout_level']))
         else:
             log.warning(u"Failed PGScouting {}: {}".format(pokemon_name,
                                                            scout_result[
                                                                'error']))
     else:
         scout_result = scout_error("PGScout URL not configured.")
     return jsonify(scout_result)