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


Python HeroPrototype.get_by_account_id方法代码示例

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


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

示例1: check_heroes

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_account_id [as 别名]
    def check_heroes(self):
        result, account_id, bundle_id = register_user('test_user', '[email protected]', '111111')
        hero_1 = HeroPrototype.get_by_account_id(account_id)

        result, account_id, bundle_id = register_user('test_user_2', '[email protected]', '111111')
        hero_2 = HeroPrototype.get_by_account_id(account_id)

        result, account_id, bundle_id = register_user('test_user_3', '[email protected]', '111111')
        hero_3 = HeroPrototype.get_by_account_id(account_id)

        hero_1.premium_state_end_at = datetime.datetime.now() + datetime.timedelta(seconds=60)
        hero_1.preferences.set_place(self.place_1)
        hero_1.preferences.set_friend(self.place_1.persons[0])
        hero_1.preferences.set_enemy(self.place_1.persons[-1])
        hero_1.save()

        hero_2.premium_state_end_at = datetime.datetime.now() + datetime.timedelta(seconds=60)
        hero_2.preferences.set_place(self.place_1)
        hero_2.preferences.set_friend(self.place_1.persons[-1])
        hero_2.preferences.set_enemy(self.place_1.persons[0])
        hero_2.save()

        hero_3.preferences.set_place(self.place_1)
        hero_3.preferences.set_friend(self.place_1.persons[-1])
        hero_3.preferences.set_enemy(self.place_1.persons[0])
        hero_3.save()

        texts = [(jinja2.escape(hero_1.name), 3),
                 (jinja2.escape(hero_2.name), 3),
                 (jinja2.escape(hero_3.name), 0)]

        self.check_html_ok(self.request_html(url('game:map:places:show', self.place_1.id)), texts=texts)
开发者ID:Alkalit,项目名称:the-tale,代码行数:34,代码来源:test_requests.py

示例2: test_register_accounts_on_initialization__multiple_accounts_bandles

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_account_id [as 别名]
    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 = HeroPrototype.get_by_account_id(self.account_2.id)
        hero_3 = HeroPrototype.get_by_account_id(account_3.id)
        hero_4 = HeroPrototype.get_by_account_id(account_4.id)
        hero_6 = HeroPrototype.get_by_account_id(account_6.id)

        hero_3.actions.current_action.bundle_id = hero_2.actions.current_action.bundle_id
        hero_3.actions.updated = True
        hero_3.save()

        hero_4.actions.current_action.bundle_id = hero_2.actions.current_action.bundle_id
        hero_4.actions.updated = True
        hero_4.save()

        hero_6.actions.current_action.bundle_id = hero_2.actions.current_action.bundle_id
        hero_6.actions.updated = True
        hero_6.save()

        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:Alkalit,项目名称:the-tale,代码行数:34,代码来源:test_supervisor_worker.py

示例3: setUp

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_account_id [as 别名]
    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 = HeroPrototype.get_by_account_id(account_1_id)
        self.enemy = HeroPrototype.get_by_account_id(account_1_id)
开发者ID:Alkalit,项目名称:the-tale,代码行数:12,代码来源:test_abilities.py

示例4: shop

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_account_id [as 别名]
def shop(context):
    hero = HeroPrototype.get_by_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:Alkalit,项目名称:the-tale,代码行数:35,代码来源:views.py

示例5: setUp

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

        self.account2.prolong_premium(30)
        self.account2.save()

        self.hero = HeroPrototype.get_by_account_id(self.account2.id)
        self.hero.places_history.add_place(self.place1.id)
        self.hero.places_history.add_place(self.place2.id)
        self.hero.places_history.add_place(self.place3.id)
        self.hero.save()

        new_name = names.generator.get_test_name('new-name')

        data = linguistics_helpers.get_word_post_data(new_name, prefix='name')
        data.update({'caption': 'bill-caption',
                     'rationale': 'bill-rationale',
                     'chronicle_on_accepted': 'chronicle-on-accepted',
                     'place': self.place1.id})

        self.client.post(reverse('game:bills:create') + ('?bill_type=%s' % PlaceRenaming.type.value), data)
        self.bill = BillPrototype(Bill.objects.all()[0])

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

示例6: _initiate_battle_with_bot

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_account_id [as 别名]
    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 = HeroPrototype.get_by_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:Alkalit,项目名称:the-tale,代码行数:27,代码来源:balancer.py

示例7: setUp

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_account_id [as 别名]
    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 = HeroPrototype.get_by_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 = HeroPrototype.get_by_account_id(self.account_2.id)

        self.client = client.Client()

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

示例8: setUp

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_account_id [as 别名]
    def setUp(self):
        super(MobsPrototypeTests, self).setUp()
        create_test_map()

        result, account_id, bundle_id = register_user('test_user')
        self.hero = HeroPrototype.get_by_account_id(account_id)

        mobs_storage.sync(force=True)
开发者ID:Alkalit,项目名称:the-tale,代码行数:10,代码来源:test_prototypes.py

