當前位置: 首頁>>代碼示例>>Python>>正文


Python Power.power_to_level方法代碼示例

本文整理匯總了Python中the_tale.game.balance.power.Power.power_to_level方法的典型用法代碼示例。如果您正苦於以下問題:Python Power.power_to_level方法的具體用法?Python Power.power_to_level怎麽用?Python Power.power_to_level使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在the_tale.game.balance.power.Power的用法示例。


在下文中一共展示了Power.power_to_level方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_corridor

# 需要導入模塊: from the_tale.game.balance.power import Power [as 別名]
# 或者: from the_tale.game.balance.power.Power import power_to_level [as 別名]
    def test_corridor(self):

        # fill_empty_keys_with_fake_phrases(u'test_hero_level_companion')

        result, account_id, bundle_id = register_user(uuid.uuid4().hex) # pylint: disable=W0612
        self.storage = LogicStorage()
        self.storage.load_account_data(AccountPrototype.get_by_id(account_id))
        self.hero = self.storage.accounts_to_heroes[account_id]

        self.set_hero_companion()

        current_time = TimePrototype.get_current_time()

        for level in xrange(1, 100):
            print
            print '-----------------------------------------------------------------------'
            print 'process level %d\texpected turns: %d\texpected days: %.2f' % (level, f.turns_on_lvl(level), f.time_on_lvl(level)/24)

            for i in xrange(f.turns_on_lvl(level)): # pylint: disable=W0612
                self.storage.process_turn()
                current_time.increment_turn()

                # simulate user behaviour on healing companion
                if self.hero.companion.health < self.hero.companion.max_health / 2:
                    self.hero.companion.health = self.hero.companion.max_health

            self.hero.randomized_level_up()


            exp_to_next_level = float(self.hero.experience) / f.exp_on_lvl(self.hero.level) * 100
            exp_from_expected = float(f.total_exp_to_lvl(self.hero.level)+self.hero.experience)/f.total_exp_to_lvl(level+1)*100
            exp_untaken = f.total_exp_to_lvl(level+1) - f.total_exp_to_lvl(self.hero.level) - self.hero.experience
            quests_untaken = float(exp_untaken) / f.experience_for_quest(c.QUEST_AREA_RADIUS)
            print u'hero level: %d\texp: %.2f%%\texp from expected: %.2f%% (%d exp, %.2f quests)\ttotal quests %d' % (self.hero.level,
                                                                                                                      exp_to_next_level,
                                                                                                                      exp_from_expected,
                                                                                                                      exp_untaken,
                                                                                                                      quests_untaken,
                                                                                                                      self.hero.statistics.quests_done)
            print u'abilities: %s' % ' '.join(u'%s-%d' % (ability_id, ability.level) for ability_id, ability in self.hero.abilities.abilities.items())
            print u'deaths: %d' % self.hero.statistics.pve_deaths

            total_gold = f.total_gold_at_lvl(self.hero.level)
            print u'total money: %d from expected %d (x%.2f)' % (self.hero.statistics.money_earned,
                                                                 total_gold,
                                                                 float(self.hero.statistics.money_earned) / total_gold if total_gold > 0 else 0)

            total_artifacts = int(f.total_time_for_lvl(self.hero.level) / 24 * c.ARTIFACTS_LOOT_PER_DAY )
            print u'total artifacts: %d from expected %d (x%.2f)' % (self.hero.statistics.artifacts_had,
                                                                     total_artifacts,
                                                                     float(self.hero.statistics.artifacts_had) / total_artifacts if total_artifacts > 0 else 0)
            print u'power: %r from expected %r' % (self.hero.power, Power.power_to_level(self.hero.preferences.archetype.power_distribution, self.hero.level))
            print u'power total: %d from expected %r (x%.2f)' % (self.hero.power.total(),
                                                                 Power.power_to_level(self.hero.preferences.archetype.power_distribution, self.hero.level).total(),
                                                                 float(self.hero.power.total()) / Power.power_to_level(self.hero.preferences.archetype.power_distribution, self.hero.level).total())
開發者ID:Alkalit,項目名稱:the-tale,代碼行數:57,代碼來源:game_test_hero_in_levels_corridor.py

示例2: get_battles_statistics

