Ejemplo n.º 1
0
    def set_embed_pp(
            self,
            mods: Mods = None,
            acc: tuple[Union[float, int]] = (95, 97.5, 100),
    ) -> None:

        if self.mode != 0:
            return

        if not mods:
            mods = self.mods

        self.embed_pp_values = []

        stars = pyttanko.diff_calc().calc(self.mapfile, mods._value_)
        for a in acc:
            n300, n100, n50 = pyttanko.acc_round(a,
                                                 len(self.mapfile.hitobjects),
                                                 0)
            pp = pyttanko.ppv2(
                stars.aim,
                stars.speed,
                n100=n100,
                n50=n50,
                mods=mods._value_,
                bmap=self.mapfile,
                n300=n300,
            )[0]
            self.embed_pp_values.append(f'{a}%-{pp:.2f}PP')
Ejemplo n.º 2
0
def calc_acc_pp(osufile, mods_num):
    acc_pp = []
    p = osu.parser()
    with open(osufile, 'r', encoding='utf-8') as f:
        bmap = p.map(f)

    stars = osu.diff_calc().calc(bmap, mods_num)
    for acc in range(95, 101):
        c300, c100, c50 = osu.acc_round(acc, len(bmap.hitobjects), 0)

        pp, _, _, _, _ = osu.ppv2(
            stars.aim, stars.speed, mods=mods_num,
            n300=c300, n100=c100, n50=c50, bmap=bmap
        )

        acc_pp.append(int(pp))
        
    return acc_pp
Ejemplo n.º 3
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.º 4
0
 async def possible_score_values(self, accuracy, beatmap, misses):
     hit_objects = beatmap.count_slider + beatmap.count_normal + beatmap.count_spinner
     n300, n100, n50 = pyttanko.acc_round(accuracy, hit_objects, misses)
     return n300, n100, n50