当前位置: 首页>>代码示例>>Python>>正文


Python artifacts_storage.generate_artifact_from_list函数代码示例

本文整理汇总了Python中the_tale.game.artifacts.storage.artifacts_storage.generate_artifact_from_list函数的典型用法代码示例。如果您正苦于以下问题:Python generate_artifact_from_list函数的具体用法?Python generate_artifact_from_list怎么用?Python generate_artifact_from_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了generate_artifact_from_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_serialize

    def test_serialize(self):
        self.bag.put_artifact(
            artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, 1, rarity=RARITY.NORMAL)
        )
        self.bag.put_artifact(
            artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, 1, rarity=RARITY.NORMAL)
        )

        self.assertEqual(self.bag.serialize(), bag.Bag.deserialize(self.hero, self.bag.serialize()).serialize())
开发者ID:lshestov,项目名称:the-tale,代码行数:9,代码来源:test_bag.py

示例2: test_compare_drop__artifact_and_artifact

    def test_compare_drop__artifact_and_artifact(self):
        artifact_1 = artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, 1, rarity=artifacts_relations.RARITY.NORMAL)
        artifact_2 = artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, 1, rarity=artifacts_relations.RARITY.NORMAL)

        artifact_2.power = Power(1, 1)
        artifact_1.power = Power(2, 2)

        distribution = self.hero.preferences.archetype.power_distribution

        self.assertTrue(self.hero.bag._compare_drop(distribution, artifact_1, artifact_2))
        self.assertFalse(self.hero.bag._compare_drop(distribution, artifact_2, artifact_1))
开发者ID:alexudracul,项目名称:the-tale,代码行数:11,代码来源:test_hero_equipment.py

示例3: test_buying_artifact_with_change

    def test_buying_artifact_with_change(self):
        while not self.hero.next_spending.is_BUYING_ARTIFACT:
            self.hero.switch_spending()

        # fill all slots with artifacts
        self.hero.equipment.test_equip_in_all_slots(artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, self.hero.level, rarity=RARITY.NORMAL))

        money = self.hero.spend_amount

        #buy artifact
        self.hero.money = money

        self.assertEqual(self.hero.statistics.money_spend, 0)
        self.assertEqual(self.hero.statistics.money_spend_for_artifacts, 0)
        self.assertEqual(self.hero.statistics.money_earned_from_artifacts, 0)

        self.storage.process_turn()
        self.assertTrue(self.hero.money > 0)
        self.assertEqual(len(self.hero.bag.items()), 0)

        self.assertTrue(self.hero.statistics.money_spend > money - self.hero.money)
        self.assertTrue(self.hero.statistics.money_spend_for_artifacts > money - self.hero.money)
        self.assertEqual(self.hero.statistics.artifacts_had, 1)
        self.assertTrue(self.hero.statistics.money_earned_from_artifacts > 0)
        self.storage._test_save()
开发者ID:Jazzis18,项目名称:the-tale,代码行数:25,代码来源:test_action_inplace.py

示例4: 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()
开发者ID:Jazzis18,项目名称:the-tale,代码行数:27,代码来源:test_action_inplace.py

示例5: test_artifacts_to_break__all_unbreakable

    def test_artifacts_to_break__all_unbreakable(self):
        self.hero.equipment._remove_all()
        for slot in relations.EQUIPMENT_SLOT.records:
            artifact = artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, self.hero.level, rarity=artifacts_relations.RARITY.NORMAL)
            self.hero.equipment.equip(slot, artifact)
            self.assertFalse(artifact.can_be_broken())

        self.assertEqual(self.hero.artifacts_to_break(), [])
开发者ID:alexudracul,项目名称:the-tale,代码行数:8,代码来源:test_hero_equipment.py

