Advertisement
darkenvy

Runescape Prestige Lookup - Python

Feb 6th, 2015
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.38 KB | None | 0 0
  1. import csv
  2. import urllib2
  3. import sys
  4.  
  5. """
  6. Made by Elderek
  7. Feel free to modify and release
  8. It is unfortunate Prestige did not make it
  9. """
  10.  
  11.  
  12. skill_list = ["Overall","Attack", "Defence", "Strength", "Constitution", "Ranged",
  13.     "Prayer", "Magic", "Cooking", "Woodcutting", "Fletching", "Fishing", "Firemaking",
  14.     "Crafting", "Smithing", "Mining", "Herblore", "Agility", "Thieving", "Slayer",
  15.     "Farming", "Runecrafting", "Hunter", "Construction", "Summoning", "Dungeoneering",
  16.     "Divination"]
  17.  
  18. # 127 slots. The 127th slot is max. (126 because first is [0])
  19. exp_table=[0,83,174,276,388,512,650,801,969,1154,1358,1584,1833,2107,
  20.     2411,2746,3115,3523,3973,4470,5018,5624,6291,7028,7842,8740,9730,
  21.     10824,12031,13363,14833,16456,18247,20224,22406,24815,27473,30408,
  22.     33648,37224,41171,45529,50339,55649,61512,67983,75127,83014,91721,
  23.     101333,111945,123660,136594,150872,166636,184040,203254,224466,247886,
  24.     273742,302288,333804,368599,407015,449428,496254,547953,605032,668051,
  25.     737627,814445,899257,992895,1096278,1210421,1336443,1475581,1629200,
  26.     1798808,1986068,2192818,2421087,2673114,2951373,3258594,3597792,3972294,
  27.     4385776,4842295,5346332,5902831,6517253,7195629,7944614,8771558,
  28.     9684577,10692629,11805606,13034431,14391160,15889109,17542976,19368992,
  29.     21385073,23611006,26068632,28782069,31777943,35085654,38737661,42769801,
  30.     47221641,52136869,57563718,63555443,70170840,77474828,85539082,94442737,
  31.     104273167,115126838,127110260,140341028,154948977,171077457,188884740,
  32.     200000000]
  33.  
  34. def vlevel(exp):
  35.     tmplvl = 0
  36.     for i in range(126):
  37.         if int(exp) >= exp_table[i]:
  38.             tmplvl += 1
  39.     return tmplvl
  40.    
  41. def plevel(exp):
  42.     tmplvl = 0
  43.     if exp > 13034431:
  44.         return int(exp) % 13034431
  45.     else:
  46.         return -1
  47.        
  48. def prestige(exp):
  49.     tmplvl = 0
  50.     if exp > 13034431:
  51.         return int(exp) / 13034431
  52.     else:
  53.         return 0
  54.        
  55.        
  56.        
  57. def main():
  58.     print "--------RS Prestige Lookup--------\n"
  59.     print "If you like this, let me know, I will make it better."
  60.     print "Note that the items in bold are at least halfway to the next prestige (92+)\n"
  61.     print "----------------------------------\n"
  62.    
  63.     name = raw_input("Enter a RS3 Name to Lookup: ")
  64.     if name == "":
  65.         name = "Elderek"
  66.        
  67.     url = 'http://services.runescape.com/m=hiscore/index_lite.ws?player={}'.format(name)
  68.     response = urllib2.urlopen(url)
  69.     cr = csv.reader(response)
  70.     cr_list = list(cr)
  71.    
  72.     print "_____________________________________"
  73.     print "\033[01m\t\t{}\033[00m".format(name)
  74.     print "_____________________________________\n\n"
  75.     print "\033[01m%-15s |  %-3s |  %-3s" % ( "Skill", "Prestige", "pLevel\033[00m" )
  76.     print "-------------------------------------"
  77.  
  78.     for i in range(27):
  79.         # Reset formatting
  80.        
  81.         # If a skill is above halfway to next prestige, highlight
  82.         if vlevel( plevel(cr_list[i][2]) ) >= 92:
  83.             sys.stdout.write("\033[01m")
  84.         else:
  85.             sys.stdout.write("\033[00m")
  86.        
  87.         # Now print the display
  88.         print "%-15s |  %-8s |  %-6s" % (
  89.             skill_list[i],
  90.             prestige( cr_list[i][2] ),
  91.             vlevel( plevel(cr_list[i][2]) )
  92.             )
  93.        
  94.     sys.stdout.write("\033[00m")
  95.  
  96. if __name__ == "__main__": main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement