SC2: Minor changes to handle edge-case generation failures

This commit is contained in:
Magnemania
2022-10-16 12:19:39 -04:00
parent db3eb3c230
commit d47168c4ab
4 changed files with 21 additions and 11 deletions

View File

@@ -56,10 +56,10 @@ def get_locations(world: Optional[MultiWorld], player: Optional[int]) -> Tuple[L
lambda state: state._sc2wol_defense_rating(world, player, True) >= 4 and
(state._sc2wol_has_common_unit(world, player) or state.has("Reaper", player))),
LocationData("Outbreak", "Outbreak: Left Infestor", SC2WOL_LOC_ID_OFFSET + 501,
lambda state: state._sc2wol_defense_rating(world, player, True) >= 4 and
lambda state: state._sc2wol_defense_rating(world, player, True) >= 2 and
(state._sc2wol_has_common_unit(world, player) or state.has("Reaper", player))),
LocationData("Outbreak", "Outbreak: Right Infestor", SC2WOL_LOC_ID_OFFSET + 502,
lambda state: state._sc2wol_defense_rating(world, player, True) >= 4 and
lambda state: state._sc2wol_defense_rating(world, player, True) >= 2 and
(state._sc2wol_has_common_unit(world, player) or state.has("Reaper", player))),
LocationData("Safe Haven", "Safe Haven: Victory", SC2WOL_LOC_ID_OFFSET + 600,
lambda state: state._sc2wol_has_common_unit(world, player) and

View File

@@ -69,7 +69,7 @@ mini_campaign_order = [
FillMission("no_build", [-1], "Mar Sara", completion_critical=True),
FillMission("easy", [0], "Colonist"),
FillMission("medium", [1], "Colonist"),
FillMission("easy", [0], "Artifact", completion_critical=True),
FillMission("medium", [0], "Artifact", completion_critical=True),
FillMission("medium", [3], "Artifact", number=4, completion_critical=True),
FillMission("hard", [4], "Artifact", number=8, completion_critical=True),
FillMission("medium", [0], "Covert", number=2),

View File

@@ -42,7 +42,7 @@ class MissionOrder(Choice):
Mini Campaign (15): Shorter version of the campaign with randomized missions and optional branches.
Grid (16): A 4x4 grid of random missions. Start at the top-left and forge a path towards All-In.
Mini Grid (9): A 3x3 version of Grid. Complete the bottom-right mission to win.
Blitz (14): 14 random missions that open up very quickly. Complete the bottom-right mission to win.
Blitz (12): 12 random missions that open up very quickly. Complete the bottom-right mission to win.
Gauntlet (7): Linear series of 7 random missions to complete the campaign."""
display_name = "Mission Order"
option_vanilla = 0

View File

@@ -44,7 +44,7 @@ def filter_missions(world: MultiWorld, player: int) -> dict[str, list[str]]:
}
mission_pools = [
no_build_regions_list,
[],
easy_regions_list,
medium_regions_list,
hard_regions_list
@@ -63,9 +63,19 @@ def filter_missions(world: MultiWorld, player: int) -> dict[str, list[str]]:
# Removing the new no-build missions from their original sets
for i in range(1, len(mission_pools)):
mission_pools[i] = [mission for mission in mission_pools[i] if mission not in excluded_missions.union(mission_pools[0])]
# If the first mission is a build mission, there may not be enough locations to reach Outbreak as a second mission
if not get_option_value(world, player, 'shuffle_no_build'):
# Swapping Outbreak and The Great Train Robbery
if "Outbreak" in mission_pools[1]:
mission_pools[1].remove("Outbreak")
mission_pools[2].append("Outbreak")
if "The Great Train Robbery" in mission_pools[2]:
mission_pools[2].remove("The Great Train Robbery")
mission_pools[1].append("The Great Train Robbery")
# Removing random missions from each difficulty set in a cycle
set_cycle = 0
current_count = sum(len(mission_pool) for mission_pool in mission_pools)
if current_count < mission_count:
raise Exception("Not enough missions available to fill the campaign on current settings. Please exclude fewer missions.")
while current_count > mission_count:
@@ -73,13 +83,13 @@ def filter_missions(world: MultiWorld, player: int) -> dict[str, list[str]]:
set_cycle = 0
# Must contain at least one mission per set
mission_pool = mission_pools[set_cycle]
if len(mission_pool) <= 1:
if all(len(mission_pool) <= 1 for mission_pool in mission_pools):
raise Exception("Not enough missions available to fill the campaign on current settings. Please exclude fewer missions.")
else:
mission_pool.remove(world.random.choice(mission_pool))
current_count -= 1
set_cycle += 1
if len(mission_pool) == 1:
if all(len(other_pool) == 1 for other_pool in mission_pools):
raise Exception("Not enough missions available to fill the campaign on current settings. Please exclude fewer missions.")
continue
mission_pool.remove(world.random.choice(mission_pool))
current_count -= 1
return {
"no_build": mission_pools[0],