Skip to content

Commit

Permalink
SC2: race-swap logic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EnvyDragon committed Jul 1, 2024
1 parent 143f9aa commit b0d8715
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
9 changes: 4 additions & 5 deletions worlds/sc2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
get_option_value, LocationInclusion, KerriganLevelItemDistribution,
KerriganPresence, KerriganPrimalStatus, kerrigan_unit_available, StarterUnit, SpearOfAdunPresence,
get_enabled_campaigns, SpearOfAdunAutonomouslyCastAbilityPresence, Starcraft2Options,
GrantStoryTech, GenericUpgradeResearch, GenericUpgradeItems, get_enabled_races
GrantStoryTech, GenericUpgradeResearch, GenericUpgradeItems,
)
from .pool_filter import filter_items
from .mission_tables import (
Expand Down Expand Up @@ -257,7 +257,6 @@ def resolve_count(count: Optional[int], max_count: int) -> int:
def flag_excludes_by_faction_presence(world: SC2World, item_list: List[FilterItem]) -> None:
"""Excludes items based on if their faction has a mission present where they can be used"""
missions = get_all_missions(world.mission_req_table)
races = get_enabled_races(world)
if world.options.take_over_ai_allies.value:
terran_missions = [mission for mission in missions if (MissionFlag.Terran|MissionFlag.AiTerranAlly) & mission.flags]
zerg_missions = [mission for mission in missions if (MissionFlag.Zerg|MissionFlag.AiZergAlly) & mission.flags]
Expand All @@ -276,13 +275,13 @@ def flag_excludes_by_faction_presence(world: SC2World, item_list: List[FilterIte

for item in item_list:
# Catch-all for all of a faction's items
if (not terran_missions or SC2Race.TERRAN not in races) and item.data.race == SC2Race.TERRAN:
if (not terran_missions and item.data.race == SC2Race.TERRAN):
item.flags |= ItemFilterFlags.Excluded
continue
if (not zerg_missions or SC2Race.ZERG not in races) and item.data.race == SC2Race.ZERG:
if (not zerg_missions and item.data.race == SC2Race.ZERG):
item.flags |= ItemFilterFlags.Excluded
continue
if (not protoss_missions or SC2Race.PROTOSS not in races) and item.data.race == SC2Race.PROTOSS:
if (not protoss_missions and item.data.race == SC2Race.PROTOSS):
if item.name not in item_groups.soa_items:
item.flags |= ItemFilterFlags.Excluded
continue
Expand Down
4 changes: 1 addition & 3 deletions worlds/sc2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,10 +1108,8 @@ async def on_step(self, iteration: int):
kerrigan_level = get_kerrigan_level(self.ctx, start_items, missions_beaten)
kerrigan_options = calculate_kerrigan_options(self.ctx)
soa_options = caclulate_soa_options(self.ctx)
mission_variant = get_mission_variant(self.mission_id)
mission_variant = get_mission_variant(self.mission_id) # 0/1/2/3 for unchanged/Terran/Zerg/Protoss
uncollected_objectives: typing.List[int] = self.get_uncollected_objectives()
# TODO: Add logic to determine which variant, based on selected map ID
mission_variant = 0 # 0/1/2/3 for unchanged/Terran/Zerg/Protoss
if self.ctx.difficulty_override >= 0:
difficulty = calc_difficulty(self.ctx.difficulty_override)
else:
Expand Down
14 changes: 7 additions & 7 deletions worlds/sc2/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,37 +66,37 @@ def wol_cleared_missions(state: CollectionState, mission_count: int) -> bool:
player: int = world.player
if SC2Campaign.WOL in enabled_campaigns:
connect(world, names, 'Menu', 'Liberation Day')
connect(world, names, 'Liberation Day', 'The Outlaws',
connect(world, names, 'Liberation Day', 'The Outlaws (T)',
lambda state: state.has("Beat Liberation Day", player))
connect(world, names, 'The Outlaws', 'Zero Hour',
connect(world, names, 'The Outlaws (T)', 'Zero Hour (T)',
lambda state: state.has("Beat The Outlaws", player))
connect(world, names, 'Zero Hour', 'Evacuation',
connect(world, names, 'Zero Hour (T)', 'Evacuation',
lambda state: state.has("Beat Zero Hour", player))
connect(world, names, 'Evacuation', 'Outbreak',
lambda state: state.has("Beat Evacuation", player))
connect(world, names, "Outbreak", "Safe Haven",
lambda state: wol_cleared_missions(state, 7) and state.has("Beat Outbreak", player))
connect(world, names, "Outbreak", "Haven's Fall",
lambda state: wol_cleared_missions(state, 7) and state.has("Beat Outbreak", player))
connect(world, names, 'Zero Hour', 'Smash and Grab',
connect(world, names, 'Zero Hour (T)', 'Smash and Grab (T)',
lambda state: state.has("Beat Zero Hour", player))
connect(world, names, 'Smash and Grab', 'The Dig',
connect(world, names, 'Smash and Grab (T)', 'The Dig',
lambda state: wol_cleared_missions(state, 8) and state.has("Beat Smash and Grab", player))
connect(world, names, 'The Dig', 'The Moebius Factor',
lambda state: wol_cleared_missions(state, 11) and state.has("Beat The Dig", player))
connect(world, names, 'The Moebius Factor', 'Supernova',
lambda state: wol_cleared_missions(state, 14) and state.has("Beat The Moebius Factor", player))
connect(world, names, 'Supernova', 'Maw of the Void',
lambda state: state.has("Beat Supernova", player))
connect(world, names, 'Zero Hour', "Devil's Playground",
connect(world, names, 'Zero Hour (T)', "Devil's Playground",
lambda state: wol_cleared_missions(state, 4) and state.has("Beat Zero Hour", player))
connect(world, names, "Devil's Playground", 'Welcome to the Jungle',
lambda state: state.has("Beat Devil's Playground", player))
connect(world, names, "Welcome to the Jungle", 'Breakout',
lambda state: wol_cleared_missions(state, 8) and state.has("Beat Welcome to the Jungle", player))
connect(world, names, "Welcome to the Jungle", 'Ghost of a Chance',
lambda state: wol_cleared_missions(state, 8) and state.has("Beat Welcome to the Jungle", player))
connect(world, names, "Zero Hour", 'The Great Train Robbery',
connect(world, names, "Zero Hour (T)", 'The Great Train Robbery',
lambda state: wol_cleared_missions(state, 6) and state.has("Beat Zero Hour", player))
connect(world, names, 'The Great Train Robbery', 'Cutthroat',
lambda state: state.has("Beat The Great Train Robbery", player))
Expand Down

0 comments on commit b0d8715

Please sign in to comment.