Ejemplo n.º 1
0
def run(consoleInput, conf, api, ircName):
    try:
        mods = pp.getModVal(consoleInput)

        userBeatmap = conf.load(ircName)
    except KeyError:
        print('Please select a beatmap first!')
        return
    except:
        print('Usage: mods <mod1> [mod2] [mod3]...')
        return

    lastBm = userBeatmap[0]
    acc = userBeatmap[2]
    misses = userBeatmap[3]

    artist = lastBm['artist']
    title = lastBm['title']
    diffName = lastBm['version']
    stars = float(lastBm['difficultyrating'])
    maxCombo = int(lastBm['count_normal'])
    od = pp.scaleHPOD(float(lastBm['diff_overall']), mods)

    hundreds = pp.getHundreds(maxCombo, misses, acc)

    peppyPoints = roundString.roundString(
        pp.calcPP(stars, maxCombo, maxCombo - misses, hundreds, misses, acc,
                  od, mods), 2)

    modString = pp.getModString(mods)

    print(
        f'{artist} - {title} [{diffName}]{modString} | {acc}%, {misses} misses: {peppyPoints}'
    )
    conf.save(ircName, [lastBm, mods, acc, misses])
Ejemplo n.º 2
0
def run(user, msg, irc, conf, api, time):	
	try:
		mods = pp.getModVal(msg)
		userBeatmap = conf.load(user)
	except KeyError:
		irc.msg(user, 'Please select a beatmap first! (Type /np)')
		print(f'User {user} issued !with without a beatmap selected.')
		return
	except:
		print('Usage: mods <mod1> [mod2] [mod3]...')
		return

	lastBm = userBeatmap[0]
	acc = userBeatmap[2]
	misses = userBeatmap[3]

	artist = lastBm['artist']
	title = lastBm['title']
	diffName = lastBm['version']
	creator = lastBm['creator']
	stars = float(lastBm['difficultyrating'])
	starsRounded = roundString.roundString(stars, 2)
	maxCombo = int(lastBm['count_normal'])
	od = pp.scaleHPOD(float(lastBm['diff_overall']), mods)
	hp = pp.scaleHPOD(float(lastBm['diff_drain']), mods)
	bpm = pp.scaleBPM(lastBm['bpm'], mods)
	
	hundreds = pp.getHundreds(maxCombo, misses, acc)
	
	modString = pp.getModString(mods)
	
	irc.msg(user, f'{artist} - {title} [{diffName}] by {creator}, {starsRounded}* {modString} OD{od} HP{hp} BPM: {bpm} FC: {maxCombo}')

	ppString = ''

	# Calculate the pp for the accuracies in the tuple
	for acc in (95.0, 96.0, 97.0, 98.0, 99.0, 100.0):
		ppVal = roundString.roundString(pp.calcPP(stars, maxCombo, maxCombo, hundreds, 0, acc, od, mods), 2)
		e = ' | ' # Separator
		if acc == 95.0: # Avoid a trailing ' | '.
			e = ''
		ppString = f'{ppString}{e}{acc}%: {ppVal}pp'

	# The second line.
	irc.msg(user, ppString)
	print(f'{time} OD{od} HP{hp} {starsRounded}* FC: {maxCombo}x')
	print(ppString + '\n')

	conf.save(user, [lastBm, mods, acc, misses])
Ejemplo n.º 3
0
def run(consoleInput, conf, api, ircName):
    try:
        bm_id = input('<3 Awesome! First we need a beatmap id: ').strip()
        if bm_id == 'cancel':
            return
        bm_id = int(bm_id)

        bm_acc = input('<3 Now the accuracy: ').strip()
        if bm_acc == 'cancel':
            return
        bm_acc = float(bm_acc)

        bm_misses = input('<3 How many misses? \'cancel\' to cancel').strip()
        if bm_misses == 'cancel':
            return
        bm_misses = int(bm_misses)

        # bm_mods = input('')
    except:
        if bm_id == None:
            print('<3 Please enter a valid beatmap id!')
        elif bm_acc == None:
            print('<3 Please enter a valid accuracy! (No percent sign!)')
        else:
            print('<3 Please enter a valid number of misses!')
        return

    beatmap = api.getBeatmap(bm_id)[0]
    conf.save(ircName, [beatmap, pp.mods['noMod'], bm_acc, bm_misses])

    artist = beatmap['artist']
    title = beatmap['title']
    diffName = beatmap['version']
    stars = float(beatmap['difficultyrating'])
    od = int(beatmap['diff_overall'])
    maxcombo = int(beatmap['count_normal'])

    peppyPoints = roundString.roundString(
        pp.calcPP(stars, maxcombo, maxcombo - bm_misses,
                  pp.getHundreds(maxcombo, bm_misses, bm_acc), bm_misses,
                  bm_acc, od, pp.mods['noMod']), 2)

    print(
        f'<3 {artist} - {title} [{diffName}] | {bm_acc}%, {bm_misses} misses, FC: {maxcombo}'
    )
    print(f'<3 {peppyPoints}pp')
