本文整理汇总了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)