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


Python LogicStorage.process_turn__single_hero方法代码示例

本文整理汇总了Python中the_tale.game.logic_storage.LogicStorage.process_turn__single_hero方法的典型用法代码示例。如果您正苦于以下问题:Python LogicStorage.process_turn__single_hero方法的具体用法?Python LogicStorage.process_turn__single_hero怎么用?Python LogicStorage.process_turn__single_hero使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在the_tale.game.logic_storage.LogicStorage的用法示例。


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

示例1: LogicStorageTests

# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import process_turn__single_hero [as 别名]

#.........这里部分代码省略.........
        self.assertEqual(save_hero_data.call_count, 2)

    @mock.patch('the_tale.game.heroes.conf.heroes_settings.DUMP_CACHED_HEROES', True)
    def test_process_turn__switch_caches(self):
        self.assertEqual(self.storage.previous_cache, {})
        self.assertEqual(self.storage.current_cache, {})

        self.storage.process_turn()
        self.storage.save_changed_data()

        self.assertEqual(self.storage.previous_cache, {})
        self.assertNotEqual(self.storage.current_cache, {})

        old_cache = self.storage.current_cache

        self.storage.process_turn()
        self.storage.save_changed_data()

        self.assertEqual(self.storage.previous_cache, old_cache)
        self.assertNotEqual(self.storage.current_cache, old_cache)

    def test_process_turn_single_hero__runned_outside_storage(self):
        action_1 = actions_prototypes.ActionRegenerateEnergyPrototype.create(hero=self.hero_1)
        action_1.state = action_1.STATE.PROCESSED

        action_2 = actions_prototypes.ActionMoveToPrototype.create(hero=self.hero_1, destination=self.p1)
        action_2.state = action_2.STATE.PROCESSED

        action_3 = actions_prototypes.ActionInPlacePrototype.create(hero=self.hero_1)
        action_3.state = action_3.STATE.PROCESSED

        self.assertEqual(self.hero_1.actions.number, 4)

        self.storage.process_turn__single_hero(hero=self.hero_1,
                                               logger=None,
                                               continue_steps_if_needed=True)

        self.assertEqual(self.hero_1.actions.number, 2)
        self.assertEqual(self.hero_1.actions.current_action.TYPE, actions_prototypes.ActionQuestPrototype.TYPE)

        self.storage.process_turn() # just nothing was broken


    def test_process_turn__process_action_chain(self):
        action_1 = actions_prototypes.ActionRegenerateEnergyPrototype.create(hero=self.hero_1)
        action_1.state = action_1.STATE.PROCESSED

        action_2 = actions_prototypes.ActionMoveToPrototype.create(hero=self.hero_1, destination=self.p1)
        action_2.state = action_2.STATE.PROCESSED

        action_3 = actions_prototypes.ActionInPlacePrototype.create(hero=self.hero_1)
        action_3.state = action_3.STATE.PROCESSED

        self.assertEqual(self.hero_1.actions.number, 4)

        self.storage.process_turn()

        self.assertEqual(self.hero_1.actions.number, 2)
        self.assertEqual(self.hero_1.actions.current_action.TYPE, actions_prototypes.ActionQuestPrototype.TYPE)


    @mock.patch('the_tale.game.heroes.conf.heroes_settings.DUMP_CACHED_HEROES', False)
    def test_process_turn__without_dump(self):
        self.assertEqual(self.storage.skipped_heroes, set())
        self.storage.process_turn()
        self.assertEqual(self.storage.skipped_heroes, set())
开发者ID:alexudracul,项目名称:the-tale,代码行数:70,代码来源:test_logic_storage.py


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