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


Python TimePrototype.get_current_time方法代码示例

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


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

示例1: test_push_power

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_time [as 别名]
    def test_push_power(self):
        self.place.push_power(0, 10)
        self.assertEqual(self.place.power, 10)

        TimePrototype.get_current_time().increment_turn()
        self.place.push_power(1, 1)
        self.assertEqual(self.place.power,
                         1 + 10*float(places_settings.POWER_HISTORY_LENGTH-1)/places_settings.POWER_HISTORY_LENGTH)

        TimePrototype(places_settings.POWER_HISTORY_LENGTH-1).save()
        self.place.push_power(places_settings.POWER_HISTORY_LENGTH-1, 100)
        self.assertEqual(self.place.power,
                         100 + 10*1.0/places_settings.POWER_HISTORY_LENGTH + 2.0/places_settings.POWER_HISTORY_LENGTH)

        TimePrototype(places_settings.POWER_HISTORY_LENGTH).save()
        self.place.push_power(places_settings.POWER_HISTORY_LENGTH, 1000)
        self.assertEqual(self.place.power,
                         1000 + 100*float(places_settings.POWER_HISTORY_LENGTH-1)/places_settings.POWER_HISTORY_LENGTH + 1.0/places_settings.POWER_HISTORY_LENGTH)

        TimePrototype(places_settings.POWER_HISTORY_LENGTH+1).save()
        self.place.push_power(places_settings.POWER_HISTORY_LENGTH+1, 10000)
        self.assertEqual(self.place.power,
                         10000 +
                         1000*float(places_settings.POWER_HISTORY_LENGTH-1)/places_settings.POWER_HISTORY_LENGTH +
                         100*float(places_settings.POWER_HISTORY_LENGTH-2)/places_settings.POWER_HISTORY_LENGTH)

        TimePrototype(places_settings.POWER_HISTORY_LENGTH+2).save()
        self.place.push_power(places_settings.POWER_HISTORY_LENGTH+2, 100000)
        self.assertEqual(round(self.place.power, 5),
                         round(100000 +
                               10000*float(places_settings.POWER_HISTORY_LENGTH-1)/places_settings.POWER_HISTORY_LENGTH +
                               1000*float(places_settings.POWER_HISTORY_LENGTH-2)/places_settings.POWER_HISTORY_LENGTH +
                               100*float(places_settings.POWER_HISTORY_LENGTH-3)/places_settings.POWER_HISTORY_LENGTH, 5) )
开发者ID:Alkalit,项目名称:the-tale,代码行数:35,代码来源:test_places_logic.py

示例2: setUp

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_time [as 别名]
    def setUp(self):
        super(TestPrototypeEnd, self).setUp()

        bill_data = PlaceRenaming(place_id=self.place1.id, name_forms=names.generator.get_test_name('new_name_1'))
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted')

        self.bill.state = relations.BILL_STATE.ACCEPTED

        TimePrototype.get_current_time().increment_turn()
开发者ID:Jazzis18,项目名称:the-tale,代码行数:11,代码来源:test_prototype.py

示例3: test_increment_turn

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_time [as 别名]
    def test_increment_turn(self):
        time = TimePrototype.get_current_time()
        self.assertEqual(time.turn_number, 0)

        time.increment_turn()
        self.assertEqual(time.turn_number, 1)
        time.save()

        time = TimePrototype.get_current_time()
        self.assertEqual(time.turn_number, 1)
开发者ID:Alkalit,项目名称:the-tale,代码行数:12,代码来源:test_time.py

示例4: test_creation

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_time [as 别名]
    def test_creation(self):
        Setting.objects.all().delete()
        settings.refresh()

        settings_number = Setting.objects.all().count()
        time = TimePrototype.get_current_time()
        self.assertEqual(time.turn_number, 0)
        self.assertEqual(Setting.objects.all().count(), settings_number+1)
        time = TimePrototype.get_current_time()
        self.assertEqual(time.turn_number, 0)
        self.assertEqual(Setting.objects.all().count(), settings_number+1)
开发者ID:Alkalit,项目名称:the-tale,代码行数:13,代码来源:test_time.py

