Files
dockipelago/worlds/kdl3/options.py
Jonathan Tinney 7971961166
Some checks failed
Analyze modified files / flake8 (push) Failing after 2m28s
Build / build-win (push) Has been cancelled
Build / build-ubuntu2204 (push) Has been cancelled
ctest / Test C++ ubuntu-latest (push) Has been cancelled
ctest / Test C++ windows-latest (push) Has been cancelled
Analyze modified files / mypy (push) Has been cancelled
Build and Publish Docker Images / Push Docker image to Docker Hub (push) Successful in 5m4s
Native Code Static Analysis / scan-build (push) Failing after 5m2s
type check / pyright (push) Successful in 1m7s
unittests / Test Python 3.11.2 ubuntu-latest (push) Failing after 16m23s
unittests / Test Python 3.12 ubuntu-latest (push) Failing after 28m19s
unittests / Test Python 3.13 ubuntu-latest (push) Failing after 14m49s
unittests / Test hosting with 3.13 on ubuntu-latest (push) Successful in 5m0s
unittests / Test Python 3.13 macos-latest (push) Has been cancelled
unittests / Test Python 3.11 windows-latest (push) Has been cancelled
unittests / Test Python 3.13 windows-latest (push) Has been cancelled
add schedule I, sonic 1/frontiers/heroes, spirit island
2026-04-02 23:46:36 -07:00

463 lines
14 KiB
Python

