本文整理汇总了Python中the_tale.game.balance.power.Power.ui_info方法的典型用法代码示例。如果您正苦于以下问题:Python Power.ui_info方法的具体用法?Python Power.ui_info怎么用?Python Power.ui_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类the_tale.game.balance.power.Power
的用法示例。
在下文中一共展示了Power.ui_info方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ArtifactPrototype
# 需要导入模块: from the_tale.game.balance.power import Power [as 别名]
# 或者: from the_tale.game.balance.power.Power import ui_info [as 别名]
#.........这里部分代码省略.........
power=Power.deserialize(data['power']),
bag_uuid=data['bag_uuid'],
integrity=integrity[0],
max_integrity=integrity[1],
rarity=relations.RARITY.index_value[data.get('rarity', relations.RARITY.NORMAL.value)],
level=data.get('level', 1))
@classmethod
def _preference_rating(cls, rarity, power, distribution):
return (power.physic * distribution.physic + power.magic * distribution.magic) * rarity.preference_rating
def preference_rating(self, distribution):
return self._preference_rating(self.rarity, self.power, distribution)
def make_better_than(self, artifact, distribution):
while self.preference_rating(distribution) <= artifact.preference_rating(distribution):
if random.uniform(0, 1) < distribution.physic:
self.power.physic += 1
else:
self.power.magic += 1
def sharp(self, distribution, max_power, force=False):
choices = []
if force or self.power.physic < max_power.physic:
choices.append(('physic', distribution.physic))
if force or self.power.magic < max_power.magic:
choices.append(('magic', distribution.magic))
if not choices:
return False
if random_value_by_priority(choices) == 'physic':
self.power.physic += 1
else:
self.power.magic += 1
self.max_integrity -= int(self.max_integrity * c.ARTIFACT_SHARP_MAX_INTEGRITY_LOST_FRACTION)
self.integrity = min(self.integrity, self.max_integrity)
return True
@property
def integrity_fraction(self):
if self.max_integrity == 0:
return 0
return float(self.integrity) / self.max_integrity
def damage_integrity(self):
self.integrity = max(0, self.integrity - c.ARTIFACT_INTEGRITY_DAMAGE_PER_BATTLE)
def can_be_broken(self):
return self.integrity < self.max_integrity * (1.0 - c.ARTIFACT_INTEGRITY_SAFE_BARRIER)
def break_it(self):
self.power = Power(physic=max(1, int(self.power.physic * (1 - random.uniform(*c.ARTIFACT_BREAK_POWER_FRACTIONS)) - 1)),
magic=max(1, int(self.power.magic * (1 - random.uniform(*c.ARTIFACT_BREAK_POWER_FRACTIONS)) - 1)) )
self.max_integrity = int(self.max_integrity * (1 - random.uniform(*c.ARTIFACT_BREAK_INTEGRITY_FRACTIONS)))
self.integrity = min(self.integrity, self.max_integrity)
def repair_it(self):
self.integrity = self.max_integrity
def ui_info(self, hero):
effect = self._effect().TYPE
special_effect = self.special_effect().TYPE
return {'type': self.type.value,
'id': self.record.id,
'equipped': self.can_be_equipped,
'name': self.name,
'integrity': (self.integrity if not self.type.is_USELESS else None,
self.max_integrity if not self.type.is_USELESS else None),
'rarity': self.rarity.value if not self.type.is_USELESS else None,
'effect': effect.value,
'special_effect': special_effect.value,
'preference_rating': self.preference_rating(hero.preferences.archetype.power_distribution) if not self.type.is_USELESS else None,
'power': self.power.ui_info() if not self.type.is_USELESS else None}
def __eq__(self, other):
return (self.record.id == other.record.id and
self.power == other.power and
self.level == other.level and
self.integrity == other.integrity and
self.max_integrity == other.max_integrity and
self.bag_uuid == other.bag_uuid)
NORMAL_ARTIFACT_LABEL = u'<span class="normal-artifact-label">%s</span> <span class="physic-label">%d</span> <span class="magic-label">%d</span>'
RARE_ARTIFACT_LABEL = u'<span class="rare-artifact-label">%s</span> <span class="physic-label">%d</span> <span class="magic-label">%d</span>'
EPIC_ARTIFACT_LABEL = u'<span class="epic-artifact-label">%s</span> <span class="physic-label">%d</span> <span class="magic-label">%d</span>'
def html_label(self):
if self.is_useless:
return self.name
if self.rarity.is_NORMAL:
return self.NORMAL_ARTIFACT_LABEL % (self.name, self.power.physic, self.power.magic)
if self.rarity.is_RARE:
return self.RARE_ARTIFACT_LABEL % (self.name, self.power.physic, self.power.magic)
if self.rarity.is_EPIC:
return self.EPIC_ARTIFACT_LABEL % (self.name, self.power.physic, self.power.magic)