Created
December 27, 2011 18:57
-
-
Save HandyAndyShortStack/1524789 to your computer and use it in GitHub Desktop.
nono_optimizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### This is a calculator to tell you how many lemene and cosmox to make | |
### if you are about to cook up some serious nono. You will need the | |
### requests and simpleson libraries and your own oauth token with read access. | |
import requests, simplejson | |
token = '' # put token with read access here | |
uri = ''.join(["http://api.glitch.com/simple/players.inventory?oauth_token=", | |
token]) | |
decoder = simplejson.JSONDecoder() | |
inventory = decoder.decode(requests.get(uri).content) | |
elements = {'red': 0, 'green': 0, 'blue': 0, 'shiny': 0} | |
for bag in inventory['contents'].keys(): | |
if inventory['contents'][bag] != None and \ | |
inventory['contents'][bag]['class_tsid'] == 'bag_elemental_pouch': | |
for slot in inventory['contents'][bag]['contents'].keys(): | |
if inventory['contents'][bag]['contents'][slot] != None and \ | |
inventory['contents'][bag]['contents'][slot]['class_tsid'] == 'element_red': | |
elements['red'] = elements['red'] + \ | |
inventory['contents'][bag]['contents'][slot]['count'] | |
elif inventory['contents'][bag]['contents'][slot] != None and \ | |
inventory['contents'][bag]['contents'][slot]['class_tsid'] == 'element_green': | |
elements['green'] = elements['green'] + \ | |
inventory['contents'][bag]['contents'][slot]['count'] | |
elif inventory['contents'][bag]['contents'][slot] != None and \ | |
inventory['contents'][bag]['contents'][slot]['class_tsid'] == 'element_blue': | |
elements['blue'] = elements['blue'] + \ | |
inventory['contents'][bag]['contents'][slot]['count'] | |
elif inventory['contents'][bag]['contents'][slot] != None and \ | |
inventory['contents'][bag]['contents'][slot]['class_tsid'] == 'element_shiny': | |
elements['shiny'] = elements['shiny'] + \ | |
inventory['contents'][bag]['contents'][slot]['count'] | |
nono_count = 0 | |
while elements['red'] >= 148 and elements['green'] >= 12 and \ | |
elements['blue'] >= 52 and elements['shiny'] >= 37: | |
elements['red'] -= 148 | |
elements['green'] -= 12 | |
elements['blue'] -= 52 | |
elements['shiny'] -= 37 | |
nono_count += 1 | |
cosmox_count = nono_count * 11 | |
lemene_count = nono_count * 4 | |
print '' | |
print 'You have enough elements to cook up:' | |
print '' | |
print nono_count, 'nonos.' | |
print '' | |
print 'You should make:' | |
print '' | |
print cosmox_count, 'cosmox,' | |
print lemene_count, 'lemene.' | |
print '' | |
print 'Have fun!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment