def submit_quest_proto(self, map_proto): log.debug("{DbWrapperBase::submit_quest_proto} called") fort_id = map_proto.get("fort_id", None) if fort_id is None: return False if 'challenge_quest' not in map_proto: return False quest_type = map_proto['challenge_quest']['quest'].get( "quest_type", None) if map_proto['challenge_quest']['quest'].get("quest_rewards", None): rewardtype = map_proto['challenge_quest']['quest'][ 'quest_rewards'][0].get("type", None) reward = map_proto['challenge_quest']['quest'].get( "quest_rewards", None) item = map_proto['challenge_quest']['quest']['quest_rewards'][0][ 'item'].get("item", None) itemamount = map_proto['challenge_quest']['quest'][ 'quest_rewards'][0]['item'].get("amount", None) stardust = map_proto['challenge_quest']['quest']['quest_rewards'][ 0].get("stardust", None) pokemon_id = map_proto['challenge_quest']['quest'][ 'quest_rewards'][0]['pokemon_encounter'].get( "pokemon_id", None) target = map_proto['challenge_quest']['quest']['goal'].get( "target", None) condition = map_proto['challenge_quest']['quest']['goal'].get( "condition", None) task = questtask(int(quest_type), str(condition), int(target)) query_quests = ( "INSERT into trs_quest (GUID, quest_type, quest_timestamp, quest_stardust, quest_pokemon_id, " "quest_reward_type, quest_item_id, quest_item_amount, quest_target, quest_condition, quest_reward, " "quest_task) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" "ON DUPLICATE KEY UPDATE quest_type=VALUES(quest_type), quest_timestamp=VALUES(quest_timestamp), " "quest_stardust=VALUES(quest_stardust), quest_pokemon_id=VALUES(quest_pokemon_id), " "quest_reward_type=VALUES(quest_reward_type), quest_item_id=VALUES(quest_item_id), " "quest_item_amount=VALUES(quest_item_amount), quest_target=VALUES(quest_target), " "quest_condition=VALUES(quest_condition), quest_reward=VALUES(quest_reward), " "quest_task=VALUES(quest_task)") vals = (fort_id, quest_type, time.time(), stardust, pokemon_id, rewardtype, item, itemamount, target, str(condition), str(reward), task) log.debug( "{DbWrapperBase::submit_quest_proto} submitted quest typ %s at stop %s" % (str(quest_type), str(fort_id))) self.execute(query_quests, vals, commit=True) if self.application_args.webhook and self.application_args.quest_webhook: log.debug('Sending quest webhook for pokestop {0}'.format( str(fort_id))) self.webhook_helper.submit_quest_webhook( self.quests_from_db(GUID=fort_id)) else: log.debug('Sending Webhook is disabled') return True
def quest(self, origin: str, quest_proto: dict, mitm_mapper): logger.debug("DbPogoProtoSubmit::quest called") fort_id = quest_proto.get("fort_id", None) if fort_id is None: return False if "challenge_quest" not in quest_proto: return False protoquest = quest_proto["challenge_quest"]["quest"] rewards = protoquest.get("quest_rewards", None) if rewards is None or not rewards: return False reward = rewards[0] item = reward['item'] encounter = reward['pokemon_encounter'] goal = protoquest['goal'] quest_type = protoquest.get("quest_type", None) quest_template = protoquest.get("template_id", None) reward_type = reward.get("type", None) item_item = item.get("item", None) item_amount = item.get("amount", None) stardust = reward.get("stardust", None) pokemon_id = encounter.get("pokemon_id", None) target = goal.get("target", None) condition = goal.get("condition", None) json_condition = json.dumps(condition) task = questtask(int(quest_type), json_condition, int(target)) mitm_mapper.collect_quest_stats(origin, fort_id) query_quests = ( "INSERT INTO trs_quest (GUID, quest_type, quest_timestamp, quest_stardust, quest_pokemon_id, " "quest_reward_type, quest_item_id, quest_item_amount, quest_target, quest_condition, quest_reward, " "quest_task, quest_template) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" "ON DUPLICATE KEY UPDATE quest_type=VALUES(quest_type), quest_timestamp=VALUES(quest_timestamp), " "quest_stardust=VALUES(quest_stardust), quest_pokemon_id=VALUES(quest_pokemon_id), " "quest_reward_type=VALUES(quest_reward_type), quest_item_id=VALUES(quest_item_id), " "quest_item_amount=VALUES(quest_item_amount), quest_target=VALUES(quest_target), " "quest_condition=VALUES(quest_condition), quest_reward=VALUES(quest_reward), " "quest_task=VALUES(quest_task), quest_template=VALUES(quest_template)" ) vals = (fort_id, quest_type, time.time(), stardust, pokemon_id, reward_type, item_item, item_amount, target, json_condition, json.dumps(rewards), task, quest_template) logger.debug( "DbPogoProtoSubmit::quest submitted quest typ {} at stop {}", str(quest_type), str(fort_id)) self._db_exec.execute(query_quests, vals, commit=True) return True
def submit_quest_proto(self, map_proto): logger.debug("DbWrapperBase::submit_quest_proto called") fort_id = map_proto.get("fort_id", None) if fort_id is None: return False if 'challenge_quest' not in map_proto: return False quest_type = map_proto['challenge_quest']['quest'].get( "quest_type", None) quest_template = map_proto['challenge_quest']['quest'].get( "template_id", None) if map_proto['challenge_quest']['quest'].get("quest_rewards", None): rewardtype = map_proto['challenge_quest']['quest'][ 'quest_rewards'][0].get("type", None) reward = map_proto['challenge_quest']['quest'].get( "quest_rewards", None) item = map_proto['challenge_quest']['quest']['quest_rewards'][0][ 'item'].get("item", None) itemamount = map_proto['challenge_quest']['quest'][ 'quest_rewards'][0]['item'].get("amount", None) stardust = map_proto['challenge_quest']['quest']['quest_rewards'][ 0].get("stardust", None) pokemon_id = map_proto['challenge_quest']['quest'][ 'quest_rewards'][0]['pokemon_encounter'].get( "pokemon_id", None) target = map_proto['challenge_quest']['quest']['goal'].get( "target", None) condition = map_proto['challenge_quest']['quest']['goal'].get( "condition", None) task = questtask(int(quest_type), str(condition), int(target)) query_quests = ( "INSERT INTO trs_quest (GUID, quest_type, quest_timestamp, quest_stardust, quest_pokemon_id, " "quest_reward_type, quest_item_id, quest_item_amount, quest_target, quest_condition, quest_reward, " "quest_task, quest_template) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" "ON DUPLICATE KEY UPDATE quest_type=VALUES(quest_type), quest_timestamp=VALUES(quest_timestamp), " "quest_stardust=VALUES(quest_stardust), quest_pokemon_id=VALUES(quest_pokemon_id), " "quest_reward_type=VALUES(quest_reward_type), quest_item_id=VALUES(quest_item_id), " "quest_item_amount=VALUES(quest_item_amount), quest_target=VALUES(quest_target), " "quest_condition=VALUES(quest_condition), quest_reward=VALUES(quest_reward), " "quest_task=VALUES(quest_task), quest_template=VALUES(quest_template)" ) vals = (fort_id, quest_type, time.time(), stardust, pokemon_id, rewardtype, item, itemamount, target, str(condition), str(reward), task, quest_template) logger.debug( "DbWrapperBase::submit_quest_proto submitted quest typ {} at stop {}", str(quest_type), str(fort_id)) self.execute(query_quests, vals, commit=True) return True