Rogue Legacy: World folder clean up and generation improvements. (#1148)

* Minor cleanup and renaming of some files/functions.

* Rename `LegacyWorld` and `LegacyWeb` to RLWorld and RLWeb.

* Undo accidental change to comment.

* Undo accidental change to comment.

* Restructure Items.py format and combine all tables into one.

* Restructure Locations.py format and combine all tables into one.

* Split boss event items into separate boss entries.

* Remove definitions folder.

* Reformatted __init__.py for Rogue Legacy.

* Allow fairy chests to be disabled.

* Add working prefill logic for early vendors.

* Re-introduce Early Architect setting.

* Revamped rules and regions and can now generate games.

* Fix normal vendors breaking everything.

* Fix early vendor logic and add fairy chest logic to require Dragons or Enchantress + runes.

* Fix issue with duplicate items being created.

* Move event placement into __init__.py and fix duplicate Vendors.

* Tweak weights and spacing.

* Update documentation and include bug report link.

* Fix relative link for template file.

* Increase amount of chest locations in `location_table`.

* Correct a refactor rename gone wrong.

* Remove unused reference in imports.

* Tweak mistake in boss name in place_events.

* English is hard.

* Tweak some lines in __init__.py to use `.settings()` method.

* Add unique id tests for Rogue Legacy.

IDs are mixed around, so let's try to avoid accidentally using the same identifier twice.

* Fix typo in doc.

* Simplify `fill_slot_data`.

* Change prefix on `_place_events` to maintain convention.

* Remove items that are **not** progression from rules.
This commit is contained in:
Zach Parks
2022-10-29 22:15:06 -05:00
committed by GitHub
parent 09d8c4b912
commit 1cad51b1af
14 changed files with 636 additions and 728 deletions

View File

@@ -1,177 +1,86 @@
from BaseClasses import MultiWorld
from .Names import LocationName, ItemName
from BaseClasses import MultiWorld, CollectionState
from ..AutoWorld import LogicMixin
from ..generic.Rules import set_rule
class LegacyLogic(LogicMixin):
def _legacy_has_any_vendors(self, player: int) -> bool:
return self.has_any({ItemName.blacksmith, ItemName.enchantress}, player)
def has_any_vendors(self: CollectionState, player: int) -> bool:
return self.has_any({"Blacksmith", "Enchantress"}, player)
def _legacy_has_all_vendors(self, player: int) -> bool:
return self.has_all({ItemName.blacksmith, ItemName.enchantress}, player)
def has_all_vendors(self: CollectionState, player: int) -> bool:
return self.has_all({"Blacksmith", "Enchantress"}, player)
def _legacy_has_stat_upgrades(self, player: int, amount: int) -> bool:
return self._legacy_stat_upgrade_count(player) >= amount
def has_stat_upgrades(self, player: int, amount: int) -> bool:
return self.stat_upgrade_count(player) >= amount
def _legacy_total_stat_upgrades_count(self, player: int) -> int:
def total_stat_upgrades_count(self, player: int) -> int:
return int(self.world.health_pool[player]) + \
int(self.world.mana_pool[player]) + \
int(self.world.attack_pool[player]) + \
int(self.world.magic_damage_pool[player]) + \
int(self.world.armor_pool[player]) + \
int(self.world.equip_pool[player])
int(self.world.magic_damage_pool[player])
def _legacy_stat_upgrade_count(self, player: int) -> int:
return self.item_count(ItemName.health, player) + self.item_count(ItemName.mana, player) + \
self.item_count(ItemName.attack, player) + self.item_count(ItemName.magic_damage, player) + \
self.item_count(ItemName.armor, player) + self.item_count(ItemName.equip, player)
def stat_upgrade_count(self: CollectionState, player: int) -> int:
return self.item_count("Health Up", player) + self.item_count("Mana Up", player) + \
self.item_count("Attack Up", player) + self.item_count("Magic Damage Up", player)
def set_rules(world: MultiWorld, player: int):
# Check for duplicate names.
if len(set(world.additional_lady_names[player].value)) != len(world.additional_lady_names[player].value):
raise Exception(f"Duplicate values are not allowed in additional_lady_names.")
if len(set(world.additional_sir_names[player].value)) != len(world.additional_sir_names[player].value):
raise Exception(f"Duplicate values are not allowed in additional_sir_names.")
if not world.allow_default_names[player]:
# Check for quantity.
name_count = len(world.additional_lady_names[player].value)
if name_count < int(world.number_of_children[player]):
raise Exception(f"allow_default_names is off, but not enough names are defined in additional_lady_names. Expected {int(world.number_of_children[player])}, Got {name_count}")
name_count = len(world.additional_sir_names[player].value)
if name_count < int(world.number_of_children[player]):
raise Exception(f"allow_default_names is off, but not enough names are defined in additional_sir_names. Expected {int(world.number_of_children[player])}, Got {name_count}")
# Chests
if world.universal_chests[player]:
for i in range(0, world.chests_per_zone[player]):
set_rule(world.get_location(f"Chest {i + 1 + (world.chests_per_zone[player] * 1)}", player),
lambda state: state.has(ItemName.boss_castle, player))
set_rule(world.get_location(f"Chest {i + 1 + (world.chests_per_zone[player] * 2)}", player),
lambda state: state.has(ItemName.boss_forest, player))
set_rule(world.get_location(f"Chest {i + 1 + (world.chests_per_zone[player] * 3)}", player),
lambda state: state.has(ItemName.boss_tower, player))
else:
for i in range(0, world.chests_per_zone[player]):
set_rule(world.get_location(f"{LocationName.garden} - Chest {i + 1}", player),
lambda state: state.has(ItemName.boss_castle, player))
set_rule(world.get_location(f"{LocationName.tower} - Chest {i + 1}", player),
lambda state: state.has(ItemName.boss_forest, player))
set_rule(world.get_location(f"{LocationName.dungeon} - Chest {i + 1}", player),
lambda state: state.has(ItemName.boss_tower, player))
# Fairy Chests
if world.universal_fairy_chests[player]:
for i in range(0, world.fairy_chests_per_zone[player]):
set_rule(world.get_location(f"Fairy Chest {i + 1 + (world.fairy_chests_per_zone[player] * 1)}", player),
lambda state: state.has(ItemName.boss_castle, player))
set_rule(world.get_location(f"Fairy Chest {i + 1 + (world.fairy_chests_per_zone[player] * 2)}", player),
lambda state: state.has(ItemName.boss_forest, player))
set_rule(world.get_location(f"Fairy Chest {i + 1 + (world.fairy_chests_per_zone[player] * 3)}", player),
lambda state: state.has(ItemName.boss_tower, player))
else:
for i in range(0, world.fairy_chests_per_zone[player]):
set_rule(world.get_location(f"{LocationName.garden} - Fairy Chest {i + 1}", player),
lambda state: state.has(ItemName.boss_castle, player))
set_rule(world.get_location(f"{LocationName.tower} - Fairy Chest {i + 1}", player),
lambda state: state.has(ItemName.boss_forest, player))
set_rule(world.get_location(f"{LocationName.dungeon} - Fairy Chest {i + 1}", player),
lambda state: state.has(ItemName.boss_tower, player))
# Vendors
if world.vendors[player] == "early":
set_rule(world.get_location(LocationName.boss_castle, player),
lambda state: state._legacy_has_all_vendors(player))
elif world.vendors[player] == "normal":
set_rule(world.get_location(LocationName.garden, player),
lambda state: state._legacy_has_any_vendors(player))
# Diaries
for i in range(0, 5):
set_rule(world.get_location(f"Diary {i + 6}", player),
lambda state: state.has(ItemName.boss_castle, player))
set_rule(world.get_location(f"Diary {i + 11}", player),
lambda state: state.has(ItemName.boss_forest, player))
set_rule(world.get_location(f"Diary {i + 16}", player),
lambda state: state.has(ItemName.boss_tower, player))
set_rule(world.get_location(f"Diary {i + 21}", player),
lambda state: state.has(ItemName.boss_dungeon, player))
if world.vendors[player] == "normal":
set_rule(world.get_location("Forest Abkhazia Boss Reward", player),
lambda state: state.has_all_vendors(player))
# Scale each manor location.
set_rule(world.get_location(LocationName.manor_left_wing_window, player),
lambda state: state.has(ItemName.boss_castle, player))
set_rule(world.get_location(LocationName.manor_left_wing_roof, player),
lambda state: state.has(ItemName.boss_castle, player))
set_rule(world.get_location(LocationName.manor_right_wing_window, player),
lambda state: state.has(ItemName.boss_castle, player))
set_rule(world.get_location(LocationName.manor_right_wing_roof, player),
lambda state: state.has(ItemName.boss_castle, player))
set_rule(world.get_location(LocationName.manor_left_big_base, player),
lambda state: state.has(ItemName.boss_castle, player))
set_rule(world.get_location(LocationName.manor_right_big_base, player),
lambda state: state.has(ItemName.boss_castle, player))
set_rule(world.get_location(LocationName.manor_left_tree1, player),
lambda state: state.has(ItemName.boss_castle, player))
set_rule(world.get_location(LocationName.manor_left_tree2, player),
lambda state: state.has(ItemName.boss_castle, player))
set_rule(world.get_location(LocationName.manor_right_tree, player),
lambda state: state.has(ItemName.boss_castle, player))
set_rule(world.get_location(LocationName.manor_left_big_upper1, player),
lambda state: state.has(ItemName.boss_forest, player))
set_rule(world.get_location(LocationName.manor_left_big_upper2, player),
lambda state: state.has(ItemName.boss_forest, player))
set_rule(world.get_location(LocationName.manor_left_big_windows, player),
lambda state: state.has(ItemName.boss_forest, player))
set_rule(world.get_location(LocationName.manor_left_big_roof, player),
lambda state: state.has(ItemName.boss_forest, player))
set_rule(world.get_location(LocationName.manor_left_far_base, player),
lambda state: state.has(ItemName.boss_forest, player))
set_rule(world.get_location(LocationName.manor_left_far_roof, player),
lambda state: state.has(ItemName.boss_forest, player))
set_rule(world.get_location(LocationName.manor_left_extension, player),
lambda state: state.has(ItemName.boss_forest, player))
set_rule(world.get_location(LocationName.manor_right_big_upper, player),
lambda state: state.has(ItemName.boss_forest, player))
set_rule(world.get_location(LocationName.manor_right_big_roof, player),
lambda state: state.has(ItemName.boss_forest, player))
set_rule(world.get_location(LocationName.manor_right_extension, player),
lambda state: state.has(ItemName.boss_forest, player))
set_rule(world.get_location(LocationName.manor_right_high_base, player),
lambda state: state.has(ItemName.boss_tower, player))
set_rule(world.get_location(LocationName.manor_right_high_upper, player),
lambda state: state.has(ItemName.boss_tower, player))
set_rule(world.get_location(LocationName.manor_right_high_tower, player),
lambda state: state.has(ItemName.boss_tower, player))
set_rule(world.get_location(LocationName.manor_observatory_base, player),
lambda state: state.has(ItemName.boss_tower, player))
set_rule(world.get_location(LocationName.manor_observatory_scope, player),
lambda state: state.has(ItemName.boss_tower, player))
manor_rules = {
"Defeat Khidr" if world.khidr[player] == "vanilla" else "Defeat Neo Khidr": [
"Manor - Left Wing Window",
"Manor - Left Wing Rooftop",
"Manor - Right Wing Window",
"Manor - Right Wing Rooftop",
"Manor - Left Big Base",
"Manor - Right Big Base",
"Manor - Left Tree 1",
"Manor - Left Tree 2",
"Manor - Right Tree",
],
"Defeat Alexander" if world.alexander[player] == "vanilla" else "Defeat Alexander IV": [
"Manor - Left Big Upper 1",
"Manor - Left Big Upper 2",
"Manor - Left Big Windows",
"Manor - Left Big Rooftop",
"Manor - Left Far Base",
"Manor - Left Far Roof",
"Manor - Left Extension",
"Manor - Right Big Upper",
"Manor - Right Big Rooftop",
"Manor - Right Extension",
],
"Defeat Ponce de Leon" if world.leon[player] == "vanilla" else "Defeat Ponce de Freon": [
"Manor - Right High Base",
"Manor - Right High Upper",
"Manor - Right High Tower",
"Manor - Observatory Base",
"Manor - Observatory Telescope",
]
}
for event, locations in manor_rules.items():
for location in locations:
set_rule(world.get_location(location, player), lambda state: state.has(event, player))
# Standard Zone Progression
set_rule(world.get_location(LocationName.garden, player),
lambda state: state._legacy_has_stat_upgrades(player, 0.125 * state._legacy_total_stat_upgrades_count(player)) and state.has(ItemName.boss_castle, player))
set_rule(world.get_location(LocationName.tower, player),
lambda state: state._legacy_has_stat_upgrades(player, 0.3125 * state._legacy_total_stat_upgrades_count(player)) and state.has(ItemName.boss_forest, player))
set_rule(world.get_location(LocationName.dungeon, player),
lambda state: state._legacy_has_stat_upgrades(player, 0.5 * state._legacy_total_stat_upgrades_count(player)) and state.has(ItemName.boss_tower, player))
world.get_entrance("Forest Abkhazia", player).access_rule = \
(lambda state: state.has_stat_upgrades(player, 0.125 * state.total_stat_upgrades_count(player)) and
(state.has("Defeat Khidr", player) or state.has("Defeat Neo Khidr", player)))
world.get_entrance("The Maya", player).access_rule = \
(lambda state: state.has_stat_upgrades(player, 0.25 * state.total_stat_upgrades_count(player)) and
(state.has("Defeat Alexander", player) or state.has("Defeat Alexander IV", player)))
world.get_entrance("Land of Darkness", player).access_rule = \
(lambda state: state.has_stat_upgrades(player, 0.375 * state.total_stat_upgrades_count(player)) and
(state.has("Defeat Ponce de Leon", player) or state.has("Defeat Ponce de Freon", player)))
world.get_entrance("The Fountain Room", player).access_rule = \
(lambda state: state.has_stat_upgrades(player, 0.5 * state.total_stat_upgrades_count(player)) and
(state.has("Defeat Herodotus", player) or state.has("Defeat Astrodotus", player)))
# Bosses
set_rule(world.get_location(LocationName.boss_castle, player),
lambda state: state.has(ItemName.boss_castle, player))
set_rule(world.get_location(LocationName.boss_forest, player),
lambda state: state.has(ItemName.boss_forest, player))
set_rule(world.get_location(LocationName.boss_tower, player),
lambda state: state.has(ItemName.boss_tower, player))
set_rule(world.get_location(LocationName.boss_dungeon, player),
lambda state: state.has(ItemName.boss_dungeon, player))
set_rule(world.get_location(LocationName.fountain, player),
lambda state: state._legacy_has_stat_upgrades(player, 0.625 * state._legacy_total_stat_upgrades_count(player))
and state.has(ItemName.boss_castle, player)
and state.has(ItemName.boss_forest, player)
and state.has(ItemName.boss_tower, player)
and state.has(ItemName.boss_dungeon, player))
world.completion_condition[player] = lambda state: state.has(ItemName.boss_fountain, player)
world.completion_condition[player] = lambda state: state.has("Defeat The Fountain", player)