本文整理汇总了Python中core.formation.Formation.iteritems方法的典型用法代码示例。如果您正苦于以下问题:Python Formation.iteritems方法的具体用法?Python Formation.iteritems怎么用?Python Formation.iteritems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.formation.Formation
的用法示例。
在下文中一共展示了Formation.iteritems方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_units
# 需要导入模块: from core.formation import Formation [as 别名]
# 或者: from core.formation.Formation import iteritems [as 别名]
def load_units(self):
from core.formation import Formation
units = {}
""":type: dict[int, Unit]"""
doc = MongoUnit.db(self.server_id).find_one({'_id': self.char_id})
for _id, _data in doc['units'].iteritems():
u = Unit(self.server_id, self.char_id, int(_id), _data)
u.calculate()
u.make_cache()
units[int(_id)] = u
race = {
1: {'level': 0, 'step': 0},
2: {'level': 0, 'step': 0},
3: {'level': 0, 'step': 0},
}
for _, u in units.iteritems():
race[u.config.race]['level'] += u.level
race[u.config.race]['step'] += u.step
additions = {
1: UnitAddition(),
2: UnitAddition(),
3: UnitAddition(),
}
for k, v in additions.iteritems():
_level_addition = ConfigUnitAddition.get_level_addition(k, race[k]['level'])
_step_addition = ConfigUnitAddition.get_step_addition(k, race[k]['step'])
if _level_addition:
for attr in UnitAddition.__slots__:
v.add_property(attr, getattr(_level_addition, attr))
if _step_addition:
for attr in UnitAddition.__slots__:
v.add_property(attr, getattr(_step_addition, attr))
# 只作用于上阵兵种
in_format_staffs = Formation(self.server_id, self.char_id).in_formation_staffs()
for k, v in in_format_staffs.iteritems():
if not v['unit_id']:
continue
u = units[v['unit_id']]
_add = additions[u.config.race]
for attr in UnitAddition.__slots__:
_old_value = getattr(u, attr)
_new_value = _old_value + getattr(_add, attr)
setattr(u, attr, _new_value)
u.make_cache()