# 需要導入模塊: from the_tale.game.balance.power import Power [as 別名]
# 或者: from the_tale.game.balance.power.Power import power_to_level [as 別名]
def get_battles_statistics(hero_1, hero_2):

    hero_1_wins = 0
    hero_2_wins = 0

    for hero_level in HERO_LEVELS:

        with mock.patch('the_tale.game.heroes.objects.Hero.power', Power.power_to_level(POWER_DISTRIBUTION, hero_level)):
            hero_1._model.level = hero_level
            hero_2._model.level = hero_level

            for i in xrange(TEST_BATTLES_NUMBER): # pylint: disable=W0612
                hero_1.health = hero_1.max_health
                hero_2.health = hero_2.max_health

                if process_battle(hero_1, hero_2):
                    hero_1_wins += 1
                else:
                    hero_2_wins += 1

    return hero_1_wins, hero_2_wins
開發者ID:Jazzis18,項目名稱:the-tale,代碼行數:23,代碼來源:heroes_compare_abilities.py

示例3: show_balance

# 需要導入模塊: from the_tale.game.balance.power import Power [as 別名]
# 或者: from the_tale.game.balance.power.Power import power_to_level [as 別名]
    def show_balance(self): # pylint: disable=R0914
        tmp_time = ['начало', '8 часов', 'день', 'неделя', 'месяц', '3 месяца', '6 месяцев', '1 год', '2 года', '3 года', '4 года', '5 лет', '6 лет']
        tmp_times = [0, 8, 24, 24*7, 24*30, 24*30*3, 24*30*6, 24*30*12, 24*30*12*2, 24*30*12*3, 24*30*12*4, 24*30*12*5, 24*30*12*6]
        tmp_lvls = list(map(f.lvl_after_time, tmp_times))

        # Всё, что ниже, должно зависеть от уровня, не от времени, т.к. время в данном случае не точный параметр, а анализ всё равно ориентируется на уровень.

        exp_for_quest = f.experience_for_quest__real(c.QUEST_AREA_RADIUS)

        tmp_exp_to_level = list(map(math.floor, list(map(f.exp_on_lvl, tmp_lvls))))
        tmp_exp_total = list(map(math.floor, list(map(f.total_exp_to_lvl, tmp_lvls))))

        tmp_quests_to_level = list(map(math.ceil, (exp/float(exp_for_quest) for exp in tmp_exp_to_level)))
        tmp_quests_total = list(map(math.ceil, (exp/float(exp_for_quest) for exp in tmp_exp_total)))

        dstr = PowerDistribution(0.5, 0.5)

        tmp_hp = list(map(f.hp_on_lvl, tmp_lvls))
        tmp_turns = list(map(f.turns_on_lvl, tmp_lvls))
        tmp_turns_to_time = list(map(int, list(map(f.hours_to_turns, tmp_times))))
        tmp_expected_damage_to_hero_per_hit = list(map(f.expected_damage_to_hero_per_hit, tmp_lvls))
        tmp_expected_damage_to_hero_per_hit_interval = [ (int(round(dmg*(1-c.DAMAGE_DELTA))), int(round(dmg*(1+c.DAMAGE_DELTA)))) for dmg in tmp_expected_damage_to_hero_per_hit]
        tmp_mob_hp = list(map(f.mob_hp_to_lvl, tmp_lvls))
        tmp_power = [Power.power_to_level(dstr, lvl) for lvl in tmp_lvls]
        tmp_expected_damage_to_mob_per_hit = list(map(f.expected_damage_to_mob_per_hit, tmp_lvls))
        tmp_real_damage_to_mob_per_hit = [p.damage().total for p in tmp_power]
        tmp_real_damage_to_mob_per_hit_interval = [ (int(round(dmg*(1-c.DAMAGE_DELTA))), int(round(dmg*(1+c.DAMAGE_DELTA)))) for dmg in tmp_real_damage_to_mob_per_hit]
        tmp_power_per_slot = [Power.power_to_artifact(dstr, lvl) for lvl in tmp_lvls]
        tmp_battles_at_lvl = list(map(math.floor, [x * c.BATTLES_PER_HOUR for x in map(f.time_on_lvl, tmp_lvls)]))
        tmp_total_battles = list(map(math.floor, [x * c.BATTLES_PER_HOUR for x in map(f.total_time_for_lvl, tmp_lvls)]))
        tmp_artifacts_per_battle = [c.ARTIFACTS_PER_BATTLE]* len(tmp_lvls)
        tmp_artifacts_total = [c.ARTIFACTS_LOOT_PER_DAY * f.total_time_for_lvl(lvl-1)/24.0 for lvl in tmp_lvls]

        tmp_gold_in_day = list(map(f.expected_gold_in_day, tmp_lvls))
        tmp_total_gold_at_lvl = list(map(f.total_gold_at_lvl, tmp_lvls))

        return self.template('balance/balance.html',
                             {'c': c,
                              'f': f ,

                              'exp_for_quest': exp_for_quest,
                              'average_path_length': c.QUEST_AREA_RADIUS,

                              'tmp_time': tmp_time,
                              'tmp_lvls': tmp_lvls,
                              'tmp_exp_to_level': tmp_exp_to_level,
                              'tmp_exp_total': tmp_exp_total,
                              'tmp_quests_to_level': tmp_quests_to_level,
                              'tmp_quests_total': tmp_quests_total,
                              'tmp_hp': tmp_hp,
                              'tmp_turns': tmp_turns,
                              'tmp_turns_to_time': tmp_turns_to_time,
                              'tmp_expected_damage_to_hero_per_hit': tmp_expected_damage_to_hero_per_hit,
                              'tmp_mob_hp': tmp_mob_hp,
                              'tmp_power': tmp_power,
                              'tmp_expected_damage_to_mob_per_hit': tmp_expected_damage_to_mob_per_hit,
                              'tmp_expected_damage_to_hero_per_hit_interval': tmp_expected_damage_to_hero_per_hit_interval,
                              'tmp_real_damage_to_mob_per_hit': tmp_real_damage_to_mob_per_hit,
                              'tmp_real_damage_to_mob_per_hit_interval': tmp_real_damage_to_mob_per_hit_interval,
                              'tmp_power_per_slot': tmp_power_per_slot,
                              'tmp_battles_at_lvl': tmp_battles_at_lvl,
                              'tmp_total_battles': tmp_total_battles,
                              'tmp_artifacts_total': tmp_artifacts_total,
                              'tmp_artifacts_per_battle': tmp_artifacts_per_battle,

                              # 'tmp_gold_at_lvl': tmp_gold_at_lvl,
                              'tmp_gold_in_day': tmp_gold_in_day,
                              'tmp_total_gold_at_lvl': tmp_total_gold_at_lvl
                              } )