示例5: test_move_out_game

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_time [as 别名]
    def test_move_out_game(self):
        self.assertEqual(self.person.place.persons_changed_at_turn, self.persons_changed_at_turn)

        TimePrototype.get_current_time().increment_turn()

        current_time = datetime.datetime.now()
        self.assertTrue(self.person.out_game_at < current_time)
        self.assertEqual(self.person.state, PERSON_STATE.IN_GAME)
        self.person.move_out_game()
        self.assertTrue(self.person.out_game_at > current_time)
        self.assertEqual(self.person.state, PERSON_STATE.OUT_GAME)

        self.assertEqual(self.person.place.persons_changed_at_turn, TimePrototype.get_current_turn_number())
开发者ID:Alkalit,项目名称:the-tale,代码行数:15,代码来源:test_prototypes.py

示例6: test_user_form__move_delay

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_time [as 别名]
    def test_user_form__move_delay(self):
        data = {'caption': 'caption-caption',
                'rationale': 'rationale',
                'chronicle_on_accepted': 'chronicle-on-accepted',
                'person': self.person_2.id,
                'new_place': self.place3.id}

        form = self.bill.data.get_user_form_update(post=data, owner_id=self.account.id)
        self.assertFalse(form.is_valid())

        TimePrototype.get_current_time().increment_turn()

        form = self.bill.data.get_user_form_update(post=data, owner_id=self.account.id)

        self.assertTrue(form.is_valid())
开发者ID:Jazzis18,项目名称:the-tale,代码行数:17,代码来源:test_person_move.py

示例7: test_processed

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_time [as 别名]
    def test_processed(self):
        current_time = TimePrototype.get_current_time()

        self.assertEqual(self.hero.journal.messages_number(), 2)

        with self.check_calls_count("the_tale.game.heroes.logic.push_message_to_diary", 0):
            self.storage.process_turn()

            current_time.increment_turn()

            self.assertEqual(self.hero.journal.messages_number(), 3)

            self.storage.process_turn()
            current_time.increment_turn()

            self.assertEqual(self.hero.journal.messages_number(), 4)

            self.storage.process_turn(continue_steps_if_needed=False)
            current_time.increment_turn()

            self.assertEqual(self.hero.journal.messages_number(), 5)

        self.assertTrue(self.hero.actions.current_action.TYPE.is_IDLENESS)

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

示例8: _end_battle

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_time [as 别名]
 def _end_battle(self, hero_1_health, hero_2_health):
     self.hero_1.health = hero_1_health
     self.hero_2.health = hero_2_health
     current_time = TimePrototype.get_current_time()
     self.meta_action_battle.process()
     current_time.increment_turn()
     self.meta_action_battle.process()
开发者ID:Jazzis18,项目名称:the-tale,代码行数:9,代码来源:test_meta_action_arena_pvp_1x1.py

示例9: test_process_next_turn

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_time [as 别名]
    def test_process_next_turn(self):

        time = TimePrototype.get_current_time()
        time.increment_turn()
        time.save()

        self.assertEqual(time.turn_number, 1)

        for i in xrange(c.MAP_SYNC_TIME - 1):
            self.worker.process_next_turn(time.turn_number)
            self.assertFalse(hasattr(self.worker, "_data_synced"))

            if time.turn_number < bills_settings.BILLS_PROCESS_INTERVAL / c.TURN_DELTA:
                self.assertFalse(hasattr(self.worker, "_bills_applied"))
            else:
                self.assertEqual(
                    self.worker._bills_applied,
                    time.turn_number / (bills_settings.BILLS_PROCESS_INTERVAL / c.TURN_DELTA),
                )

            time.increment_turn()
            time.save()

        self.worker.process_next_turn(time.turn_number)
        self.assertTrue(self.worker._data_synced)
开发者ID:lshestov,项目名称:the-tale,代码行数:27,代码来源:test_highlevel_worker.py

示例10: test_sync_persons_add_new_person__force_when_zero_persons

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_time [as 别名]
    def test_sync_persons_add_new_person__force_when_zero_persons(self):
        TimePrototype.get_current_time().increment_turn()

        self.assertEqual(self.place.persons_changed_at_turn, 0)
        self.assertFalse(self.place.can_add_person)

        old_persons = self.place.persons

        for person in self.place.persons:
            person.move_out_game()

        self.place.sync_persons(force_add=False)

        self.assertEqual(self.place.persons_changed_at_turn, TimePrototype.get_current_turn_number())
        self.assertEqual(len(self.place.persons), 1)
        self.assertFalse(self.place.persons[0] in old_persons)
