Switch to random.sample for lore instead of random.choice
This commit is contained in:
parent
966e0fba61
commit
599dff39a8
1 changed files with 4 additions and 7 deletions
|
@ -166,13 +166,10 @@ def _lore(channel, count):
|
||||||
pins = channel.saved_pins
|
pins = channel.saved_pins
|
||||||
if not pins:
|
if not pins:
|
||||||
return None
|
return None
|
||||||
if len(pins) < count:
|
try:
|
||||||
return [_extract_lore(p) for p in pins]
|
out_lore = set(_extract_lore(l) for l in random.sample(pins, count))
|
||||||
out_lore = set()
|
except ValueError:
|
||||||
while len(out_lore) < count:
|
out_lore = [_extract_lore(p) for p in pins]
|
||||||
random_lore = random.choice(pins)
|
|
||||||
lore = _extract_lore(random_lore)
|
|
||||||
out_lore.add(lore)
|
|
||||||
return out_lore
|
return out_lore
|
||||||
|
|
||||||
def _scribe():
|
def _scribe():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue