Ejemplo n.º 1
0
    def convert_difficulty_attrs(self) -> None:
        v = pyttanko.mods_apply(
            mods=self.mods._value_,
            ar=self.ar,
            od=self.od,
            cs=self.cs,
            hp=self.hp,
        )[1:]

        self.ar, self.od, self.cs, self.hp = v
Ejemplo n.º 2
0
    async def get_pyttanko(self,
                           map_id: str,
                           accs=[100],
                           mods=0,
                           misses=0,
                           combo=None,
                           completion=None,
                           fc=None):
        url = 'https://osu.ppy.sh/osu/{}'.format(map_id)
        file_path = os.getcwd() + '/temp/{}.osu'.format(map_id)
        await self.download_file(url, file_path)
        bmap = pyttanko.parser().map(open(file_path))
        _, ar, od, cs, hp = pyttanko.mods_apply(mods,
                                                ar=bmap.ar,
                                                od=bmap.od,
                                                cs=bmap.cs,
                                                hp=bmap.hp)
        stars = pyttanko.diff_calc().calc(bmap, mods=mods)
        bmap.stars = stars.total
        bmap.aim_stars = stars.aim
        bmap.speed_stars = stars.speed

        if not combo:
            combo = bmap.max_combo()

        bmap.pp = []
        bmap.aim_pp = []
        bmap.speed_pp = []
        bmap.acc_pp = []

        bmap.acc = accs

        for acc in accs:
            n300, n100, n50 = pyttanko.acc_round(acc, len(bmap.hitobjects),
                                                 misses)
            pp, aim_pp, speed_pp, acc_pp, _ = pyttanko.ppv2(bmap.aim_stars,
                                                            bmap.speed_stars,
                                                            bmap=bmap,
                                                            mods=mods,
                                                            n300=n300,
                                                            n100=n100,
                                                            n50=n50,
                                                            nmiss=misses,
                                                            combo=combo)
            bmap.pp.append(pp)
            bmap.aim_pp.append(aim_pp)
            bmap.speed_pp.append(speed_pp)
            bmap.acc_pp.append(acc_pp)
        if fc:
            n300, n100, n50 = pyttanko.acc_round(fc, len(bmap.hitobjects), 0)
            # print("-------------", n300, n100, n50)
            fc_pp, _, _, _, _ = pyttanko.ppv2(bmap.aim_stars,
                                              bmap.speed_stars,
                                              bmap=bmap,
                                              mods=mods,
                                              n300=n300 + misses,
                                              n100=n100,
                                              n50=n50,
                                              nmiss=0,
                                              combo=bmap.max_combo())

        pyttanko_json = {
            'version': bmap.version,
            'title': bmap.title,
            'artist': bmap.artist,
            'creator': bmap.creator,
            'combo': combo,
            'max_combo': bmap.max_combo(),
            'misses': misses,
            'mode': bmap.mode,
            'stars': bmap.stars,
            'aim_stars': bmap.aim_stars,
            'speed_stars': bmap.speed_stars,
            'pp': bmap.pp,  # list
            'aim_pp': bmap.aim_pp,
            'speed_pp': bmap.speed_pp,
            'acc_pp': bmap.acc_pp,
            'acc': bmap.acc,  # list
            'cs': cs,
            'od': od,
            'ar': ar,
            'hp': hp
        }

        if completion:
            try:
                pyttanko_json['map_completion'] = (completion /
                                                   len(bmap.hitobjects)) * 100
            except:
                pyttanko_json['map_completion'] = "Error"

        os.remove(file_path)
        return pyttanko_json
Ejemplo n.º 3
0
 async def beatmap_difficulity_with_mods(self, mods, beatmap_default):
     mods_from_str = await self.submitted_play_mods(mods)
     ar, od, hp, cs = beatmap_default
     return pyttanko.mods_apply(mods_from_str, ar=ar, od=od, cs=cs, hp=hp)