开发者ID:Alkalit,项目名称:the-tale,代码行数:18,代码来源:test_places_logic.py

示例11: test_not_enough_voices_percents

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_time [as 别名]
    def test_not_enough_voices_percents(self):

        current_time = TimePrototype.get_current_time()
        current_time.increment_turn()
        current_time.increment_turn()

        VotePrototype.create(self.account2, self.bill, relations.VOTE_TYPE.AGAINST)
        VotePrototype.create(self.account3, self.bill, relations.VOTE_TYPE.REFRAINED)

        self.assertEqual(Post.objects.all().count(), 1)

        with self.check_not_changed(lambda: self.place1.attrs.stability):
            with mock.patch('the_tale.accounts.workers.accounts_manager.Worker.cmd_run_account_method') as cmd_run_account_method:
                self.assertFalse(self.bill.apply())

            self.assertEqual(cmd_run_account_method.call_count, 0)
            self.assertTrue(self.bill.state.is_REJECTED)

            self.assertEqual(Post.objects.all().count(), 2)

            bill = BillPrototype.get_by_id(self.bill.id)
            self.assertTrue(bill.state.is_REJECTED)

            places_storage.places.sync(force=True)

            self.place1.refresh_attributes()

        self.assertEqual(bill.applyed_at_turn, current_time.turn_number)

        self.check_place(self.place1.id, self.place1.name, self.place1.utg_name.forms)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:32,代码来源:test_prototype.py

示例12: quest_test_method

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_time [as 别名]
    def quest_test_method(self):

        # defends from first quest rule
        self.hero.statistics.change_quests_done(1)
        self.hero.save()

        current_time = TimePrototype.get_current_time()

        test_upgrade_equipment = random.randint(0, 1) # test child quest or upgrade equipment for SearchSmith

        while self.hero.actions.current_action.TYPE != ActionQuestPrototype.TYPE or not self.hero.quests.has_quests:
            if quest == SearchSmith and test_upgrade_equipment:
                self.hero._model.money = QuestPrototype.upgrade_equipment_cost(self.hero) * 2
                self.hero._model.next_spending = ITEMS_OF_EXPENDITURE.INSTANT_HEAL

            self.storage.process_turn()
            current_time.increment_turn()

        # test if quest is serializable
        s11n.to_json(self.hero.quests.current_quest.serialize())

        self.complete_quest()

        self.assertEqual(self.hero.actions.current_action.TYPE, ActionIdlenessPrototype.TYPE)

        if quest == SearchSmith and test_upgrade_equipment:
            self.assertTrue(self.hero.statistics.money_spend_for_artifacts > 0 or
                            self.hero.statistics.money_spend_for_sharpening > 0)
开发者ID:Alkalit,项目名称:the-tale,代码行数:30,代码来源:test_quests.py

示例13: complete_quest

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_time [as 别名]
    def complete_quest(self):
        current_time = TimePrototype.get_current_time()

        while not self.action_idl.leader:
            self.storage.process_turn()
            current_time.increment_turn()

            self.hero.ui_info(actual_guaranteed=True) # test if ui info formed correctly
开发者ID:Alkalit,项目名称:the-tale,代码行数:10,代码来源:test_quests.py

示例14: test_percents_consistency

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_time [as 别名]
    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)
开发者ID:Alkalit,项目名称:the-tale,代码行数:10,代码来源:test_general.py

示例15: test_companion_healing_by_hero__not_healed

# 需要导入模块: from the_tale.game.prototypes import TimePrototype [as 别名]
# 或者: from the_tale.game.prototypes.TimePrototype import get_current_time [as 别名]
    def test_companion_healing_by_hero__not_healed(self):

        current_time = TimePrototype.get_current_time()
        self.hero.companion.health = 1

        with self.check_delta(lambda: self.hero.companion.health, c.COMPANIONS_HEALTH_PER_HEAL):
            self.action_heal_companion.state = self.action_heal_companion.STATE.PROCESSED
            self.storage.process_turn(continue_steps_if_needed=False)
            current_time.increment_turn()
开发者ID:alexudracul,项目名称:the-tale,代码行数:11,代码来源:test_action_heal_companion.py


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