Use random.sample instead of random.choices. - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit e71c6746ae86f639be9e6a5d444e472ce4894ccb DIR parent e633438c4baa7d8cffee0038bc0062e8507171d6 HTML Author: Annna Robert-Houdin <annna@bitreich.org> Date: Wed, 30 Aug 2023 12:32:31 +0200 Use random.sample instead of random.choices. Random.sample gives back unique entries. Diffstat: M modules/idlerpg/idlerpg-channel-se… | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- DIR diff --git a/modules/idlerpg/idlerpg-channel-service.py b/modules/idlerpg/idlerpg-channel-service.py @@ -224,10 +224,10 @@ def main(args): hackers[hacker][5] = newlevel if random.randint(1, 65535) > 65500 and len(hackers) > 1: - (attacker, defender) = random.choices(list(hackers.keys()), k=2) + (attacker, defender) = random.sample(list(hackers.keys()), 2) attack(hackers, attacker, defender) - elif random.randint(1, 65535) < 10 and len(hackers) > 1: - questhackers = random.choices(list(hackers.keys()), k=random.randint(1, len(hackers))) + elif random.randint(1, 65535) < 30 and len(hackers) > 1: + questhackers = random.sample(list(hackers.keys()), random.randint(1, len(hackers))) go_on_quest(hackers, questhackers) writeout_dictfile("%s/hackers.txt" % (basepath), hackers) @@ -266,7 +266,7 @@ def main(args): if len(cmdargs) > 0 and cmdargs[0] in hackers: attack(hackers, hacker, cmdargs[0]) else: - (attacker, defender) = random.choices(list(hackers.keys()), k=2) + (attacker, defender) = random.sample(list(hackers.keys()), 2) attack(hackers, attacker, defender) elif cmd == "!quest": if len (cmdargs) > 0 and cmdargs[0] in hackers: @@ -276,7 +276,7 @@ def main(args): argsinhackers.append(cmdarg) go_on_quest(hackers, argsinhackers) else: - questhackers = random.choices(list(hackers.keys()), k=random.randint(1, len(hackers))) + questhackers = random.sample(list(hackers.keys()), random.randint(1, len(hackers))) go_on_quest(hackers, questhackers) elif user == "-!-":