view pyikriam/example.py @ 199:b33c8dbe9b04

fixed is_any_corruption
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Mon, 03 Nov 2008 12:00:54 +0800
parents bf4ddf5bffb9
children
line wrap: on
line source

import sys
import buildings
from ikariam import Ikariam

if len(sys.argv) != 2:
    print >> sys.stderr, 'Usage: %s <city id>' % (sys.argv[0])
    sys.exit(1)
    pass

city_id = int(sys.argv[1]) # 117261

i = Ikariam()
city = i.city(city_id)

print "pull datas of the city %s" % (city_id)
city.sync()

print 'gold is ' + city.gold
print 'inhabitants is ' + city.inhabitants
print 'wood is ' + city.wood
print 'wine is ' + city.wine
print 'marble is ' + city.marble
print 'crystal is ' + city.crystal
print 'sulfur is ' + city.sulfur

for idx, pos in enumerate(city.positions):
    if not isinstance(pos, buildings.position):
        continue
    pos.sync()
    building_attrs  = filter(lambda attr: not attr[0].startswith('_'),
                             pos.__dict__.items())
    building_attrs.sort(key=lambda x: x[0])
    print
    print 'positions[%d]' % (idx)
    for building_attr, value in building_attrs:
        print '\t%s: %s' % (building_attr, repr(value))
        pass