示例#1
0
文件: config.py 项目: linkclau/MAD
 def settings_ivlist(self):
     try:
         identifier = request.args.get('id')
         current_mons = self._data_manager.get_data(identifier)['mon_ids_iv']
     except Exception as err:
         current_mons = []
     all_pokemon = self.get_pokemon()
     mondata = all_pokemon['mondata']
     current_mons_list = []
     for mon_id in current_mons:
         try:
             mon_name = i8ln(mondata[str(mon_id)]["name"])
         except KeyError:
             mon_name = "No-name-in-file-please-fix"
         current_mons_list.append({"mon_name": mon_name, "mon_id": str(mon_id)})
     required_data = {
         'identifier': 'id',
         'base_uri': '/api/monivlist',
         'redirect': '/settings/ivlists',
         'html_single': 'settings_singleivlist.html',
         'html_all': 'settings_ivlists.html',
         'subtab': 'monivlist',
         'passthrough': {
             'current_mons_list': current_mons_list
         }
     }
     return self.process_element(**required_data)
示例#2
0
def get_mons():
    mons = []
    monList =[]

    mondata = open_json_file('pokemon')

    with open('raidmons.json') as f:
        raidmon = json.load(f)

    for mons in raidmon:
        for mon in mons['DexID']:
            lvl = mons['Level']
            if str(mon).find("_") > -1:
                mon_split = str(mon).split("_")
                mon = mon_split[0]
                frmadd = mon_split[1]
            else:
                frmadd = "00"

            mon = '{:03d}'.format(int(mon))

            monPic = '/asset/pokemon_icons/pokemon_icon_' + mon + '_00.png'
            monName = 'unknown'
            monid = int(mon)

            if str(monid) in mondata:
                monName = i8ln(mondata[str(monid)]["name"])

            monJson = ({'filename': monPic, 'mon': monid, 'name': monName, 'lvl': lvl})
            monList.append(monJson)

    return jsonify(monList)
示例#3
0
    def get_map_mons(self):
        import traceback
        neLat, neLon, swLat, swLon, oNeLat, oNeLon, oSwLat, oSwLon = getBoundParameter(
            request)
        timestamp = request.args.get("timestamp", None)

        data = self._db.get_mons_in_rectangle(neLat=neLat,
                                              neLon=neLon,
                                              swLat=swLat,
                                              swLon=swLon,
                                              oNeLat=oNeLat,
                                              oNeLon=oNeLon,
                                              oSwLat=oSwLat,
                                              oSwLon=oSwLon,
                                              timestamp=timestamp)

        mons_raw = {}

        for i, mon in enumerate(data):
            try:
                id = data[i]["mon_id"]
                if str(id) in mons_raw:
                    mon_raw = mons_raw[str(id)]
                else:
                    mon_raw = get_raid_boss_cp(id)
                    mons_raw[str(id)] = mon_raw

                data[i]["encounter_id"] = str(data[i]["encounter_id"])
                data[i]["name"] = i8ln(mon_raw["name"])
            except Exception:
                traceback.print_exc()

        return jsonify(data)
示例#4
0
    def game_stats_mon(self):
        minutes_spawn = request.args.get('minutes_spawn', 10)

        # Spawn
        iv = []
        noniv = []
        sumg = []
        sumup = {}

        data = self._db_stats_reader.get_pokemon_count(minutes_spawn)
        for dat in data:
            if dat[2] == 1:
                iv.append([(self.utc2local(dat[0]) * 1000), dat[1]])
            else:
                noniv.append([(self.utc2local(dat[0]) * 1000), dat[1]])

            if (self.utc2local(dat[0]) * 1000) in sumup:
                sumup[(self.utc2local(dat[0]) * 1000)] += dat[1]
            else:
                sumup[(self.utc2local(dat[0]) * 1000)] = dat[1]

        for dat in sumup:
            sumg.append([dat, sumup[dat]])

        spawn = {'iv': iv, 'noniv': noniv, 'sum': sumg}

        # good_spawns avg
        good_spawns = []
        data = self._db_stats_reader.get_best_pokemon_spawns()
        if data is not None:
            for dat in data:
                mon = "%03d" % dat[1]
                monPic = 'asset/pokemon_icons/pokemon_icon_' + mon + '_00.png'
                monName_raw = (get_raid_boss_cp(dat[1]))
                monName = i8ln(monName_raw['name'])
                if self._args.db_method == "rm":
                    lvl = calculate_mon_level(dat[6])
                else:
                    lvl = dat[6]
                good_spawns.append({
                    'id':
                    dat[1],
                    'iv':
                    round(calculate_iv(dat[3], dat[4], dat[5]), 0),
                    'lvl':
                    lvl,
                    'cp':
                    dat[7],
                    'img':
                    monPic,
                    'name':
                    monName,
                    'periode':
                    datetime.datetime.fromtimestamp(self.utc2local(
                        dat[2])).strftime(self._datetimeformat)
                })

        stats = {'spawn': spawn, 'good_spawns': good_spawns}
        return jsonify(stats)
示例#5
0
def generate_quest(quest):
    gettext.find('quest', 'locales', all=True)
    lang = gettext.translation('quest', localedir='locale', fallback=True)
    lang.install()

    quest_reward_type = questreward(quest['quest_reward_type'])
    quest_type = questtype(quest['quest_type'])
    if '{0}' in quest_type:
        quest_type = quest_type.replace('{0}', str(quest['quest_target']))

    item_id = 0
    item_amount = 1
    pokemon_id = '000'
    pokemon_name = ''
    item_type = ''
    pokemon_form = extractForm(quest["quest_reward"])

    if quest_reward_type == _('Item'):
        item_amount = quest['quest_item_amount']
        item_type = rewarditem(quest['quest_item_id'])
        item_id = quest['quest_item_id']
    elif quest_reward_type == _('Stardust'):
        item_amount = quest['quest_stardust']
        item_type = _('Stardust')
    elif quest_reward_type == _('Pokemon'):
        item_type = 'Pokemon'
        pokemon_name = i8ln(pokemonname(str(quest['quest_pokemon_id'])))
        pokemon_id = quest['quest_pokemon_id']

    if not quest['task']:
        quest_task = questtask(
            quest['quest_type'], quest['quest_condition'], quest['quest_target'])
    else:
        quest_task = quest['task']

    quest_raw = ({
        'pokestop_id': quest['pokestop_id'],
        'name': quest['name'],
        'url': quest['image'],
        'latitude': quest['latitude'],
        'longitude': quest['longitude'],
        'timestamp': quest['quest_timestamp'],
        'item_id': item_id,
        'item_amount': item_amount,
        'item_type': item_type,
        'pokemon_id': pokemon_id,
        'pokemon_name': pokemon_name,
        'pokemon_form': pokemon_form,
        'quest_type': quest_type,
        'quest_type_raw': quest['quest_type'],
        'quest_reward_type': quest_reward_type,
        'quest_reward_type_raw': quest['quest_reward_type'],
        'quest_task': quest_task,
        'quest_target': quest['quest_target'],
        'quest_condition': quest['quest_condition'],
        'quest_template': quest['quest_template']
    })
    return quest_raw
示例#6
0
文件: config.py 项目: Hupe7/MAD
 def get_pokemon(self):
     mondata = open_json_file('pokemon')
     # Why o.O
     stripped_mondata = {}
     for mon_id in mondata:
         stripped_mondata[mondata[str(mon_id)]["name"]] = mon_id
         if os.environ['LANGUAGE'] != "en":
             try:
                 localized_name = i8ln(mondata[str(mon_id)]["name"])
                 stripped_mondata[localized_name] = mon_id
             except KeyError:
                 pass
     return {'mondata': mondata, 'locale': stripped_mondata}
示例#7
0
def generate_quest(quest):
    
    gettext.find('quest', 'locales', all=True)
    lang = gettext.translation('quest', localedir='locale', fallback=True)
    lang.install()
    
    pokestop_id  = (quest['pokestop_id'])
    quest_reward_type = (questreward(quest['quest_reward_type']))
    quest_reward_type_raw = quest['quest_reward_type']
    quest_type_raw = quest['quest_type']
    quest_type = (questtype(quest['quest_type']))
    quest_condition = quest['quest_condition']
    name = quest['name']
    latitude = quest['latitude']
    longitude = quest['longitude']
    url = quest['image']
    timestamp = quest['quest_timestamp']
    quest_target = str(quest['quest_target'])
    
    if quest_reward_type == _("Item"):
        item_amount = str(quest['quest_item_amount'])
        item_id = quest['quest_item_id']
        item_type = str(rewarditem(quest['quest_item_id']))
        pokemon_id = "0"
        pokemon_name = ""
    elif quest_reward_type == _("Stardust"):
        item_amount = str(quest['quest_stardust'])
        item_type = _("Stardust")
        item_id = "000"
        pokemon_id = "0"
        pokemon_name = ""
    elif quest_reward_type == _("Pokemon"):
        item_amount = "1"
        item_type = "Pokemon"
        item_id = "000"
        pokemon_name = i8ln(pokemonname(str(quest['quest_pokemon_id'])))
        pokemon_id = str(quest['quest_pokemon_id'])
    if '{0}' in quest_type:
        quest_type_text = quest_type.replace('{0}', quest_target)            

    if not quest['task']:
        quest_task = questtask(quest['quest_type'], quest['quest_condition'], quest['quest_target'])
    else:
        quest_task = quest['task']
        
    quest_raw = ({'pokestop_id': pokestop_id, 'latitude': latitude, 'longitude': longitude, 
        'quest_type_raw': quest_type_raw, 'quest_type': quest_type_text, 'quest_condition': quest_condition, 'item_amount': item_amount, 'item_type': item_type, 
        'quest_target': quest_target, 'name': name, 'url': url, 'timestamp': timestamp, 'pokemon_id': pokemon_id, 'item_id': item_id,
        'pokemon_name': pokemon_name, 'quest_reward_type': quest_reward_type, 'quest_reward_type_raw': quest_reward_type_raw, 'quest_task': quest_task,
        'quest_condition': quest_condition})
    return quest_raw
示例#8
0
def get_raids():
    raids = []
    eggIdsByLevel = [1, 1, 2, 2, 3]

    data = db_wrapper.get_gym_infos()

    mondata = open_json_file('pokemon')

    hashdata = json.loads(getAllHash('raid'))

    for file in glob.glob("ocr/www_hash/raid_*.jpg"):
        unkfile = re.search('raid_(-?\d+)_(-?\d+)_((?s).*)\.jpg', file)
        hashvalue = (unkfile.group(3))

        if str(hashvalue) in hashdata:
            monName = 'unknown'
            raidjson = hashdata[str(hashvalue)]["id"]
            count = hashdata[hashvalue]["count"]
            modify = hashdata[hashvalue]["modify"]

            raidHash_ = decodeHashJson(raidjson)
            gymid = raidHash_[0]
            lvl = raidHash_[1]
            mon = int(raidHash_[2])
            monid = int(raidHash_[2])
            mon = "%03d" % mon

            if mon == '000':
                type = 'egg'
                monPic = ''
            else:
                type = 'mon'
                monPic = '/asset/pokemon_icons/pokemon_icon_' + mon + '_00.png'
                if str(monid) in mondata:
                    monName = i8ln(mondata[str(monid)]["name"])

            eggId = eggIdsByLevel[int(lvl) - 1]
            if eggId == 1:
                eggPic = '/asset/static_assets/png/ic_raid_egg_normal.png'
            if eggId == 2:
                eggPic = '/asset/static_assets/png/ic_raid_egg_rare.png'
            if eggId == 3:
                eggPic = '/asset/static_assets/png/ic_raid_egg_legendary.png'

            creationdate = datetime.datetime.fromtimestamp(creation_date(file)).strftime('%Y-%m-%d %H:%M:%S')

            if conf_args.madmin_time == "12":
                creationdate = datetime.datetime.strptime(creationdate, '%Y-%m-%d %H:%M:%S').strftime('%Y-%m-%d %I:%M:%S %p')
                modify = datetime.datetime.strptime(modify, '%Y-%m-%d %H:%M:%S').strftime('%Y-%m-%d %I:%M:%S %p')

            name = 'unknown'
            lat = '0'
            lon = '0'
            url = '0'
            description = ''

            gymImage = 'ocr/gym_img/_' + str(gymid) + '_.jpg'

            if str(gymid) in data:
                name = data[str(gymid)]["name"].replace("\\", r"\\").replace('"', '')
                lat = data[str(gymid)]["latitude"]
                lon = data[str(gymid)]["longitude"]
                if data[str(gymid)]["description"]:
                    description = data[str(gymid)]["description"].replace("\\", r"\\").replace('"', '').replace("\n", "")

            raidJson = ({'id': gymid, 'lat': lat, 'lon': lon, 'hashvalue': hashvalue, 'filename': file[4:], 'name': name, 'description': description, 'gymimage': gymImage, 'count': count, 'creation': creationdate, 'modify': modify,  'level': lvl, 'mon': mon, 'type': type, 'eggPic': eggPic, 'monPic': monPic, 'monname': monName })
            raids.append(raidJson)
        else:
            log.debug("File: " + str(file) + " not found in Database")
            os.remove(str(file))
            continue

    return jsonify(raids)
示例#9
0
文件: questGen.py 项目: spammer23/MAD
def questtask(typeid, condition, target):
    gettext.find('quest', 'locales', all=True)
    lang = gettext.translation('quest', localedir='locale', fallback=True)
    lang.install()

    pokemonTypes = open_json_file('pokemonTypes')
    items = open_json_file('items')
    throwTypes = {"10": _("Nice"), "11": _("Great"),
                  "12": _("Excellent"), "13": _("Curveball")}
    arr = {}
    arr['0'] = target
    text = questtype(typeid)

    if typeid == 4:
        arr['wb'] = ""
        arr['type'] = ""
        arr['poke'] = ""
        text = _("Catch {0} {type}Pokemon{wb}.")
        match_object = re.search(r'"pokemon_type": \[([0-9, ]+)\]', condition)
        if match_object is not None:
            pt = match_object.group(1).split(', ')
            last = len(pt)
            cur = 1
            if last == 1:
                arr['type'] = pokemonTypes[pt[0]].title() + _('-type ')
            else:
                for ty in pt:
                    arr['type'] += (_('or ') if last == cur else '') + \
                        pokemonTypes[ty].title() + (_('-type ')
                                                    if last == cur else '-, ')
                    cur += 1
        if re.search(r"'type': 3", condition) is not None:
            arr['wb'] = _(" with weather boost")
        match_object = re.search(r'"pokemon_ids": \[([0-9, ]+)\]', condition)
        if match_object is not None:
            pt = match_object.group(1).split(', ')
            last = len(pt)
            cur = 1
            if last == 1:
                arr['poke'] = i8ln(pokemonname(pt[0]))
            else:
                for ty in pt:
                    arr['poke'] += (_('or ') if last == cur else '') + \
                        i8ln(pokemonname(ty)) + ('' if last == cur else ', ')
                    cur += 1
            text = _('Catch {0} {poke}.')
    elif typeid == 5:
        text = _("Spin {0} Pokestops or Gyms.")
        if re.search(r'"type": 12', condition) is not None:
            text = _("Spin {0} never visited Pokestops or Gyms.")
    elif typeid == 6:
        text = _("Hatch {0} Eggs.")
    elif typeid == 7:
        if re.search(r'"type": 9', condition) is not None:
            text = _("Win {0} Gym Battles.")
        elif re.search(r'"type": 10', condition) is not None:
            text = _("Use a supereffective Charged Attack in {0} Gym battles.")
        else:
            text = _("Battle in a Gym {0} times.")
    elif typeid == 8:
        if re.search(r'"type": 6', condition) is not None:
            text = _("Win {0} Raids.")
            if re.search(r'"raid_level": \[3, 4, 5\]', condition) is not None:
                text = _('Win a level 3 or higher raid.')
            if re.search(r'"raid_level": \[2, 3, 4, 5\]', condition) is not None:
                text = _('Win a level 2 or higher raid.')
        else:
            text = _("Battle in {0} Raids.")
    elif typeid == 10:
        text = _("Transfer {0} Pokemon.")
    elif typeid == 11:
        test = _("Favourite {0} Pokemon.")
    elif typeid == 13:
        text = _('Use {0} {type}Berries to help catch Pokemon.')
        arr['type'] = ""
        match_object = re.search(r'"item": ([0-9]+)', condition)
        if match_object is not None:
            arr['type'] = items[match_object.group(
                1)]['name'].replace(_(' Berry'), '')+" "
    elif typeid == 14:
        text = _('Power up Pokemon {0} times.')
    elif typeid == 15:
        text = _("Evolve {0} Pokemon.")
        # [{'type': 1, 'with_pokemon_type': {'pokemon_type': [12]}}]
        if re.search(r'"type": 11', condition) is not None:
            text = _("Use an item to evolve a Pokemon.")
        elif re.search(r'"type": 1', condition) is not None:
            text = _("Evolve {0} {type}Pokemon")
            arr['wb'] = ""
            arr['type'] = ""
            arr['poke'] = ""
            match_object = re.search(
                r'"pokemon_type": \[([0-9, ]+)\]', condition)
            if match_object is not None:
                pt = match_object.group(1).split(', ')
                last = len(pt)
                cur = 1
                if last == 1:
                    arr['type'] = pokemonTypes[pt[0]].title() + _('-type ')
                else:
                    for ty in pt:
                        arr['type'] += (_('or ') if last == cur else '') + pokemonTypes[ty].title() + (
                            _('-type ') if last == cur else '-, ')
                        cur += 1
        elif re.search(r'"type": 2', condition) is not None:
            arr['wb'] = ""
            arr['type'] = ""
            arr['poke'] = ""

            match_object = re.search(
                r'"pokemon_ids": \[([0-9, ]+)\]', condition)
            if match_object is not None:
                pt = match_object.group(1).split(', ')
                last = len(pt)
                cur = 1
                if last == 1:
                    arr['poke'] = i8ln(pokemonname(pt[0]))
                else:
                    for ty in pt:
                        arr['poke'] += (_('or ') if last == cur else '') + i8ln(pokemonname(ty)) + (
                            '' if last == cur else ', ')
                        cur += 1
                text = _('Evolve {0} {poke}.')
    elif typeid == 16:
        arr['inrow'] = ""
        arr['curve'] = ""
        arr['type'] = ""
        if re.search(r'"type": 14', condition) is not None:
            arr['inrow'] = _(" in a row")
        if re.search(r'"type": 15', condition) is not None:
            arr['curve'] = _("Curveball ")
        match_object = re.search(r'"throw_type": ([0-9]{2})', condition)
        if match_object is not None:
            arr['type'] = throwTypes[match_object.group(1)]+" "
        text = _("Make {0} {type}{curve}Throws{inrow}.")
    elif typeid == 17:
        text = _('Earn {0} Candies walking with your buddy.')
    elif typeid == 23:
        text = _('Trade {0} Pokemon.')
    elif typeid == 24:
        text = _('Send {0} gifts to friends.')

    if int(target) == int(1):
        text = text.replace(_(' Eggs'), _('n Egg'))
        text = text.replace(_(' Raids'), _(' Raid'))
        text = text.replace(_(' Battles'), _(' Battle'))
        text = text.replace(_(' candies'), _(' candy'))
        text = text.replace(_(' gifts'), _(' gift'))
        text = text.replace(_(' {0} times'), '')
        arr['0'] = _("a")

    for key, val in arr.items():
        text = text.replace('{'+key+'}', str(val))

    text = text.replace(' .', '.')
    text = text.replace('  ', ' ')
    return text