開發者ID:,項目名稱:,代碼行數:71,代碼來源:

示例4: show_balance

# 需要導入模塊: from the_tale.game.balance.power import Power [as 別名]
# 或者: from the_tale.game.balance.power.Power import power_to_level [as 別名]
    def show_balance(self):  # pylint: disable=R0914
        tmp_time = [
            u"начало",
            u"8 часов",
            u"день",
            u"неделя",
            u"месяц",
            u"3 месяца",
            u"6 месяцев",
            u"1 год",
            u"2 года",
            u"3 года",
            u"4 года",
            u"5 лет",
            u"6 лет",
        ]
        tmp_times = [
            0,
            8,
            24,
            24 * 7,
            24 * 30,
            24 * 30 * 3,
            24 * 30 * 6,
            24 * 30 * 12,
            24 * 30 * 12 * 2,
            24 * 30 * 12 * 3,
            24 * 30 * 12 * 4,
            24 * 30 * 12 * 5,
            24 * 30 * 12 * 6,
        ]
        tmp_lvls = map(f.lvl_after_time, tmp_times)

        # Всё, что ниже, должно зависеть от уровня, не от времени, т.к. время в данном случае не точный параметр, а анализ всё равно ориентируется на уровень.

        exp_for_quest = f.experience_for_quest__real(c.QUEST_AREA_RADIUS)

        tmp_exp_to_level = map(math.floor, map(f.exp_on_lvl, tmp_lvls))
        tmp_exp_total = map(math.floor, map(f.total_exp_to_lvl, tmp_lvls))

        tmp_quests_to_level = map(math.ceil, (exp / float(exp_for_quest) for exp in tmp_exp_to_level))
        tmp_quests_total = map(math.ceil, (exp / float(exp_for_quest) for exp in tmp_exp_total))

        dstr = PowerDistribution(0.5, 0.5)

        tmp_hp = map(f.hp_on_lvl, tmp_lvls)
        tmp_turns = map(f.turns_on_lvl, tmp_lvls)
        tmp_turns_to_time = map(int, map(f.hours_to_turns, tmp_times))
        tmp_expected_damage_to_hero_per_hit = map(f.expected_damage_to_hero_per_hit, tmp_lvls)
        tmp_expected_damage_to_hero_per_hit_interval = [
            (int(round(dmg * (1 - c.DAMAGE_DELTA))), int(round(dmg * (1 + c.DAMAGE_DELTA))))
            for dmg in tmp_expected_damage_to_hero_per_hit
        ]
        tmp_mob_hp = map(f.mob_hp_to_lvl, tmp_lvls)
        tmp_power = map(lambda lvl: Power.power_to_level(dstr, lvl), tmp_lvls)
        tmp_expected_damage_to_mob_per_hit = map(f.expected_damage_to_mob_per_hit, tmp_lvls)
        tmp_real_damage_to_mob_per_hit = map(lambda p: p.damage().total, tmp_power)
        tmp_real_damage_to_mob_per_hit_interval = [
            (int(round(dmg * (1 - c.DAMAGE_DELTA))), int(round(dmg * (1 + c.DAMAGE_DELTA))))
            for dmg in tmp_real_damage_to_mob_per_hit
        ]
        tmp_power_per_slot = [Power.power_to_artifact(dstr, lvl) for lvl in tmp_lvls]
        tmp_battles_at_lvl = map(math.floor, [x * c.BATTLES_PER_HOUR for x in map(f.time_on_lvl, tmp_lvls)])
        tmp_total_battles = map(math.floor, [x * c.BATTLES_PER_HOUR for x in map(f.total_time_for_lvl, tmp_lvls)])
        tmp_artifacts_per_battle = [c.ARTIFACTS_PER_BATTLE] * len(tmp_lvls)
        tmp_artifacts_total = [c.ARTIFACTS_LOOT_PER_DAY * f.total_time_for_lvl(lvl - 1) / 24.0 for lvl in tmp_lvls]

        tmp_gold_in_day = map(f.expected_gold_in_day, tmp_lvls)
        tmp_total_gold_at_lvl = map(f.total_gold_at_lvl, tmp_lvls)

        return self.template(
            "balance/balance.html",
            {
                "c": c,
                "f": f,
                "exp_for_quest": exp_for_quest,
                "average_path_length": c.QUEST_AREA_RADIUS,
                "tmp_time": tmp_time,
                "tmp_lvls": tmp_lvls,
                "tmp_exp_to_level": tmp_exp_to_level,
                "tmp_exp_total": tmp_exp_total,
                "tmp_quests_to_level": tmp_quests_to_level,
                "tmp_quests_total": tmp_quests_total,
                "tmp_hp": tmp_hp,
                "tmp_turns": tmp_turns,
                "tmp_turns_to_time": tmp_turns_to_time,
                "tmp_expected_damage_to_hero_per_hit": tmp_expected_damage_to_hero_per_hit,
                "tmp_mob_hp": tmp_mob_hp,
                "tmp_power": tmp_power,
                "tmp_expected_damage_to_mob_per_hit": tmp_expected_damage_to_mob_per_hit,
                "tmp_expected_damage_to_hero_per_hit_interval": tmp_expected_damage_to_hero_per_hit_interval,
                "tmp_real_damage_to_mob_per_hit": tmp_real_damage_to_mob_per_hit,
                "tmp_real_damage_to_mob_per_hit_interval": tmp_real_damage_to_mob_per_hit_interval,
                "tmp_power_per_slot": tmp_power_per_slot,
                "tmp_battles_at_lvl": tmp_battles_at_lvl,
                "tmp_total_battles": tmp_total_battles,
                "tmp_artifacts_total": tmp_artifacts_total,
                "tmp_artifacts_per_battle": tmp_artifacts_per_battle,
                # 'tmp_gold_at_lvl': tmp_gold_at_lvl,
                "tmp_gold_in_day": tmp_gold_in_day,
#.........這裏部分代碼省略.........
開發者ID:lshestov,項目名稱:the-tale,代碼行數:103,代碼來源:views.py


注:本文中的the_tale.game.balance.power.Power.power_to_level方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。