示例9: test_can_not_voted

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_account_id [as 别名]
    def test_can_not_voted(self):
        self.assertEqual(HeroPrototype.get_by_account_id(self.account1.id).places_history.history, [])

        # one vote automaticaly created for bill author
        bill_data = PlaceRenaming(place_id=self.place1.id, name_forms=names.generator.get_test_name('new_name_1'))
        self.create_bills(1, self.account1, 'Caption-a1-%d', 'rationale-a1-%d', bill_data)
        bill = Bill.objects.all()[0]

        self.check_html_ok(self.request_html(reverse('game:bills:show', args=[bill.id])), texts=(('pgf-can-not-vote-message', 0),))
开发者ID:Alkalit,项目名称:the-tale,代码行数:11,代码来源:test_requests.py

示例10: remove_game_data

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

    hero = HeroPrototype.get_by_account_id(account.id)

    for action in reversed(hero.actions.actions_list):
        action.remove()

    hero.remove()
开发者ID:alexudracul,项目名称:the-tale,代码行数:11,代码来源:logic.py

示例11: test_get_random_mob__terrain

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_account_id [as 别名]
    def test_get_random_mob__terrain(self):
        result, account_id, bundle_id = register_user('test_user_1', '[email protected]', '111111')
        hero = HeroPrototype.get_by_account_id(account_id)

        terrain = map_relations.TERRAIN.random()

        with mock.patch('the_tale.game.heroes.prototypes.HeroPositionPrototype.get_terrain', lambda h: terrain):
            mob = mobs_storage.get_random_mob(hero)

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

示例12: setUp

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_account_id [as 别名]
    def setUp(self):
        super(PrototypeTests, self).setUp()
        create_test_map()

        result, account_id, bundle_id = register_user('test_user')
        self.hero = HeroPrototype.get_by_account_id(account_id)

        artifacts_storage.sync(force=True)

        self.artifact_record = artifacts_storage.all()[0]
开发者ID:Alkalit,项目名称:the-tale,代码行数:12,代码来源:test_prototypes.py

示例13: test_get_random_mob__action_type

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_account_id [as 别名]
    def test_get_random_mob__action_type(self):
        result, account_id, bundle_id = register_user('test_user_1', '[email protected]', '111111')
        hero = HeroPrototype.get_by_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:alexudracul,项目名称:the-tale,代码行数:12,代码来源:test_storage.py

示例14: test_process_arena_pvp_1x1

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_account_id [as 别名]
    def test_process_arena_pvp_1x1(self):
        task = SupervisorTaskPrototype.create_arena_pvp_1x1(self.account_1, self.account_2)

        task.capture_member(self.account_1.id)
        task.capture_member(self.account_2.id)

        battle_1 = Battle1x1Prototype.create(self.account_1)
        battle_1.set_enemy(self.account_2)
        battle_1.save()

        battle_2 = Battle1x1Prototype.create(self.account_2)
        battle_2.set_enemy(self.account_1)
        battle_2.save()

        self.assertEqual(Battle1x1.objects.filter(state=BATTLE_1X1_STATE.PREPAIRING).count(), 2)
        self.assertEqual(Battle1x1.objects.filter(state=BATTLE_1X1_STATE.PROCESSING).count(), 0)

        old_hero = HeroPrototype.get_by_account_id(self.account_1.id)
        old_hero.health = 1
        old_hero.save()

        task.process(bundle_id=666)

        new_hero = HeroPrototype.get_by_account_id(self.account_1.id)
        new_hero_2 = HeroPrototype.get_by_account_id(self.account_2.id)

        self.assertEqual(new_hero.actions.current_action.bundle_id, new_hero_2.actions.current_action.bundle_id)
        self.assertNotEqual(new_hero.actions.actions_list[0].bundle_id, new_hero.actions.actions_list[1].bundle_id)
        self.assertNotEqual(new_hero_2.actions.actions_list[0].bundle_id, new_hero_2.actions.actions_list[1].bundle_id)

        self.assertNotEqual(old_hero, new_hero)
        self.assertTrue(old_hero.actions.number < new_hero.actions.number)
        self.assertEqual(new_hero.health, new_hero.max_health)

        self.assertEqual(new_hero.actions.number, 2)
        self.assertEqual(new_hero_2.actions.number, 2)

        self.assertEqual(new_hero.actions.current_action.meta_action.serialize(),
                         new_hero_2.actions.current_action.meta_action.serialize())

        self.assertEqual(Battle1x1.objects.filter(state=BATTLE_1X1_STATE.PREPAIRING).count(), 0)
        self.assertEqual(Battle1x1.objects.filter(state=BATTLE_1X1_STATE.PROCESSING).count(), 2)
开发者ID:alexudracul,项目名称:the-tale,代码行数:44,代码来源:test_supervisor_task.py

示例15: load_account_data

# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_account_id [as 别名]
    def load_account_data(self, account):
        hero = HeroPrototype.get_by_account_id(account.id)
        hero.update_with_account_data(is_fast=account.is_fast,
                                      premium_end_at=account.premium_end_at,
                                      active_end_at=account.active_end_at,
                                      ban_end_at=account.ban_game_end_at,
                                      might=account.might,
                                      actual_bills=account.actual_bills)
        self._add_hero(hero)

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


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