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


Python logic.load_hero函数代码示例

本文整理汇总了Python中the_tale.game.heroes.logic.load_hero函数的典型用法代码示例。如果您正苦于以下问题:Python load_hero函数的具体用法?Python load_hero怎么用?Python load_hero使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_register_accounts_on_initialization__multiple_accounts_bandles

    def test_register_accounts_on_initialization__multiple_accounts_bandles(self):
        account_3 = self.accounts_factory.create_account()
        account_4 = self.accounts_factory.create_account()
        account_5 = self.accounts_factory.create_account()
        account_6 = self.accounts_factory.create_account()

        hero_2 = heroes_logic.load_hero(account_id=self.account_2.id)
        hero_3 = heroes_logic.load_hero(account_id=account_3.id)
        hero_4 = heroes_logic.load_hero(account_id=account_4.id)
        hero_6 = heroes_logic.load_hero(account_id=account_6.id)

        hero_3.actions.current_action.bundle_id = hero_2.actions.current_action.bundle_id
        hero_3.actions.updated = True
        heroes_logic.save_hero(hero_3)

        hero_4.actions.current_action.bundle_id = hero_2.actions.current_action.bundle_id
        hero_4.actions.updated = True
        heroes_logic.save_hero(hero_4)

        hero_6.actions.current_action.bundle_id = hero_2.actions.current_action.bundle_id
        hero_6.actions.updated = True
        heroes_logic.save_hero(hero_6)

        self.worker.process_initialize()

        self.assertEqual(self.worker.accounts_owners, {self.account_1.id: 'game_logic_1',
                                                       self.account_2.id: 'game_logic_2',
                                                       account_3.id: 'game_logic_2',
                                                       account_4.id: 'game_logic_2',
                                                       account_5.id: 'game_logic_1',
                                                       account_6.id: 'game_logic_2'})
        self.assertEqual(self.worker.logic_accounts_number, {'game_logic_1': 2, 'game_logic_2': 4})
开发者ID:Jazzis18,项目名称:the-tale,代码行数:32,代码来源:test_supervisor_worker.py

示例2: test_game_info_data_hidding

    def test_game_info_data_hidding(self):
        '''
        player hero always must show actual data
        enemy hero always must show data on statrt of the turn
        '''
        self.pvp_create_battle(self.account_1, self.account_2, BATTLE_1X1_STATE.PROCESSING)
        self.pvp_create_battle(self.account_2, self.account_1, BATTLE_1X1_STATE.PROCESSING)

        hero_1 = heroes_logic.load_hero(account_id=self.account_1.id)
        hero_2 = heroes_logic.load_hero(account_id=self.account_2.id)

        hero_1.pvp.set_energy(1)
        heroes_logic.save_hero(hero_1)

        hero_2.pvp.set_energy(2)
        heroes_logic.save_hero(hero_2)

        data = form_game_info(self.account_1, is_own=True)

        self.assertEqual(data['account']['hero']['pvp']['energy'], 1)
        self.assertEqual(data['enemy']['hero']['pvp']['energy'], 0)

        hero_2.pvp.store_turn_data()
        heroes_logic.save_hero(hero_2)

        data = form_game_info(self.account_1, is_own=True)

        self.assertEqual(data['enemy']['hero']['pvp']['energy'], 2)
开发者ID:ruckysolis,项目名称:the-tale,代码行数:28,代码来源:test_logic.py

示例3: setUp

    def setUp(self):
        super(AbilitiesTests, self).setUp()

        create_test_map()

        result, account_1_id, bundle_id = register_user('test_user_1', '[email protected]', '111111')
        result, account_1_id, bundle_id = register_user('test_user_2', '[email protected]', '111111')

        self.hero = heroes_logic.load_hero(account_id=account_1_id)
        self.enemy = heroes_logic.load_hero(account_id=account_1_id)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:10,代码来源:test_abilities.py

示例4: test_save_all

    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, heroes_logic.load_hero(hero_id=self.hero_1.id).health)
        self.assertEqual(self.hero_2.health, heroes_logic.load_hero(hero_id=self.hero_2.id).health)

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

示例5: setUp

    def setUp(self):
        super(BaseEffectsTests, self).setUp()

        create_test_map()

        self.account_1 = self.accounts_factory.create_account()
        self.hero_1 = heroes_logic.load_hero(account_id=self.account_1.id)

        self.account_2 = self.accounts_factory.create_account()
        self.hero_2 = heroes_logic.load_hero(account_id=self.account_2.id)

        self.account_3 = self.accounts_factory.create_account()
        self.hero_3 = heroes_logic.load_hero(account_id=self.account_3.id)

        self.effect = effects.EFFECT.PLACE_SAFETY
开发者ID:Jazzis18,项目名称:the-tale,代码行数:15,代码来源:test_effects.py

示例6: _initiate_battle_with_bot

    def _initiate_battle_with_bot(self, record):

        # search free bot
        # since now bots needed only for PvP, we can do simplified search
        battled_accounts_ids = Battle1x1Prototype._model_class.objects.all().values_list("account_id", flat=True)

        try:
            bot_account = AccountPrototype(
                model=AccountPrototype._model_class.objects.filter(is_bot=True).exclude(id__in=battled_accounts_ids)[0]
            )
        except IndexError:
            bot_account = None

        if bot_account is None:
            return [record], []

        bot_hero = heroes_logic.load_hero(account_id=bot_account.id)

        self.logger.info("start battle between account %d and bot %d" % (record.account_id, bot_account.id))

        # create battle for bot
        self.add_to_arena_queue(bot_hero.id)
        bot_record = self.arena_queue[bot_account.id]

        self._initiate_battle(record, bot_record, calculate_ratings=False)

        return [], [record, bot_record]
开发者ID:Jazzis18,项目名称:the-tale,代码行数:27,代码来源:balancer.py

示例7: shop

def shop(context):
    hero = heroes_logic.load_hero(account_id=context.account.id)

    if context.account.is_premium:
        featured_group = relations.GOODS_GROUP.CHEST
    else:
        featured_group = relations.GOODS_GROUP.PREMIUM

    price_types = [group.type for group in price_list.PRICE_GROUPS]

    def _cmp(x, y):
        choices = { (relations.GOODS_GROUP.PREMIUM, relations.GOODS_GROUP.CHEST, False): -1,
                    (relations.GOODS_GROUP.PREMIUM, relations.GOODS_GROUP.CHEST, True): 1,
                    (relations.GOODS_GROUP.CHEST, relations.GOODS_GROUP.PREMIUM, False): 1,
                    (relations.GOODS_GROUP.CHEST, relations.GOODS_GROUP.PREMIUM, True): -1,

                    (relations.GOODS_GROUP.PREMIUM, relations.GOODS_GROUP.ENERGY, False): -1,
                    (relations.GOODS_GROUP.PREMIUM, relations.GOODS_GROUP.ENERGY, True): 1,
                    (relations.GOODS_GROUP.ENERGY, relations.GOODS_GROUP.PREMIUM, False): 1,
                    (relations.GOODS_GROUP.ENERGY, relations.GOODS_GROUP.PREMIUM, True): -1 }

        return choices.get((x.type, y.type, context.account.is_premium), cmp(price_types.index(x.type), price_types.index(y.type)))

    price_groups = sorted(price_list.PRICE_GROUPS, cmp=_cmp)

    return dext_views.Page('shop/shop.html',
                           content={'PRICE_GROUPS': price_groups,
                                    'hero': hero,
                                    'payments_settings': payments_settings,
                                    'account': context.account,
                                    'featured_group': featured_group,
                                    'page_type': 'shop',
                                    'resource': context.resource})
开发者ID:Jazzis18,项目名称:the-tale,代码行数:33,代码来源:views.py

