Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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."""
Exempt-Medic marked this conversation as resolved.
Show resolved Hide resolved
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
Loading