Untitled
By: a guest | Mar 21st, 2010 | Syntax:
Python | Size: 1.49 KB | Hits: 49 | Expires: Never
# if check_if_top10 returns true
def replace_top10(self): # either replace a slower time (either the player's own time or someone else's) or append the time
for i in range(len(self.top10_list)): # loop through list
if self.name == self.top10_list[i][0]: # if player's own name is found in the top_10 list
bot.sendArenaMessage("PLAYER IS ALREADY IN TOP10_LIST") # spam
if self.race_time < self.top10_list[i][1]: # update if new time is faster than old time
bot.sendArenaMessage("NEW TIME IS FASTER!") # spam
self.top10_list[i][1] = self.race_time # update time
self.top10_list[i][2] = self.date # update date
else: # if new time is slower than old time, then print how far away the player is from beating his/her own record
bot.sendArenaMessage("NEWB! NEW TIME IS SLOWER") # spam
bot.sendArenaMessage( "Almost! You are %.3f sec away from your previous record (%.3f sec)!" % ( (self.race_time - self.top10_list[i][1]) , self.top10_list[i][1]) )
return
bot.sendArenaMessage("PLAYER IS NOT IN TOP10_LIST") # spam
if range(len(self.top10_list)) == 3: # if there are 10 players in top 10_list, change the 10th player to the new player
self.top10_list[9][0] = self.name
self.top10_list[9][1] = self.race_time
self.top10_list[9][2] = self.date
else: # if < 10 players, then simply append the player to top10_list
bot.sendArenaMessage("APPENDING TIME") # spam
self.top10_list.append([ self.name, self.race_time , self.date ]) # append time