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


Python HeroPrototype.get_by_id方法代码示例

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


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

示例1: test_save_all

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_id [as 别名]
    def test_save_all(self):

        self.hero_1.health = 1
        self.hero_2.health = 1

        self.hero_1.actions.updated = True

        self.storage.save_all()

        self.assertEqual(self.hero_1.health, HeroPrototype.get_by_id(self.hero_1.id).health)
        self.assertEqual(self.hero_2.health, HeroPrototype.get_by_id(self.hero_2.id).health)

        self.assertFalse(self.hero_1.actions.updated)
开发者ID:alexudracul,项目名称:the-tale,代码行数:15,代码来源:test_logic_storage.py

示例2: accept_battle

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_id [as 别名]
    def accept_battle(cls, pvp_balancer, battle_id, hero_id):

        accepted_battle = Battle1x1Prototype.get_by_id(battle_id)

        if accepted_battle is None:
            return ACCEPT_BATTLE_RESULT.BATTLE_NOT_FOUND

        if not accepted_battle.state.is_WAITING:
            return ACCEPT_BATTLE_RESULT.WRONG_ACCEPTED_BATTLE_STATE

        if not accepted_battle.account_id in pvp_balancer.arena_queue:
            return ACCEPT_BATTLE_RESULT.NOT_IN_QUEUE

        initiator_id = HeroPrototype.get_by_id(hero_id).account_id

        initiator_battle = Battle1x1Prototype.get_by_account_id(initiator_id)

        if initiator_battle is not None and not initiator_battle.state.is_WAITING:
            return ACCEPT_BATTLE_RESULT.WRONG_INITIATOR_BATTLE_STATE

        if initiator_id not in pvp_balancer.arena_queue:
            pvp_balancer.add_to_arena_queue(hero_id)

        pvp_balancer.force_battle(accepted_battle.account_id, initiator_id)

        return ACCEPT_BATTLE_RESULT.PROCESSED
开发者ID:Alkalit,项目名称:the-tale,代码行数:28,代码来源:arena_pvp_1x1_accept.py

示例3: _test_save

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_id [as 别名]
    def _test_save(self):
        for hero_id in self.heroes:
            self._save_hero_data(hero_id)

        test_storage = LogicStorage()
        for hero_id in self.heroes:
            test_storage._add_hero(HeroPrototype.get_by_id(hero_id))

        return self == test_storage
开发者ID:alexudracul,项目名称:the-tale,代码行数:11,代码来源:logic_storage.py

示例4: test_use

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_id [as 别名]
    def test_use(self):

        self.hero.add_experience(self.hero.experience_to_next_level / 2)

        self.assertTrue(self.hero.experience > 0)
        self.assertEqual(self.hero.level, 1)

        with self.check_not_changed(lambda: self.hero.experience):
            with self.check_delta(lambda: self.hero.level, 1):
                result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
                self.assertEqual((result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ()))

        saved_hero = HeroPrototype.get_by_id(self.hero.id)
        self.assertEqual(saved_hero.abilities.destiny_points, self.abilities.destiny_points)
开发者ID:alexudracul,项目名称:the-tale,代码行数:16,代码来源:test_level_up.py

示例5: test_dispatch_command_for_unregistered_account

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_id [as 别名]
    def test_dispatch_command_for_unregistered_account(self):
        self.worker.process_initialize()

        result, account_3_id, bundle_id = register_user('test_user_3', '[email protected]', '111111')

        account_3 = AccountPrototype.get_by_id(account_3_id)
        hero_3 = HeroPrototype.get_by_id(account_3_id)

        with mock.patch('the_tale.game.workers.logic.Worker.cmd_logic_task') as logic_task_counter:
            with mock.patch.object(self.worker.logger, 'warn') as logger_warn_counter:
                self.worker.process_update_hero_with_account_data(account_3_id,
                                                                  is_fast=account_3.is_fast,
                                                                  premium_end_at=account_3.premium_end_at,
                                                                  active_end_at=account_3.active_end_at,
                                                                  ban_end_at=account_3.ban_game_end_at,
                                                                  might=666,
                                                                  actual_bills=7)

        self.assertEqual(logic_task_counter.call_count, 0)
        self.assertEqual(logger_warn_counter.call_count, 1)
        self.assertFalse(account_3_id in self.worker.accounts_owners)
        self.assertTrue(account_3_id in self.worker.accounts_queues)
开发者ID:Alkalit,项目名称:the-tale,代码行数:24,代码来源:test_supervisor_worker.py

示例6: add_to_arena_queue

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_id [as 别名]
    def add_to_arena_queue(self, hero_id):

        hero = HeroPrototype.get_by_id(hero_id)

        if hero.account_id in self.arena_queue:
            return None

        battle = Battle1x1Prototype.create(AccountPrototype.get_by_id(hero.account_id))

        if not battle.state.is_WAITING:
            raise PvPBalancerException('account %d already has battle not in waiting state' % hero.account_id)

        record = QueueRecord(account_id=battle.account_id,
                             created_at=battle.created_at,
                             battle_id=battle.id,
                             hero_level=hero.level)

        if record.account_id in self.arena_queue:
            raise PvPBalancerException('account %d already added in balancer queue' % record.account_id)

        self.arena_queue[record.account_id] = record

        return battle
开发者ID:Alkalit,项目名称:the-tale,代码行数:25,代码来源:balancer.py


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