Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KH2: Update all instances of multiworld.option_name to option.option_name #2634

Merged
merged 6 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions worlds/kh2/OpenKH.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,30 @@ def increaseStat(i):
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]
Expand Down Expand Up @@ -142,11 +143,11 @@ def increaseStat(i):
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]
Expand All @@ -172,7 +173,7 @@ def increaseStat(i):
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,
Expand All @@ -192,7 +193,7 @@ def increaseStat(i):
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,
Expand Down Expand Up @@ -224,7 +225,7 @@ def increaseStat(i):
"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,
Expand Down Expand Up @@ -379,35 +380,35 @@ def increaseStat(i):
}
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__)
Expand Down
10 changes: 5 additions & 5 deletions worlds/kh2/Regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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,
Expand All @@ -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,
Expand Down
41 changes: 21 additions & 20 deletions worlds/kh2/Rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def kh2_has_any(self, items: list, state: CollectionState):

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])
Expand All @@ -170,8 +170,8 @@ def get_form_level_requirement(self, state, amount):
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)
Expand Down Expand Up @@ -273,34 +273,35 @@ def set_kh2_rules(self) -> None:

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):
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -935,7 +936,7 @@ def get_cor_first_fight_rules(self, state: CollectionState) -> bool:

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
Expand Down
Loading
Loading