• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python artifacts_storage.generate_artifact_from_list函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: test_base_equip__in_filled_slot

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

        with self.check_delta(lambda: self.hero.statistics.artifacts_had, 1):
            equipped, unequipped, coins = self.hero.receive_artifact(equip=True, better=False, prefered_slot=True, prefered_item=True, archetype=True)

        self.assertEqual(self.hero.equipment.get(equipped.type.equipment_slot), equipped)
        self.assertFalse(equipped in self.hero.bag.values())
        self.assertFalse(unequipped in self.hero.bag.values())

        self.assertTrue(coins > 0)
开发者ID:alexudracul,项目名称:the-tale,代码行数:13,代码来源:test_hero_equipment.py


示例17: test_artifacts_to_break__all_broken__from_all

    def test_artifacts_to_break__all_broken__from_all(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)
            artifact.integrity = slot.value
            artifact.max_integrity = 100

            self.hero.equipment.equip(slot, artifact)
            self.assertTrue(artifact.can_be_broken())

        for i in xrange(100):
            for candidate in self.hero.artifacts_to_break(from_all=True):
                self.assertTrue(candidate.integrity <= int(c.EQUIP_SLOTS_NUMBER * c.EQUIPMENT_BREAK_FRACTION) + 1)
开发者ID:alexudracul,项目名称:the-tale,代码行数:13,代码来源:test_hero_equipment.py


示例18: randomize_equip

    def randomize_equip(self):
        for slot in relations.EQUIPMENT_SLOT.records:
            self.equipment.unequip(slot)

            artifacts_list = self.receive_artifacts_choices(better=False, prefered_slot=False, prefered_item=False, archetype=True)

            artifacts_list = [artifact for artifact in artifacts_list if artifact.type.equipment_slot == slot]

            if not artifacts_list:
                continue

            artifact = artifacts_storage.generate_artifact_from_list(artifacts_list, self.level, rarity=artifacts_relations.RARITY.NORMAL)

            self.equipment.equip(slot, artifact)
开发者ID:Alkalit,项目名称:the-tale,代码行数:14,代码来源:equipment_methods.py


示例19: test_sell_artifact__sell_price_less_than_zero

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

        self.assertEqual(self.hero.bag.occupation, 1)
        self.assertEqual(self.hero.money, 0)
        self.assertEqual(self.hero.statistics.money_earned_from_loot, 0)
        self.assertEqual(self.hero.statistics.money_earned_from_artifacts, 0)

        self.assertEqual(self.hero.sell_artifact(artifact), 1)

        self.assertEqual(self.hero.bag.occupation, 0)
        self.assertEqual(self.hero.money, 1)
        self.assertEqual(self.hero.statistics.money_earned_from_loot, 0)
        self.assertEqual(self.hero.statistics.money_earned_from_artifacts, 1)
开发者ID:alexudracul,项目名称:the-tale,代码行数:15,代码来源:test_hero_equipment.py


示例20: test_pop_artifact

    def test_pop_artifact(self):
        artifact = artifacts_storage.generate_artifact_from_list(artifacts_storage.artifacts, 1, rarity=RARITY.NORMAL)

        self.bag.put_artifact(artifact)

        self.bag.updated = False
        self.bag._ui_info = "fake ui info"

        with self.check_delta(lambda: self.bag.occupation, -1):
            self.bag.pop_artifact(artifact)

        self.assertTrue(self.bag.updated)
        self.assertEqual(self.bag._ui_info, None)

        self.assertEqual(self.bag.bag, {})
开发者ID:lshestov,项目名称:the-tale,代码行数:15,代码来源:test_bag.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python power.Power类代码示例发布时间:2022-05-27
下一篇:
Python prototypes.ArtifactRecordPrototype类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap