Example #1
0
    def get_expirience_for_quest(self, quest_uid, hero):
        experience = f.experience_for_quest(c.QUEST_AREA_RADIUS)

        if hero.statistics.quests_done == 0:
            # since we get shortest path for first quest
            # and want to give exp as fast as can
            # and do not want to give more exp than level up required
            experience = int(experience/2)

        place_experience_bonuses = {}
        person_experience_bonuses = {}

        for participant in self.quest_participants(quest_uid):

            fact = self.knowledge_base[participant.participant]

            if isinstance(fact, facts.Person):
                person = persons_storage.persons.get(fact.externals['id'])
                person_experience_bonuses[person.id] = person.attrs.experience_bonus
                place = person.place
            elif isinstance(fact, facts.Place):
                place = places_storage.places.get(fact.externals['id'])

            place_experience_bonuses[place.id] = place.attrs.experience_bonus

        experience += experience * (sum(place_experience_bonuses.values()) + sum(person_experience_bonuses.values()))

        return experience
Example #2
0
    def get_expirience_for_quest(self, quest_uid, hero):
        experience = f.experience_for_quest(c.QUEST_AREA_RADIUS)

        if hero.statistics.quests_done == 0:
            # since we get shortest path for first quest
            # and want to give exp as fast as can
            # and do not want to give more exp than level up required
            experience = int(experience / 2)

        place_experience_bonuses = {}
        person_experience_bonuses = {}

        for participant in self.quest_participants(quest_uid):

            fact = self.knowledge_base[participant.participant]

            if isinstance(fact, facts.Person):
                person = persons_storage.persons.get(fact.externals['id'])
                person_experience_bonuses[
                    person.id] = person.attrs.experience_bonus
                place = person.place
            elif isinstance(fact, facts.Place):
                place = places_storage.places.get(fact.externals['id'])

            place_experience_bonuses[place.id] = place.attrs.experience_bonus

        experience += experience * (sum(place_experience_bonuses.values()) +
                                    sum(person_experience_bonuses.values()))

        return experience
Example #3
0
 def get_expirience_for_quest(cls, hero):
     experience = f.experience_for_quest(c.QUEST_AREA_RADIUS)
     if hero.statistics.quests_done == 0:
         # since we get shortest path for first quest
         # and want to give exp as fast as can
         # and do not want to give more exp than level up required
         experience = int(experience/2)
     return experience
Example #4
0
 def get_expirience_for_quest(cls, hero):
     experience = f.experience_for_quest(c.QUEST_AREA_RADIUS)
     if hero.statistics.quests_done == 0:
         # since we get shortest path for first quest
         # and want to give exp as fast as can
         # and do not want to give more exp than level up required
         experience = int(experience / 2)
     return experience
    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())
Example #6
0
    def job_experience(self, place_id, person_id, message_type, job_power):
        experience = max(
            1,
            int(
                math.ceil(
                    f.experience_for_quest(c.QUEST_AREA_RADIUS) * job_power *
                    c.NORMAL_JOB_LENGTH * c.JOB_HERO_REWARD_FRACTION)))
        self.add_experience(experience, without_modifications=True)

        self.add_message(message_type,
                         diary=True,
                         hero=self,
                         experience=experience,
                         **self.get_job_variables(place_id, person_id))
Example #7
0
 def test_experience_for_quest(self):
     self.assertTrue(f.experience_for_quest(100) < f.experience_for_quest(1000)< f.experience_for_quest(10000))
     self.assertEqual(int(f.experience_for_quest__real(100)), 50)
    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()

        for level in range(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 range(f.turns_on_lvl(level)):  # pylint: disable=W0612
                self.storage.process_turn()
                turn.increment()

                # 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(
                '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('abilities: %s' %
                  ' '.join('%s-%d' % (ability_id, ability.level)
                           for ability_id, ability in list(
                               self.hero.abilities.abilities.items())))
            print('deaths: %d' % self.hero.statistics.pve_deaths)

            total_gold = f.total_gold_at_lvl(self.hero.level)
            print('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('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('power: %r from expected %r' %
                  (self.hero.power,
                   Power.power_to_level(
                       self.hero.preferences.archetype.power_distribution,
                       self.hero.level)))
            print('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()))
Example #9
0
    def job_experience(self, place_id, person_id, message_type, job_power):
        experience = max(1, int(math.ceil(f.experience_for_quest(c.QUEST_AREA_RADIUS) * job_power * c.NORMAL_JOB_LENGTH)))
        self.add_experience(experience, without_modifications=True)

        self.add_message(message_type, diary=True, hero=self, experience=experience, **self.get_job_variables(place_id, person_id))
Example #10
0
 def test_experience_for_quest(self):
     self.assertTrue(
         f.experience_for_quest(100) < f.experience_for_quest(1000) <
         f.experience_for_quest(10000))
     self.assertEqual(int(f.experience_for_quest__real(100)), 50)