• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python prototypes.HeroPrototype类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: check_heroes

    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,代码行数:32,代码来源:test_requests.py


示例2: 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 = 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,代码行数:32,代码来源:test_supervisor_worker.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 = HeroPrototype.get_by_account_id(account_1_id)
        self.enemy = HeroPrototype.get_by_account_id(account_1_id)
开发者ID:Alkalit,项目名称: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, 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,代码行数:13,代码来源:test_logic_storage.py


示例5: _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 = 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,代码行数:25,代码来源:balancer.py


示例6: setUp

    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,代码行数:25,代码来源:test_requests.py


示例7: 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 = 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,代码行数:26,代码来源:arena_pvp_1x1_accept.py


示例8: shop

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,代码行数:33,代码来源:views.py


示例9: _form_game_account_info

def _form_game_account_info(game_time, account, in_pvp_queue, is_own, client_turns=None):
    from the_tale.game.heroes.prototypes import HeroPrototype

    data = { 'new_messages': account.new_messages_number if is_own else 0,
             'id': account.id,
             'last_visit': time.mktime((account.active_end_at - datetime.timedelta(seconds=accounts_settings.ACTIVE_STATE_TIMEOUT)).timetuple()),
             'is_own': is_own,
             'is_old': False,
             'hero': None,
             'in_pvp_queue': in_pvp_queue }

    hero_data = HeroPrototype.cached_ui_info_for_hero(account_id=account.id,
                                                      recache_if_required=is_own,
                                                      patch_turns=client_turns,
                                                      for_last_turn=(not is_own))
    data['hero'] = hero_data

    data['is_old'] = (data['hero']['actual_on_turn'] < game_time.turn_number)

    if not is_own:
        if 'cards' in hero_data:
            hero_data['cards'] = cards_container.CardsContainer.ui_info_null()
        if 'energy' in hero_data:
            hero_data['energy']['max'] = 0
            hero_data['energy']['value'] = 0
            hero_data['energy']['bonus'] = 0
            hero_data['energy']['discount'] = 0

    return data
开发者ID:alexudracul,项目名称:the-tale,代码行数:29,代码来源:logic.py


示例10: setUp

    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,代码行数:8,代码来源:test_prototypes.py


示例11: 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 = 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,代码行数:17,代码来源:test_requests.py


示例12: get_achievements_source_iterator

    def get_achievements_source_iterator(self, achievement):
        from the_tale.accounts.prototypes import AccountPrototype
        from the_tale.game.heroes.prototypes import HeroPrototype

        if achievement.type.source.is_ACCOUNT:
            return (AccountPrototype(model=account_model) for account_model in AccountPrototype._db_all())

        if achievement.type.source.is_GAME_OBJECT:
            return (HeroPrototype(model=hero_model) for hero_model in HeroPrototype._db_all())
开发者ID:Alkalit,项目名称:the-tale,代码行数:9,代码来源:achievements_manager.py


示例13: remove_game_data

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,代码行数:9,代码来源:logic.py


示例14: test_can_not_voted

    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,代码行数:9,代码来源:test_requests.py


示例15: _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(HeroPrototype.get_by_id(hero_id))

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


示例16: setUp

    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,代码行数:10,代码来源:test_prototypes.py


示例17: test_get_random_mob__terrain

    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,代码行数:10,代码来源:test_storage.py


示例18: test_get_random_mob__action_type

    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,代码行数:10,代码来源:test_storage.py


示例19: test_process_arena_pvp_1x1

    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,代码行数:42,代码来源:test_supervisor_task.py


示例20: load_account_data

    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,代码行数:11,代码来源:logic_storage.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python relations.MODIFIERS类代码示例发布时间:2022-05-27
下一篇:
Python logic.save_hero函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap