Spire: Convert options, clean up random calls, and add DeathLink (#3704)

* Convert StS options

* probably a bad idea

* Update worlds/spire/Options.py

Co-authored-by: Scipio Wright <scipiowright@gmail.com>

---------

Co-authored-by: Kono Tyran <Kono@koifysh.dev>
Co-authored-by: Scipio Wright <scipiowright@gmail.com>
This commit is contained in:
Exempt-Medic 2024-07-31 12:27:35 -04:00 committed by GitHub
parent 75b8c7891c
commit 4620493828
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 14 deletions

View File

@ -1,5 +1,7 @@
import typing import typing
from Options import TextChoice, Option, Range, Toggle from dataclasses import dataclass
from Options import TextChoice, Range, Toggle, PerGameCommonOptions
class Character(TextChoice): class Character(TextChoice):
@ -55,9 +57,18 @@ class Downfall(Toggle):
default = 0 default = 0
spire_options: typing.Dict[str, type(Option)] = { class DeathLink(Range):
"character": Character, """Percentage of health to lose when a death link is received."""
"ascension": Ascension, display_name = "Death Link %"
"final_act": FinalAct, range_start = 0
"downfall": Downfall, range_end = 100
} default = 0
@dataclass
class SpireOptions(PerGameCommonOptions):
character: Character
ascension: Ascension
final_act: FinalAct
downfall: Downfall
death_link: DeathLink

View File

@ -3,7 +3,7 @@ import string
from BaseClasses import Entrance, Item, ItemClassification, Location, MultiWorld, Region, Tutorial from BaseClasses import Entrance, Item, ItemClassification, Location, MultiWorld, Region, Tutorial
from .Items import event_item_pairs, item_pool, item_table from .Items import event_item_pairs, item_pool, item_table
from .Locations import location_table from .Locations import location_table
from .Options import spire_options from .Options import SpireOptions
from .Regions import create_regions from .Regions import create_regions
from .Rules import set_rules from .Rules import set_rules
from ..AutoWorld import WebWorld, World from ..AutoWorld import WebWorld, World
@ -27,7 +27,8 @@ class SpireWorld(World):
immense power, and Slay the Spire! immense power, and Slay the Spire!
""" """
option_definitions = spire_options options_dataclass = SpireOptions
options: SpireOptions
game = "Slay the Spire" game = "Slay the Spire"
topology_present = False topology_present = False
web = SpireWeb() web = SpireWeb()
@ -63,15 +64,13 @@ class SpireWorld(World):
def fill_slot_data(self) -> dict: def fill_slot_data(self) -> dict:
slot_data = { slot_data = {
'seed': "".join(self.multiworld.per_slot_randoms[self.player].choice(string.ascii_letters) for i in range(16)) 'seed': "".join(self.random.choice(string.ascii_letters) for i in range(16))
} }
for option_name in spire_options: slot_data.update(self.options.as_dict("character", "ascension", "final_act", "downfall", "death_link"))
option = getattr(self.multiworld, option_name)[self.player]
slot_data[option_name] = option.value
return slot_data return slot_data
def get_filler_item_name(self) -> str: def get_filler_item_name(self) -> str:
return self.multiworld.random.choice(["Card Draw", "Card Draw", "Card Draw", "Relic", "Relic"]) return self.random.choice(["Card Draw", "Card Draw", "Card Draw", "Relic", "Relic"])
def create_region(world: MultiWorld, player: int, name: str, locations=None, exits=None): def create_region(world: MultiWorld, player: int, name: str, locations=None, exits=None):