Removed nonlocal and pass arguments instead

This commit is contained in:
spinerak
2024-06-14 20:38:04 +02:00
parent 4a5a79988f
commit 3c9c16de7a
2 changed files with 5 additions and 8 deletions

View File

@@ -218,6 +218,7 @@ def dice_simulation_strings(categories, num_dice, num_rolls, fixed_mult, step_mu
def dice_simulation_fill_pool(state, options):
"""
Returns the feasible score that one can reach with the current state, options and difficulty.
This function is called with state being a list, during filling of item pool.
"""
categories, num_dice, num_rolls, fixed_mult, step_mult, expoints = extract_progression(state, "state_is_a_list", options)
return (
@@ -230,6 +231,7 @@ def dice_simulation_fill_pool(state, options):
def dice_simulation_state_change(state, player, options):
"""
Returns the feasible score that one can reach with the current state, options and difficulty.
This function is called with state being a AP state object, while doing access rules.
"""
if state.prog_items[player]["state_is_fresh"] == 0:

View File

@@ -173,12 +173,7 @@ class YachtDiceWorld(World):
multipliers_added = 0
items_added = 0
def get_item_to_add():
nonlocal weights
nonlocal extra_points_added
nonlocal multipliers_added
nonlocal items_added
def get_item_to_add(weights, extra_points_added, multipliers_added, items_added):
items_added += 1
all_items = self.itempool + self.precollected
@@ -258,7 +253,7 @@ class YachtDiceWorld(World):
# adding 17 items as a start seems like the smartest way to get close to 1000 points
for _ in range(17):
self.itempool.append(get_item_to_add())
self.itempool.append(get_item_to_add(weights, extra_points_added, multipliers_added, items_added))
score_in_logic = dice_simulation_fill_pool(self.itempool + self.precollected, self.options)
@@ -272,7 +267,7 @@ class YachtDiceWorld(World):
else:
# Keep adding items until a score of 1000 is in logic
while score_in_logic < 1000:
item_to_add = get_item_to_add()
item_to_add = get_item_to_add(weights, extra_points_added, multipliers_added, items_added)
self.itempool.append(item_to_add)
if item_to_add == "1 Point":
score_in_logic += 1