示例6: test_not_bying_artifact__when_has_equip_candidates_in_bag

    def test_not_bying_artifact__when_has_equip_candidates_in_bag(self):
        while not self.hero.next_spending.is_BUYING_ARTIFACT:
            self.hero.switch_spending()

        # fill all slots with artifacts
        self.hero.equipment.test_equip_in_all_slots(artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, self.hero.level, rarity=RARITY.NORMAL))

        money = self.hero.spend_amount
        self.hero.money = money

        self.hero.bag.put_artifact(artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, 666, rarity=RARITY.EPIC))

        with self.check_not_changed(lambda: self.hero.statistics.money_spend):
            with self.check_not_changed(lambda: self.hero.statistics.money_spend_for_artifacts):
                with self.check_not_changed(lambda: self.hero.statistics.money_earned_from_artifacts):
                    with self.check_not_changed(lambda: self.hero.statistics.artifacts_had):
                        with self.check_not_changed(lambda: self.hero.bag.occupation):
                            self.storage.process_turn()
开发者ID:Jazzis18,项目名称:the-tale,代码行数:18,代码来源:test_action_inplace.py

示例7: test_equipping_process

    def test_equipping_process(self):
        self.assertEqual(self.hero.get_equip_candidates(), (None, None, None))

        #equip artefact in empty slot
        artifact = artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, self.hero.level, rarity=artifacts_relations.RARITY.NORMAL)

        equip_slot = artifact.type.equipment_slot
        self.hero.equipment.unequip(equip_slot)

        self.hero.bag.put_artifact(artifact)

        slot, unequipped, equipped = self.hero.get_equip_candidates()
        self.assertTrue(slot)
        self.assertTrue(unequipped is None)
        self.assertEqual(equipped, artifact)

        with mock.patch('the_tale.game.heroes.prototypes.HeroPrototype.reset_accessors_cache') as reset_accessors_cache:
            self.hero.change_equipment(slot, unequipped, equipped)

        self.assertEqual(reset_accessors_cache.call_count, 1)

        self.assertTrue(not self.hero.bag.items())
        self.assertEqual(self.hero.equipment.get(slot), artifact)

        # change artifact
        new_artifact = artifacts_storage.generate_artifact_from_list([artifact.record], self.hero.level, rarity=artifacts_relations.RARITY.NORMAL)
        new_artifact.power = artifact.power + Power(1, 1)
        self.hero.bag.put_artifact(new_artifact)

        slot, unequipped, equipped = self.hero.get_equip_candidates()
        self.assertTrue(slot)
        self.assertEqual(unequipped, artifact)
        self.assertEqual(equipped, new_artifact)

        with mock.patch('the_tale.game.heroes.prototypes.HeroPrototype.reset_accessors_cache') as reset_accessors_cache:
            self.hero.change_equipment(slot, unequipped, equipped)

        self.assertEqual(reset_accessors_cache.call_count, 1)

        self.assertEqual(self.hero.bag.items()[0][1], artifact)
        self.assertEqual(len(self.hero.bag.items()), 1)
        self.assertEqual(self.hero.equipment.get(slot), new_artifact)

        self.storage._test_save()
开发者ID:alexudracul,项目名称:the-tale,代码行数:44,代码来源:test_hero_equipment.py

示例8: test_damage_integrity__safe

    def test_damage_integrity__safe(self):
        self.hero.equipment._remove_all()
        for slot in relations.EQUIPMENT_SLOT.records:
            artifact = artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, self.hero.level, rarity=artifacts_relations.RARITY.NORMAL)
            self.assertEqual(artifact.integrity, artifact.max_integrity)

        self.hero.damage_integrity()

        for artifact in self.hero.equipment.values():
            self.assertEqual(artifact.integrity, artifact.max_integrity)
开发者ID:alexudracul,项目名称:the-tale,代码行数:10,代码来源:test_hero_equipment.py

示例9: use

    def use(self, task, storage, **kwargs): # pylint: disable=R0911,W0613
        artifacts_list, rarity = self.get_new_artifact_data()

        artifact = artifacts_storage.generate_artifact_from_list(artifacts_list, task.hero.level, rarity=rarity)

        task.hero.put_loot(artifact, force=True)

        task.hero.actions.request_replane()

        return task.logic_result(message=u'В рюкзаке героя появился новый артефакт: %(artifact)s' % {'artifact': artifact.html_label()})
开发者ID:Alkalit,项目名称:the-tale,代码行数:10,代码来源:effects.py

示例10: test_equip_action_create

    def test_equip_action_create(self):
        artifact = artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, 1, rarity=RARITY.NORMAL)
        artifact.power = Power(666, 666)
        self.hero.bag.put_artifact(artifact)

        self.storage.process_turn()
        self.assertEqual(len(self.hero.actions.actions_list), 3)
        self.assertEqual(self.hero.actions.current_action.TYPE, prototypes.ActionEquippingPrototype.TYPE)

        self.storage._test_save()
开发者ID:Jazzis18,项目名称:the-tale,代码行数:10,代码来源:test_action_inplace.py

示例11: test_ui_info_cache

    def test_ui_info_cache(self):
        artifact = artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, 1, rarity=RARITY.NORMAL)
        self.equipment.equip(artifact.type.equipment_slot, artifact)

        ui_info = self.equipment.ui_info(self.hero)

        self.assertEqual(self.equipment._ui_info, ui_info)

        self.equipment.mark_updated()

        self.assertEqual(self.equipment._ui_info, None)
开发者ID:lshestov,项目名称:the-tale,代码行数:11,代码来源:test_bag.py

示例12: test_can_safe_artifact_integrity__favorite_item__wrong_slot

    def test_can_safe_artifact_integrity__favorite_item__wrong_slot(self):
        artifact = artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, self.hero.level, rarity=artifacts_relations.RARITY.NORMAL)

        wrong_slot = None
        for slot in relations.EQUIPMENT_SLOT.records:
            if artifact.type.equipment_slot != slot:
                wrong_slot = slot
                break

        self.hero.preferences.set_favorite_item(wrong_slot)
        self.assertFalse(any(self.hero.can_safe_artifact_integrity(artifact) for i in xrange(100)))
开发者ID:Jazzis18,项目名称:the-tale,代码行数:11,代码来源:test_logic_accessors.py

示例13: test_trade_action_create

    def test_trade_action_create(self):

        for i in xrange(int(c.MAX_BAG_SIZE * c.BAG_SIZE_TO_SELL_LOOT_FRACTION) + 1):
            artifact = artifacts_storage.generate_artifact_from_list(artifacts_storage.loot, 1, rarity=RARITY.NORMAL)
            self.hero.bag.put_artifact(artifact)

        self.storage.process_turn()
        self.assertEqual(len(self.hero.actions.actions_list), 3)
        self.assertEqual(self.hero.actions.current_action.TYPE, prototypes.ActionTradingPrototype.TYPE)

        self.storage._test_save()
开发者ID:Jazzis18,项目名称:the-tale,代码行数:11,代码来源:test_action_inplace.py

示例14: test_success__critical

    def test_success__critical(self):
        self.hero.bag.put_artifact(artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, self.hero.level, rarity=RARITY.NORMAL))

        old_money_stats = self.hero.statistics.money_earned_from_help

        self.assertEqual(self.hero.bag.occupation, 1)

        self.assertEqual(self.ability.use(**self.use_attributes), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ()))

        self.assertEqual(self.hero.bag.occupation, 0)

        self.assertTrue(old_money_stats < self.hero.statistics.money_earned_from_help)
开发者ID:ruckysolis,项目名称:the-tale,代码行数:12,代码来源:test_ability_drop_item.py

示例15: test_drop_cheapest_item

    def test_drop_cheapest_item(self):
        artifact_1 = artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, self.hero.level, rarity=artifacts_relations.RARITY.NORMAL)
        artifact_2 = artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, self.hero.level, rarity=artifacts_relations.RARITY.NORMAL)

        artifact_1.power = Power(200, 200)
        artifact_2.power = Power(1, 1)

        self.hero.bag.put_artifact(artifact_1)
        self.hero.bag.put_artifact(artifact_2)

        distribution = self.hero.preferences.archetype.power_distribution

        self.assertEqual(self.hero.bag.occupation, 2)

        dropped_item = self.hero.bag.drop_cheapest_item(distribution)

        self.assertEqual(self.hero.bag.occupation, 1)

        self.assertEqual(dropped_item.id, artifact_2.id)

        self.assertEqual(self.hero.bag.values()[0].id, artifact_1.id)
开发者ID:alexudracul,项目名称:the-tale,代码行数:21,代码来源:test_hero_equipment.py


注:本文中的the_tale.game.artifacts.storage.artifacts_storage.generate_artifact_from_list函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。