mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Rogue Legacy: Update to Options API (#3755)
* fix deprecation * multiworld.random -> world.random * Various small fixes --------- Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com> Co-authored-by: Exempt-Medic <ExemptMedic@Gmail.com>
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
from BaseClasses import CollectionState, MultiWorld
|
||||
from BaseClasses import CollectionState
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import RLWorld
|
||||
|
||||
|
||||
def get_upgrade_total(multiworld: MultiWorld, player: int) -> int:
|
||||
return int(multiworld.health_pool[player]) + int(multiworld.mana_pool[player]) + \
|
||||
int(multiworld.attack_pool[player]) + int(multiworld.magic_damage_pool[player])
|
||||
def get_upgrade_total(world: "RLWorld") -> int:
|
||||
return int(world.options.health_pool) + int(world.options.mana_pool) + \
|
||||
int(world.options.attack_pool) + int(world.options.magic_damage_pool)
|
||||
|
||||
|
||||
def get_upgrade_count(state: CollectionState, player: int) -> int:
|
||||
@@ -19,8 +23,8 @@ def has_upgrade_amount(state: CollectionState, player: int, amount: int) -> bool
|
||||
return get_upgrade_count(state, player) >= amount
|
||||
|
||||
|
||||
def has_upgrades_percentage(state: CollectionState, player: int, percentage: float) -> bool:
|
||||
return has_upgrade_amount(state, player, round(get_upgrade_total(state.multiworld, player) * (percentage / 100)))
|
||||
def has_upgrades_percentage(state: CollectionState, world: "RLWorld", percentage: float) -> bool:
|
||||
return has_upgrade_amount(state, world.player, round(get_upgrade_total(world) * (percentage / 100)))
|
||||
|
||||
|
||||
def has_movement_rune(state: CollectionState, player: int) -> bool:
|
||||
@@ -47,15 +51,15 @@ def has_defeated_dungeon(state: CollectionState, player: int) -> bool:
|
||||
return state.has("Defeat Herodotus", player) or state.has("Defeat Astrodotus", player)
|
||||
|
||||
|
||||
def set_rules(multiworld: MultiWorld, player: int):
|
||||
def set_rules(world: "RLWorld", player: int):
|
||||
# If 'vendors' are 'normal', then expect it to show up in the first half(ish) of the spheres.
|
||||
if multiworld.vendors[player] == "normal":
|
||||
multiworld.get_location("Forest Abkhazia Boss Reward", player).access_rule = \
|
||||
if world.options.vendors == "normal":
|
||||
world.get_location("Forest Abkhazia Boss Reward").access_rule = \
|
||||
lambda state: has_vendors(state, player)
|
||||
|
||||
# Gate each manor location so everything isn't dumped into sphere 1.
|
||||
manor_rules = {
|
||||
"Defeat Khidr" if multiworld.khidr[player] == "vanilla" else "Defeat Neo Khidr": [
|
||||
"Defeat Khidr" if world.options.khidr == "vanilla" else "Defeat Neo Khidr": [
|
||||
"Manor - Left Wing Window",
|
||||
"Manor - Left Wing Rooftop",
|
||||
"Manor - Right Wing Window",
|
||||
@@ -66,7 +70,7 @@ def set_rules(multiworld: MultiWorld, player: int):
|
||||
"Manor - Left Tree 2",
|
||||
"Manor - Right Tree",
|
||||
],
|
||||
"Defeat Alexander" if multiworld.alexander[player] == "vanilla" else "Defeat Alexander IV": [
|
||||
"Defeat Alexander" if world.options.alexander == "vanilla" else "Defeat Alexander IV": [
|
||||
"Manor - Left Big Upper 1",
|
||||
"Manor - Left Big Upper 2",
|
||||
"Manor - Left Big Windows",
|
||||
@@ -78,7 +82,7 @@ def set_rules(multiworld: MultiWorld, player: int):
|
||||
"Manor - Right Big Rooftop",
|
||||
"Manor - Right Extension",
|
||||
],
|
||||
"Defeat Ponce de Leon" if multiworld.leon[player] == "vanilla" else "Defeat Ponce de Freon": [
|
||||
"Defeat Ponce de Leon" if world.options.leon == "vanilla" else "Defeat Ponce de Freon": [
|
||||
"Manor - Right High Base",
|
||||
"Manor - Right High Upper",
|
||||
"Manor - Right High Tower",
|
||||
@@ -90,24 +94,24 @@ def set_rules(multiworld: MultiWorld, player: int):
|
||||
# Set rules for manor locations.
|
||||
for event, locations in manor_rules.items():
|
||||
for location in locations:
|
||||
multiworld.get_location(location, player).access_rule = lambda state: state.has(event, player)
|
||||
world.get_location(location).access_rule = lambda state: state.has(event, player)
|
||||
|
||||
# Set rules for fairy chests to decrease headache of expectation to find non-movement fairy chests.
|
||||
for fairy_location in [location for location in multiworld.get_locations(player) if "Fairy" in location.name]:
|
||||
for fairy_location in [location for location in world.multiworld.get_locations(player) if "Fairy" in location.name]:
|
||||
fairy_location.access_rule = lambda state: has_fairy_progression(state, player)
|
||||
|
||||
# Region rules.
|
||||
multiworld.get_entrance("Forest Abkhazia", player).access_rule = \
|
||||
lambda state: has_upgrades_percentage(state, player, 12.5) and has_defeated_castle(state, player)
|
||||
world.get_entrance("Forest Abkhazia").access_rule = \
|
||||
lambda state: has_upgrades_percentage(state, world, 12.5) and has_defeated_castle(state, player)
|
||||
|
||||
multiworld.get_entrance("The Maya", player).access_rule = \
|
||||
lambda state: has_upgrades_percentage(state, player, 25) and has_defeated_forest(state, player)
|
||||
world.get_entrance("The Maya").access_rule = \
|
||||
lambda state: has_upgrades_percentage(state, world, 25) and has_defeated_forest(state, player)
|
||||
|
||||
multiworld.get_entrance("Land of Darkness", player).access_rule = \
|
||||
lambda state: has_upgrades_percentage(state, player, 37.5) and has_defeated_tower(state, player)
|
||||
world.get_entrance("Land of Darkness").access_rule = \
|
||||
lambda state: has_upgrades_percentage(state, world, 37.5) and has_defeated_tower(state, player)
|
||||
|
||||
multiworld.get_entrance("The Fountain Room", player).access_rule = \
|
||||
lambda state: has_upgrades_percentage(state, player, 50) and has_defeated_dungeon(state, player)
|
||||
world.get_entrance("The Fountain Room").access_rule = \
|
||||
lambda state: has_upgrades_percentage(state, world, 50) and has_defeated_dungeon(state, player)
|
||||
|
||||
# Win condition.
|
||||
multiworld.completion_condition[player] = lambda state: state.has("Defeat The Fountain", player)
|
||||
world.multiworld.completion_condition[player] = lambda state: state.has("Defeat The Fountain", player)
|
||||
|
||||
Reference in New Issue
Block a user