Exemple #1
0
    async def cache_pp(self, mods: Mods) -> None:
        """Cache some common acc pp values for specified mods."""
        pp_params = {'mode': self.mode.as_vanilla, 'mods': mods}
        self.pp_cache[mods] = [0.0, 0.0, 0.0, 0.0, 0.0]

        async with Owoppai(self.id, **pp_params) as owo:
            # start with 100% on vanilla
            self.pp_cache[mods][-1] = owo.pp

            # calc other acc values
            for idx, acc in enumerate((90, 95, 98, 99)):
                owo.acc = acc
                await owo.calc()

                self.pp_cache[mods][idx] = owo.pp
Exemple #2
0
async def _with(p: Player, c: Messageable, msg: Sequence[str]) -> str:
    """Specify custom accuracy & mod combinations with `/np`."""
    if isinstance(c, Channel) or c.id != 1:
        return 'This command can only be used in DM with Aika.'

    if not p.last_np:
        return 'Please /np a map first!'

    # +?<mods> <acc>%?
    if 1 < len(msg) > 2:
        return 'Invalid syntax: !with <mods/acc> ...'

    mods = acc = None

    for param in (p.strip('+%') for p in msg):
        if cmyui._isdecimal(param, _float=True):
            acc = float(param)
        elif ~len(param) & 1: # len(param) % 2 == 0
            mods = Mods.from_str(param)
        else:
            return 'Invalid syntax: !with <mods/acc> ...'

    _msg = [p.last_np.embed]
    if not mods:
        mods = Mods.NOMOD

    _msg.append(repr(mods))

    if acc:
        # they're requesting pp for specified acc value.
        async with Owoppai(p.last_np.id, acc=acc, mods=mods) as owo:
            await owo.calc()
            pp_values = [(owo.acc, owo.pp)]
    else:
        # they're requesting pp for general accuracy values.
        if mods not in p.last_np.pp_cache:
            # cache
            await p.last_np.cache_pp(mods)

        pp_values = zip(
            (90, 95, 98, 99, 100),
            p.last_np.pp_cache[mods]
        )

    pp_msg = ' | '.join(f'{acc:.2f}%: {pp:.2f}pp'
                        for acc, pp in pp_values)
    return f"{' '.join(_msg)}: {pp_msg}"
Exemple #3
0
    def calc_diff(self) -> Tuple[float, float]:
        """Calculate PP and star rating for our score."""
        if self.game_mode not in {0, 1}:
            # Currently only std and taiko are supported,
            # since we are simply using oppai-ng alone.
            return (0.0, 0.0)

        owpi: Owoppai = Owoppai(
            map_id = self.bmap.id,
            mods = self.mods,
            combo = self.max_combo,
            misses = self.nmiss,
            gamemode = self.game_mode,
            accuracy = self.acc
        )

        # Returns (pp, sr)
        return owpi.calculate_pp()
Exemple #4
0
    async def calc_diff(self) -> Tuple[float, float]:
        """Calculate PP and star rating for our score."""
        if self.game_mode not in (0, 1):
            # Currently only std and taiko are supported,
            # since we are simply using oppai-ng alone.
            return (0.0, 0.0)

        pp_params = {
            'mods': self.mods,
            'combo': self.max_combo,
            'nmiss': self.nmiss,
            'mode': self.game_mode,
            'acc': self.acc
        }

        async with Owoppai(self.bmap.id, **pp_params) as owo:
            ret = (owo.pp, owo.stars)

        return ret
Exemple #5
0
    def cache_pp(self) -> None:
        owpi = Owoppai(map_id=self.id)

        for idx, acc in enumerate((90, 95, 98, 99, 100)):
            owpi.accuracy = acc
            self.pp_values[idx] = owpi.calculate_pp()[0]
Exemple #6
0
 async def cache_pp(self) -> None:
     async with Owoppai(self.id) as owo:
         for idx, acc in enumerate((90, 95, 98, 99, 100)):
             owo.set_acc(acc)
             self.pp_values[idx] = owo.pp