本文整理汇总了Python中the_tale.game.companions.logic.create_random_companion_record函数的典型用法代码示例。如果您正苦于以下问题:Python create_random_companion_record函数的具体用法?Python create_random_companion_record怎么用?Python create_random_companion_record使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_random_companion_record函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_politics_power_multiplier__all_effects
def test_politics_power_multiplier__all_effects(self):
with self.check_increased(self.hero.politics_power_multiplier):
self.hero.might = 1000
with self.check_increased(self.hero.politics_power_multiplier):
self.hero.level = 100
with self.check_increased(self.hero.politics_power_multiplier):
self.hero.actual_bills.append(time.time())
self.hero.actual_bills.append(time.time())
with self.check_increased(self.hero.politics_power_multiplier):
self.hero.preferences.set_risk_level(relations.RISK_LEVEL.VERY_HIGH)
with self.check_increased(self.hero.politics_power_multiplier):
self.hero.equipment.get(relations.EQUIPMENT_SLOT.PLATE).record.special_effect = artifacts_relations.ARTIFACT_EFFECT.GREAT_POWER
with self.check_increased(self.hero.politics_power_multiplier):
companion_record = companions_logic.create_random_companion_record(name='test-companion',
state=companions_relations.STATE.ENABLED,
abilities=companions_abilities_container.Container(start=(companions_effects.ABILITIES.KNOWN,)))
companion = companions_logic.create_companion(companion_record)
self.hero.set_companion(companion)
with self.check_increased(self.hero.politics_power_multiplier):
self.hero.abilities.add(nonbattle_abilities.DIPLOMATIC.get_id(), level=len(nonbattle_abilities.DIPLOMATIC.POWER_MULTIPLIER))
示例2: setUp
def setUp(self):
super(InPlaceActionCompanionLeaveTests, self).setUp()
self.place_1, self.place_2, self.place_3 = create_test_map()
self.account = self.accounts_factory.create_account()
self.storage = LogicStorage()
self.storage.load_account_data(self.account)
self.hero = self.storage.accounts_to_heroes[self.account.id]
self.action_idl = self.hero.actions.current_action
self.companion_record = companions_logic.create_random_companion_record('thief', state=companions_relations.STATE.ENABLED)
self.hero.set_companion(companions_logic.create_companion(self.companion_record))
self.hero.money = f.expected_gold_in_day(self.hero.level)
self.hero.position.set_place(self.place_1)
self.hero.position.update_previous_place()
self.hero.position.set_place(self.place_2)
self.artifact = artifacts_storage.generate_artifact_from_list(artifacts_storage.loot, 1, rarity=RARITY.NORMAL)
self.hero.put_loot(self.artifact)
self.assertEqual(self.hero.bag.occupation, 1)
self.hero.position.move_out_place()
示例3: test_exclude__different_data
def test_exclude__different_data(self):
cards = []
companions_models.CompanionRecord.objects.all().delete()
companions_storage.companions.refresh()
for rarity, rarity_abilities in companions_helpers.RARITIES_ABILITIES.iteritems():
companions_logic.create_random_companion_record(
"%s companion" % rarity,
mode=companions_relations.MODE.AUTOMATIC,
abilities=rarity_abilities,
state=companions_relations.STATE.ENABLED,
)
for i in xrange(len(relations.CARD_TYPE.records)):
card = self.hero.cards.get_new_card(exclude=cards)
cards.append(card)
self.assertEqual(self.hero.cards.get_new_card(exclude=cards), None)
cards[0].data = {"fake-data": True}
self.assertEqual(cards[0].type, self.hero.cards.get_new_card(exclude=cards).type)
self.assertEqual(set(card.type for card in cards), set(relations.CARD_TYPE.records))
示例4: set_hero_companion
def set_hero_companion(self):
from the_tale.game.companions import storage
from the_tale.game.companions import models
from the_tale.game.companions import logic
COMPANION_NAME = u'test_hero_level_companion'
for companion in storage.companions.all():
if companion.name.startswith(COMPANION_NAME):
models.CompanionRecord.objects.filter(id=companion.id).delete()
storage.companions.refresh()
break
companion_record = logic.create_random_companion_record(COMPANION_NAME)
self.hero.set_companion(logic.create_companion(companion_record))
示例5: _test_companion_death_speed
def _test_companion_death_speed(self):
current_time = game_prototypes.TimePrototype.get_current_time()
companion_record = logic.create_random_companion_record('test companion',
state=relations.STATE.ENABLED,
dedication=relations.DEDICATION.BRAVE)#,#,;
# abilities=abilities_container.Container(start=(effects.ABILITIES.BODYGUARD,)),# effects.ABILITIES.PUNY)),
# dedication=relations.DEDICATION.HEROIC)
# abilities=abilities_container.Container(common=(effects.ABILITIES.COWARDLY, )),
# dedication=relations.DEDICATION.INDECISIVE)
companion = logic.create_companion(companion_record)
self.hero.set_companion(companion)
# self.hero.preferences.set_companion_dedication(heroes_relations.COMPANION_DEDICATION.EGOISM)
self.hero.preferences.set_companion_dedication(heroes_relations.COMPANION_DEDICATION.NORMAL)
# self.hero.preferences.set_companion_dedication(heroes_relations.COMPANION_DEDICATION.ALTRUISM)
# self.hero.preferences.set_companion_dedication(heroes_relations.COMPANION_DEDICATION.EVERY_MAN_FOR_HIMSELF)
old_health = self.hero.companion.health
print 'defend_probability: ', self.hero.companion.defend_in_battle_probability
# for i in xrange(50):
# self.hero.randomized_level_up(increment_level=True)
while self.hero.companion:
self.hero.companion.coherence = 50
self.storage.process_turn()
current_time.increment_turn()
self.hero.randomized_level_up()
if not self.hero.is_alive:
if hasattr(self.hero.actions.current_action, 'fast_resurrect'):
self.hero.actions.current_action.fast_resurrect()
print '!'
if self.hero.companion:
if old_health != self.hero.companion.health:
print '%.2f:\t%s -> %s [%s] c%s' % ( (current_time.turn_number / c.TURNS_IN_HOUR / 24.0),
self.hero.companion.health - self.hero.companion.max_health,
self.hero.companion.health,
self.hero.companion.health - old_health,
self.hero.companion.coherence)
old_health = self.hero.companion.health
示例6: setUp
def setUp(self):
super(InPlaceActionCompanionStealingTest, self).setUp()
create_test_map()
self.account = self.accounts_factory.create_account()
self.storage = LogicStorage()
self.storage.load_account_data(self.account)
self.hero = self.storage.accounts_to_heroes[self.account.id]
self.action_idl = self.hero.actions.current_action
self.action_inplace = prototypes.ActionInPlacePrototype.create(hero=self.hero)
self.action_inplace.state = self.action_inplace.STATE.PROCESSED
self.companion_record = companions_logic.create_random_companion_record('thief', state=companions_relations.STATE.ENABLED)
self.hero.set_companion(companions_logic.create_companion(self.companion_record))
示例7: test_healed_companion
def test_healed_companion(self):
self.companion_record = companions_logic.create_random_companion_record('companion', state=companions_relations.STATE.ENABLED)
self.hero.set_companion(companions_logic.create_companion(self.companion_record))
self.hero.companion.health = self.hero.companion.max_health
while not self.hero.next_spending.is_HEAL_COMPANION:
self.hero.switch_spending()
money = self.hero.spend_amount
self.hero.money = money + 666
with self.check_not_changed(lambda: self.hero.statistics.money_spend):
with self.check_not_changed(lambda: self.hero.statistics.money_spend_for_companions):
with self.check_not_changed(lambda: self.hero.money):
self.storage.process_turn()
self.storage._test_save()
示例8: test_heal_companion
def test_heal_companion(self):
self.companion_record = companions_logic.create_random_companion_record('companion', state=companions_relations.STATE.ENABLED)
self.hero.set_companion(companions_logic.create_companion(self.companion_record))
self.hero.companion.health = 1
while not self.hero.next_spending.is_HEAL_COMPANION:
self.hero.switch_spending()
money = self.hero.spend_amount
self.hero.money = money + 666
with self.check_increased(lambda: self.hero.companion.health):
with self.check_delta(lambda: self.hero.money, -money):
self.storage.process_turn()
self.assertEqual(self.hero.statistics.money_spend, money)
self.assertEqual(self.hero.statistics.money_spend_for_companions, money)
self.storage._test_save()
示例9: test_choose_ability__additional_companion_abilities
def test_choose_ability__additional_companion_abilities(self):
from the_tale.game.heroes.habilities import ABILITIES
from the_tale.game.companions.abilities import effects as companions_effects
from the_tale.game.companions.abilities import container as abilities_container
from the_tale.game.companions import logic as companions_logic
from the_tale.game.companions import relations as companions_relations
abilities = [ability for ability in companions_effects.ABILITIES.records
if ( isinstance(ability.effect, companions_effects.BaseBattleAbility) and
ability.effect.ABILITY.get_id() != 'hit' )]
companion_ability = random.choice(abilities)
all_abilities = [ability(level=ability.MAX_LEVEL)
for ability in ABILITIES.values()
if ability.get_id() != companion_ability.effect.ABILITY.get_id()]
active_abilities = set(ability.get_id() for ability in ABILITIES.values() if ability.ACTIVATION_TYPE.is_ACTIVE)
companion_record = companions_logic.create_random_companion_record(u'battle',
abilities=abilities_container.Container(start=(companion_ability,)),
state=companions_relations.STATE.ENABLED)
self.hero.set_companion(companions_logic.create_companion(companion_record))
self.hero.health = 1 # allow regeneration
actor = battle.Actor(self.hero, BattleContext())
chosen_abilities = set()
# mock abilities modify_attribute instead of hereos, since we test correct work of it
def modify_attribute(self, modifier, value):
if modifier.is_ADDITIONAL_ABILITIES:
return all_abilities
return value
with mock.patch('the_tale.game.heroes.habilities.AbilitiesPrototype.modify_attribute', modify_attribute):
for i in xrange(1000):
chosen_abilities.add(actor.choose_ability().get_id())
self.assertEqual(len(active_abilities), len(chosen_abilities) + 1)
self.assertEqual(active_abilities - set([companion_ability.effect.ABILITY.get_id()]), chosen_abilities)
示例10: test_heal_companion__swich_spending_on_full_health
def test_heal_companion__swich_spending_on_full_health(self):
self.companion_record = companions_logic.create_random_companion_record('companion', state=companions_relations.STATE.ENABLED)
self.hero.set_companion(companions_logic.create_companion(self.companion_record))
while not self.hero.next_spending.is_HEAL_COMPANION:
self.hero.switch_spending()
self.hero.companion.health = self.hero.companion.max_health
money = self.hero.spend_amount
self.hero.money = money + 666
with self.check_not_changed(lambda: self.hero.companion.health):
with self.check_not_changed(lambda: self.hero.money):
with mock.patch('the_tale.game.heroes.objects.Hero.switch_spending') as switch_spending:
self.storage.process_turn()
self.assertEqual(switch_spending.call_count, 1)
self.assertEqual(self.hero.statistics.money_spend, 0)
self.assertEqual(self.hero.statistics.money_spend_for_companions, 0)
self.storage._test_save()
示例11: create_test_map
def create_test_map():
linguistics_logic.sync_static_restrictions()
map_logic.create_test_my_info()
p1 = PlacePrototype.create( x=1, y=1, size=1, utg_name=names.generator.get_test_name(name='1x1'))
p2 = PlacePrototype.create( x=3, y=3, size=3, utg_name=names.generator.get_test_name(name='10x10'))
p3 = PlacePrototype.create( x=1, y=3, size=3, utg_name=names.generator.get_test_name(name='1x10'))
for place in places_storage.all():
place.sync_persons(force_add=True)
RoadPrototype.create(point_1=p1, point_2=p2).update()
RoadPrototype.create(point_1=p2, point_2=p3).update()
update_waymarks()
update_nearest_cells()
mob_1 = MobRecordPrototype.create_random('mob_1')
mob_2 = MobRecordPrototype.create_random('mob_2')
mob_3 = MobRecordPrototype.create_random('mob_3')
ArtifactRecordPrototype.create_random('loot_1', mob=mob_1)
ArtifactRecordPrototype.create_random('loot_2', mob=mob_2)
ArtifactRecordPrototype.create_random('loot_3', mob=mob_3)
ArtifactRecordPrototype.create_random('helmet_1', type_=ARTIFACT_TYPE.HELMET, mob=mob_1)
ArtifactRecordPrototype.create_random('plate_1', type_=ARTIFACT_TYPE.PLATE, mob=mob_2)
ArtifactRecordPrototype.create_random('boots_1', type_=ARTIFACT_TYPE.BOOTS, mob=mob_3)
ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.PANTS, type_=ARTIFACT_TYPE.PANTS)
ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.BOOTS, type_=ARTIFACT_TYPE.BOOTS)
ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.PLATE, type_=ARTIFACT_TYPE.PLATE)
ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.GLOVES, type_=ARTIFACT_TYPE.GLOVES)
ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.WEAPON, type_=ARTIFACT_TYPE.MAIN_HAND)
companions_logic.create_random_companion_record('companion_1', dedication=companions_relations.DEDICATION.HEROIC, state=companions_relations.STATE.ENABLED)
companions_logic.create_random_companion_record('companion_2', dedication=companions_relations.DEDICATION.BOLD, state=companions_relations.STATE.ENABLED)
companions_logic.create_random_companion_record('companion_3', dedication=companions_relations.DEDICATION.BOLD, state=companions_relations.STATE.DISABLED)
return p1, p2, p3
示例12: test_rarities_abilities
def test_rarities_abilities(self):
for rarity, rarity_abilities in helpers.RARITIES_ABILITIES.iteritems():
companion = logic.create_random_companion_record('%s companion' % rarity,
abilities=rarity_abilities)
self.assertEqual(companion.rarity, rarity)