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


Python Formation.find_socket_by_hero方法代碼示例

本文整理匯總了Python中core.formation.Formation.find_socket_by_hero方法的典型用法代碼示例。如果您正苦於以下問題:Python Formation.find_socket_by_hero方法的具體用法?Python Formation.find_socket_by_hero怎麽用?Python Formation.find_socket_by_hero使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在core.formation.Formation的用法示例。


在下文中一共展示了Formation.find_socket_by_hero方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _add_equip_attrs

# 需要導入模塊: from core.formation import Formation [as 別名]
# 或者: from core.formation.Formation import find_socket_by_hero [as 別名]
    def _add_equip_attrs(self):
        from core.item import Equipment
        f = Formation(self.char_id)
        socket = f.find_socket_by_hero(self.id)
        if not socket:
            return

        # 先把裝備數值加到人物上
        equipments = []
        for x in ['weapon', 'armor', 'jewelry']:
            equip_id = getattr(socket, x)
            if equip_id:
                equip = Equipment(self.char_id, equip_id)
                self.attack += equip.attack
                self.defense += equip.defense
                self.hp += equip.hp

                equipments.append(equip)

        # 然後加成人物的專屬裝備
        additions = {}
        special_equipments = self.model_hero.special_equipments
        if special_equipments:
            for equip in equipments:
                _cls = equip.equip.cls
                if _cls not in special_equipments:
                    continue

                _tp = equip.equip.tp
                additions[_tp] = additions.get(_tp, 0) + special_equipments[_cls]

        for _tp, _add_percent in additions.items():
            if _tp == 1:
                # attack
                self.attack *= (1 + _add_percent / 100.0)
            elif _tp == 2:
                # defense
                self.defense *= (1 + _add_percent / 100.0)
            else:
                # hp
                self.hp *= (1 + _add_percent / 100.0)
                self.hp = int(self.hp)

        # 最後再把寶石加上
        for equip in equipments:
            for k, v in equip.gem_attributes.iteritems():
                value = getattr(self, k)
                setattr(self, k, value + v)

        # 馬
        if socket.horse:
            horse = Horse(self.char_id).mongo_horse.horses[str(socket.horse)]
            self.attack += horse.attack
            self.defense += horse.defense
            self.hp += horse.hp
            self.crit += int(HORSE[horse.oid].crit / 10)
開發者ID:yaosj,項目名稱:sanguo-server,代碼行數:58,代碼來源:hero.py


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