Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 21st, 2010 | Syntax: Python | Size: 1.49 KB | Hits: 49 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1.         # if check_if_top10 returns true
  2.         def replace_top10(self): # either replace a slower time (either the player's own time or someone else's) or append the time
  3.                 for i in range(len(self.top10_list)): # loop through list
  4.                         if self.name == self.top10_list[i][0]: # if player's own name is found in the top_10 list
  5.                                 bot.sendArenaMessage("PLAYER IS ALREADY IN TOP10_LIST") # spam
  6.                                 if self.race_time < self.top10_list[i][1]: # update if new time is faster than old time
  7.                                         bot.sendArenaMessage("NEW TIME IS FASTER!") # spam
  8.                                         self.top10_list[i][1] = self.race_time # update time
  9.                                         self.top10_list[i][2] = self.date # update date
  10.                                 else: # if new time is slower than old time, then print how far away the player is from beating his/her own record
  11.                                         bot.sendArenaMessage("NEWB! NEW TIME IS SLOWER") # spam
  12.                                         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]) )
  13.                         return
  14.                
  15.                 bot.sendArenaMessage("PLAYER IS NOT IN TOP10_LIST") # spam
  16.                 if range(len(self.top10_list)) == 3: # if there are 10 players in top 10_list, change the 10th player to the new player
  17.                         self.top10_list[9][0] = self.name
  18.                         self.top10_list[9][1] = self.race_time
  19.                         self.top10_list[9][2] = self.date
  20.                 else: # if < 10 players, then simply append the player to top10_list
  21.                         bot.sendArenaMessage("APPENDING TIME") # spam
  22.                         self.top10_list.append([ self.name, self.race_time , self.date ]) # append time