.BANCHO. Add accuracy, beatmap link and rank to !last
This commit is contained in:
parent
e11ae27b36
commit
f9d6e79447
|
@ -479,7 +479,8 @@ def tillerinoAcc(fro, chan, message):
|
|||
|
||||
def tillerinoLast(fro, chan, message):
|
||||
try:
|
||||
data = glob.db.fetch("""SELECT beatmaps.song_name as sn, scores.pp
|
||||
data = glob.db.fetch("""SELECT beatmaps.song_name as sn, scores.*,
|
||||
beatmaps.beatmap_id as bid
|
||||
FROM scores
|
||||
LEFT JOIN beatmaps ON beatmaps.beatmap_md5=scores.beatmap_md5
|
||||
LEFT JOIN users ON users.id = scores.userid
|
||||
|
@ -488,7 +489,19 @@ def tillerinoLast(fro, chan, message):
|
|||
LIMIT 1""", [fro])
|
||||
if data == None:
|
||||
return False
|
||||
return "{0:.2f}pp ({1} on {2})".format(data["pp"], fro, data["sn"])
|
||||
|
||||
rank = generalFunctions.getRank(data["play_mode"], data["mods"], data["accuracy"],\
|
||||
data["300_count"], data["100_count"], data["50_count"], data["misses_count"])
|
||||
|
||||
msg = "{0:.2f}pp".format(data["pp"])
|
||||
msg += " on " if chan == "FokaBot" else " | {0} on ".format(fro)
|
||||
msg += "({0})[http://osu.ppy.sh/b/{1}]".format(data["sn"], data["bid"])
|
||||
|
||||
if data["mods"]:
|
||||
msg += ' +' + generalFunctions.readableMods(data["mods"])
|
||||
msg += " ({0:.2f}%, {1})".format(data["accuracy"], rank.upper())
|
||||
|
||||
return msg
|
||||
except Exception as a:
|
||||
log.error(a)
|
||||
return False
|
||||
|
|
|
@ -37,4 +37,4 @@ def handle(userToken, _):
|
|||
glob.tokens.deleteToken(requestToken)
|
||||
|
||||
# Console output
|
||||
log.info("{} have been disconnected.".format(username))
|
||||
log.info("{} has been disconnected.".format(username))
|
||||
|
|
|
@ -165,7 +165,7 @@ class handler(requestHelper.asyncRequestHandler):
|
|||
responseData = serverPackets.loginError()
|
||||
responseData += serverPackets.notification("Whoops! Something went wrong, please login again.")
|
||||
log.warning("Received packet from unknown token ({}).".format(requestTokenString))
|
||||
log.info("{} have been disconnected (invalid token)".format(requestTokenString))
|
||||
log.info("{} has been disconnected (invalid token)".format(requestTokenString))
|
||||
finally:
|
||||
# Unlock token
|
||||
if userToken != None:
|
||||
|
|
|
@ -53,6 +53,73 @@ def readableMods(__mods):
|
|||
|
||||
return r
|
||||
|
||||
def getRank(gameMode, __mods, acc, c300, c100, c50, cmiss):
|
||||
"""
|
||||
Return a string with rank/grade for a given score.
|
||||
Used mainly for "tillerino"
|
||||
|
||||
gameMode -- mode (0 = osu!, 1 = Taiko, 2 = CtB, 3 = osu!mania)
|
||||
__mods -- mods bitwise number
|
||||
acc -- accuracy
|
||||
c300 -- 300 hit count
|
||||
c100 -- 100 hit count
|
||||
c50 -- 50 hit count
|
||||
cmiss -- miss count
|
||||
return -- rank/grade string
|
||||
"""
|
||||
total = c300 + c100 + c50 + cmiss
|
||||
hdfl = (__mods & mods.Hidden > 0) or (__mods & mods.Flashlight > 0)
|
||||
|
||||
def ss():
|
||||
return "sshd" if hdfl else "ss"
|
||||
|
||||
def s():
|
||||
return "shd" if hdfl else "s"
|
||||
|
||||
if gameMode == 0:
|
||||
# osu!std
|
||||
if acc == 100:
|
||||
return ss()
|
||||
if c300 / total > 0.90 and c50 / total < 0.1 and cmiss == 0:
|
||||
return s()
|
||||
if (c300 / total > 0.80 and cmiss == 0) or (c300 / total > 0.90):
|
||||
return "a"
|
||||
if (c300 / total > 0.70 and cmiss == 0) or (c300 / total > 0.80):
|
||||
return "b"
|
||||
if c300 / total > 0.60:
|
||||
return "c"
|
||||
return "d"
|
||||
elif gameMode == 1:
|
||||
# taiko not implemented as of yet.
|
||||
return "a"
|
||||
elif gameMode == 2:
|
||||
# CtB
|
||||
if acc == 100:
|
||||
return ss()
|
||||
if acc >= 98.01 and acc <= 99.99:
|
||||
return s()
|
||||
if acc >= 94.01 and acc <= 98.00:
|
||||
return "a"
|
||||
if acc >= 90.01 and acc <= 94.00:
|
||||
return "b"
|
||||
if acc >= 98.01 and acc <= 90.00:
|
||||
return "c"
|
||||
return "d"
|
||||
elif gameMode == 3:
|
||||
# osu!mania
|
||||
if acc == 100:
|
||||
return ss()
|
||||
if acc > 95:
|
||||
return s()
|
||||
if acc > 90:
|
||||
return "a"
|
||||
if acc > 80:
|
||||
return "b"
|
||||
if acc > 70:
|
||||
return "c"
|
||||
return "d"
|
||||
|
||||
return "a"
|
||||
|
||||
def strContains(s, w):
|
||||
return (' ' + w + ' ') in (' ' + s + ' ')
|
||||
|
|
Loading…
Reference in New Issue
Block a user