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


Python LogicStorage.tests_get_last_action方法代码示例

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


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

示例1: GeneralTest

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

#.........这里部分代码省略.........

    @mock.patch('the_tale.game.actions.prototypes.ActionIdlenessPrototype.HELP_CHOICES', set((HELP_CHOICES.HEAL_COMPANION, HELP_CHOICES.MONEY)))
    def test_help_choice_has_heal_companion__for_low_health_with_alternative(self):
        companion_record = companions_storage.companions.enabled_companions().next()
        self.hero.set_companion(companions_logic.create_companion(companion_record))
        self.hero.companion.health = 1
        self.check_heal_companion_in_choices(True)


    def check_stock_up_energy_in_choices(self, result):
        stock_found = False
        for i in xrange(1000):
            stock_found = stock_found or (self.action_idl.get_help_choice() == HELP_CHOICES.STOCK_UP_ENERGY)

        self.assertEqual(stock_found, result)

    @mock.patch('the_tale.game.actions.prototypes.ActionIdlenessPrototype.HELP_CHOICES', set((HELP_CHOICES.STOCK_UP_ENERGY, HELP_CHOICES.MONEY)))
    def test_help_choice_has_stock_up_energy__can_stock(self):
        self.hero.energy_charges = 0
        self.check_stock_up_energy_in_choices(True)

    @mock.patch('the_tale.game.actions.prototypes.ActionIdlenessPrototype.HELP_CHOICES', set((HELP_CHOICES.STOCK_UP_ENERGY, HELP_CHOICES.MONEY)))
    def test_help_choice_has_stock_up_energy__can_not_stock(self):
        self.hero.energy_bonus = c.ANGEL_FREE_ENERGY_MAXIMUM
        self.check_stock_up_energy_in_choices(False)

    def test_percents_consistency(self):
        current_time = TimePrototype.get_current_time()

        # just test that quest will be ended
        while not self.action_idl.leader:
            self.storage.process_turn()
            current_time.increment_turn()
            self.assertEqual(self.storage.tests_get_last_action().percents, self.hero.last_action_percents)

    def test_help_choice_heal_not_in_choices_for_dead_hero(self):

        self.hero.health = 1
        self.hero.save()

        self.assertTrue(HELP_CHOICES.HEAL in self.action_idl.help_choices)

        self.hero.kill()
        self.hero.save()

        self.assertFalse(HELP_CHOICES.HEAL in self.action_idl.help_choices)

    def test_action_default_serialization(self):
        # class TestAction(ActionBase):
        #     TYPE = 'test-action'

        default_action = TestAction( hero=self.hero,
                                     bundle_id=self.bundle_id,
                                     state=TestAction.STATE.UNINITIALIZED)

        self.assertEqual(default_action.serialize(), {'bundle_id': self.bundle_id,
                                                      'state': TestAction.STATE.UNINITIALIZED,
                                                      'percents': 0.0,
                                                      'description': None,
                                                      'type': TestAction.TYPE.value,
                                                      'created_at_turn': TimePrototype.get_current_turn_number()})

        self.assertEqual(default_action, TestAction.deserialize(self.hero, default_action.serialize()))


    def test_action_full_serialization(self):
开发者ID:Alkalit,项目名称:the-tale,代码行数:70,代码来源:test_general.py


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