From 50999711bfb9b9fc6eced4b7976d29b0f8f3597a Mon Sep 17 00:00:00 2001 From: Kiel <95580337+kielbasiago@users.noreply.github.com> Date: Sun, 27 Feb 2022 09:17:23 -0500 Subject: [PATCH 1/6] Update coliseum random to handle percentage * Remove shuffle as -crsr 0 is the same as -cos --- args/coliseum.py | 39 +++++++++++++++++++++------------------ data/coliseum.py | 26 ++++++++++++++++---------- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/args/coliseum.py b/args/coliseum.py index 6f7d6cfc..81688bb6 100644 --- a/args/coliseum.py +++ b/args/coliseum.py @@ -7,16 +7,20 @@ def parse(parser): coliseum = parser.add_argument_group("Coliseum") coliseum_opponents = coliseum.add_mutually_exclusive_group() - coliseum_opponents.add_argument("-cos", "--coliseum-opponents-shuffle", action = "store_true", - help = "Coliseum opponents shuffled") - coliseum_opponents.add_argument("-cor", "--coliseum-opponents-random", action = "store_true", - help = "Coliseum opponents randomized") + coliseum_opponents.add_argument("-cor", "--coliseum-opponents-random", default = None, type = int, + metavar = "PERCENT", choices = range(101), + help = "Coliseum opponents original with a given percent randomized") + coliseum_opponents.add_argument("-cosr", "--coliseum-opponents-shuffle-random", default = None, type = int, + metavar = "PERCENT", choices = range(101), + help = "Coliseum opponents shuffled and then given percent randomized") coliseum_rewards = coliseum.add_mutually_exclusive_group() - coliseum_rewards.add_argument("-crs", "--coliseum-rewards-shuffle", action = "store_true", - help = "Coliseum rewards shuffled") - coliseum_rewards.add_argument("-crr", "--coliseum-rewards-random", action = "store_true", - help = "Coliseum rewards randomized") + coliseum_rewards.add_argument("-crr", "--coliseum-rewards-random", default = None, type = int, + metavar = "PERCENT", choices = range(101), + help = "Coliseum rewards original with a given percent randomized") + coliseum_rewards.add_argument("-crsr", "--coliseum-rewards-shuffle-random", default = None, type = int, + metavar = "PERCENT", choices = range(101), + help = "Coliseum rewards shuffled and then a given percent randomized") coliseum.add_argument("-crvr", "--coliseum-rewards-visible-random", default = None, type = int, nargs = 2, metavar = ("MIN", "MAX"), choices = range(ITEM_COUNT), @@ -34,16 +38,15 @@ def process(args): def flags(args): flags = "" - - if args.coliseum_opponents_shuffle: - flags += " -cos" - elif args.coliseum_opponents_random: - flags += " -cor" - - if args.coliseum_rewards_shuffle: - flags += " -crs" - elif args.coliseum_rewards_random: - flags += " -crr" + if args.coliseum_opponents_random: + flags += f" -cor {args.coliseum_opponents_random}" + elif args.coliseum_opponents_shuffle_random: + flags += f" -cor {args.coliseum_opponents_shuffle_random}" + + if args.coliseum_rewards_random: + flags += f" -crr {args.coliseum_rewards_random}" + elif args.coliseum_rewards_shuffle_random: + flags += f" -crr {args.coliseum_rewards_shuffle_random}" if args.coliseum_rewards_visible_random: flags += f" -crvr {args.coliseum_rewards_visible_random_min} {args.coliseum_rewards_visible_random_max}" diff --git a/data/coliseum.py b/data/coliseum.py index 095f6a2f..ebb65909 100644 --- a/data/coliseum.py +++ b/data/coliseum.py @@ -30,9 +30,11 @@ def shuffle_opponents(self): for match_index, match in enumerate(self.matches): match.opponent = opponents[match_index] - def randomize_opponents(self): + def randomize_opponents(self, random_opponent_percent = None): + import random + for match in self.matches: - match.opponent = self.enemies.get_random() + match.opponent = self.enemies.get_random() if random_opponent_percent is not None and (random.random() < random_opponent_percent) else match.opponent def shuffle_rewards(self): rewards = [] @@ -44,9 +46,11 @@ def shuffle_rewards(self): for match_index, match in enumerate(self.matches): match.reward = rewards[match_index] - def randomize_rewards(self): + def randomize_rewards(self, random_reward_percent = None): + import random + for match in self.matches: - match.reward = self.items.get_random() + match.reward = self.items.get_random() if random_reward_percent is not None and (random.random() < random_reward_percent) else match.reward def remove_excluded_items(self): import random @@ -76,15 +80,17 @@ def randomize_rewards_hidden(self): self.matches[match_index].reward_hidden = 1 def mod(self): - if self.args.coliseum_opponents_shuffle: + if self.args.coliseum_opponents_random: + self.randomize_opponents(self.args.coliseum_opponents_random / 100.0) + elif self.args.coliseum_opponents_shuffle_random: self.shuffle_opponents() - elif self.args.coliseum_opponents_random: - self.randomize_opponents() + self.randomize_opponents(self.args.coliseum_opponents_shuffle_random / 100.0) - if self.args.coliseum_rewards_shuffle: + if self.args.coliseum_rewards_random: + self.randomize_rewards(self.args.coliseum_rewards_random / 100.0) + elif self.args.coliseum_rewards_shuffle_random: self.shuffle_rewards() - elif self.args.coliseum_rewards_random: - self.randomize_rewards() + self.randomize_rewards(self.args.coliseum_rewards_shuffle_random / 100.0) self.remove_excluded_items() From 6a7ef1584a38eb47bb085e17cde08f85a72218a7 Mon Sep 17 00:00:00 2001 From: Kiel <95580337+kielbasiago@users.noreply.github.com> Date: Sun, 27 Feb 2022 09:22:20 -0500 Subject: [PATCH 2/6] Remove deprecated -cor and -crr flags --- args/coliseum.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/args/coliseum.py b/args/coliseum.py index 81688bb6..357672d5 100644 --- a/args/coliseum.py +++ b/args/coliseum.py @@ -7,17 +7,11 @@ def parse(parser): coliseum = parser.add_argument_group("Coliseum") coliseum_opponents = coliseum.add_mutually_exclusive_group() - coliseum_opponents.add_argument("-cor", "--coliseum-opponents-random", default = None, type = int, - metavar = "PERCENT", choices = range(101), - help = "Coliseum opponents original with a given percent randomized") coliseum_opponents.add_argument("-cosr", "--coliseum-opponents-shuffle-random", default = None, type = int, metavar = "PERCENT", choices = range(101), help = "Coliseum opponents shuffled and then given percent randomized") coliseum_rewards = coliseum.add_mutually_exclusive_group() - coliseum_rewards.add_argument("-crr", "--coliseum-rewards-random", default = None, type = int, - metavar = "PERCENT", choices = range(101), - help = "Coliseum rewards original with a given percent randomized") coliseum_rewards.add_argument("-crsr", "--coliseum-rewards-shuffle-random", default = None, type = int, metavar = "PERCENT", choices = range(101), help = "Coliseum rewards shuffled and then a given percent randomized") From fa84fbb2a87d85d626bd3714f716c2fec141273c Mon Sep 17 00:00:00 2001 From: Kiel <95580337+kielbasiago@users.noreply.github.com> Date: Sun, 27 Feb 2022 09:24:24 -0500 Subject: [PATCH 3/6] readd cor and crr flags --- args/coliseum.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/args/coliseum.py b/args/coliseum.py index 357672d5..81688bb6 100644 --- a/args/coliseum.py +++ b/args/coliseum.py @@ -7,11 +7,17 @@ def parse(parser): coliseum = parser.add_argument_group("Coliseum") coliseum_opponents = coliseum.add_mutually_exclusive_group() + coliseum_opponents.add_argument("-cor", "--coliseum-opponents-random", default = None, type = int, + metavar = "PERCENT", choices = range(101), + help = "Coliseum opponents original with a given percent randomized") coliseum_opponents.add_argument("-cosr", "--coliseum-opponents-shuffle-random", default = None, type = int, metavar = "PERCENT", choices = range(101), help = "Coliseum opponents shuffled and then given percent randomized") coliseum_rewards = coliseum.add_mutually_exclusive_group() + coliseum_rewards.add_argument("-crr", "--coliseum-rewards-random", default = None, type = int, + metavar = "PERCENT", choices = range(101), + help = "Coliseum rewards original with a given percent randomized") coliseum_rewards.add_argument("-crsr", "--coliseum-rewards-shuffle-random", default = None, type = int, metavar = "PERCENT", choices = range(101), help = "Coliseum rewards shuffled and then a given percent randomized") From 51636fc38a5d5fe9a8ac9ebb3299774efeac1242 Mon Sep 17 00:00:00 2001 From: Kiel <95580337+kielbasiago@users.noreply.github.com> Date: Sun, 27 Feb 2022 11:20:46 -0500 Subject: [PATCH 4/6] Remove removed shuffle options from options --- args/coliseum.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/args/coliseum.py b/args/coliseum.py index 81688bb6..35d0868a 100644 --- a/args/coliseum.py +++ b/args/coliseum.py @@ -65,15 +65,11 @@ def options(args): result = [] opponents = "Original" - if args.coliseum_opponents_shuffle: - opponents = "Shuffle" - elif args.coliseum_opponents_random: + if args.coliseum_opponents_random: opponents = "Random" rewards = "Original" - if args.coliseum_rewards_shuffle: - rewards = "Shuffle" - elif args.coliseum_rewards_random: + if args.coliseum_rewards_random: rewards = "Random" rewards_visible = "Original" From 434d8c7915af063c4bf9f87c6947aaebfa49e66b Mon Sep 17 00:00:00 2001 From: asilverthorn <96998881+asilverthorn@users.noreply.github.com> Date: Sun, 2 Apr 2023 09:21:37 -0600 Subject: [PATCH 5/6] allowing 0 argument -cor --- args/coliseum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/args/coliseum.py b/args/coliseum.py index 35d0868a..133fdd22 100644 --- a/args/coliseum.py +++ b/args/coliseum.py @@ -7,7 +7,7 @@ def parse(parser): coliseum = parser.add_argument_group("Coliseum") coliseum_opponents = coliseum.add_mutually_exclusive_group() - coliseum_opponents.add_argument("-cor", "--coliseum-opponents-random", default = None, type = int, + coliseum_opponents.add_argument("-cor", "--coliseum-opponents-random", nargs='?', const=100, default = None, type = int, metavar = "PERCENT", choices = range(101), help = "Coliseum opponents original with a given percent randomized") coliseum_opponents.add_argument("-cosr", "--coliseum-opponents-shuffle-random", default = None, type = int, From b17fb74eb5b6a335609ad955e2c4b8b8c407bf68 Mon Sep 17 00:00:00 2001 From: asilverthorn <96998881+asilverthorn@users.noreply.github.com> Date: Sat, 8 Apr 2023 10:48:02 -0600 Subject: [PATCH 6/6] Making -crr work with no arg --- args/coliseum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/args/coliseum.py b/args/coliseum.py index 133fdd22..6e38ebc8 100644 --- a/args/coliseum.py +++ b/args/coliseum.py @@ -15,7 +15,7 @@ def parse(parser): help = "Coliseum opponents shuffled and then given percent randomized") coliseum_rewards = coliseum.add_mutually_exclusive_group() - coliseum_rewards.add_argument("-crr", "--coliseum-rewards-random", default = None, type = int, + coliseum_rewards.add_argument("-crr", "--coliseum-rewards-random", nargs='?', const=100, default = None, type = int, metavar = "PERCENT", choices = range(101), help = "Coliseum rewards original with a given percent randomized") coliseum_rewards.add_argument("-crsr", "--coliseum-rewards-shuffle-random", default = None, type = int,