import random
from dataclasses import dataclass
from typing import List
from Options import DeathLinkMixin, Choice, Toggle, OptionDict, Range, PlandoBosses, DefaultOnToggle, \
PerGameCommonOptions, Visibility, NamedRange, OptionGroup, PlandoConnections, OptionCounter
from .names import location_name
class RemoteItems(DefaultOnToggle):
"""
Enables receiving items from your own world, primarily for co-op play.
"""
display_name = "Remote Items"
class KDL3PlandoConnections(PlandoConnections):
entrances = exits = {f"{i} {j}" for i in location_name.level_names for j in range(1, 7)}
class Goal(Choice):
"""
Zero: collect the Heart Stars, and defeat Zero in the Hyper Zone.
Boss Butch: collect the Heart Stars, and then complete the boss rematches in the Boss Butch mode.
MG5: collect the Heart Stars, and then complete a perfect run through the minigame gauntlet within the Super MG5
Jumping: collect the Heart Stars, and then reach a designated score within the Jumping sub-game
"""
display_name = "Goal"
option_zero = 0
option_boss_butch = 1
option_MG5 = 2
option_jumping = 3
default = 0
@classmethod
def get_option_name(cls, value: int) -> str:
if value == 2:
return cls.name_lookup[value].upper()
return super().get_option_name(value)
class GoalSpeed(Choice):
"""
Normal: the goal is unlocked after purifying the five bosses
Fast: the goal is unlocked after acquiring the target number of Heart Stars
"""
display_name = "Goal Speed"
option_normal = 0
option_fast = 1
class MaxHeartStars(Range):
"""
Maximum number of heart stars to include in the pool of items.
If fewer available locations exist in the pool than this number, the number of available locations will be used instead.
"""
display_name = "Max Heart Stars"
range_start = 5 # set to 5 so strict bosses does not degrade
range_end = 99 # previously set to 50, set to highest it can be should there be less locations than heart stars
default = 30
class HeartStarsRequired(Range):
"""
Percentage of heart stars required to purify the five bosses and reach Zero.
Each boss will require a differing amount of heart stars to purify.
"""
display_name = "Required Heart Stars"
range_start = 1
range_end = 100
default = 50
class LevelShuffle(Choice):
"""
None: No stage shuffling.
Same World: shuffles stages around their world.
Pattern: shuffles stages according to the stage pattern (stage 3 will always be a minigame stage, etc.)
Shuffled: shuffles stages across all worlds.
"""
display_name = "Stage Shuffle"
option_none = 0
option_same_world = 1
option_pattern = 2
option_shuffled = 3
default = 0
class DoorShuffle(Toggle):
"""
Shuffles the connections between doors. The Heart Star for each level will remain the same.
"""
display_name = "Door Shuffle"
class BossShuffle(PlandoBosses):
"""
None: Bosses will remain in their vanilla locations
Shuffled: Bosses will be shuffled amongst each other
Full: Bosses will be randomized
Singularity: All (non-Zero) bosses will be replaced with a single boss
Supports plando placement.
"""
bosses = frozenset(location_name.boss_names.keys())
locations = frozenset(location_name.level_names.keys())
duplicate_bosses = True
@classmethod
def can_place_boss(cls, boss: str, location: str) -> bool:
# Kirby has no logic about requiring bosses in specific locations (since we load in their stage)
return True
display_name = "Boss Shuffle"
option_none = 0
option_shuffled = 1
option_full = 2
option_singularity = 3
class BossShuffleAllowBB(Choice):
"""
Allow Boss Butch variants of bosses in Boss Shuffle.
Enabled: any boss placed will have a 50% chance of being the Boss Butch variant, including bosses not present
Enforced: all bosses will be their Boss Butch variant.
Boss Butch boss changes are only visual.
"""
display_name = "Allow Boss Butch Bosses"
option_disabled = 0
option_enabled = 1
option_enforced = 2
default = 0
class AnimalRandomization(Choice):
"""
Disabled: all animal positions will be vanilla.
Shuffled: all animal positions will be shuffled amongst each other.
Full: random animals will be placed across the levels. At least one of each animal is guaranteed.
"""
display_name = "Animal Randomization"
option_disabled = 0
option_shuffled = 1
option_full = 2
default = 0
class CopyAbilityRandomization(Choice):
"""
Disabled: enemies give regular copy abilities and health.
Enabled: all enemies will have the copy ability received from them randomized.
Enabled Plus Minus: enemies (except minibosses) can additionally give you anywhere from +2 health to -1 health when eaten.
"""
display_name = "Copy Ability Randomization"
option_disabled = 0
option_enabled = 1
option_enabled_plus_minus = 2
class StrictBosses(DefaultOnToggle):
"""
If enabled, one will not be able to move onto the next world until the previous world's boss has been purified.
"""
display_name = "Strict Bosses"
class OpenWorld(DefaultOnToggle):
"""
If enabled, all 6 stages will be unlocked upon entering a world for the first time. A certain amount of stages
will need to be completed in order to unlock the bosses
"""
display_name = "Open World"
class OpenWorldBossRequirement(Range):
"""
The amount of stages completed needed to unlock the boss of a world when Open World is turned on.
"""
display_name = "Open World Boss Requirement"
range_start = 1
range_end = 6
default = 3
class BossRequirementRandom(Toggle):
"""
If enabled, boss purification will require a random amount of Heart Stars. Depending on options, this may have
boss purification unlock in a random order.
"""
display_name = "Randomize Purification Requirement"
class JumpingTarget(Range):
"""
The required score needed to complete the Jumping minigame.
"""
display_name = "Jumping Target Score"
range_start = 1
range_end = 25
default = 10
class GameLanguage(Choice):
"""
The language that the game should display. This does not have to match the given rom.
"""
display_name = "Game Language"
option_japanese = 0
option_english = 1
default = 1
class FillerPercentage(Range):
"""
Percentage of non-required Heart Stars to be converted to filler items (1-Ups, Maxim Tomatoes, Invincibility Candy).
"""
display_name = "Filler Percentage"
range_start = 0
range_end = 100
default = 50
class TrapPercentage(Range):
"""
Percentage of filler items to be converted to trap items (Gooey Bags, Slowness, Eject Ability, etc).
"""
display_name = "Trap Percentage"
range_start = 0
range_end = 100
default = 50
class TrapWeights(OptionCounter):
"""
Relative weights for each individual trap item to appear when a trap item is created.
"""
max = 100
min = 0
display_name = "Trap Weights"
valid_keys = frozenset({"Gooey Bag", "Eject Ability", "Slowness", "Fast Trap", "Ice Trap", "Push Trap"})
default = {
key: 50 for key in valid_keys
}
class ConsumableChecks(Toggle):
"""
When enabled, adds all 1-Ups and Maxim Tomatoes as possible locations.
"""
display_name = "Consumable-sanity"
class StarChecks(Toggle):
"""
When enabled, every star in a given stage will become a check.
Will increase the possible filler pool to include 1/3/5 stars.
"""
display_name = "Starsanity"
class KirbyFlavorPreset(Choice):
"""
The color of Kirby, from a list of presets.
"""
display_name = "Kirby Flavor"
option_default = 0
option_bubblegum = 1
option_cherry = 2
option_blueberry = 3
option_lemon = 4
option_kiwi = 5
option_grape = 6
option_chocolate = 7
option_marshmallow = 8
option_licorice = 9
option_watermelon = 10
option_orange = 11
option_lime = 12
option_lavender = 13
option_miku = 14
option_custom = -1
default = 0
@classmethod
def from_text(cls, text: str) -> Choice:
text = text.lower()
if text == "random":
choice_list = list(cls.name_lookup)
choice_list.remove(-1)
return cls(random.choice(choice_list))
return super().from_text(text)
class KirbyFlavor(OptionDict):
"""
A custom color for Kirby. To use a custom color, set the preset to Custom and then define a dict of keys from "1" to
"15", with their values being an HTML hex color.
"""
display_name = "Custom Kirby Flavor"
default = {
"1": "B01810",
"2": "F0E0E8",
"3": "C8A0A8",
"4": "A87070",
"5": "E02018",
"6": "F0A0B8",
"7": "D07880",
"8": "A85048",
"9": "E8D0D0",
"10": "E85048",
"11": "D0C0C0",
"12": "B08888",
"13": "E87880",
"14": "F8F8F8",
"15": "B03830",
}
visibility = Visibility.template | Visibility.spoiler # likely never supported on guis
class GooeyFlavorPreset(Choice):
"""
The color of Gooey, from a list of presets.
"""
display_name = "Gooey Flavor"
option_default = 0
option_bubblegum = 1
option_cherry = 2
option_blueberry = 3
option_lemon = 4
option_kiwi = 5
option_grape = 6
option_chocolate = 7
option_marshmallow = 8
option_licorice = 9
option_watermelon = 10
option_orange = 11
option_lime = 12
option_lavender = 13
option_custom = -1
default = 0
@classmethod
def from_text(cls, text: str) -> Choice:
text = text.lower()
if text == "random":
choice_list = list(cls.name_lookup)
choice_list.remove(-1)
return cls(random.choice(choice_list))
return super().from_text(text)
class GooeyFlavor(OptionDict):
"""
A custom color for Gooey. To use a custom color, set the preset to Custom and then define a dict of keys from "1" to
"15", with their values being an HTML hex color.
"""
display_name = "Custom Gooey Flavor"
default = {
"1": "000808",
"2": "102838",
"3": "183048",
"4": "183878",
"5": "1838A0",
"6": "B01810",
"7": "E85048",
"8": "D0C0C0",
"9": "F8F8F8",
}
visibility = Visibility.template | Visibility.spoiler # likely never supported on guis
class MusicShuffle(Choice):
"""
None: default music will play
Shuffled: music will be shuffled amongst each other
Full: random music will play in each room
Note that certain songs will not be chosen in shuffled or full
"""
display_name = "Music Randomization"
option_none = 0
option_shuffled = 1
option_full = 2
default = 0
class VirtualConsoleChanges(Choice):
"""
Adds the ability to enable 2 of the Virtual Console changes.
Flash Reduction: reduces the flashing during the Zero battle.
Color Changes: changes the color of the background within the Zero Boss Butch rematch.
"""
display_name = "Virtual Console Changes"
option_none = 0
option_flash_reduction = 1
option_color_changes = 2
option_both = 3
default = 1
class Gifting(Toggle):
"""
When enabled, the goal game item will be sent to other compatible games as a gift,
and you can receive gifts from other players. This can be enabled during gameplay
using the client.
"""
display_name = "Gifting"
class TrapLink(Toggle):
"""
When enabled, traps you receive will be shared across compatible games, and you
will receive equivalent traps when other TrapLink players receive trap items.
"""
display_name = "TrapLink"
@dataclass
class KDL3Options(PerGameCommonOptions, DeathLinkMixin):
remote_items: RemoteItems
plando_connections: KDL3PlandoConnections
game_language: GameLanguage
goal: Goal
goal_speed: GoalSpeed
max_heart_stars: MaxHeartStars
heart_stars_required: HeartStarsRequired
filler_percentage: FillerPercentage
trap_percentage: TrapPercentage
trap_weights: TrapWeights
jumping_target: JumpingTarget
stage_shuffle: LevelShuffle
door_shuffle: DoorShuffle
boss_shuffle: BossShuffle
allow_bb: BossShuffleAllowBB
animal_randomization: AnimalRandomization
copy_ability_randomization: CopyAbilityRandomization
strict_bosses: StrictBosses
open_world: OpenWorld
ow_boss_requirement: OpenWorldBossRequirement
boss_requirement_random: BossRequirementRandom
consumables: ConsumableChecks
starsanity: StarChecks
trap_link: TrapLink
gifting: Gifting
kirby_flavor_preset: KirbyFlavorPreset
kirby_flavor: KirbyFlavor
gooey_flavor_preset: GooeyFlavorPreset
gooey_flavor: GooeyFlavor
music_shuffle: MusicShuffle
virtual_console: VirtualConsoleChanges
kdl3_option_groups: List[OptionGroup] = [
OptionGroup("Goal Options", [Goal, GoalSpeed, MaxHeartStars, HeartStarsRequired, JumpingTarget, ]),
OptionGroup("World Options", [RemoteItems, StrictBosses, OpenWorld, OpenWorldBossRequirement, ConsumableChecks,
StarChecks, FillerPercentage, TrapPercentage, TrapWeights, LevelShuffle, DoorShuffle,
BossShuffle, AnimalRandomization, CopyAbilityRandomization, BossRequirementRandom,
Gifting, TrapLink, ]),
OptionGroup("Cosmetic Options", [GameLanguage, BossShuffleAllowBB, KirbyFlavorPreset, KirbyFlavor,
GooeyFlavorPreset, GooeyFlavor, MusicShuffle, VirtualConsoleChanges, ]),
]