本文整理汇总了Python中the_tale.game.balance.power.Power类的典型用法代码示例。如果您正苦于以下问题:Python Power类的具体用法?Python Power怎么用?Python Power使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Power类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_better_artifact_power
def check_better_artifact_power(self, distribution):
median_power = Power.power_to_artifact(distribution, 100)
for i in range(100):
power = Power.better_artifact_power_randomized(distribution, 100)
self.assertTrue(median_power.physic < power.physic)
self.assertTrue(median_power.magic < power.magic)
示例2: test_corridor
def test_corridor(self):
# fill_empty_keys_with_fake_phrases(u'test_hero_level_companion')
result, account_id, bundle_id = register_user(uuid.uuid4().hex) # pylint: disable=W0612
self.storage = LogicStorage()
self.storage.load_account_data(AccountPrototype.get_by_id(account_id))
self.hero = self.storage.accounts_to_heroes[account_id]
self.set_hero_companion()
current_time = TimePrototype.get_current_time()
for level in xrange(1, 100):
print
print '-----------------------------------------------------------------------'
print 'process level %d\texpected turns: %d\texpected days: %.2f' % (level, f.turns_on_lvl(level), f.time_on_lvl(level)/24)
for i in xrange(f.turns_on_lvl(level)): # pylint: disable=W0612
self.storage.process_turn()
current_time.increment_turn()
# simulate user behaviour on healing companion
if self.hero.companion.health < self.hero.companion.max_health / 2:
self.hero.companion.health = self.hero.companion.max_health
self.hero.randomized_level_up()
exp_to_next_level = float(self.hero.experience) / f.exp_on_lvl(self.hero.level) * 100
exp_from_expected = float(f.total_exp_to_lvl(self.hero.level)+self.hero.experience)/f.total_exp_to_lvl(level+1)*100
exp_untaken = f.total_exp_to_lvl(level+1) - f.total_exp_to_lvl(self.hero.level) - self.hero.experience
quests_untaken = float(exp_untaken) / f.experience_for_quest(c.QUEST_AREA_RADIUS)
print u'hero level: %d\texp: %.2f%%\texp from expected: %.2f%% (%d exp, %.2f quests)\ttotal quests %d' % (self.hero.level,
exp_to_next_level,
exp_from_expected,
exp_untaken,
quests_untaken,
self.hero.statistics.quests_done)
print u'abilities: %s' % ' '.join(u'%s-%d' % (ability_id, ability.level) for ability_id, ability in self.hero.abilities.abilities.items())
print u'deaths: %d' % self.hero.statistics.pve_deaths
total_gold = f.total_gold_at_lvl(self.hero.level)
print u'total money: %d from expected %d (x%.2f)' % (self.hero.statistics.money_earned,
total_gold,
float(self.hero.statistics.money_earned) / total_gold if total_gold > 0 else 0)
total_artifacts = int(f.total_time_for_lvl(self.hero.level) / 24 * c.ARTIFACTS_LOOT_PER_DAY )
print u'total artifacts: %d from expected %d (x%.2f)' % (self.hero.statistics.artifacts_had,
total_artifacts,
float(self.hero.statistics.artifacts_had) / total_artifacts if total_artifacts > 0 else 0)
print u'power: %r from expected %r' % (self.hero.power, Power.power_to_level(self.hero.preferences.archetype.power_distribution, self.hero.level))
print u'power total: %d from expected %r (x%.2f)' % (self.hero.power.total(),
Power.power_to_level(self.hero.preferences.archetype.power_distribution, self.hero.level).total(),
float(self.hero.power.total()) / Power.power_to_level(self.hero.preferences.archetype.power_distribution, self.hero.level).total())
示例3: test_better_artifact_power__on_low_levels
def test_better_artifact_power__on_low_levels(self):
median_power = Power.power_to_artifact(PowerDistribution(0.5, 0.5), 1)
self.assertEqual(median_power, Power(1, 1))
powers = set()
for i in range(100):
power = Power.better_artifact_power_randomized(PowerDistribution(0.5, 0.5), 1)
powers.add(power.magic)
powers.add(power.physic)
self.assertEqual(1 + c.ARTIFACT_BETTER_MIN_POWER_DELTA * 2, len(powers))
示例4: receive_artifacts_slots_choices
def receive_artifacts_slots_choices(self, better, prefered_slot, prefered_item):
from the_tale.game.artifacts.prototypes import ArtifactPrototype
allowed_slots = list(relations.EQUIPMENT_SLOT.records)
slot_choices = list(allowed_slots)
if prefered_slot and self.preferences.equipment_slot and self.can_upgrade_prefered_slot:
slot_choices = [self.preferences.equipment_slot]
if prefered_item and self.preferences.favorite_item and self.preferences.favorite_item in slot_choices: #after prefered slot, since prefered item is more important
slot_choices.remove(self.preferences.favorite_item)
result_choices = []
if better:
for slot in slot_choices:
artifact = self.equipment.get(slot)
if artifact is not None:
distribution = self.preferences.archetype.power_distribution
min_power, max_power = Power.artifact_power_interval(distribution, self.level) # pylint: disable=W0612
if artifact.preference_rating(distribution) >= ArtifactPrototype._preference_rating(artifact.rarity, max_power, distribution):
continue
result_choices.append(slot)
else:
result_choices = slot_choices
return result_choices
示例5: break_it
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)
示例6: test_receive_artifacts_slots_choices__better_false
def test_receive_artifacts_slots_choices__better_false(self):
distribution = self.hero.preferences.archetype.power_distribution
min_power, max_power = Power.artifact_power_interval(distribution, self.hero.level) # pylint: disable=W0612
for artifact in self.hero.equipment.values():
artifact.power = max_power
self.assertEqual(set(self.hero.receive_artifacts_slots_choices(better=False, prefered_slot=False, prefered_item=False)),
set(relations.EQUIPMENT_SLOT.records))
示例7: use
def use(self, task, storage, **kwargs): # pylint: disable=R0911,W0613
for artifact in task.hero.equipment.values():
distribution = task.hero.preferences.archetype.power_distribution
min_power, max_power = Power.artifact_power_interval(distribution, task.hero.level)
artifact.sharp(distribution=distribution, max_power=max_power, force=True)
return task.logic_result(message=u"Вся экипировка героя улучшена")
示例8: test_purchase_artifact__better_artifact__min_level
def test_purchase_artifact__better_artifact__min_level(self):
self.assertEqual(self.hero.level, 1)
rarity = RARITY.NORMAL
distribution = self.hero.preferences.archetype.power_distribution
middle_power = Power.power_to_artifact(distribution, self.hero.level)
for i in xrange(100):
self.assertTrue(self.hero.purchase_artifact(rarity=RARITY.NORMAL, better=True).preference_rating(distribution) >
ArtifactPrototype._preference_rating(rarity, middle_power, distribution))
示例9: test_sharp_preferences_with_max_power
def test_sharp_preferences_with_max_power(self):
distribution = self.hero.preferences.archetype.power_distribution
min_power, max_power = Power.artifact_power_interval(distribution, self.hero.level)
self.hero.preferences.set_equipment_slot(relations.EQUIPMENT_SLOT.HAND_PRIMARY)
artifact = self.hero.equipment.get(relations.EQUIPMENT_SLOT.HAND_PRIMARY)
artifact.power = max_power
artifact = self.hero.sharp_artifact()
self.assertFalse(artifact.type.is_MAIN_HAND)
示例10: use
def use(self, task, storage, **kwargs): # pylint: disable=R0911,W0613
artifact = random.choice(task.hero.equipment.values())
distribution=task.hero.preferences.archetype.power_distribution
min_power, max_power = Power.artifact_power_interval(distribution, task.hero.level)
artifact.sharp(distribution=distribution,
max_power=max_power,
force=True)
return task.logic_result(message=u'Улучшена экипировка героя: %(artifact)s' % {'artifact': artifact.html_label()})
示例11: damage_integrity
def damage_integrity(self):
if random.random() < self.safe_artifact_integrity_probability:
return
expected_artifact_power = Power.normal_power_to_level(self.level)
for artifact in self.equipment.values():
delta = c.ARTIFACT_INTEGRITY_DAMAGE_PER_BATTLE * (float(artifact.power.total()) / expected_artifact_power)**2
if self.preferences.favorite_item is not None and self.preferences.favorite_item == artifact.type.equipment_slot:
delta *= c.ARTIFACT_INTEGRITY_DAMAGE_FOR_FAVORITE_ITEM
artifact.damage_integrity(delta)
示例12: purchase_artifact
def purchase_artifact(self, rarity, better):
distribution = self.preferences.archetype.power_distribution
power = Power.better_artifact_power_randomized(distribution, self.level) if better else Power.artifact_power_randomized(distribution, self.level)
artifacts_storage.sync()
artifact = random.choice(artifacts_storage.artifacts).create_artifact(level=self.level,
power=power,
rarity=rarity)
self.put_loot(artifact, force=True)
self.actions.request_replane()
return artifact
示例13: test_sharp_artifact_when_all_artifacts_has_max_power
def test_sharp_artifact_when_all_artifacts_has_max_power(self):
distribution = self.hero.preferences.archetype.power_distribution
min_power, max_power = Power.artifact_power_interval(distribution, self.hero.level)
for artifact in self.hero.equipment.equipment.values():
artifact.power = max_power.clone()
old_power = self.hero.power
artifact = self.hero.sharp_artifact()
self.assertTrue(self.hero.power.physic > old_power.physic or
self.hero.power.magic > old_power.magic)
self.assertTrue(artifact.power == max_power + Power(1, 0) or
artifact.power == max_power + Power(0, 1))
self.assertTrue(self.hero.equipment.updated)
示例14: test_only_better_for_prefered_slot
def test_only_better_for_prefered_slot(self):
self.hero._model.level = 9999
self.hero.preferences.set_equipment_slot(relations.EQUIPMENT_SLOT.PLATE)
# just set any artifact
self.hero.receive_artifact(equip=True, better=False, prefered_slot=True, prefered_item=True, archetype=True)
distribution = self.hero.preferences.archetype.power_distribution
min_power, max_power = Power.artifact_power_interval(distribution, self.hero.level)
for i in xrange(100):
old_artifact = self.hero.equipment.get(relations.EQUIPMENT_SLOT.PLATE)
old_artifact.power = max_power - Power(1, 1)
self.hero.receive_artifact(equip=True, better=True, prefered_slot=True, prefered_item=True, archetype=True)
self.assertTrue(self.hero.equipment.get(relations.EQUIPMENT_SLOT.PLATE).preference_rating(distribution) > old_artifact.preference_rating(distribution))
示例15: test_purchase_artifact__better_artifact__large_level
def test_purchase_artifact__better_artifact__large_level(self):
self.hero.level = 100
self.assertEqual(self.hero.level, 100)
rarity = RARITY.NORMAL
distribution = self.hero.preferences.archetype.power_distribution
middle_power = Power.power_to_artifact(distribution, self.hero.level)
N = 100
with mock.patch('the_tale.game.actions.container.ActionsContainer.request_replane') as request_replane:
for i in xrange(N):
self.assertTrue(self.hero.purchase_artifact(rarity=RARITY.NORMAL, better=True).preference_rating(distribution) >
ArtifactPrototype._preference_rating(rarity, middle_power, distribution))
self.assertEqual(request_replane.call_count, N)