Ejemplo n.º 4
0
def run(consoleInput, conf, api, ircName):
    splitInput = consoleInput.split(' ')

    try:
        acc = float(splitInput[1])
        misses = int(splitInput[2])

        userBeatmap = conf.load(ircName)
    except KeyError:
        print('Please select a beatmap first!')
        return
    except:
        print('Usage: with <acc> <misses>')
        return

    lastBm = userBeatmap[0]
    mods = userBeatmap[1]

    artist = lastBm['artist']
    title = lastBm['title']
    diffName = lastBm['version']
    stars = float(lastBm['difficultyrating'])
    maxCombo = int(lastBm['count_normal'])
    od = float(lastBm['diff_overall'])

    hundreds = pp.getHundreds(maxCombo, misses, acc)

    peppyPoints = roundString.roundString(
        pp.calcPP(stars, maxCombo, maxCombo - misses, hundreds, misses, acc,
                  od, mods), 2)

    modString = pp.getModString(mods)

    print(
        f'{artist} - {title} [{diffName}]{modString} | {acc}%, {misses} misses: {peppyPoints}'
    )

    conf.save(ircName, [lastBm, mods, acc, misses])
Ejemplo n.º 5
0
def run(user, msg, irc, conf, api, time):
    diffnameRegex = re.compile(
        r'\[.*\[(.*)\]\]'
    )  # The regex finding the difficulty name, see 'diffname ='.
    setidRegex = re.compile(
        r'/b/([0-9]*)')  # The regex finding the set id, see 'setid ='.

    setid = setidRegex.search(msg).group(1)
    # diffname = diffnameRegex.search(msg).group(1) # Search for [...], e.g. [Oni]
    # isTaiko = bool(re.search(r'<Taiko>', msg))    # Determines whether the beatmap is in taiko mode or not.
    # 												# This will not filter out converts!

    modsVal = 0  # The binary number given to pp.calcPP() containing the enabled mods.
    mods = ''  # The string used for message building.

    for mod in pp.mods:  # Loop through the mods and change the modsVal according to the enabled mods.
        if msg.find('+' + mod) != -1:
            modsVal += pp.mods[mod]
            mods = ' '.join([mods, f'+{mod}'])

    # # Console logging
    # print(f'{time} {user} issued a request for beatmap set id {setid}, difficulty [{diffname}]{mods}, the beatmap was ', end='')
    # if isTaiko:
    # 	print('in taiko mode.')
    # else:
    # 	print('not in taiko mode.')

    # requestedBeatmap = None # Set to None to check if set later on.

    # foundTaikoMap = False   # Was there a taiko map in the set?

    beatmapSet = api.getBeatmap(setid, modsVal)

    if not len(beatmapSet) > 0:
        print(f'Beatmap set id {setid} could not be found. Is there an error?')
        irc.msg(
            user,
            'I\'m sorry, but the beatmap could not be found. Perhaps Bancho had an error?'
        )
        return

    requestedBeatmap = beatmapSet[0]
    diffName = requestedBeatmap['version']

    if not requestedBeatmap[
            'mode'] == '1':  # 'mode' == 1 means the beatmap mode is osu!taiko.
        print(
            f'{time} {user} issued a request for beatmap set id {setid}, difficulty [{diffName}]{mods}, the beatmap was not in taiko mode.'
        )
        irc.msg(
            user,
            'The map you requested doesn\'t appear to be a taiko map. Converts are not (yet) supported, sorry.'
        )
        return

    # for beatmap in beatmapSet: # Loop through all the beatmaps in the set
    # 	if beatmap['mode'] != '1': # Speed up the process for mixed-mode beatmap sets
    # 		continue

    # 	if beatmap['mode'] == '1': # 'mode' == 1 means the beatmap mode is osu!taiko.
    # 		foundTaikoMap = True

    # 	if beatmap['version'] != diffname: # Skip the difficulties with the wrong difficulty name.
    # 		continue

    # 	requestedBeatmap = beatmap
    # 	conf.save(user, [beatmap, modsVal, 100.0, 0])

    print(
        f'{time} {user} issued a request for beatmap set id {setid}, difficulty [{diffName}]{mods}, the beatmap was in taiko mode.'
    )

    # Metadata collection for marginally easier to read code.
    artist = requestedBeatmap['artist']
    title = requestedBeatmap['title']
    diffName = requestedBeatmap['version']
    creator = requestedBeatmap['creator']
    stars = float(requestedBeatmap['difficultyrating'])
    starsRounded = roundString.roundString(stars, 2)
    maxCombo = int(requestedBeatmap['count_normal'])
    od = pp.scaleHPOD(float(requestedBeatmap['diff_overall']), modsVal)
    hp = pp.scaleHPOD(float(requestedBeatmap['diff_drain']), modsVal)
    bpm = pp.scaleBPM(
        requestedBeatmap['bpm'],
        modsVal)  # Not converted to int because we only use it for printing

    # The first line shown to the user containing general info about the difficulty.
    irc.msg(
        user,
        f'{artist} - {title} [{diffName}] by {creator}, {starsRounded}* {mods} OD{od} HP{hp} BPM: {bpm} FC: {maxCombo}'
    )

    ppString = ''  # The string shown to the user as the second line in the end.

    # Calculate the pp for the accuracies in the tuple
    for acc in (95.0, 96.0, 97.0, 98.0, 99.0, 100.0):
        ppVal = roundString.roundString(
            pp.calcPP(stars, maxCombo, maxCombo,
                      pp.getHundreds(maxCombo, 0, acc), 0, acc, od, modsVal),
            2)
        e = ' | '  # Separator
        if acc == 95.0:  # Avoid a trailing ' | '.
            e = ''
        ppString = f'{ppString}{e}{acc}%: {ppVal}pp'

    # The second line.
    irc.msg(user, ppString)
    print(f'OD{od} {starsRounded}* FC: {maxCombo}x')
    print(ppString + '\n')

    conf.save(user, [requestedBeatmap, modsVal, 100, 0])
