From 0874c50ea9ba626773634d806d1bfbdaa443497d Mon Sep 17 00:00:00 2001 From: evilchili Date: Sun, 31 Dec 2023 11:23:15 -0800 Subject: [PATCH] don't choose a frequency if rarity is supplied --- dnd_item/types.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/dnd_item/types.py b/dnd_item/types.py index a58a49e..1c9c1ca 100644 --- a/dnd_item/types.py +++ b/dnd_item/types.py @@ -455,18 +455,18 @@ class ItemGenerator: If a rarity is supplied, ensure we return items of that rarity; in this case challenge_rating is ignored. """ - if challenge_rating in range(1, 5): - frequency = "1-4" - elif challenge_rating in range(5, 11): - frequency = "5-10" - elif challenge_rating in range(11, 17): - frequency = "11-16" - elif challenge_rating >= 17: - frequency = "17" - else: - frequency = "default" - self.rarity.set_frequency(frequency) - + if not rarity: + if challenge_rating in range(1, 5): + frequency = "1-4" + elif challenge_rating in range(5, 11): + frequency = "5-10" + elif challenge_rating in range(11, 17): + frequency = "11-16" + elif challenge_rating >= 17: + frequency = "17" + else: + frequency = "default" + self.rarity.set_frequency(frequency) items = [] for _ in range(count): items.append(self.item_class.from_dict(self.random_properties(rarity=rarity)))