annotate pyikriam/ikariam.py @ 219:7107c26ba197

Add class CreateAccount. this class is not finsh yet.
author kevin@localhost.localdomain
date Tue, 04 Nov 2008 16:27:10 +0800
parents 785c89e5db32
children 5fa938cbe058
rev   line source
166
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1 from lazy.www import c
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2 from lconf import LoadConfigfile
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3 import cookielib
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
4 import os
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
5 import urllib2
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
6 import urllib
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
7 from utils import dyna_prog, decorator
168
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
8 from lxml import etree
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
9 from StringIO import StringIO
166
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
10
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
11 class fake_moz(object):
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
12 __metaclass__ = decorator
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
13
218
785c89e5db32 Remove those file, and change the addheader from fake moz
kevin@localhost.localdomain
parents: 175
diff changeset
14 def __init__(self,headers=0):
785c89e5db32 Remove those file, and change the addheader from fake moz
kevin@localhost.localdomain
parents: 175
diff changeset
15 fakeheaders=[('User-agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.12pre) Gecko/20071220 BonEcho/2.0.0.12pre')]
785c89e5db32 Remove those file, and change the addheader from fake moz
kevin@localhost.localdomain
parents: 175
diff changeset
16 if headers:
785c89e5db32 Remove those file, and change the addheader from fake moz
kevin@localhost.localdomain
parents: 175
diff changeset
17 fakeheaders=fakeheaders+headers
166
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
18 super(fake_moz, self).__init__()
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
19 cookie_jar = cookielib.LWPCookieJar()
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
20 cookie_proc = urllib2.HTTPCookieProcessor(cookie_jar)
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
21 opener = urllib2.build_opener(cookie_proc)
218
785c89e5db32 Remove those file, and change the addheader from fake moz
kevin@localhost.localdomain
parents: 175
diff changeset
22 opener.addheaders = fakeheaders
166
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
23 fake_moz.set_backend(self, opener)
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
24 self.cookie_jar = cookie_jar
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
25 pass
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
26 pass
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
27
219
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
28 class CreateAccount:
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
29 """
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
30 For create sheep to cheat. take care of the ip address & email check by yourself.
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
31 """
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
32 def __init__(self,account,email,password,server):
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
33 self.account=account
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
34 self.password=password
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
35 self.server=server
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
36 self.email=email
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
37 headers=[('Referer','http://'+self.server[self.server.find('.')+1:]+'/register.php')]
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
38 self.browser = fake_moz(headers)
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
39 urllib2.install_opener(self.browser)
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
40 pass
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
41
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
42 def ca(self):
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
43 self.baseurl='http://'+self.server
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
44 params = {
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
45 "function":"createAvatar",\
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
46 "name":self.account,\
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
47 "email":self.email,\
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
48 "password":self.password,\
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
49 "agb":"on"}
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
50 ret=c(self.baseurl+'/index.php?action=newPlayer').get(params).get_content()
7107c26ba197 Add class CreateAccount. this class is not finsh yet.
kevin@localhost.localdomain
parents: 218
diff changeset
51 pass
166
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
52
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
53 class Ikariam:
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
54
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
55 cities = {}
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
56 COOKIEFILE = '/tmp/ikariam.lwp'
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
57
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
58 def __init__(self):
218
785c89e5db32 Remove those file, and change the addheader from fake moz
kevin@localhost.localdomain
parents: 175
diff changeset
59 self.browser = fake_moz()
785c89e5db32 Remove those file, and change the addheader from fake moz
kevin@localhost.localdomain
parents: 175
diff changeset
60 self._cookie_jar = self.browser.cookie_jar
166
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
61
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
62 if os.path.isfile(self.COOKIEFILE):
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
63 self._cookie_jar.load(self.COOKIEFILE)
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
64 pass
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
65
218
785c89e5db32 Remove those file, and change the addheader from fake moz
kevin@localhost.localdomain
parents: 175
diff changeset
66 urllib2.install_opener(self.browser)
166
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
67 self.confdata=LoadConfigfile().cd
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
68 self.baseurl='http://'+self.confdata['server']
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
69
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
70 self.login()
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
71 pass
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
72
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
73 def login(self):
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
74 print "login to %s...." % self.confdata['server']
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
75 params = {"universe":self.confdata['server'], \
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
76 "name":self.confdata['user'], \
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
77 "password":self.confdata['pass']}
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
78 ret = c(self.baseurl+'/index.php?action=loginAvatar&function=login').get(params).get_content()
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
79 self._cookie_jar.save(self.COOKIEFILE)
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
80 pass
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
81
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
82 def logout(self):
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
83 print "logut from %s...." % self.confdata['server']
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
84 c(self.baseurl+'/index.php?action=loginAvatar&function=logout')
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
85 os.remove(self.COOKIEFILE)
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
86 pass
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
87
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
88 ##
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
89 # \note We can cache data with decorator 'dynamic programming'.
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
90 #
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
91 @dyna_prog
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
92 def city(self, id):
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
93 return IkariamCity(id=id, core=self)
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
94 pass
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
95
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
96 class IkariamCity:
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
97 data_patterns = {
175
9f248c8460ce Simplize xpath patterns.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
98 'gold': 'value_gold',
9f248c8460ce Simplize xpath patterns.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
99 'inhabitants': 'value_inhabitants',
9f248c8460ce Simplize xpath patterns.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
100 'wood': 'value_wood',
9f248c8460ce Simplize xpath patterns.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
101 'wine': 'value_wine',
9f248c8460ce Simplize xpath patterns.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
102 'marble': 'value_marble',
9f248c8460ce Simplize xpath patterns.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
103 'crystal': 'value_crystal',
9f248c8460ce Simplize xpath patterns.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
104 'sulfur': 'value_sulfur'
166
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
105 }
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
106 def __init__(self, id, core ):
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
107 self.core = core
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
108 self.id = id
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
109 self.params = {'view':'city','id':id}
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
110
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
111 def sync(self):
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
112 page = c(self.core.baseurl).get(self.params).get_content()
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
113 parser = etree.HTMLParser(encoding='utf8')
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
114 page_dom = etree.parse(StringIO(page), parser)
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
115
175
9f248c8460ce Simplize xpath patterns.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
116 xpath_globalinfo = '/descendant::*[@id=\'%s\']/text()'
9f248c8460ce Simplize xpath patterns.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
117 for name, tag_id in self.data_patterns.items():
9f248c8460ce Simplize xpath patterns.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
118 xpath = xpath_globalinfo % (tag_id)
166
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
119 value = page_dom.xpath(xpath)[0]
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
120 setattr(self, name, value)
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
121 pass
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
122
175
9f248c8460ce Simplize xpath patterns.
Thinker K.F. Li <thinker@branda.to>
parents: 168
diff changeset
123 xpath_mainview = '/descendant::div[@id=\'mainview\']/ul/li'
166
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
124 pos_doms = page_dom.xpath(xpath_mainview)
168
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
125 positions = [self._mk_position(pos_dom, idx)
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
126 for idx, pos_dom in enumerate(pos_doms)]
166
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
127 self.positions = positions
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
128 pass
168
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
129
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
130 def _mk_position(self, pos_dom, idx):
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
131 import buildings
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
132
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
133 build_type = pos_dom.get('class').split()[-1].lower()
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
134 if hasattr(buildings, build_type):
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
135 clz = getattr(buildings, build_type)
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
136 if issubclass(clz, buildings.position):
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
137 building = clz(self.id, idx, self.core.baseurl)
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
138 return building
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
139 pass
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
140 return build_type
166
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
141 pass
168
8f699a9da6c0 Extract building level of townhalls.
Thinker K.F. Li <thinker@branda.to>
parents: 166
diff changeset
142