Esempio n. 1
0
 def assign_stats_from_pool(self, pool):
     """
     When gaining a new group of stats, generally as a new mage, we give them based off the weightings for the class
     Some classes will override the default weightings to generally grant new skill points in different areas.
     Uses the stat normalizing factor to smooth the curve to make outlier stats compared the mages weightings less
     common.
     :param pool:
     :return:
     """
     weightings = self.stat_weight.copy()
     for _ in range(pool):
         stat_to_boost = random.weighted_rand(weightings)
         self.__setattr__(stat_to_boost, self.__getattribute__(stat_to_boost) + 1)
         weightings[stat_to_boost] = int(weightings[stat_to_boost] * STAT_NORMALIZING_FACTOR)
Esempio n. 2
0
    def craft_recipe(self, player, tier):
        """
        When you craft a recipe, depending on tier, you have a higher chance of getting the better version of items.
        We take the normal weighting matrix and add 20 * tier to all weightings. For example if weights were 5, 10, 15
        and the tier was 1, the new weightings would be 25, 30, 35. Getting the best item is now a 25/90 instead of 5
        out of 30. If you used tier 2, it would be 45, 50, 55, or 45/150
        :param player:
        :param tier:
        :return:
        """
        assert self.can_afford(player, tier), 'Tried to craft an item the player could not afford!'
        self.pay_price(player, tier)

        rand_modifier = tier * 20
        item_pool = self.item_pool.copy()

        for key in item_pool.keys():
            item_pool[key] += rand_modifier

        return weighted_rand(item_pool)