示例#10
0
def questtask(typeid, condition, target):
    gettext.find('quest', 'locales', all=True)
    lang = gettext.translation('quest', localedir='locale', fallback=True)
    lang.install()

    pokemonTypes = open_json_file('pokemonTypes')
    items = open_json_file('items')
    throwTypes = {"10": _("Nice"), "11": _("Great"),
                  "12": _("Excellent"), "13": _("Curveball")}
    arr = {}
    arr['0'] = target
    text = questtype(typeid)

    if typeid == 4:
        arr['wb'] = ""
        arr['type'] = ""
        arr['poke'] = ""
        arr['different'] = ""

        text = _("Catch {0}{different} {type}Pokemon{wb}")
        match_object = re.search(r'"pokemon_type": \[([0-9, ]+)\]', condition)
        if match_object is not None:
            pt = match_object.group(1).split(', ')
            last = len(pt)
            cur = 1
            if last == 1:
                arr['type'] = pokemonTypes[pt[0]].title() + _('-type ')
            else:
                for ty in pt:
                    arr['type'] += (_('or ') if last == cur else '') + \
                        pokemonTypes[ty].title() + (_('-type ')
                                                    if last == cur else '-, ')
                    cur += 1
        if re.search(r'"type": 3', condition) is not None:
            arr['wb'] = _(" with weather boost")
        elif re.search(r'"type": 21', condition) is not None:
            arr['different'] = _(" different species of")
        match_object = re.search(r'"pokemon_ids": \[([0-9, ]+)\]', condition)
        if match_object is not None:
            pt = match_object.group(1).split(', ')
            last = len(pt)
            cur = 1
            if last == 1:
                arr['poke'] = i8ln(pokemonname(pt[0]))
            else:
                for ty in pt:
                    arr['poke'] += (_('or ') if last == cur else '') + \
                        i8ln(pokemonname(ty)) + ('' if last == cur else ', ')
                    cur += 1
            text = _('Catch {0} {poke}')
    elif typeid == 5:
        text = _("Spin {0} Pokestops or Gyms")
        if re.search(r'"type": 12', condition) is not None:
            text = _("Spin {0} Pokestops you haven't visited before")
    elif typeid == 6:
        text = _("Hatch {0} Eggs")
    elif typeid == 7:
        if re.search(r'"type": 9', condition) is not None:
            text = _("Win {0} Gym Battles")
        elif re.search(r'"type": 10', condition) is not None:
            text = _("Use a supereffective Charged Attack in {0} Gym battles")
        else:
            text = _("Battle in a Gym {0} times")
    elif typeid == 8:
        if re.search(r'"type": 6', condition) is not None:
            text = _("Win {0} Raids")
            if re.search(r'"raid_level": \[3, 4, 5\]', condition) is not None:
                text = _('Win a level 3 or higher raid')
            if re.search(r'"raid_level": \[2, 3, 4, 5\]', condition) is not None:
                text = _('Win a level 2 or higher raid')
        else:
            text = _("Battle in {0} Raids")
    elif typeid == 10:
        text = _("Transfer {0} Pokemon")
    elif typeid == 11:
        text = _("Favourite {0} Pokemon")
    elif typeid == 13:
        text = _('Use {0} {type}Berries to help catch Pokemon')
        arr['type'] = ""
        match_object = re.search(r'"item": ([0-9]+)', condition)
        if match_object is not None:
            arr['type'] = items[match_object.group(
                1)]['name'].replace(_(' Berry'), '')+" "
    elif typeid == 14:
        text = _('Power up Pokemon {0} times')
    elif typeid == 15:
        text = _("Evolve {0} Pokemon")
        if re.search(r'"type": 11', condition) is not None:
            text = _("Use an item to evolve a Pokemon")
        elif re.search(r'"type": 1', condition) is not None:
            text = _("Evolve {0} {type}Pokemon")
            arr['wb'] = ""
            arr['type'] = ""
            arr['poke'] = ""
            match_object = re.search(
                r'"pokemon_type": \[([0-9, ]+)\]', condition)
            if match_object is not None:
                pt = match_object.group(1).split(', ')
                last = len(pt)
                cur = 1
                if last == 1:
                    arr['type'] = pokemonTypes[pt[0]].title() + _('-type ')
                else:
                    for ty in pt:
                        arr['type'] += (_('or ') if last == cur else '') + pokemonTypes[ty].title() + (
                            _('-type ') if last == cur else '-, ')
                        cur += 1
        elif re.search(r'"type": 2', condition) is not None:
            arr['wb'] = ""
            arr['type'] = ""
            arr['poke'] = ""

            match_object = re.search(
                r'"pokemon_ids": \[([0-9, ]+)\]', condition)
            if match_object is not None:
                pt = match_object.group(1).split(', ')
                last = len(pt)
                cur = 1
                if last == 1:
                    arr['poke'] = i8ln(pokemonname(pt[0]))
                else:
                    for ty in pt:
                        arr['poke'] += (_('or ') if last == cur else '') + i8ln(pokemonname(ty)) + (
                            '' if last == cur else ', ')
                        cur += 1
                text = _('Evolve {0} {poke}')
    elif typeid == 16:
        arr['inrow'] = ""
        arr['curve'] = ""
        arr['type'] = ""
        if re.search(r'"type": 14', condition) is not None:
            arr['inrow'] = _(" in a row")
        if re.search(r'"type": 15', condition) is not None:
            arr['curve'] = _("Curveball ")
        match_object = re.search(r'"throw_type": ([0-9]{2})', condition)
        if match_object is not None:
            arr['type'] = throwTypes[match_object.group(1)]+" "
        text = _("Make {0} {type}{curve}Throws{inrow}")
    elif typeid == 17:
        text = _('Earn {0} Candies walking with your buddy')
    elif typeid == 22:
        if int(target) == int(1):
            text = _('Make a new friend')
        else:
            text = _('Make {0} new friends')
    elif typeid == 23:
        text = _('Trade {0} Pokemon')
        arr['distance'] = ""
        if re.search(r'"type": 25', condition) is not None:
            arr['distance'] = re.search(r'"distance_km": ([0-9, ]+)', condition).group(1)
            if int(target) == int(1):
                text = _('Trade Pokemon caught {distance} km apart')
            else:
                text = _('Trade {0} Pokemon caught {distance} km apart')
    elif typeid == 24:
        text = _('Send {0} gifts to friends')
    elif typeid == 27:
        # PVP against trainer or team leader.
        if re.search(r'"type": 22', condition) is not None:
            text = _('Battle a Team Leader {0} times')
        elif re.search(r'"type": 23', condition) is not None:
            text = _('Battle another Trainer {0} times')
    elif typeid == 28:
        # Take snapshots quest
        if re.search(r'"type": 28', condition) is not None:
            text = _("Take {0} snapshots of your Buddy")
        elif re.search(r'"type": 2', condition) is not None:
            arr['poke'] = ""

            match_object = re.search(
                r'"pokemon_ids": \[([0-9, ]+)\]', condition)
            if match_object is not None:
                pt = match_object.group(1).split(', ')
                last = len(pt)
                cur = 1
                if last == 1:
                    arr['poke'] = i8ln(pokemonname(pt[0]))
                else:
                    for ty in pt:
                        arr['poke'] += (_('or ') if last == cur else '') + i8ln(pokemonname(ty)) + (
                            '' if last == cur else ', ')
                        cur += 1
                text = _("Take {0} snapshots of {poke}")
        elif re.search(r'"type": 1', condition) is not None:
            text = _("Take {0} snapshots of {type} Pokemon")
            arr['wb'] = ""
            arr['type'] = ""
            arr['poke'] = ""
            match_object = re.search(
                r'"pokemon_type": \[([0-9, ]+)\]', condition)
            if match_object is not None:
                pt = match_object.group(1).split(', ')
                last = len(pt)
                cur = 1
                if last == 1:
                    arr['type'] = pokemonTypes[pt[0]].title() + _('-type ')
                else:
                    for ty in pt:
                        arr['type'] += (_('or ') if last == cur else '') + pokemonTypes[ty].title() + (
                            _('-type ') if last == cur else '-, ')
                        cur += 1
    elif typeid == 29:
        # QUEST_BATTLE_TEAM_ROCKET Team Go rucket grunt batles.
        # Condition type 27 means against a grunt leader WITH_INVASION_CHARACTER
        if re.search(r'"type": 27', condition) is not None:
            text = _('Battle {0} times against the Team GO Rocket Leaders')
        elif int(target) == int(1):
            text = _('Battle against a Team Rocket Grunt')

        # Condition type 18 means win a battle
        if re.search(r'"type": 18', condition) is not None:
            text = text.replace(_('Battle'), _('Win'))

    if int(target) == int(1):
        text = text.replace(_(' Eggs'), _('n Egg'))
        text = text.replace(_(' Raids'), _(' Raid'))
        text = text.replace(_(' Battles'), _(' Battle'))
        text = text.replace(_(' candies'), _(' candy'))
        text = text.replace(_(' gifts'), _(' gift'))
        text = text.replace(_(' Pokestops'), _(' Pokestop'))
        text = text.replace(_(' {0} snapshots'), _(' a snapshot'))
        text = text.replace(_('Make {0} {type}{curve}Throws'), _('Make a {type}{curve}Throw'))
        text = text.replace(_(' {0} times'), '')
        text = text.replace(_('{0} hearts'), _('a heart'))
        arr['0'] = _("a")

    for key, val in arr.items():
        text = text.replace('{'+key+'}', str(val))

    text = text.replace('  ', ' ').strip()
    return text
示例#11
0
    def game_stats_shiny_v2(self):
        logger.debug('game_stats_shiny_v2')
        timestamp_from = request.args.get('from', None)
        if (timestamp_from):
            timestamp_from = self.local2utc(int(timestamp_from))
            logger.debug('using timestamp_from: {}', timestamp_from)

        timestamp_to = request.args.get('to', None)
        if (timestamp_to):
            timestamp_to = self.local2utc(int(timestamp_to))
            logger.debug('using timestamp_to: {}', timestamp_to)

        tmp_perworker_v2 = {}
        data = self._db.statistics_get_shiny_stats_v2(timestamp_from,
                                                      timestamp_to)
        # SELECT pokemon.pokemon_id, pokemon.form, pokemon.latitude, pokemon.longitude, pokemon.gender, pokemon.costume, tr.count, tr.timestamp_scan, tr.worker, pokemon.encounter_id
        found_shiny_mon_id = []
        shiny_count = {}
        mon_names = {}
        tmp_perhour_v2 = {}

        if data is None or len(data) == 0:
            return jsonify({'empty': True})

        shiny_stats_v2 = []
        for dat in data:
            form_suffix = "%02d" % form_mapper(dat[0], dat[1])
            mon = "%03d" % dat[0]
            monPic = 'asset/pokemon_icons/pokemon_icon_' + mon + '_' + form_suffix + '_shiny.png'
            monName_raw = (get_raid_boss_cp(dat[0]))
            monName = i8ln(monName_raw['name'])
            mon_names[dat[0]] = monName
            found_shiny_mon_id.append(
                mon
            )  # append everything now, we will set() it later to remove duplicates
            if dat[8] not in tmp_perworker_v2:
                tmp_perworker_v2[dat[8]] = 0
            tmp_perworker_v2[dat[8]] += 1

            if dat[0] not in shiny_count:
                shiny_count[dat[0]] = {}
            if dat[1] not in shiny_count[dat[0]]:
                shiny_count[dat[0]][dat[1]] = 0
            shiny_count[dat[0]][dat[1]] += 1

            # there is later strftime which converts to local time too, can't use utc2local - it will do double shift
            timestamp = datetime.datetime.fromtimestamp(dat[7])

            if timestamp.hour in tmp_perhour_v2:
                tmp_perhour_v2[timestamp.hour] += 1
            else:
                tmp_perhour_v2[timestamp.hour] = 1

            shiny_stats_v2.append({
                'img':
                monPic,
                'name':
                monName,
                'worker':
                dat[8],
                'lat':
                dat[2],
                'lat_5':
                "{:.5f}".format(dat[2]),
                'lng_5':
                "{:.5f}".format(dat[3]),
                'lng':
                dat[3],
                'timestamp':
                timestamp.strftime(self._datetimeformat),
                'form':
                dat[1],
                'mon_id':
                dat[0],
                'encounter_id':
                dat[9]
            })

        #print(shiny_count)
        global_shiny_stats_v2 = []
        data = self._db.statistics_get_shiny_stats_global_v2(
            set(found_shiny_mon_id), timestamp_from, timestamp_to)
        for dat in data:
            if dat[1] in shiny_count and dat[2] in shiny_count[dat[1]]:
                odds = round(dat[0] / shiny_count[dat[1]][dat[2]], 0)
                form_suffix = "%02d" % form_mapper(dat[1], dat[2])
                mon = "%03d" % dat[1]
                monPic = 'asset/pokemon_icons/pokemon_icon_' + mon + '_' + form_suffix + '_shiny.png'
                global_shiny_stats_v2.append({
                    'name':
                    mon_names[dat[1]],
                    'count':
                    dat[0],
                    'img':
                    monPic,
                    'shiny':
                    shiny_count[dat[1]][dat[2]],
                    'odds':
                    odds,
                    'mon_id':
                    dat[1],
                    'form':
                    dat[2],
                    'gender':
                    dat[3],
                    'costume':
                    dat[4]
                })

        shiny_stats_perworker_v2 = []
        for worker in tmp_perworker_v2:
            shiny_stats_perworker_v2.append({
                'name': worker,
                'count': tmp_perworker_v2[worker]
            })

        shiny_stats_perhour_v2 = []
        for hour in tmp_perhour_v2:
            shiny_stats_perhour_v2.append([hour, tmp_perhour_v2[hour]])

        stats = {
            'empty': False,
            'shiny_statistics': shiny_stats_v2,
            'global_shiny_statistics': global_shiny_stats_v2,
            'per_worker': shiny_stats_perworker_v2,
            'per_hour': shiny_stats_perhour_v2
        }
        return jsonify(stats)
示例#12
0
    def shiny_stats_data(self):
        # shiny hour

        shiny_hour_temp = {}
        shiny_hour_calc = {}
        shiny_hour = []
        data = self._db.statistics_get_shiny_stats_hour()
        for dat in data:
            if dat[1] not in shiny_hour_temp:
                shiny_hour_temp[dat[1]] = dat[0]

        for dat in shiny_hour_temp:
            if shiny_hour_temp[dat] not in shiny_hour_calc:
                shiny_hour_calc[shiny_hour_temp[dat]] = 0
            shiny_hour_calc[shiny_hour_temp[dat]] += 1

        for dat in sorted(shiny_hour_calc):
            sht = ([
                self.utc2local(dat * 60 * 60) * 1000, shiny_hour_calc[dat]
            ])
            shiny_hour.append(sht)

        shiny_stats = []
        shiny_worker = {}
        shiny_avg = {}
        data = self._db.statistics_get_shiny_stats()
        for dat in data:
            form_suffix = "%02d" % form_mapper(dat[2], dat[5])
            mon = "%03d" % dat[2]
            monPic = 'asset/pokemon_icons/pokemon_icon_' + mon + '_' + form_suffix + '_shiny.png'
            monName_raw = (get_raid_boss_cp(dat[2]))
            monName = i8ln(monName_raw['name'])
            diff: int = dat[0]
            if diff == 0:
                logger.warning(
                    'No deeper mon stats are possible - not enought data '
                    '(check config.ini // game_stats_raw)')
                diff = 1

            ratio = round(dat[1] * 100 / diff, 2)
            if dat[3] not in shiny_worker: shiny_worker[dat[3]] = 0
            shiny_worker[dat[3]] += dat[1]

            if dat[2] not in shiny_avg: shiny_avg[dat[2]] = {}
            if dat[5] not in shiny_avg[dat[2]]:
                shiny_avg[dat[2]][dat[5]] = {}
                shiny_avg[dat[2]][dat[5]]['total_shiny'] = []
                shiny_avg[dat[2]][dat[5]]['total_nonshiny'] = []

            shiny_avg[dat[2]][dat[5]]['total_shiny'].append(dat[1])
            shiny_avg[dat[2]][dat[5]]['total_nonshiny'].append(diff)

            shiny_stats.append({
                'sum':
                dat[0],
                'shiny':
                dat[1],
                'img':
                monPic,
                'name':
                monName,
                'ratio':
                ratio,
                'worker':
                dat[3],
                'encounterid':
                dat[4],
                'periode':
                datetime.datetime.fromtimestamp(dat[6]).strftime(
                    self._datetimeformat)
            })

        shiny_stats_avg = []
        for dat in shiny_avg:
            for form_dat in shiny_avg[dat]:
                form_suffix = "%02d" % form_mapper(dat, form_dat)
                mon = "%03d" % dat
                monPic = 'asset/pokemon_icons/pokemon_icon_' + mon + '_' + form_suffix + '_shiny.png'
                monName_raw = (get_raid_boss_cp(dat))
                monName = i8ln(monName_raw['name'])

                total_shiny_encounters = sum(
                    shiny_avg[dat][form_dat]['total_shiny'])
                total_nonshiny_encounters = sum(
                    shiny_avg[dat][form_dat]['total_nonshiny'])
                shiny_avg_click = round(
                    total_nonshiny_encounters / total_shiny_encounters, 0)

                shiny_stats_avg.append({
                    'name': monName,
                    'img': monPic,
                    'total_shiny_encounters': total_shiny_encounters,
                    'total_nonshiny_encounters': total_nonshiny_encounters,
                    'click_for_shiny': shiny_avg_click
                })

        shiny_stats_worker = []
        for dat in shiny_worker:
            shiny_stats_worker.append({
                'sum': shiny_worker[dat],
                'worker': dat
            })

        stats = {
            'shiny': shiny_stats,
            'shiny_worker': shiny_stats_worker,
            'shiny_hour': shiny_hour,
            'shiny_stats_avg': shiny_stats_avg
        }
        return jsonify(stats)
