Rogue Legacy: More refactoring and clean up. (#1297)
* Rogue Legacy: More refactoring and clean up. * Also marked Blacksmith as Progression as it's used in a rule. * Remove extra newline. * Prevent divide by zero type error. * Scratch last commit, got the math mixed in my head. * Clarified name of rule regarding percentage of stat upgrades. * Move early vendors/architect creation into `create_items` logic. * Rename parameter in `create_region`. * Rename local var in `create_region`. * Removed accidental links in Markdown docs. * Refactor `create_region` signature and caller. * Remove redundant if-else. * Revert change to if-else, and moved item_pool to function instead of obj var. * Rename LegacyLogic to RLLogic. * Remove LogicMixin for rules.
This commit is contained in:
@@ -30,7 +30,7 @@ class RLWorld(World):
|
||||
you. Every child is unique. One child might be colorblind, another might have vertigo-- they could even be a dwarf.
|
||||
But that's OK, because no one is perfect, and you don't have to be to succeed.
|
||||
"""
|
||||
game: str = "Rogue Legacy"
|
||||
game = "Rogue Legacy"
|
||||
option_definitions = rl_options
|
||||
topology_present = True
|
||||
data_version = 4
|
||||
@@ -40,158 +40,154 @@ class RLWorld(World):
|
||||
item_name_to_id = {name: data.code for name, data in item_table.items()}
|
||||
location_name_to_id = {name: data.code for name, data in location_table.items()}
|
||||
|
||||
item_pool: List[RLItem] = []
|
||||
|
||||
def setting(self, name: str):
|
||||
# TODO: Replace calls to this function with "options-dict", once that PR is completed and merged.
|
||||
def get_setting(self, name: str):
|
||||
return getattr(self.multiworld, name)[self.player]
|
||||
|
||||
def fill_slot_data(self) -> dict:
|
||||
return {option_name: self.setting(option_name).value for option_name in rl_options}
|
||||
return {option_name: self.get_setting(option_name).value for option_name in rl_options}
|
||||
|
||||
def generate_early(self):
|
||||
# Check validation of names.
|
||||
additional_lady_names = len(self.setting("additional_lady_names").value)
|
||||
additional_sir_names = len(self.setting("additional_sir_names").value)
|
||||
if not self.setting("allow_default_names"):
|
||||
# Check for max_quantity.
|
||||
if additional_lady_names < int(self.setting("number_of_children")):
|
||||
additional_lady_names = len(self.get_setting("additional_lady_names").value)
|
||||
additional_sir_names = len(self.get_setting("additional_sir_names").value)
|
||||
if not self.get_setting("allow_default_names"):
|
||||
if additional_lady_names < int(self.get_setting("number_of_children")):
|
||||
raise Exception(
|
||||
f"allow_default_names is off, but not enough names are defined in additional_lady_names. "
|
||||
f"Expected {int(self.setting('number_of_children'))}, Got {additional_lady_names}")
|
||||
f"Expected {int(self.get_setting('number_of_children'))}, Got {additional_lady_names}")
|
||||
|
||||
if additional_sir_names < int(self.setting("number_of_children")):
|
||||
if additional_sir_names < int(self.get_setting("number_of_children")):
|
||||
raise Exception(
|
||||
f"allow_default_names is off, but not enough names are defined in additional_sir_names. "
|
||||
f"Expected {int(self.setting('number_of_children'))}, Got {additional_sir_names}")
|
||||
f"Expected {int(self.get_setting('number_of_children'))}, Got {additional_sir_names}")
|
||||
|
||||
if self.setting("vendors") == "early":
|
||||
self.multiworld.local_early_items[self.player]["Blacksmith"] = 1
|
||||
self.multiworld.local_early_items[self.player]["Enchantress"] = 1
|
||||
|
||||
if self.setting("architect") == "early":
|
||||
self.multiworld.local_early_items[self.player]["Architect"] = 1
|
||||
|
||||
def generate_basic(self):
|
||||
self.item_pool = []
|
||||
total_locations = 64 + (self.setting("chests_per_zone") * 4) + (self.setting("fairy_chests_per_zone") * 4)
|
||||
|
||||
# Add items to item pool. Anything with a "continue" will not be added to the item pool.
|
||||
def create_items(self):
|
||||
item_pool: List[RLItem] = []
|
||||
total_locations = len(self.multiworld.get_unfilled_locations(self.player))
|
||||
for name, data in item_table.items():
|
||||
quantity = data.max_quantity
|
||||
|
||||
# Architect
|
||||
if name == "Architect":
|
||||
if self.setting("architect") == "disabled":
|
||||
if self.get_setting("architect") == "disabled":
|
||||
continue
|
||||
if self.setting("architect") == "start_unlocked":
|
||||
if self.get_setting("architect") == "start_unlocked":
|
||||
self.multiworld.push_precollected(self.create_item(name))
|
||||
continue
|
||||
if self.get_setting("architect") == "early":
|
||||
self.multiworld.local_early_items[self.player]["Architect"] = 1
|
||||
continue
|
||||
|
||||
# Blacksmith and Enchantress
|
||||
if name == "Blacksmith" or name == "Enchantress":
|
||||
if self.setting("vendors") == "start_unlocked":
|
||||
if self.get_setting("vendors") == "start_unlocked":
|
||||
self.multiworld.push_precollected(self.create_item(name))
|
||||
continue
|
||||
if self.get_setting("vendors") == "early":
|
||||
self.multiworld.local_early_items[self.player]["Blacksmith"] = 1
|
||||
self.multiworld.local_early_items[self.player]["Enchantress"] = 1
|
||||
continue
|
||||
|
||||
# Haggling
|
||||
if name == "Haggling" and self.setting("disable_charon"):
|
||||
if name == "Haggling" and self.get_setting("disable_charon"):
|
||||
continue
|
||||
|
||||
# Blueprints
|
||||
if data.category == "Blueprints":
|
||||
# No progressive blueprints if progressive_blueprints are disabled.
|
||||
if name == "Progressive Blueprints" and not self.setting("progressive_blueprints"):
|
||||
if name == "Progressive Blueprints" and not self.get_setting("progressive_blueprints"):
|
||||
continue
|
||||
# No distinct blueprints if progressive_blueprints are enabled.
|
||||
elif name != "Progressive Blueprints" and self.setting("progressive_blueprints"):
|
||||
elif name != "Progressive Blueprints" and self.get_setting("progressive_blueprints"):
|
||||
continue
|
||||
|
||||
# Classes
|
||||
if data.category == "Classes":
|
||||
if name == "Progressive Knights":
|
||||
if "Knight" not in self.setting("available_classes"):
|
||||
if "Knight" not in self.get_setting("available_classes"):
|
||||
continue
|
||||
|
||||
if self.setting("starting_class") == "knight":
|
||||
if self.get_setting("starting_class") == "knight":
|
||||
quantity = 1
|
||||
if name == "Progressive Mages":
|
||||
if "Mage" not in self.setting("available_classes"):
|
||||
if "Mage" not in self.get_setting("available_classes"):
|
||||
continue
|
||||
|
||||
if self.setting("starting_class") == "mage":
|
||||
if self.get_setting("starting_class") == "mage":
|
||||
quantity = 1
|
||||
if name == "Progressive Barbarians":
|
||||
if "Barbarian" not in self.setting("available_classes"):
|
||||
if "Barbarian" not in self.get_setting("available_classes"):
|
||||
continue
|
||||
|
||||
if self.setting("starting_class") == "barbarian":
|
||||
if self.get_setting("starting_class") == "barbarian":
|
||||
quantity = 1
|
||||
if name == "Progressive Knaves":
|
||||
if "Knave" not in self.setting("available_classes"):
|
||||
if "Knave" not in self.get_setting("available_classes"):
|
||||
continue
|
||||
|
||||
if self.setting("starting_class") == "knave":
|
||||
if self.get_setting("starting_class") == "knave":
|
||||
quantity = 1
|
||||
if name == "Progressive Miners":
|
||||
if "Miner" not in self.setting("available_classes"):
|
||||
if "Miner" not in self.get_setting("available_classes"):
|
||||
continue
|
||||
|
||||
if self.setting("starting_class") == "miner":
|
||||
if self.get_setting("starting_class") == "miner":
|
||||
quantity = 1
|
||||
if name == "Progressive Shinobis":
|
||||
if "Shinobi" not in self.setting("available_classes"):
|
||||
if "Shinobi" not in self.get_setting("available_classes"):
|
||||
continue
|
||||
|
||||
if self.setting("starting_class") == "shinobi":
|
||||
if self.get_setting("starting_class") == "shinobi":
|
||||
quantity = 1
|
||||
if name == "Progressive Liches":
|
||||
if "Lich" not in self.setting("available_classes"):
|
||||
if "Lich" not in self.get_setting("available_classes"):
|
||||
continue
|
||||
|
||||
if self.setting("starting_class") == "lich":
|
||||
if self.get_setting("starting_class") == "lich":
|
||||
quantity = 1
|
||||
if name == "Progressive Spellthieves":
|
||||
if "Spellthief" not in self.setting("available_classes"):
|
||||
if "Spellthief" not in self.get_setting("available_classes"):
|
||||
continue
|
||||
|
||||
if self.setting("starting_class") == "spellthief":
|
||||
if self.get_setting("starting_class") == "spellthief":
|
||||
quantity = 1
|
||||
if name == "Dragons":
|
||||
if "Dragon" not in self.setting("available_classes"):
|
||||
if "Dragon" not in self.get_setting("available_classes"):
|
||||
continue
|
||||
if name == "Traitors":
|
||||
if "Traitor" not in self.setting("available_classes"):
|
||||
if "Traitor" not in self.get_setting("available_classes"):
|
||||
continue
|
||||
|
||||
# Skills
|
||||
if name == "Health Up":
|
||||
quantity = self.setting("health_pool")
|
||||
quantity = self.get_setting("health_pool")
|
||||
elif name == "Mana Up":
|
||||
quantity = self.setting("mana_pool")
|
||||
quantity = self.get_setting("mana_pool")
|
||||
elif name == "Attack Up":
|
||||
quantity = self.setting("attack_pool")
|
||||
quantity = self.get_setting("attack_pool")
|
||||
elif name == "Magic Damage Up":
|
||||
quantity = self.setting("magic_damage_pool")
|
||||
quantity = self.get_setting("magic_damage_pool")
|
||||
elif name == "Armor Up":
|
||||
quantity = self.setting("armor_pool")
|
||||
quantity = self.get_setting("armor_pool")
|
||||
elif name == "Equip Up":
|
||||
quantity = self.setting("equip_pool")
|
||||
quantity = self.get_setting("equip_pool")
|
||||
elif name == "Crit Chance Up":
|
||||
quantity = self.setting("crit_chance_pool")
|
||||
quantity = self.get_setting("crit_chance_pool")
|
||||
elif name == "Crit Damage Up":
|
||||
quantity = self.setting("crit_damage_pool")
|
||||
quantity = self.get_setting("crit_damage_pool")
|
||||
|
||||
# Ignore filler, it will be added in a later stage.
|
||||
if data.category == "Filler":
|
||||
continue
|
||||
|
||||
self.item_pool += [self.create_item(name) for _ in range(0, quantity)]
|
||||
item_pool += [self.create_item(name) for _ in range(0, quantity)]
|
||||
|
||||
# Fill any empty locations with filler items.
|
||||
while len(self.item_pool) < total_locations:
|
||||
self.item_pool.append(self.create_item(self.get_filler_item_name()))
|
||||
while len(item_pool) < total_locations:
|
||||
item_pool.append(self.create_item(self.get_filler_item_name()))
|
||||
|
||||
self.multiworld.itempool += self.item_pool
|
||||
self.multiworld.itempool += item_pool
|
||||
|
||||
def get_filler_item_name(self) -> str:
|
||||
fillers = get_items_by_category("Filler")
|
||||
@@ -219,7 +215,7 @@ class RLWorld(World):
|
||||
self.create_event("Defeat The Fountain"))
|
||||
|
||||
# Khidr / Neo Khidr
|
||||
if self.setting("khidr") == "vanilla":
|
||||
if self.get_setting("khidr") == "vanilla":
|
||||
self.multiworld.get_location("Castle Hamson Boss Room", self.player).place_locked_item(
|
||||
self.create_event("Defeat Khidr"))
|
||||
else:
|
||||
@@ -227,7 +223,7 @@ class RLWorld(World):
|
||||
self.create_event("Defeat Neo Khidr"))
|
||||
|
||||
# Alexander / Alexander IV
|
||||
if self.setting("alexander") == "vanilla":
|
||||
if self.get_setting("alexander") == "vanilla":
|
||||
self.multiworld.get_location("Forest Abkhazia Boss Room", self.player).place_locked_item(
|
||||
self.create_event("Defeat Alexander"))
|
||||
else:
|
||||
@@ -235,7 +231,7 @@ class RLWorld(World):
|
||||
self.create_event("Defeat Alexander IV"))
|
||||
|
||||
# Ponce de Leon / Ponce de Freon
|
||||
if self.setting("leon") == "vanilla":
|
||||
if self.get_setting("leon") == "vanilla":
|
||||
self.multiworld.get_location("The Maya Boss Room", self.player).place_locked_item(
|
||||
self.create_event("Defeat Ponce de Leon"))
|
||||
else:
|
||||
@@ -243,7 +239,7 @@ class RLWorld(World):
|
||||
self.create_event("Defeat Ponce de Freon"))
|
||||
|
||||
# Herodotus / Astrodotus
|
||||
if self.setting("herodotus") == "vanilla":
|
||||
if self.get_setting("herodotus") == "vanilla":
|
||||
self.multiworld.get_location("Land of Darkness Boss Room", self.player).place_locked_item(
|
||||
self.create_event("Defeat Herodotus"))
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user