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


Python logic.save_hero函数代码示例

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


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

示例1: quest_test_method

    def quest_test_method(self):

        # defends from first quest rule
        self.hero.statistics.change_quests_done(1)
        heroes_logic.save_hero(self.hero)

        current_time = TimePrototype.get_current_time()

        test_upgrade_equipment = random.randint(0, 1) # test child quest or upgrade equipment for SearchSmith

        while self.hero.actions.current_action.TYPE != ActionQuestPrototype.TYPE or not self.hero.quests.has_quests:
            if quest == SearchSmith and test_upgrade_equipment:
                self.hero.money = QuestPrototype.upgrade_equipment_cost(self.hero) * 2
                self.hero.next_spending = ITEMS_OF_EXPENDITURE.INSTANT_HEAL

            self.storage.process_turn()
            current_time.increment_turn()

        # test if quest is serializable
        s11n.to_json(self.hero.quests.current_quest.serialize())

        self.complete_quest()

        self.assertEqual(self.hero.actions.current_action.TYPE, ActionIdlenessPrototype.TYPE)

        if quest == SearchSmith and test_upgrade_equipment:
            self.assertTrue(self.hero.statistics.money_spend_for_artifacts > 0 or
                            self.hero.statistics.money_spend_for_sharpening > 0)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:28,代码来源:test_quests.py

示例2: setUp

    def setUp(self):
        super(QuestsTestBase, self).setUp()
        self.p1, self.p2, self.p3 = create_test_map()

        # add more persons, to lower conflicts
        places_logic.add_person_to_place(self.p1)
        places_logic.add_person_to_place(self.p1)
        places_logic.add_person_to_place(self.p2)
        places_logic.add_person_to_place(self.p2)
        places_logic.add_person_to_place(self.p3)
        places_logic.add_person_to_place(self.p3)

        persons_logic.sync_social_connections()

        result, account_id, bundle_id = register_user('test_user')

        self.storage = LogicStorage()
        self.storage.load_account_data(AccountPrototype.get_by_id(account_id))
        self.hero = self.storage.accounts_to_heroes[account_id]
        self.action_idl = self.hero.actions.current_action

        self.hero.money += 1
        self.hero.preferences.set_mob(mobs_storage.all()[0])
        self.hero.preferences.set_place(self.p1)
        self.hero.preferences.set_friend(self.p1.persons[0])
        self.hero.preferences.set_enemy(self.p2.persons[0])
        self.hero.preferences.set_equipment_slot(EQUIPMENT_SLOT.PLATE)
        self.hero.position.set_place(self.p3)
        heroes_logic.save_hero(self.hero)

        self.p2.set_modifier(places_modifiers.CITY_MODIFIERS.HOLY_CITY)
        places_logic.save_place(self.p2)

        self.p1.persons[0].type = PERSON_TYPE.BLACKSMITH
        persons_logic.save_person(self.p1.persons[0])
开发者ID:Jazzis18,项目名称:the-tale,代码行数:35,代码来源:test_quests.py

示例3: test_initiate_battle_with_bot__create_battle

    def test_initiate_battle_with_bot__create_battle(self):
        self.hero_1.level = 50
        heroes_logic.save_hero(self.hero_1)

        result, bot_account_id, bundle_id = register_user('bot_user', '[email protected]', '111111', is_bot=True)

        records_to_remove, records_to_exclude = self.worker._initiate_battle_with_bot(self.battle_1_record())

        bot_battle = Battle1x1Prototype.get_by_id(records_to_exclude[1].battle_id)

        bot_record = QueueRecord(account_id=bot_account_id,
                                 battle_id=bot_battle.id,
                                 created_at=bot_battle.created_at + datetime.timedelta(seconds=0),
                                 hero_level=1)

        self.assertEqual(records_to_remove, [])
        self.assertEqual(records_to_exclude, [self.battle_1_record(), bot_record])
        self.assertEqual(SupervisorTask.objects.all().count(), 1)

        battle_player = Battle1x1Prototype.get_by_account_id(self.account_1.id)
        battle_bot = Battle1x1Prototype.get_by_account_id(bot_account_id)

        self.assertEqual(battle_player.enemy_id, bot_account_id)
        self.assertFalse(battle_player.calculate_rating)
        self.assertEqual(battle_bot.enemy_id, self.account_1.id)
        self.assertFalse(battle_bot.calculate_rating)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:26,代码来源:test_balancer.py

示例4: test_banned

 def test_banned(self):
     self.hero.ban_state_end_at = datetime.datetime.now() + datetime.timedelta(days=1)
     heroes_logic.save_hero(self.hero)
     self.assertEqual(
         self.task.process(FakePostpondTaskPrototype(), self.storage), POSTPONED_TASK_LOGIC_RESULT.ERROR
     )
     self.assertEqual(self.task.state, ComplexChangeTask.STATE.BANNED)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:7,代码来源:test_ability_use_task.py

示例5: test_buying_artifact_without_change

    def test_buying_artifact_without_change(self):
        while not self.hero.next_spending.is_BUYING_ARTIFACT:
            self.hero.switch_spending()

        money = self.hero.spend_amount

        self.assertEqual(self.hero.statistics.money_spend, 0)
        self.assertEqual(self.hero.statistics.money_spend_for_artifacts, 0)
        self.assertEqual(self.hero.statistics.money_earned_from_artifacts, 0)

        #unequip all arefact
        self.hero.equipment._remove_all()
        heroes_logic.save_hero(self.hero)

        #buy artifact
        self.hero.money = money

        self.storage.process_turn()
        self.assertEqual(self.hero.money, 0)
        self.assertEqual(len(self.hero.bag.items()), 0)

        self.assertEqual(self.hero.statistics.money_spend, money - self.hero.money)
        self.assertEqual(self.hero.statistics.money_spend_for_artifacts, money - self.hero.money)
        self.assertEqual(self.hero.statistics.artifacts_had, 1)
        self.storage._test_save()
