Example #1
0
    def receive_artifact(self,
                         equip,
                         better,
                         prefered_slot,
                         prefered_item,
                         archetype,
                         rarity_type=None,
                         power_bonus=0,
                         level_delta=0):

        artifact_choices = self.receive_artifacts_choices(
            better=better,
            prefered_slot=prefered_slot,
            prefered_item=prefered_item,
            archetype=archetype)

        if rarity_type is None:
            rarity_type = artifacts_storage.get_rarity_type(self)

        artifact = artifacts_storage.generate_artifact_from_list(
            artifact_choices, max(1, self.level + level_delta), rarity_type)

        artifact.power += Power(int(artifact.power.physic * power_bonus),
                                int(artifact.power.magic * power_bonus))

        if artifact is None:
            return None, None, None

        self.bag.put_artifact(artifact)
        self.statistics.change_artifacts_had(1)

        if not equip:
            return artifact, None, None

        slot = artifact.type.equipment_slot
        unequipped = self.equipment.get(slot)

        distribution = self.preferences.archetype.power_distribution

        if (better and unequipped is not None
                and artifact.preference_rating(distribution) <=
                unequipped.preference_rating(distribution)):
            artifact.make_better_than(unequipped, distribution)

        self.change_equipment(slot, unequipped, artifact)

        sell_price = None

        if unequipped is not None:
            sell_price = self.sell_artifact(unequipped)

        return artifact, unequipped, sell_price
Example #2
0
    def receive_artifact(self, equip, better, prefered_slot, prefered_item, archetype, rarity_type=None, power_bonus=0):

        artifact_choices = self.receive_artifacts_choices(better=better, prefered_slot=prefered_slot, prefered_item=prefered_item, archetype=archetype)

        if rarity_type is None:
            rarity_type = artifacts_storage.get_rarity_type(self)

        artifact = artifacts_storage.generate_artifact_from_list(artifact_choices, self.level, rarity_type)

        artifact.power += Power(int(artifact.power.physic * power_bonus),
                                int(artifact.power.magic * power_bonus))

        if artifact is None:
            return None, None, None

        self.bag.put_artifact(artifact)
        self.statistics.change_artifacts_had(1)

        if not equip:
            return artifact, None, None

        slot = artifact.type.equipment_slot
        unequipped = self.equipment.get(slot)

        distribution = self.preferences.archetype.power_distribution

        if (better and unequipped is not None and
            artifact.preference_rating(distribution) <= unequipped.preference_rating(distribution)):
            artifact.make_better_than(unequipped, distribution)

        self.change_equipment(slot, unequipped, artifact)

        sell_price = None

        if unequipped is not None:
            sell_price = self.sell_artifact(unequipped)

        return artifact, unequipped, sell_price
Example #3
0
 def test_get_rarity_type__epic(self):
     self.assertTrue(artifacts_storage.get_rarity_type(self.hero))
Example #4
0
 def test_get_rarity_type__epic(self):
     self.assertTrue(artifacts_storage.get_rarity_type(self.hero))