Last active
January 24, 2017 09:16
-
-
Save fmartingr/11395388 to your computer and use it in GitHub Desktop.
Check for free planet slots on positions 7-9 on ogame uni122
This file contains hidden or 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
#!/usr/bin/env python | |
import requests | |
from xml.etree import ElementTree | |
url = 'http://s122-es.ogame.gameforge.com/api/universe.xml' | |
response = requests.get(url) | |
universe = ElementTree.fromstring(response.content) | |
SAVE = {} | |
def is_free(solar_system, position): | |
return not SAVE[solar_system][position] | |
for elem in universe.getchildren(): | |
galaxy, solar_system, position = elem.attrib['coords'].split(':') | |
if int(galaxy) == 2: | |
if int(solar_system) not in SAVE: | |
SAVE[int(solar_system)] = [False for x in range(0, 17)] | |
SAVE[int(solar_system)][int(position)] = True | |
for key, solar in SAVE.iteritems(): | |
if is_free(key, 7): | |
print('2:{}:7 is free!'.format(key)) | |
if is_free(key, 8): | |
print('2:{}:8 is free!'.format(key)) | |
if is_free(key, 9): | |
print('2:{}:9 is free!'.format(key)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment