Skip to content

Commit

Permalink
Spire: Convert options, clean up random calls, and add DeathLink (Arc…
Browse files Browse the repository at this point in the history
…hipelagoMW#3704)

* Convert StS options

* probably a bad idea

* Update worlds/spire/Options.py

Co-authored-by: Scipio Wright <[email protected]>

---------

Co-authored-by: Kono Tyran <[email protected]>
Co-authored-by: Scipio Wright <[email protected]>
  • Loading branch information
3 people authored and agilbert1412 committed Aug 24, 2024
1 parent 31d35e5 commit ecdd3be
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
25 changes: 18 additions & 7 deletions worlds/spire/Options.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import typing
from Options import TextChoice, Option, Range, Toggle
from dataclasses import dataclass

from Options import TextChoice, Range, Toggle, PerGameCommonOptions


class Character(TextChoice):
Expand Down Expand Up @@ -55,9 +57,18 @@ class Downfall(Toggle):
default = 0


spire_options: typing.Dict[str, type(Option)] = {
"character": Character,
"ascension": Ascension,
"final_act": FinalAct,
"downfall": Downfall,
}
class DeathLink(Range):
"""Percentage of health to lose when a death link is received."""
display_name = "Death Link %"
range_start = 0
range_end = 100
default = 0


@dataclass
class SpireOptions(PerGameCommonOptions):
character: Character
ascension: Ascension
final_act: FinalAct
downfall: Downfall
death_link: DeathLink
13 changes: 6 additions & 7 deletions worlds/spire/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from BaseClasses import Entrance, Item, ItemClassification, Location, MultiWorld, Region, Tutorial
from .Items import event_item_pairs, item_pool, item_table
from .Locations import location_table
from .Options import spire_options
from .Options import SpireOptions
from .Regions import create_regions
from .Rules import set_rules
from ..AutoWorld import WebWorld, World
Expand All @@ -27,7 +27,8 @@ class SpireWorld(World):
immense power, and Slay the Spire!
"""

option_definitions = spire_options
options_dataclass = SpireOptions
options: SpireOptions
game = "Slay the Spire"
topology_present = False
web = SpireWeb()
Expand Down Expand Up @@ -63,15 +64,13 @@ def create_regions(self):

def fill_slot_data(self) -> dict:
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:
option = getattr(self.multiworld, option_name)[self.player]
slot_data[option_name] = option.value
slot_data.update(self.options.as_dict("character", "ascension", "final_act", "downfall", "death_link"))
return slot_data

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):
Expand Down

0 comments on commit ecdd3be

Please sign in to comment.