Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2014
5,797
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.67 KB | None | 0 0
  1. import urllib2
  2. import json
  3. import string
  4. import time
  5. import traceback
  6.  
  7. goals = [
  8.     { "goal" : "Evolving Battle Point Booster", "prize" : 1.8, "description" : "Grants a new Battle Point Booster that improves as your compendium level increases."},
  9.     { "goal" : "Loading Screen Treasure", "prize" : 2.0, "description" : "Grants three Treasures that contain Loading Screens. Extra Treasures available as rewards based on Compendium levels."},
  10.     { "goal" : "Arcana Vote", "prize" : 2.2, "description" : "Unlocks the ability to vote on which hero should receive the next Arcana."},
  11.     { "goal" : "Special Edition HUD", "prize" : 2.4, "description" : "Grants a new Compendium-themed HUD."},
  12.     { "goal" : "Solo Championship Vote", "prize" : 2.6, "description" : "Unlocks the ability to vote on the participants of an 8 player Solo Championship at The International."},
  13.     { "goal" : "New Game Mode", "prize" : 2.9, "description" : "Unlocks the All Random Deathmatch game modes (available to all players, not just Compendium owners)."},
  14.     { "goal" : "Immortal Treasures", "prize" : 3.2, "description" : "Grants a Treasure containing Valve created Immortal Items. Every 10 compendium levels grants you an extra Treasure."},
  15.     { "goal" : "Chat Emoticons", "prize" : 3.5, "description" : "Grants access to special emoticons that can be used in Dota 2 chat."},
  16.     { "goal" : "Mini-Pudge Courier", "prize" : 4.0, "description" : "Grants a special Mini Pudge Courier. Level 50 compendium owners have an alternate skin."},
  17.     { "goal" : "New Music", "prize" : 4.5, "description" : "Grants a new music pack for Dota 2."},
  18.     { "goal" : "New Matchmaking", "prize" : 5.0, "description" : "Unlocks a 1v1 mid-lane-only Match-making option (available to all players, not just Compendium owners)."},
  19.     { "goal" : "Environmental Effects", "prize" : 5.5, "description" : "Grants new environment effects in the Dota map."},
  20.     { "goal" : "Base Customization", "prize" : 6.0, "description" : "Grants an item that allows Compendium owners to customize a building in their base."},
  21.     { "goal" : "Techies Unusual Taunt", "prize" : 6.4, "description" : "Performs a special Taunt animation with added visual effects. Techies will also taunt enemies in their Death Cam when killed by you. Item will be granted to all Compendium Owners when Techies is released after The International.", "status":0},
  22.     { "goal" : "Daily Hero Challange", "prize" : 6.8, "description" : "Earn 25 compendium points every day by winning a game with the Hero we choose for you.", "status":0},
  23.     { "goal" : "Alternate Voice", "prize" : 7.2, "description" : "Vote for the Hero you'd like to receive a new, alternate voice & dialogue pack. When the recording is complete, you will be granted an item that unlocks the new voice.", "status":0},
  24.     { "goal" : "Favorite Hero Challange", "prize" : 7.6, "description" : "Start training for the next international. Select one of you Least Played heroes and we'll provide a GPM / XPM analysis tool during the game to help you compare your performance with previous games. Win 10 games before July 28th and you'll earn compendium points.", "status":0},
  25.     { "goal" : "Model Update Vote", "prize" : 8.0, "description" : "Vote for the Hero you'd like to receive a reworked model.", "status":0},
  26.     { "goal" : "Multi-Kill Banner", "prize" : 8.4, "description" : "You'll receive an item that customizes your Multi-Kill Banner.", "status":0},
  27.     { "goal" : "Afterparty Broadcast", "prize" : 8.8, "description" : "Live Broadcasting of the after party with special guest Darude.", "status":0},
  28.     { "goal" : "New Upgraded Creeps", "prize" : 9.2, "description" : "Unlocks new models for your creeps after you've killed the enemy barracks. (Available to all players, not just Compendium Owners)", "status":0},
  29.     { "goal" : "A->Z Challenge Support", "prize" : 9.6, "description" : "A new quest system will be added to track your progress, and earn you rewards as you win with all the Dota Heroes. (Available to all players, not just Compendium Owners)", "status":0},
  30.     { "goal" : "Victory Prediction Taunt", "prize" : 10, "description" : "Unlocks the ability for you to perform a voice taunt with your hero in the early stages of the game. Keeps track of how many successful predictions you've made in a row.", "status":0}
  31. ]
  32.  
  33. def execute(params):
  34.  
  35.     if len(params) > 0:
  36.         params = str(params[0])
  37.     else:
  38.         pass
  39.  
  40.  
  41.     try:
  42.         try:
  43.             all = string.maketrans('','')
  44.             nodigits = all.translate(all, string.digits)
  45.             jsonurl = urllib2.urlopen('http://dota2.cyborgmatt.com/prizetracker/overlay.php?leagueid=600')
  46.             text = jsonurl.read()
  47.             money = int(text.translate(all, nodigits))
  48.             moneyhelper = (money // 10**4) / 100.
  49.             # get some vars up
  50.             loadsamoney = '{:,}'.format(money)
  51.             strappedmoney = money - 1600000
  52.             valvesamoney = '{:,}'.format(strappedmoney * 3)
  53.             totalmoney = '{:,}'.format(strappedmoney * 4)
  54.             unixtime = int(time.time()) - 1399701600
  55.             gpmoney = '{:,}'.format((strappedmoney * 3) / (unixtime / 60 ))
  56.         except:
  57.             print "TI4 Prizepool API is down, blame CMatt."
  58.  
  59.  
  60.         try:
  61.             paramsfloat = float(params)
  62.         except:
  63.             pass
  64.  
  65.         if len(params) > 0:
  66.             if params == "all":
  67.                 for line in goals:
  68.                     goalhit = (line["prize"] <= moneyhelper and "X") or " "
  69.                     print "[%s] - $%sM >>> %s" % (goalhit, line["prize"], line["goal"])
  70.  
  71.             elif params:
  72.                 for line in goals:
  73.                     if paramsfloat <= line["prize"]:
  74.                         leftcount = line["prize"]*10**6 - money
  75.                         leftnumber = '{:,}'.format(int(leftcount))
  76.                         leftstring = (leftcount >= 0 and "($"+leftnumber+" left) " ) or ""
  77.                         print 'Stretch goal at $%sM %sis "%s": %s' % (line["prize"], leftstring, line["goal"], line["description"])
  78.                         break
  79.                     else:
  80.                             continue
  81.  
  82.         else:
  83.             try:
  84.                 lastgoal = ""
  85.                 lastprize = 1.6
  86.                 for line in goals:
  87.                     if line["prize"] > moneyhelper:
  88.                         remaining = '{:,}'.format(int(line["prize"]*(10**6)  - money))
  89.                         leftsmall = int(line["prize"]*(10**6) - lastprize*(10**6))
  90.                         leftvalue = int(money - lastprize*(10**6))
  91.                         percentage = (leftvalue * 100) / leftsmall
  92.                         print "Ti4 Prizepool Total: $%s | Total Sales Volume: $%s | GPM: $%s | Last goal was at $%sM: %s | Next goal in $%s (%s%%): %s" % (loadsamoney, totalmoney, gpmoney, lastprize, lastgoal, remaining, percentage, line["goal"])
  93.                         break
  94.                     else:
  95.                         lastprize = line["prize"]
  96.                         lastgoal = line["goal"]
  97.                         continue
  98.                     break
  99.             except:
  100.                 print "Can't connect to the Ti4 Prizepool tracker. Blame Volvo."
  101.     except:
  102.         traceback.print_exc()
  103.         print "Invalid syntax. Try a floating value or 'all' instead."
  104.         pass
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111. params1 = []
  112. params2 = ['all']
  113. params3 = ['8.2']
  114. print "\n\n"
  115. execute(params1)
  116. print "\n\n"
  117. execute(params2)
  118. print "\n\n"
  119. execute(params3)
  120. print "\n\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement