Skip to content

Commit

Permalink
Zillion: new map generation feature (#3604)
Browse files Browse the repository at this point in the history
  • Loading branch information
beauxq authored Jul 3, 2024
1 parent 95110c4 commit 50f7a79
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
6 changes: 3 additions & 3 deletions worlds/zillion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ def generate_early(self) -> None:
self._item_counts = item_counts

with redirect_stdout(self.lsi): # type: ignore
self.zz_system.make_randomizer(zz_op)

self.zz_system.seed(self.multiworld.seed)
self.zz_system.set_options(zz_op)
self.zz_system.seed(self.random.randrange(1999999999))
self.zz_system.make_map()
self.zz_system.make_randomizer()

# just in case the options changed anything (I don't think they do)
assert self.zz_system.randomizer, "init failed"
Expand Down
34 changes: 26 additions & 8 deletions worlds/zillion/options.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from collections import Counter
from dataclasses import dataclass
from typing import ClassVar, Dict, Tuple
from typing import ClassVar, Dict, Literal, Tuple
from typing_extensions import TypeGuard # remove when Python >= 3.10

from Options import Choice, DefaultOnToggle, NamedRange, OptionGroup, PerGameCommonOptions, Range, Toggle
from Options import Choice, DefaultOnToggle, NamedRange, OptionGroup, PerGameCommonOptions, Range, Removed, Toggle

from zilliandomizer.options import (
Options as ZzOptions, char_to_gun, char_to_jump, ID,
Expand Down Expand Up @@ -251,9 +251,25 @@ class ZillionStartingCards(NamedRange):
}


class ZillionRoomGen(Toggle):
""" whether to generate rooms with random terrain """
display_name = "room generation"
class ZillionMapGen(Choice):
"""
- none: vanilla map
- rooms: random terrain inside rooms, but path through base is vanilla
- full: random path through base
"""
display_name = "map generation"
option_none = 0
option_rooms = 1
option_full = 2
default = 0

def zz_value(self) -> Literal['none', 'rooms', 'full']:
if self.value == ZillionMapGen.option_none:
return "none"
if self.value == ZillionMapGen.option_rooms:
return "rooms"
assert self.value == ZillionMapGen.option_full
return "full"


@dataclass
Expand All @@ -276,7 +292,9 @@ class ZillionOptions(PerGameCommonOptions):
early_scope: ZillionEarlyScope
skill: ZillionSkill
starting_cards: ZillionStartingCards
room_gen: ZillionRoomGen
map_gen: ZillionMapGen

room_gen: Removed


z_option_groups = [
Expand Down Expand Up @@ -375,7 +393,7 @@ def validate(options: ZillionOptions) -> "Tuple[ZzOptions, Counter[str]]":

starting_cards = options.starting_cards

room_gen = options.room_gen
map_gen = options.map_gen.zz_value()

zz_item_counts = convert_item_counts(item_counts)
zz_op = ZzOptions(
Expand All @@ -393,7 +411,7 @@ def validate(options: ZillionOptions) -> "Tuple[ZzOptions, Counter[str]]":
bool(options.early_scope.value),
True, # balance defense
starting_cards.value,
bool(room_gen.value)
map_gen
)
zz_validate(zz_op)
return zz_op, item_counts
2 changes: 1 addition & 1 deletion worlds/zillion/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
zilliandomizer @ git+https://github.com/beauxq/zilliandomizer@1dd2ce01c9d818caba5844529699b3ad026d6a07#0.7.1
zilliandomizer @ git+https://github.com/beauxq/zilliandomizer@4a2fec0aa1c529df866e510cdfcf6dca4d53679b#0.8.0
typing-extensions>=4.7, <5

0 comments on commit 50f7a79

Please sign in to comment.