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


Python LogicStorage.save_bundle_data方法代码示例

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


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

示例1: test_save_bundle_data

# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import save_bundle_data [as 别名]
    def test_save_bundle_data(self):

        storage = LogicStorage()

        storage.bundles_to_accounts[555] = set([1, 2])
        storage.bundles_to_accounts[666] = set([3, 7, 9])
        storage.bundles_to_accounts[777] = set([4, 5])

        storage.accounts_to_heroes = {1: mock.Mock(id=1),
                                      2: mock.Mock(id=2),
                                      3: mock.Mock(id=3),
                                      4: mock.Mock(id=4),
                                      5: mock.Mock(id=5),
                                      7: mock.Mock(id=7),
                                      9: mock.Mock(id=9)}

        with mock.patch('the_tale.game.logic_storage.LogicStorage._save_hero_data') as _save_hero_data:
            with mock.patch('the_tale.game.logic_storage.LogicStorage.process_cache_queue') as process_cache_queue:
                storage.save_bundle_data(666)

        self.assertEqual(_save_hero_data.call_count, 3)
        self.assertEqual(storage.cache_queue, set([3, 7, 9]))
        self.assertEqual(process_cache_queue.call_count, 1)

        self.assertEqual(set(call[0][0] for call in _save_hero_data.call_args_list), set([3, 7, 9]))
开发者ID:alexudracul,项目名称:the-tale,代码行数:27,代码来源:test_logic_storage.py

示例2: Worker

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

#.........这里部分代码省略.........
        if account is None:
            raise LogicException('can not get account with id "%d"' % (account_id,))
        self.storage.load_account_data(account)

    def cmd_release_account(self, account_id):
        return self.send_cmd('release_account', {'account_id': account_id})

    def process_release_account(self, account_id):
        self.release_account(account_id)

    def cmd_logic_task(self, account_id, task_id):
        return self.send_cmd('logic_task', {'task_id': task_id,
                                            'account_id': account_id})

    def process_logic_task(self, account_id, task_id): # pylint: disable=W0613
        hero = self.storage.accounts_to_heroes[account_id]
        bundle_id = hero.actions.current_action.bundle_id

        if bundle_id in self.storage.ignored_bundles:
            return

        with self.storage.on_exception(self.logger,
                                       message='LogicWorker.process_logic_task catch exception, while processing hero %d, try to save all bundles except %d',
                                       data=(hero.id, bundle_id),
                                       excluded_bundle_id=bundle_id):
            task = postponed_tasks.PostponedTaskPrototype.get_by_id(task_id)
            task.process(self.logger, storage=self.storage)
            task.do_postsave_actions()

            self.storage.recache_bundle(bundle_id)


    def cmd_force_save(self, account_id):
        return self.send_cmd('force_save', {'account_id': account_id})

    def process_force_save(self, account_id): # pylint: disable=W0613
        hero = self.storage.accounts_to_heroes[account_id]
        bundle_id = hero.actions.current_action.bundle_id
        if bundle_id in self.storage.ignored_bundles:
            return
        self.storage.save_bundle_data(bundle_id=bundle_id)

    def cmd_start_hero_caching(self, account_id):
        self.send_cmd('start_hero_caching', {'account_id': account_id})

    def process_start_hero_caching(self, account_id):
        hero = self.storage.accounts_to_heroes[account_id]

        if hero.actions.current_action.bundle_id in self.storage.ignored_bundles:
            return

        hero.ui_caching_started_at = datetime.datetime.now()
        self.storage.recache_bundle(hero.actions.current_action.bundle_id)

    def cmd_update_hero_with_account_data(self, account_id, is_fast, premium_end_at, active_end_at, ban_end_at, might, actual_bills):
        self.send_cmd('update_hero_with_account_data', {'account_id': account_id,
                                                        'is_fast': is_fast,
                                                        'premium_end_at': premium_end_at,
                                                        'active_end_at': active_end_at,
                                                        'ban_end_at': ban_end_at,
                                                        'might': might,
                                                        'actual_bills': actual_bills})

    def process_update_hero_with_account_data(self, account_id, is_fast, premium_end_at, active_end_at, ban_end_at, might, actual_bills):
        hero = self.storage.accounts_to_heroes[account_id]

        if hero.actions.current_action.bundle_id in self.storage.ignored_bundles:
            return

        hero.update_with_account_data(is_fast=is_fast,
                                      premium_end_at=datetime.datetime.fromtimestamp(premium_end_at),
                                      active_end_at=datetime.datetime.fromtimestamp(active_end_at),
                                      ban_end_at=datetime.datetime.fromtimestamp(ban_end_at),
                                      might=might,
                                      actual_bills=actual_bills)
        self.storage.save_bundle_data(hero.actions.current_action.bundle_id)

    def cmd_highlevel_data_updated(self):
        self.send_cmd('highlevel_data_updated')

    def process_highlevel_data_updated(self):
        self.storage.on_highlevel_data_updated()

    def cmd_setup_quest(self, account_id, knowledge_base):
        return self.send_cmd('setup_quest', {'account_id': account_id,
                                             'knowledge_base': knowledge_base})

    def process_setup_quest(self, account_id, knowledge_base):
        hero = self.storage.accounts_to_heroes[account_id]
        bundle_id = hero.actions.current_action.bundle_id

        if bundle_id in self.storage.ignored_bundles:
            return

        with self.storage.on_exception(self.logger,
                                       message='LogicWorker.process_logic_task catch exception, while processing hero %d, try to save all bundles except %d',
                                       data=(hero.id, bundle_id),
                                       excluded_bundle_id=bundle_id):
            quests_logic.setup_quest_for_hero(hero, knowledge_base)
            self.storage.recache_bundle(bundle_id)
开发者ID:Alkalit,项目名称:the-tale,代码行数:104,代码来源:logic.py


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