當前位置: 首頁>>代碼示例>>Python>>正文


Python Formation.iteritems方法代碼示例

本文整理匯總了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()
開發者ID:yueyoum,項目名稱:dianjing,代碼行數:57,代碼來源:unit.py


注:本文中的core.formation.Formation.iteritems方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。