Add commas to numbers

This commit is contained in:
Robert Miles 2020-11-17 01:33:30 +00:00
parent 70afa121c9
commit 42447c526b
1 changed files with 6 additions and 6 deletions

View File

@ -105,9 +105,9 @@ def on_befriend(event):
delta_r = round(final_delta,2)
score_r = round(score,2)
if first_bun:
respond(event,f"Congratulations on your first bun! This bun has waited {delta_r} second(s), and is therefore worth {score_r} point(s)!")
respond(event,f"Congratulations on your first bun! This bun has waited {delta_r:,} second(s), and is therefore worth {score_r:,} point(s)!")
else:
respond(event,f"This bun has waited {delta_r} second(s), and is therefore worth {score_r} point(s)!")
respond(event,f"This bun has waited {delta_r:,} second(s), and is therefore worth {score_r:,} point(s)!")
def on_peek(event):
if not event.target.startswith("#"): return
@ -117,7 +117,7 @@ def on_peek(event):
score, delta = get_bun_score(event.target)
delta_r=round(delta,2)
score_r=round(score,2)
respond(event,f"If you were to befriend the bun right now, it would have waited {delta_r} second(s), and would therefore be worth {score_r} point(s).")
respond(event,f"If you were to befriend the bun right now, it would have waited {delta_r:,} second(s), and would therefore be worth {score_r:,} point(s).")
average = lambda l: sum(l)/len(l)
@ -133,7 +133,7 @@ def on_stats(event):
return
bunc = len(buns)
avg_bunt = average(buns) # *av*era*g*e *bun* *t*ime
stat_out = "You have befriended {} bun{}. Your average befriend time is {:0.02f}, and your current score is {:0.02f}.".format(bunc,"s" if bunc!=1 else "",avg_bunt,bungame_data["score_cache"].get(account,0))
stat_out = "You have befriended {:,} bun{}. Your average befriend time is {:,.02f}, and your current score is {:,.02f}.".format(bunc,"s" if bunc!=1 else "",avg_bunt,bungame_data["score_cache"].get(account,0))
respond(event,stat_out)
def on_top10(event):
@ -153,9 +153,9 @@ def on_top10(event):
out = f"Top 10 in {mode}: "
for account in accounts:
if mode == "count":
out += "{act[0]} ({act[1]:d})".format(act=account)
out += "{act[0]} ({act[1]:n})".format(act=account)
else:
out += "{act[0]} ({act[1]:0.02f})".format(act=account)
out += "{act[0]} ({act[1]:,.02f})".format(act=account)
out+=", "
out=out[:-2]
respond(event,out)