annotate pyikriam/example.py @ 176:3ba3edda6d1e

Extract more information for building townhall.
author Thinker K.F. Li <thinker@branda.to>
date Sun, 02 Nov 2008 11:32:59 +0800
parents 8f699a9da6c0
children 6adad3bcca78
rev   line source
162
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
1 import sys
166
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents: 162
diff changeset
2 from ikariam import Ikariam
62
a4c364888197 add ikriam game binding lib python version
hychen@mluna
parents:
diff changeset
3
162
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
4 if len(sys.argv) != 2:
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
5 print >> sys.stderr, 'Usage: %s <city id>' % (sys.argv[0])
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
6 sys.exit(1)
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
7 pass
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
8
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
9 city_id = int(sys.argv[1]) # 117261
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
10
64
19d2a7b175b3 Load configure data from .eagleeye.pm
kevin@localhost.localdomain
parents: 62
diff changeset
11 i = Ikariam()
162
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
12 city = i.city(city_id)
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
13
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
14 print "pull datas of the city %s" % (city_id)
62
a4c364888197 add ikriam game binding lib python version
hychen@mluna
parents:
diff changeset
15 city.sync()
162
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
16
160
7551342718b6 Refactory pyikriam with patterns.
Thinker K.F. Li <thinker@branda.to>
parents: 64
diff changeset
17 print 'gold is ' + city.gold
161
1507c2d16b35 Extract wood, marble, crystal, sulfure, and inhabitants information.
Thinker K.F. Li <thinker@branda.to>
parents: 160
diff changeset
18 print 'inhabitants is ' + city.inhabitants
1507c2d16b35 Extract wood, marble, crystal, sulfure, and inhabitants information.
Thinker K.F. Li <thinker@branda.to>
parents: 160
diff changeset
19 print 'wood is ' + city.wood
1507c2d16b35 Extract wood, marble, crystal, sulfure, and inhabitants information.
Thinker K.F. Li <thinker@branda.to>
parents: 160
diff changeset
20 print 'wine is ' + city.wine
1507c2d16b35 Extract wood, marble, crystal, sulfure, and inhabitants information.
Thinker K.F. Li <thinker@branda.to>
parents: 160
diff changeset
21 print 'marble is ' + city.marble
1507c2d16b35 Extract wood, marble, crystal, sulfure, and inhabitants information.
Thinker K.F. Li <thinker@branda.to>
parents: 160
diff changeset
22 print 'crystal is ' + city.crystal
1507c2d16b35 Extract wood, marble, crystal, sulfure, and inhabitants information.
Thinker K.F. Li <thinker@branda.to>
parents: 160
diff changeset
23 print 'sulfur is ' + city.sulfur
162
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
24 print 'positions ' + repr(city.positions)
160
7551342718b6 Refactory pyikriam with patterns.
Thinker K.F. Li <thinker@branda.to>
parents: 64
diff changeset
25
168
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
26 city.positions[0].sync()
176
3ba3edda6d1e Extract more information for building townhall.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
27 city_attrs = ('level', 'occupied', 'rooms', 'growth', 'happiness',
3ba3edda6d1e Extract more information for building townhall.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
28 'interest_base', 'interest_research', 'interest_capital',
3ba3edda6d1e Extract more information for building townhall.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
29 'pop_citizens', 'pop_woodworkers', 'pop_specialworkers',
3ba3edda6d1e Extract more information for building townhall.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
30 'pop_scientists', 'is_upgrading', 'upgrade_uri')
3ba3edda6d1e Extract more information for building townhall.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
31 for city_attr in city_attrs:
3ba3edda6d1e Extract more information for building townhall.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
32 value = getattr(city.positions[0], city_attr)
3ba3edda6d1e Extract more information for building townhall.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
33 print 'positions[0].%s is %s' % (city_attr, str(value))
3ba3edda6d1e Extract more information for building townhall.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
34 pass