diff --git a/worlds/kh2/OpenKH.py b/worlds/kh2/OpenKH.py index 6b0418c9..c30aeec6 100644 --- a/worlds/kh2/OpenKH.py +++ b/worlds/kh2/OpenKH.py @@ -54,29 +54,30 @@ def patch_kh2(self, output_directory): formName = None levelsetting = list() - if self.multiworld.Keyblade_Minimum[self.player].value > self.multiworld.Keyblade_Maximum[self.player].value: + if self.options.Keyblade_Minimum.value > self.options.Keyblade_Maximum.value: logging.info( f"{self.multiworld.get_file_safe_player_name(self.player)} has Keyblade Minimum greater than Keyblade Maximum") - keyblademin = self.multiworld.Keyblade_Maximum[self.player].value - keyblademax = self.multiworld.Keyblade_Minimum[self.player].value + keyblademin = self.options.Keyblade_Maximum.value + keyblademax = self.options.Keyblade_Minimum.value else: - keyblademin = self.multiworld.Keyblade_Minimum[self.player].value - keyblademax = self.multiworld.Keyblade_Maximum[self.player].value + keyblademin = self.options.Keyblade_Minimum.value + keyblademax = self.options.Keyblade_Maximum.value - if self.multiworld.LevelDepth[self.player] == "level_50": + if self.options.LevelDepth == "level_50": levelsetting.extend(exclusion_table["Level50"]) - elif self.multiworld.LevelDepth[self.player] == "level_99": + elif self.options.LevelDepth == "level_99": levelsetting.extend(exclusion_table["Level99"]) - elif self.multiworld.LevelDepth[self.player] != "level_1": + elif self.options.LevelDepth != "level_1": levelsetting.extend(exclusion_table["Level50Sanity"]) - if self.multiworld.LevelDepth[self.player] == "level_99_sanity": + if self.options.LevelDepth == "level_99_sanity": levelsetting.extend(exclusion_table["Level99Sanity"]) mod_name = f"AP-{self.multiworld.seed_name}-P{self.player}-{self.multiworld.get_file_safe_player_name(self.player)}" all_valid_locations = {location for location, data in all_locations.items()} + for location in self.multiworld.get_filled_locations(self.player): if location.name in all_valid_locations: data = all_locations[location.name] @@ -142,11 +143,11 @@ def patch_kh2(self, output_directory): if data.locid == 2: formDict = {1: "Valor", 2: "Wisdom", 3: "Limit", 4: "Master", 5: "Final"} formDictExp = { - 1: self.multiworld.Valor_Form_EXP[self.player].value, - 2: self.multiworld.Wisdom_Form_EXP[self.player].value, - 3: self.multiworld.Limit_Form_EXP[self.player].value, - 4: self.multiworld.Master_Form_EXP[self.player].value, - 5: self.multiworld.Final_Form_EXP[self.player].value + 1: self.options.Valor_Form_EXP.value, + 2: self.options.Wisdom_Form_EXP.value, + 3: self.options.Limit_Form_EXP.value, + 4: self.options.Master_Form_EXP.value, + 5: self.options.Final_Form_EXP.value } formexp = formDictExp[data.charName] formName = formDict[data.charName] @@ -172,7 +173,7 @@ def patch_kh2(self, output_directory): for x in range(1, 7): self.formattedFmlv["Summon"].append({ "Ability": 123, - "Experience": int(formExp[0][x] / self.multiworld.Summon_EXP[self.player].value), + "Experience": int(formExp[0][x] / self.options.Summon_EXP.value), "FormId": 0, "FormLevel": x, "GrowthAbilityLevel": 0, @@ -192,7 +193,7 @@ def patch_kh2(self, output_directory): increaseStat(self.random.randint(0, 3)) itemcode = 0 self.formattedLvup["Sora"][self.i] = { - "Exp": int(soraExp[self.i] / self.multiworld.Sora_Level_EXP[self.player].value), + "Exp": int(soraExp[self.i] / self.options.Sora_Level_EXP.value), "Strength": self.strength, "Magic": self.magic, "Defense": self.defense, @@ -224,7 +225,7 @@ def patch_kh2(self, output_directory): "Unknown": 0 }) self.formattedLvup["Sora"][1] = { - "Exp": int(soraExp[1] / self.multiworld.Sora_Level_EXP[self.player].value), + "Exp": int(soraExp[1] / self.options.Sora_Level_EXP.value), "Strength": 2, "Magic": 6, "Defense": 2, @@ -379,35 +380,35 @@ def patch_kh2(self, output_directory): } lucky_emblem_text = { 0: "Your Goal is not Lucky Emblem. It is Hitlist or Three Proofs.", - 1: f"Lucky Emblem Required: {self.multiworld.LuckyEmblemsRequired[self.player]} out of {self.multiworld.LuckyEmblemsAmount[self.player]}", + 1: f"Lucky Emblem Required: {self.options.LuckyEmblemsRequired} out of {self.options.LuckyEmblemsAmount}", 2: "Your Goal is not Lucky Emblem. It is Hitlist or Three Proofs.", - 3: f"Lucky Emblem Required: {self.multiworld.LuckyEmblemsRequired[self.player]} out of {self.multiworld.LuckyEmblemsAmount[self.player]}" + 3: f"Lucky Emblem Required: {self.options.LuckyEmblemsRequired} out of {self.options.LuckyEmblemsAmount}" } hitlist_text = { 0: "Your Goal is not Hitlist. It is Lucky Emblem or Three Proofs", 1: "Your Goal is not Hitlist. It is Lucky Emblem or Three Proofs", - 2: f"Bounties Required: {self.multiworld.BountyRequired[self.player]} out of {self.multiworld.BountyAmount[self.player]}", - 3: f"Bounties Required: {self.multiworld.BountyRequired[self.player]} out of {self.multiworld.BountyAmount[self.player]}", + 2: f"Bounties Required: {self.options.BountyRequired} out of {self.options.BountyAmount}", + 3: f"Bounties Required: {self.options.BountyRequired} out of {self.options.BountyAmount}", } self.pooh_text = [ { 'id': 18326, - 'en': f"Your goal is {goal_to_text[self.multiworld.Goal[self.player].value]}" + 'en': f"Your goal is {goal_to_text[self.options.Goal.value]}" }, { 'id': 18327, - 'en': lucky_emblem_text[self.multiworld.Goal[self.player].value] + 'en': lucky_emblem_text[self.options.Goal.value] }, { 'id': 18328, - 'en': hitlist_text[self.multiworld.Goal[self.player].value] + 'en': hitlist_text[self.options.Goal.value] } ] self.level_depth_text = [ { 'id': 0x3BF1, - 'en': f"Your Level Depth is {self.multiworld.LevelDepth[self.player].current_option_name}" + 'en': f"Your Level Depth is {self.options.LevelDepth.current_option_name}" } ] mod_dir = os.path.join(output_directory, mod_name + "_" + Utils.__version__) diff --git a/worlds/kh2/Regions.py b/worlds/kh2/Regions.py index 235500ec..7fc2ad8a 100644 --- a/worlds/kh2/Regions.py +++ b/worlds/kh2/Regions.py @@ -935,7 +935,7 @@ def create_regions(self): for level_region_name in level_region_list: KH2REGIONS[level_region_name] = [] - if multiworld.LevelDepth[player] == "level_50": + if self.options.LevelDepth == "level_50": KH2REGIONS[RegionName.LevelsVS1] = [LocationName.Lvl2, LocationName.Lvl4, LocationName.Lvl7, LocationName.Lvl9, LocationName.Lvl10] KH2REGIONS[RegionName.LevelsVS3] = [LocationName.Lvl12, LocationName.Lvl14, LocationName.Lvl15, @@ -949,7 +949,7 @@ def create_regions(self): KH2REGIONS[RegionName.LevelsVS15] = [LocationName.Lvl50] # level 99 - elif multiworld.LevelDepth[player] == "level_99": + elif self.options.LevelDepth == "level_99": KH2REGIONS[RegionName.LevelsVS1] = [LocationName.Lvl7, LocationName.Lvl9] KH2REGIONS[RegionName.LevelsVS3] = [LocationName.Lvl12, LocationName.Lvl15, LocationName.Lvl17, LocationName.Lvl20] @@ -965,7 +965,7 @@ def create_regions(self): KH2REGIONS[RegionName.LevelsVS26] = [LocationName.Lvl99] # level sanity # has to be [] instead of {} for in - elif multiworld.LevelDepth[player] in ["level_50_sanity", "level_99_sanity"]: + elif self.options.LevelDepth in ["level_50_sanity", "level_99_sanity"]: KH2REGIONS[RegionName.LevelsVS1] = [LocationName.Lvl2, LocationName.Lvl3, LocationName.Lvl4, LocationName.Lvl5, LocationName.Lvl6, LocationName.Lvl7, LocationName.Lvl8, LocationName.Lvl9, LocationName.Lvl10] @@ -986,7 +986,7 @@ def create_regions(self): LocationName.Lvl46, LocationName.Lvl47, LocationName.Lvl48, LocationName.Lvl49, LocationName.Lvl50] # level 99 sanity - if multiworld.LevelDepth[player] == "level_99_sanity": + if self.options.LevelDepth == "level_99_sanity": KH2REGIONS[RegionName.LevelsVS15] = [LocationName.Lvl51, LocationName.Lvl52, LocationName.Lvl53, LocationName.Lvl54, LocationName.Lvl55, LocationName.Lvl56, LocationName.Lvl57, @@ -1012,7 +1012,7 @@ def create_regions(self): LocationName.Lvl95, LocationName.Lvl96, LocationName.Lvl97, LocationName.Lvl98, LocationName.Lvl99] KH2REGIONS[RegionName.Summon] = [] - if multiworld.SummonLevelLocationToggle[player]: + if self.options.SummonLevelLocationToggle: KH2REGIONS[RegionName.Summon] = [LocationName.Summonlvl2, LocationName.Summonlvl3, LocationName.Summonlvl4, diff --git a/worlds/kh2/Rules.py b/worlds/kh2/Rules.py index 1124f810..4370ad36 100644 --- a/worlds/kh2/Rules.py +++ b/worlds/kh2/Rules.py @@ -157,7 +157,7 @@ class KH2Rules: def form_list_unlock(self, state: CollectionState, parent_form_list, level_required, fight_logic=False) -> bool: form_access = {parent_form_list} - if self.multiworld.AutoFormLogic[self.player] and state.has(ItemName.SecondChance, self.player) and not fight_logic: + if self.world.options.AutoFormLogic and state.has(ItemName.SecondChance, self.player) and not fight_logic: if parent_form_list == ItemName.MasterForm: if state.has(ItemName.DriveConverter, self.player): form_access.add(auto_form_dict[parent_form_list]) @@ -170,8 +170,8 @@ class KH2Rules: forms_available = 0 form_list = [ItemName.ValorForm, ItemName.WisdomForm, ItemName.LimitForm, ItemName.MasterForm, ItemName.FinalForm] - if self.world.multiworld.FinalFormLogic[self.player] != "no_light_and_darkness": - if self.world.multiworld.FinalFormLogic[self.player] == "light_and_darkness": + if self.world.options.FinalFormLogic != "no_light_and_darkness": + if self.world.options.FinalFormLogic == "light_and_darkness": if state.has(ItemName.LightDarkness, self.player) and state.has_any(set(form_list), self.player): forms_available += 1 form_list.remove(ItemName.FinalForm) @@ -273,34 +273,35 @@ class KH2WorldRules(KH2Rules): def set_kh2_goal(self): final_xemnas_location = self.multiworld.get_location(LocationName.FinalXemnasEventLocation, self.player) - if self.multiworld.Goal[self.player] == "three_proofs": + if self.world.options.Goal == "three_proofs": final_xemnas_location.access_rule = lambda state: self.kh2_has_all(three_proofs, state) - if self.multiworld.FinalXemnas[self.player]: + if self.world.options.FinalXemnas: self.multiworld.completion_condition[self.player] = lambda state: state.has(ItemName.Victory, self.player, 1) else: self.multiworld.completion_condition[self.player] = lambda state: self.kh2_has_all(three_proofs, state) # lucky emblem hunt - elif self.multiworld.Goal[self.player] == "lucky_emblem_hunt": - final_xemnas_location.access_rule = lambda state: state.has(ItemName.LuckyEmblem, self.player, self.multiworld.LuckyEmblemsRequired[self.player].value) - if self.multiworld.FinalXemnas[self.player]: + elif self.world.options.Goal == "lucky_emblem_hunt": + final_xemnas_location.access_rule = lambda state: state.has(ItemName.LuckyEmblem, self.player, self.world.options.LuckyEmblemsRequired.value) + if self.world.options.FinalXemnas: self.multiworld.completion_condition[self.player] = lambda state: state.has(ItemName.Victory, self.player, 1) else: - self.multiworld.completion_condition[self.player] = lambda state: state.has(ItemName.LuckyEmblem, self.player, self.multiworld.LuckyEmblemsRequired[self.player].value) + self.multiworld.completion_condition[self.player] = lambda state: state.has(ItemName.LuckyEmblem, self.player, self.world.options.LuckyEmblemsRequired.value) # hitlist if == 2 - elif self.multiworld.Goal[self.player] == "hitlist": - final_xemnas_location.access_rule = lambda state: state.has(ItemName.Bounty, self.player, self.multiworld.BountyRequired[self.player].value) - if self.multiworld.FinalXemnas[self.player]: + elif self.world.options.Goal == "hitlist": + final_xemnas_location.access_rule = lambda state: state.has(ItemName.Bounty, self.player, self.world.options.BountyRequired.value) + if self.world.options.FinalXemnas: self.multiworld.completion_condition[self.player] = lambda state: state.has(ItemName.Victory, self.player, 1) else: - self.multiworld.completion_condition[self.player] = lambda state: state.has(ItemName.Bounty, self.player, self.multiworld.BountyRequired[self.player].value) + self.multiworld.completion_condition[self.player] = lambda state: state.has(ItemName.Bounty, self.player, self.world.options.BountyRequired.value) else: - final_xemnas_location.access_rule = lambda state: state.has(ItemName.Bounty, self.player, self.multiworld.BountyRequired[self.player].value) and \ - state.has(ItemName.LuckyEmblem, self.player, self.multiworld.LuckyEmblemsRequired[self.player].value) - if self.multiworld.FinalXemnas[self.player]: + + final_xemnas_location.access_rule = lambda state: state.has(ItemName.Bounty, self.player, self.world.options.BountyRequired.value) and \ + state.has(ItemName.LuckyEmblem, self.player, self.world.options.LuckyEmblemsRequired.value) + if self.world.options.FinalXemnas: self.multiworld.completion_condition[self.player] = lambda state: state.has(ItemName.Victory, self.player, 1) else: - self.multiworld.completion_condition[self.player] = lambda state: state.has(ItemName.Bounty, self.player, self.multiworld.BountyRequired[self.player].value) and \ - state.has(ItemName.LuckyEmblem, self.player, self.multiworld.LuckyEmblemsRequired[self.player].value) + self.multiworld.completion_condition[self.player] = lambda state: state.has(ItemName.Bounty, self.player, self.world.options.BountyRequired.value) and \ + state.has(ItemName.LuckyEmblem, self.player, self.world.options.LuckyEmblemsRequired.value) class KH2FormRules(KH2Rules): @@ -409,7 +410,7 @@ class KH2FightRules(KH2Rules): # if skip rules are of return false def __init__(self, world: KH2World) -> None: super().__init__(world) - self.fight_logic = self.multiworld.FightLogic[self.player].current_key + self.fight_logic = world.options.FightLogic.current_key self.fight_region_rules = { RegionName.ShanYu: lambda state: self.get_shan_yu_rules(state), @@ -935,7 +936,7 @@ class KH2FightRules(KH2Rules): def get_cor_skip_first_rules(self, state: CollectionState) -> bool: # if option is not allow skips return false else run rules - if not self.multiworld.CorSkipToggle[self.player]: + if not self.world.options.CorSkipToggle: return False # easy: aerial dodge 3,master form,fire # normal: aerial dodge 2, master form,fire diff --git a/worlds/kh2/__init__.py b/worlds/kh2/__init__.py index d02614d3..4125bcb2 100644 --- a/worlds/kh2/__init__.py +++ b/worlds/kh2/__init__.py @@ -240,7 +240,7 @@ class KH2World(World): self.hitlist_verify() - prio_hitlist = [location for location in self.multiworld.priority_locations[self.player].value if + prio_hitlist = [location for location in self.options.priority_locations.value if location in self.random_super_boss_list] for bounty in range(self.options.BountyAmount.value): if prio_hitlist: @@ -261,11 +261,11 @@ class KH2World(World): if self.options.WeaponSlotStartHint: for location in all_weapon_slot: - self.multiworld.start_location_hints[self.player].value.add(location) + self.options.start_location_hints.value.add(location) if self.options.FillerItemsLocal: for item in filler_items: - self.multiworld.local_items[self.player].value.add(item) + self.options.local_items.value.add(item) # By imitating remote this doesn't have to be plandoded filler anymore # for location in {LocationName.JunkMedal, LocationName.JunkMedal}: # self.plando_locations[location] = random_stt_item @@ -325,7 +325,7 @@ class KH2World(World): self.item_quantity_dict[random_ability] -= 1 self.total_locations -= 1 self.slot_data_donald_weapon = [item_name.name for item_name in self.donald_weapon_abilities] - if not self.multiworld.DonaldGoofyStatsanity[self.player]: + if not self.options.DonaldGoofyStatsanity: # pre plando donald get bonuses self.donald_get_bonus_abilities += [self.create_item(random_prog_ability)] self.total_locations -= 1 @@ -385,7 +385,7 @@ class KH2World(World): location.place_locked_item(random_ability) self.goofy_weapon_abilities.remove(random_ability) - if not self.multiworld.DonaldGoofyStatsanity[self.player]: + if not self.options.DonaldGoofyStatsanity: # plando goofy get bonuses goofy_get_bonus_location_pool = [self.multiworld.get_location(location, self.player) for location in Goofy_Checks.keys() if Goofy_Checks[location].yml != "Keyblade"] @@ -406,7 +406,7 @@ class KH2World(World): location.place_locked_item(random_ability) self.donald_weapon_abilities.remove(random_ability) - if not self.multiworld.DonaldGoofyStatsanity[self.player]: + if not self.options.DonaldGoofyStatsanity: # plando goofy get bonuses donald_get_bonus_location_pool = [self.multiworld.get_location(location, self.player) for location in Donald_Checks.keys() if Donald_Checks[location].yml != "Keyblade"] @@ -428,7 +428,7 @@ class KH2World(World): """ Making sure the player doesn't put too many abilities in their starting inventory. """ - for item, value in self.multiworld.start_inventory[self.player].value.items(): + for item, value in self.options.start_inventory.value.items(): if item in ActionAbility_Table \ or item in SupportAbility_Table or exclusion_item_table["StatUps"] \ or item in DonaldAbility_Table or item in GoofyAbility_Table: @@ -461,7 +461,7 @@ class KH2World(World): """ Making sure hitlist have amount>=required. """ - for location in self.multiworld.exclude_locations[self.player].value: + for location in self.options.exclude_locations.value: if location in self.random_super_boss_list: self.random_super_boss_list.remove(location) @@ -491,7 +491,7 @@ class KH2World(World): self.options.BountyAmount.value = temp if self.options.BountyStartingHintToggle: - self.multiworld.start_hints[self.player].value.add(ItemName.Bounty) + self.options.start_hints.value.add(ItemName.Bounty) if ItemName.ProofofNonexistence in self.item_quantity_dict: del self.item_quantity_dict[ItemName.ProofofNonexistence] @@ -503,19 +503,19 @@ class KH2World(World): # Option to turn off all superbosses. Can do this individually but its like 20+ checks if not self.options.SuperBosses: for superboss in exclusion_table["SuperBosses"]: - self.multiworld.exclude_locations[self.player].value.add(superboss) + self.options.exclude_locations.value.add(superboss) # Option to turn off Olympus Colosseum Cups. if self.options.Cups == "no_cups": for cup in exclusion_table["Cups"]: - self.multiworld.exclude_locations[self.player].value.add(cup) + self.options.exclude_locations.value.add(cup) # exclude only hades paradox. If cups and hades paradox then nothing is excluded elif self.options.Cups == "cups": - self.multiworld.exclude_locations[self.player].value.add(LocationName.HadesCupTrophyParadoxCups) + self.options.exclude_locations.value.add(LocationName.HadesCupTrophyParadoxCups) if not self.options.AtlanticaToggle: for loc in exclusion_table["Atlantica"]: - self.multiworld.exclude_locations[self.player].value.add(loc) + self.options.exclude_locations.value.add(loc) def level_subtraction(self): """