Ejemplo n.º 6
0
def run(user, msg, irc, conf, api):
	try:
		userBeatmap = conf.load(user)
	except KeyError:
		irc.msg(user, 'Please select a beatmap first! (Type /np)')
		print(f'User {user} issued !with without a beatmap selected.')
		return

	lastBm = userBeatmap[0]
	mods = userBeatmap[1]

	artist = lastBm['artist']
	title = lastBm['title']
	diffName = lastBm['version']
	stars = float(lastBm['difficultyrating'])
	maxCombo = int(lastBm['count_normal'])
	od = pp.scaleHPOD(float(lastBm['diff_overall']), mods)

	arg1Regex = re.compile(r'!with ([^ ]*)? ') # Gets the first argument
	arg2Regex = re.compile(r'!with .*? ([^ ]*)?')

	accFloatRegex = re.compile(r'([0-9]{1,3})[\.\,]([0-9]{1,2})[%]*') # xx[x].yy[%] => Group 1: xx[x]; Group 2: yy
	accIntRegex = re.compile(r'([0-9]{1,3})[%]*') # xx[x][%] -> Group 1: xx[x]

	print(f'User {user} issued a !with command.')

	rawAcc = arg1Regex.search(msg)
	if rawAcc == None: # No first argument?
		irc.msg(user, 'Usage: !with <accuracy> <misses>')
		print(f'Printed usage for !with for {user}. (No arguments)')
		return

	accMatch = accFloatRegex.search(rawAcc.group(0))
	if accMatch == None: # Couldn't find the accuracy (xx[x].yy[%]).
		accMatch = accIntRegex.search(rawAcc.group(0))
		if accMatch == None: # Couldn't find the accuracy (xx[x][%]). -> Odd argument.
			irc.msg(user, 'Usage: !with <accuracy> <misses>')
			print(f'Printed usage for !with for {user}. (Odd accuracy)')
			return
			
		acc = float(accMatch.group(1))
	else:
		acc = float(accMatch.group(1) + '.' + accMatch.group(2)) # Two groups ignoring the floating point cuz localization.

	rawMisses = arg2Regex.search(msg)
	if rawMisses == None: # No second argument?
		irc.msg(user, 'Usage: !with <accuracy> <misses>')
		print(f'Printed usage for !with for {user}. (No second argument)')
		return

	missesMatch = re.search('([0-9]*)', rawMisses.group(1)) # Look if the second argument only contains numbers.
	if missesMatch == None:
		irc.msg(user, 'Usage: !with <accuracy> <misses>')
		print(f'Printed usage for !with for {user}. (Odd misses)')
		return

	misses = int(missesMatch.group(0))

	hundreds = pp.getHundreds(maxCombo, misses, acc)

	peppyPoints = roundString.roundString(pp.calcPP(stars, maxCombo, maxCombo - misses, hundreds, misses, acc, od, mods), 2)

	modString = pp.getModString(mods)

	irc.msg(user, f'{artist} - {title} [{diffName}]{modString} | {acc}%, {misses} misses: {peppyPoints}')
	print(f'{artist} - {title} [{diffName}]{modString} | {acc}%, {misses} misses: {peppyPoints}')

	conf.save(user, [lastBm, mods, acc, misses])