开发者ID:Jazzis18,项目名称:the-tale,代码行数:25,代码来源:test_action_inplace.py

示例6: test_process_no_energy

 def test_process_no_energy(self):
     self.hero.energy = 0
     self.hero.energy_bonus = 0
     heroes_logic.save_hero(self.hero)
     self.assertEqual(
         self.task.process(FakePostpondTaskPrototype(), self.storage), POSTPONED_TASK_LOGIC_RESULT.ERROR
     )
     self.assertEqual(self.task.state, ComplexChangeTask.STATE.HERO_CONDITIONS_NOT_PASSED)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:8,代码来源:test_ability_use_task.py

示例7: test_low_level_battle

 def test_low_level_battle(self):
     self.hero_1.level = 100
     heroes_logic.save_hero(self.hero_1)
     self.pvp_create_battle(self.account_2, None, BATTLE_1X1_STATE.WAITING)
     self.check_html_ok(
         self.client.get(reverse("game:pvp:calls")),
         texts=[("pgf-no-calls-message", 0), ("pgf-no-current-battles-message", 1), ("pgf-can-not-accept-call", 1)],
     )
开发者ID:Jazzis18,项目名称:the-tale,代码行数:8,代码来源:test_requests.py

示例8: message_to_hero

def message_to_hero(hero):
    text = MESSAGES[(hero.gender, hero.race)]

    message = MessageSurrogate.create(key=None, externals={}, position=hero.position.get_description())
    message._message = text

    hero.push_message(message, diary=True, journal=False)

    save_hero(hero)
开发者ID:ruckysolis,项目名称:the-tale,代码行数:9,代码来源:portal_8_march.py

示例9: test_success

    def test_success(self):
        self.request_login(self.account.email)

        self.hero.cards.add_card(self.card)
        heroes_logic.save_hero(self.hero)

        response = self.post_ajax_json(logic.use_card_url(self.card.uid), self.post_data(self.card.uid))
        task = PostponedTaskPrototype._db_get_object(0)

        self.check_ajax_processing(response, task.status_url)

        task.remove()
开发者ID:Tiendil,项目名称:the-tale,代码行数:12,代码来源:test_requests.py

示例10: test_form_invalid

    def test_form_invalid(self):
        self.request_login(self.account.email)

        self.hero.cards.add_card(self.card)
        heroes_logic.save_hero(self.hero)

        self.check_ajax_error(
            self.post_ajax_json(
                logic.use_card_url(self.card.uid),
                self.post_data(self.card.uid, place_id=666, building_id=666, person_id=666),
            ),
            "form_errors",
        )
开发者ID:Tiendil,项目名称:the-tale,代码行数:13,代码来源:test_requests.py

示例11: test_show__places_history

    def test_show__places_history(self):
        texts = [(self.place1.name, 1),
                 (self.place2.name, 1),
                 (self.place3.name, 0),
                 ('pgf-no-common-places-message', 0)]

        hero = heroes_logic.load_hero(account_id=self.account_1.id)
        hero.places_history.add_place(self.place1.id)
        hero.places_history.add_place(self.place2.id)
        hero.places_history.add_place(self.place1.id)
        heroes_logic.save_hero(hero)

        self.check_html_ok(self.request_html(reverse('accounts:show', args=[self.account_1.id])), texts=texts)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:13,代码来源:test_requests_account.py

示例12: test_created

    def test_created(self):
        self.request_login(self.account.email)

        card_1 = objects.Card(relations.CARD_TYPE.ADD_GOLD_COMMON)
        card_2 = objects.Card(relations.CARD_TYPE.ADD_GOLD_COMMON)

        self.hero.cards.add_card(card_1)
        self.hero.cards.add_card(card_2)

        heroes_logic.save_hero(self.hero)

        with self.check_delta(PostponedTaskPrototype._db_count, 1):
            response = self.post_ajax_json(logic.combine_cards_url((card_1.uid, card_2.uid)))

        task = PostponedTaskPrototype._db_get_object(0)

        self.check_ajax_processing(response, task.status_url)
开发者ID:Tiendil,项目名称:the-tale,代码行数:17,代码来源:test_requests.py

示例13: test_initiate_battle_without_rating_by_level

    def test_initiate_battle_without_rating_by_level(self):

        self.assertEqual(SupervisorTask.objects.all().count(), 0)

        self.hero_1.level = 100
        heroes_logic.save_hero(self.hero_1)

        self.worker._initiate_battle(self.battle_1_record(), self.battle_2_record())

        battle_1 = Battle1x1Prototype.get_by_id(self.battle_1.id)
        battle_2 = Battle1x1Prototype.get_by_id(self.battle_2.id)

        self.assertEqual(battle_1.enemy_id, self.account_2.id)
        self.assertFalse(battle_1.calculate_rating)
        self.assertEqual(battle_2.enemy_id, self.account_1.id)
        self.assertFalse(battle_2.calculate_rating)

        self.assertEqual(SupervisorTask.objects.all().count(), 1)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:18,代码来源:test_balancer.py

示例14: 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 = heroes_logic.load_hero(account_id=self.account_1.id)
        old_hero.health = 1
        heroes_logic.save_hero(old_hero)

        task.process(bundle_id=666)

        new_hero = heroes_logic.load_hero(account_id=self.account_1.id)
        new_hero_2 = heroes_logic.load_hero(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:Jazzis18,项目名称:the-tale,代码行数:42,代码来源:test_supervisor_task.py

示例15: 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


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