本文整理汇总了Python中hero.Hero.get_state方法的典型用法代码示例。如果您正苦于以下问题:Python Hero.get_state方法的具体用法?Python Hero.get_state怎么用?Python Hero.get_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hero.Hero
的用法示例。
在下文中一共展示了Hero.get_state方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Account
# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_state [as 别名]
#.........这里部分代码省略.........
params[name] = value
# alter it
params['name'] = self.user_name
params['password'] = self.password
params['lowRes'] = '1'
params['s1'] = 'Einloggen'
params['w'] = '1920:1080'
# perform login and return village overview
doc = self.request_POST("/dorf1.php", params)
self.ajax_token = reader.read_ajax_token(doc)
return doc
def logout(self):
self.request_GET("/logout.php", createDom=False)
def loadup(self):
"""
Loads cookies, Logins,
Loads all villages, events and the hero.
"""
self.load_db()
self.load_cookie()
doc_resources = self.request_GET("/dorf1.php")
if not len(reader.read_resource_fields(doc_resources)):
self.clear_cookie()
doc_resources = self.login(doc_login = doc_resources)
self.save_cookie()
if not len(reader.read_resource_fields(doc_resources)):
logger.log_error("login failed", "The login failed")
else:
self.ajax_token = reader.read_ajax_token(doc_resources)
village = self.request_village(None, doc_resources)
other_villages = self.villages.keys() ^ { village.village_id } # all villages except the active
self.request_villages(other_villages)
self.request_hero()
self.production_boost = reader.read_production_boost(doc_resources)
def request_village(self, village_id, doc_login = None):
'''
If village_id is None, doc_login will be used and a list of villages will be stored.
'''
doc_resources = doc_login or self.request_GET("/dorf1.php?newdid=%d" % village_id)
pages = { 'resources': doc_resources,
'village': self.request_GET("/dorf2.php") }
active_village = reader.read_villages(doc_resources, True)[0]
if village_id is None:
all_villages = reader.read_villages(doc_resources)
self.villages.clear()
self.villages.update( { vill['village_id']: Village(self, **vill) for vill in all_villages } )
if active_village['village_id'] not in self.villages:
self.villages[active_village['village_id']] = Village(self, **active_village)
self.current_village = self.villages[active_village['village_id']]
village = self.villages[active_village['village_id']]
if active_village['name'] != village.name:
logger.log_info("village renamed", "Village %s renamed to %s" % (village.name, active_village['name']))
village.name = active_village['name']
village.read_content(pages)
village.read_events(pages)
village.new_refresh_time()
return village
def request_villages(self, village_keys=None):
"""
Requests all villages, or only those with the given keys.
Writes the village data into existing village instances or creates new ones.
"""
village_keys = village_keys if village_keys is not None else self.villages.keys()
for village_id in village_keys:
self.request_village(village_id)
def request_hero(self):
doc = self.request_GET('/hero_inventory.php')
reader.read_hero(doc, self.hero)
def get_state(self):
return AccountState(self.production_boost, self.hero.get_state())
def update(self):
for vill in self.villages.values():
vill.update()