示例#13
0
文件: config.py 项目: JoniValles/MAD
    def showmonsidpicker(self):
        edit = request.args.get('edit')
        type = request.args.get('type')
        header = ""
        title = ""

        if request.method == 'GET' and (not edit or not type):
            return render_template('showmonsidpicker.html', error_msg="How did you end up here? Missing params.",
                                   header=header, title=title)

        with open('configs/mappings.json') as f:
            mapping = json.load(f)

        if "areas" not in mapping:
            return render_template('showmonsidpicker.html',
                                   error_msg="No areas defined at all, please configure first.", header=header,
                                   title=title)

        this_area = None
        this_area_index = -1
        for t_area in mapping["areas"]:
            this_area_index += 1
            if t_area["name"] == edit and t_area["mode"] == type:
                this_area = t_area
                break

        if this_area == None:
            return render_template('showmonsidpicker.html',
                                   error_msg="No area (" + edit + " with mode: " + type + ") found in mappings, add it first.",
                                   header=header, title=title)

        title = "Mons ID Picker for " + edit
        header = "Editing area " + edit + " (" + type + ")"
        backurl = "config?type=" + type + "&area=areas&block=settings&edit=" + edit

        if "settings" not in this_area:
            return render_template('showmonsidpicker.html',
                                   error_msg="No settings key found for area " + edit + "(" + type + "). Configure it first.",
                                   header=header, title=title)

        if request.method == 'POST':
            new_mons_list = request.form.get('current_mons_list')
            if not new_mons_list:
                return redirect("/showsettings", code=302)

            mapping["areas"][this_area_index]["settings"]["mon_ids_iv"] = ast.literal_eval(new_mons_list)

            with open('configs/mappings.json', 'w') as outfile:
                json.dump(mapping, outfile, indent=4, sort_keys=True)
            return redirect(backurl, code=302)

        if "mon_ids_iv" not in this_area["settings"]:
            current_mons = []
        else:
            current_mons = this_area["settings"]["mon_ids_iv"]

        mondata = open_json_file('pokemon')

        current_mons_list = []

        for mon_id in current_mons:
            try:
                mon_name = i8ln(mondata[str(mon_id)]["name"])
            except KeyError:
                mon_name = "No-name-in-file-please-fix"
            current_mons_list.append({"mon_name": mon_name, "mon_id": str(mon_id)})

        # Why o.O
        stripped_mondata = {}
        for mon_id in mondata:
            stripped_mondata[mondata[str(mon_id)]["name"]] = mon_id
            if os.environ['LANGUAGE'] != "en":
                try:
                    localized_name = i8ln(mondata[str(mon_id)]["name"])
                    stripped_mondata[localized_name] = mon_id
                except KeyError:
                    pass

        formhiddeninput = '<form action="showmonsidpicker?edit=' + edit + '&type=' + type + '" id="showmonsidpicker" method="post">'
        formhiddeninput += '<input type="hidden" id="current_mons_list" name="current_mons_list" value="' + str(
            current_mons) + '">'
        formhiddeninput += '<button type="submit" class="btn btn-success">Save</button></form>'
        return render_template('showmonsidpicker.html', backurl=backurl, formhiddeninput=formhiddeninput,
                               current_mons_list=current_mons_list, stripped_mondata=stripped_mondata, header=header,
                               title=title)
示例#14
0
    def game_stats(self):
        minutes_usage = request.args.get('minutes_usage', 10)
        minutes_spawn = request.args.get('minutes_spawn', 10)

        data = self._db.statistics_get_location_info()
        location_info = []
        for dat in data:
            location_info.append({'worker': str(dat[0]), 'locations': str(dat[1]), 'locationsok': str(dat[2]),
                                  'locationsnok': str(dat[3]), 'ratio': str(dat[4]), })

        # empty scans
        data = self._db.statistics_get_all_empty_scanns()
        detection_empty = []
        for dat in data:
            detection_empty.append({'lat': str(dat[1]), 'lng': str(dat[2]), 'worker': str(dat[3]),
                                    'count': str(dat[0]), 'type': str(dat[4]), 'lastscan': str(dat[5]),
                                    'countsuccess': str(dat[6])})

        # statistics_get_detection_count
        data = self._db.statistics_get_detection_count(grouped=False)
        detection = []
        for dat in data:
            detection.append({'worker': str(dat[1]), 'mons': str(dat[2]), 'mons_iv': str(dat[3]),
                              'raids': str(dat[4]), 'quests': str(dat[5])})

        # Stop
        stop = []
        data = self._db.statistics_get_stop_quest()
        for dat in data:
            stop.append({'label': dat[0], 'data': dat[1]})

        # Quest
        quest: list = []
        quest_db = self._db.statistics_get_quests_count(1)
        for ts, count in quest_db:
            quest_raw = (ts * 1000, count)
            quest.append(quest_raw)

        # Usage
        insta = {}
        usage = []
        idx = 0
        usa = self._db.statistics_get_usage_count(minutes_usage)

        for dat in usa:
            if 'CPU-' + dat[4] not in insta:
                insta['CPU-' + dat[4]] = {}
                insta['CPU-' + dat[4]]["axis"] = 1
                insta['CPU-' + dat[4]]["data"] = []
            if 'MEM-' + dat[4] not in insta:
                insta['MEM-' + dat[4]] = {}
                insta['MEM-' + dat[4]]['axis'] = 2
                insta['MEM-' + dat[4]]["data"] = []
            if self._args.stat_gc:
                if 'CO-' + dat[4] not in insta:
                    insta['CO-' + dat[4]] = {}
                    insta['CO-' + dat[4]]['axis'] = 3
                    insta['CO-' + dat[4]]["data"] = []

            insta['CPU-' + dat[4]]['data'].append([dat[3] * 1000, dat[0]])
            insta['MEM-' + dat[4]]['data'].append([dat[3] * 1000, dat[1]])
            if self._args.stat_gc:
                insta['CO-' + dat[4]]['data'].append([dat[3] * 1000, dat[2]])

        for label in insta:
            usage.append(
                {'label': label, 'data': insta[label]['data'], 'yaxis': insta[label]['axis'], 'idx': idx})
            idx += 1

        # Gym
        gym = []
        data = self._db.statistics_get_gym_count()
        for dat in data:
            if dat[0] == 'WHITE':
                color = '#999999'
                text = 'Uncontested'
            elif dat[0] == 'BLUE':
                color = '#0051CF'
                text = 'Mystic'
            elif dat[0] == 'RED':
                color = '#FF260E'
                text = 'Valor'
            elif dat[0] == 'YELLOW':
                color = '#FECC23'
                text = 'Instinct'
            gym.append({'label': text, 'data': dat[1], 'color': color})

        # Spawn
        iv = []
        noniv = []
        sum = []
        sumup = {}

        data = self._db.statistics_get_pokemon_count(minutes_spawn)
        for dat in data:
            if dat[2] == 1:
                iv.append([(self.utc2local(dat[0]) * 1000), dat[1]])
            else:
                noniv.append([(self.utc2local(dat[0]) * 1000), dat[1]])

            if (self.utc2local(dat[0]) * 1000) in sumup:
                sumup[(self.utc2local(dat[0]) * 1000)] += dat[1]
            else:
                sumup[(self.utc2local(dat[0]) * 1000)] = dat[1]

        for dat in sumup:
            sum.append([dat, sumup[dat]])

        spawn = {'iv': iv, 'noniv': noniv, 'sum': sum}

        # good_spawns avg
        good_spawns = []
        data = self._db.get_best_pokemon_spawns()
        for dat in data:
            mon = "%03d" % dat[1]
            monPic = 'asset/pokemon_icons/pokemon_icon_' + mon + '_00.png'
            monName_raw = (get_raid_boss_cp(dat[1]))
            monName = i8ln(monName_raw['name'])
            if self._args.db_method == "rm":
                lvl = calculate_mon_level(dat[6])
            else:
                lvl = dat[6]
            good_spawns.append({'id': dat[1], 'iv': round(calculate_iv(dat[3], dat[4], dat[5]), 0),
                                'lvl': lvl, 'cp': dat[7], 'img': monPic,
                                'name': monName,
                                'periode': datetime.datetime.fromtimestamp(dat[2]).strftime(self._datetimeformat)})

        stats = {'spawn': spawn, 'gym': gym, 'detection': detection, 'detection_empty': detection_empty,
                 'quest': quest, 'stop': stop, 'usage': usage, 'good_spawns': good_spawns,
                 'location_info': location_info}
        return jsonify(stats)
示例#15
0
    def game_stats_mon(self):
        minutes_spawn = request.args.get('minutes_spawn', 10)

        # Spawn
        iv = []
        noniv = []
        sumg = []
        sumup = {}

        data = self._db.statistics_get_pokemon_count(minutes_spawn)
        for dat in data:
            if dat[2] == 1:
                iv.append([(self.utc2local(dat[0]) * 1000), dat[1]])
            else:
                noniv.append([(self.utc2local(dat[0]) * 1000), dat[1]])

            if (self.utc2local(dat[0]) * 1000) in sumup:
                sumup[(self.utc2local(dat[0]) * 1000)] += dat[1]
            else:
                sumup[(self.utc2local(dat[0]) * 1000)] = dat[1]

        for dat in sumup:
            sumg.append([dat, sumup[dat]])

        spawn = {'iv': iv, 'noniv': noniv, 'sum': sumg}

        #shiny hour

        shiny_hour_temp = {}
        shiny_hour_calc = {}
        shiny_hour = []
        data = self._db.statistics_get_shiny_stats_hour()
        for dat in data:
            if dat[1] not in shiny_hour_temp:
                shiny_hour_temp[dat[1]] = dat[0]

        for dat in shiny_hour_temp:
            if shiny_hour_temp[dat] not in shiny_hour_calc:
                shiny_hour_calc[shiny_hour_temp[dat]] = 0
            shiny_hour_calc[shiny_hour_temp[dat]] += 1

        for dat in sorted(shiny_hour_calc):
            sht = ([
                self.utc2local(dat * 60 * 60) * 1000, shiny_hour_calc[dat]
            ])
            shiny_hour.append(sht)

        # good_spawns avg
        good_spawns = []
        data = self._db.get_best_pokemon_spawns()
        for dat in data:
            mon = "%03d" % dat[1]
            monPic = 'asset/pokemon_icons/pokemon_icon_' + mon + '_00.png'
            monName_raw = (get_raid_boss_cp(dat[1]))
            monName = i8ln(monName_raw['name'])
            if self._args.db_method == "rm":
                lvl = calculate_mon_level(dat[6])
            else:
                lvl = dat[6]
            good_spawns.append({
                'id':
                dat[1],
                'iv':
                round(calculate_iv(dat[3], dat[4], dat[5]), 0),
                'lvl':
                lvl,
                'cp':
                dat[7],
                'img':
                monPic,
                'name':
                monName,
                'periode':
                datetime.datetime.fromtimestamp(self.utc2local(
                    dat[2])).strftime(self._datetimeformat)
            })

        shiny_stats = []
        shiny_worker = {}
        shiny_avg = {}
        data = self._db.statistics_get_shiny_stats()
        for dat in data:
            form_suffix = "%02d" % form_mapper(dat[2], dat[5])
            mon = "%03d" % dat[2]
            monPic = 'asset/pokemon_icons/pokemon_icon_' + mon + '_' + form_suffix + '_shiny.png'
            monName_raw = (get_raid_boss_cp(dat[2]))
            monName = i8ln(monName_raw['name'])
            diff: int = dat[0]
            if diff == 0:
                logger.warning(
                    'No deeper mon stats are possible - not enought data '
                    '(check config.ini // game_stats_raw)')
                diff = 1

            ratio = round(dat[1] * 100 / diff, 2)
            if dat[3] not in shiny_worker: shiny_worker[dat[3]] = 0
            shiny_worker[dat[3]] += dat[1]

            if dat[2] not in shiny_avg: shiny_avg[dat[2]] = {}
            if dat[5] not in shiny_avg[dat[2]]:
                shiny_avg[dat[2]][dat[5]] = {}
                shiny_avg[dat[2]][dat[5]]['total_shiny'] = []
                shiny_avg[dat[2]][dat[5]]['total_nonshiny'] = []

            shiny_avg[dat[2]][dat[5]]['total_shiny'].append(dat[1])
            shiny_avg[dat[2]][dat[5]]['total_nonshiny'].append(diff)

            shiny_stats.append({
                'sum':
                dat[0],
                'shiny':
                dat[1],
                'img':
                monPic,
                'name':
                monName,
                'ratio':
                ratio,
                'worker':
                dat[3],
                'encounterid':
                dat[4],
                'periode':
                datetime.datetime.fromtimestamp(self.utc2local(
                    dat[6])).strftime(self._datetimeformat)
            })

        shiny_stats_avg = []
        for dat in shiny_avg:
            for form_dat in shiny_avg[dat]:

                form_suffix = "%02d" % form_mapper(dat, form_dat)
                mon = "%03d" % dat
                monPic = 'asset/pokemon_icons/pokemon_icon_' + mon + '_' + form_suffix + '_shiny.png'
                monName_raw = (get_raid_boss_cp(dat))
                monName = i8ln(monName_raw['name'])

                total_shiny_encounters = sum(
                    shiny_avg[dat][form_dat]['total_shiny'])
                total_nonshiny_encounters = sum(
                    shiny_avg[dat][form_dat]['total_nonshiny'])
                shiny_avg_click = round(
                    total_nonshiny_encounters / total_shiny_encounters, 0)

                shiny_stats_avg.append({
                    'name': monName,
                    'img': monPic,
                    'total_shiny_encounters': total_shiny_encounters,
                    'total_nonshiny_encounters': total_nonshiny_encounters,
                    'click_for_shiny': shiny_avg_click
                })

        shiny_stats_worker = []
        for dat in shiny_worker:
            shiny_stats_worker.append({
                'sum': shiny_worker[dat],
                'worker': dat
            })

        stats = {
            'spawn': spawn,
            'good_spawns': good_spawns,
            'shiny': shiny_stats,
            'shiny_worker': shiny_stats_worker,
            'shiny_hour': shiny_hour,
            'shiny_stats_avg': shiny_stats_avg
        }
        return jsonify(stats)