Fix crashes

This commit is contained in:
Robert Miles 2020-06-13 23:08:05 -04:00
parent 84ffca31c5
commit 72916a23a4
1 changed files with 4 additions and 4 deletions

View File

@ -120,7 +120,7 @@ def on_cmd_transmute(event,silent=False):
# TODO: implement auto transmute of 3 worst badges
if len(parts)==1 and parts[0].lower() in 'a auto'.split():
rarities = badge.calculate_rarities(population.value.population)
badges = list(reversed(sorted(population.value.badges[account],key=lambda x: rarities[x.name][2])))
badges = list(reversed(sorted(population.value.badges.get(account,[]),key=lambda x: rarities[x.name][2])))
parts = [x.name for x in badges[:3]]
if "Tildebadge" in parts:
respond(event,"This would burn a Tildebadge. To proceed, type `+transmute {}` (or equivalent)".format(" ".join(parts)))
@ -212,9 +212,9 @@ def on_cmd_transmuteall(event):
if account is None: return
while True:
rarities = badge.calculate_rarities(population.value.population)
badges = list(reversed(sorted(population.value.badges[account],key=lambda x: rarities[x.name][2])))
badges = list(reversed(sorted(population.value.badges.get(account,[]),key=lambda x: rarities[x.name][2])))
parts = [x.name for x in badges[:3]]
if "Tildebadge" in parts:
if "Tildebadge" in parts or len(parts)<3:
respond(event,"Finished!")
return
event.data["parts"]=parts
@ -236,7 +236,7 @@ def admin_takebadge(event):
try:
account, badge = event.parts[:2]
badge = badge[0].upper()+badge[1:].lower()
i=len(population.value.badges[account])-1
i=len(population.value.badges.get(account,[]))-1
while i>0:
if populations.value.badges[account][i].name==badge:
populations.value.badges[account].pop(i)