示例8: accept_battle

    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 = heroes_logic.load_hero(hero_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:Jazzis18,项目名称:the-tale,代码行数:26,代码来源:arena_pvp_1x1_accept.py

示例9: __init__

    def __init__(self, choosen_person_id, owner_id, *args, **kwargs):
        super(UserForm, self).__init__(*args, **kwargs)

        hero_id = heroes_logic.load_hero(account_id=owner_id).id

        self.fields['new_place'].choices = places_storage.places.get_choices()
        self.fields['person'].choices = persons_objects.Person.form_choices(choosen_person=persons_storage.persons.get(choosen_person_id),
                                                                            predicate=lambda place, person: person.politic_power.is_in_inner_circle(hero_id))
开发者ID:Jazzis18,项目名称:the-tale,代码行数:8,代码来源:person_move.py

示例10: setUp

    def setUp(self):
        super(TestRequestsBase, self).setUp()
        create_test_map()

        result, account_id, bundle_id = register_user("test_user", "[email protected]", "111111")
        self.account_1_id = account_id
        self.account_1 = AccountPrototype.get_by_id(account_id)
        self.hero_1 = heroes_logic.load_hero(account_id=self.account_1.id)

        result, account_id, bundle_id = register_user("test_user_2", "[email protected]", "111111")
        self.account_2_id = account_id
        self.account_2 = AccountPrototype.get_by_id(account_id)
        self.hero_2 = heroes_logic.load_hero(account_id=self.account_2.id)

        self.client = client.Client()

        self.request_login("[email protected]")
开发者ID:Jazzis18,项目名称:the-tale,代码行数:17,代码来源:test_requests.py

示例11: setUp

    def setUp(self):
        super(SupervisorWorkerTests, self).setUp()

        self.p1, self.p2, self.p3 = create_test_map()

        self.account_1 = self.accounts_factory.create_account()
        self.hero_1 = heroes_logic.load_hero(account_id=self.account_1.id)

        self.account_2 = self.accounts_factory.create_account()
        self.hero_2 = heroes_logic.load_hero(account_id=self.account_2.id)

        environment.deinitialize()
        environment.initialize()

        self.worker = environment.workers.supervisor

        self.worker.logger = mock.Mock()
开发者ID:Jazzis18,项目名称:the-tale,代码行数:17,代码来源:test_supervisor_worker.py

示例12: test_save_hero_data_with_meta_action

    def test_save_hero_data_with_meta_action(self):
        bundle_id = 666

        meta_action_battle = meta_actions.ArenaPvP1x1.create(self.storage, self.hero_1, self.hero_2)

        actions_prototypes.ActionMetaProxyPrototype.create(hero=self.hero_1, _bundle_id=bundle_id, meta_action=meta_action_battle)
        actions_prototypes.ActionMetaProxyPrototype.create(hero=self.hero_2, _bundle_id=bundle_id, meta_action=meta_action_battle)

        self.storage._save_hero_data(self.hero_1.id)
        self.storage._save_hero_data(self.hero_2.id)

        self.hero_1 = heroes_logic.load_hero(hero_id=self.hero_1.id)
        self.hero_2 = heroes_logic.load_hero(hero_id=self.hero_2.id)


        self.assertEqual(meta_action_battle.serialize(), self.hero_1.actions.current_action.saved_meta_action.serialize())
        self.assertEqual(meta_action_battle.serialize(), self.hero_2.actions.current_action.saved_meta_action.serialize())
开发者ID:Jazzis18,项目名称:the-tale,代码行数:17,代码来源:test_logic_storage.py

示例13: _test_save

    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(heroes_logic.load_hero(hero_id=hero_id))

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

示例14: test_get_random_mob__action_type

    def test_get_random_mob__action_type(self):
        account = self.accounts_factory.create_account()
        hero = heroes_logic.load_hero(account_id=account.id)

        action_type = actions_relations.ACTION_TYPE.random()

        with mock.patch("the_tale.game.actions.prototypes.ActionBase.ui_type", action_type):
            mob = mobs_storage.get_random_mob(hero)

        self.assertEqual(mob.action_type, action_type)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:10,代码来源:test_storage.py

示例15: show

def show(context):

    accounts_short_infos = game_short_info.get_accounts_accounts_info(list(context.person.politic_power.inner_accounts_ids()))

    return dext_views.Page('persons/show.html',
                           content={'person': context.person,
                                    'person_meta_object': meta_relations.Person.create_from_object(context.person),
                                    'accounts_short_infos': accounts_short_infos,
                                    'hero': heroes_logic.load_hero(account_id=context.account.id) if context.account else None,
                                    'resource': context.resource})
开发者ID:Jazzis18,项目名称:the-tale,代码行数:10,代码来源:views.py


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