V6: Use new options api (#2668)
* v6: Use new options API * v6: Add display names for some options
This commit is contained in:
parent
fe3bc8d6be
commit
d000b52ae0
|
@ -1,8 +1,10 @@
|
|||
import typing
|
||||
from Options import Option, DeathLink, Range, Toggle
|
||||
from dataclasses import dataclass
|
||||
from Options import Option, DeathLink, Range, Toggle, PerGameCommonOptions
|
||||
|
||||
class DoorCost(Range):
|
||||
"""Amount of Trinkets required to enter Areas. Set to 0 to disable artificial locks."""
|
||||
display_name = "Door Cost"
|
||||
range_start = 0
|
||||
range_end = 3
|
||||
default = 3
|
||||
|
@ -13,6 +15,7 @@ class AreaCostRandomizer(Toggle):
|
|||
|
||||
class DeathLinkAmnesty(Range):
|
||||
"""Amount of Deaths to take before sending a DeathLink signal, for balancing difficulty"""
|
||||
display_name = "Death Link Amnesty"
|
||||
range_start = 0
|
||||
range_end = 30
|
||||
default = 15
|
||||
|
@ -25,11 +28,11 @@ class MusicRandomizer(Toggle):
|
|||
"""Randomize Music"""
|
||||
display_name = "Music Randomizer"
|
||||
|
||||
v6_options: typing.Dict[str,type(Option)] = {
|
||||
"MusicRandomizer": MusicRandomizer,
|
||||
"AreaRandomizer": AreaRandomizer,
|
||||
"DoorCost": DoorCost,
|
||||
"AreaCostRandomizer": AreaCostRandomizer,
|
||||
"death_link": DeathLink,
|
||||
"DeathLinkAmnesty": DeathLinkAmnesty
|
||||
}
|
||||
@dataclass
|
||||
class V6Options(PerGameCommonOptions):
|
||||
music_rando: MusicRandomizer
|
||||
area_rando: AreaRandomizer
|
||||
door_cost: DoorCost
|
||||
area_cost: AreaCostRandomizer
|
||||
death_link: DeathLink
|
||||
death_link_amnesty: DeathLinkAmnesty
|
||||
|
|
|
@ -31,14 +31,3 @@ def create_regions(world: MultiWorld, player: int):
|
|||
locWrp_names = ["Edge Games"]
|
||||
regWrp.locations += [V6Location(player, loc_name, location_table[loc_name], regWrp) for loc_name in locWrp_names]
|
||||
world.regions.append(regWrp)
|
||||
|
||||
|
||||
def connect_regions(world: MultiWorld, player: int, source: str, target: str, rule):
|
||||
sourceRegion = world.get_region(source, player)
|
||||
targetRegion = world.get_region(target, player)
|
||||
|
||||
connection = Entrance(player,'', sourceRegion)
|
||||
connection.access_rule = rule
|
||||
|
||||
sourceRegion.exits.append(connection)
|
||||
connection.connect(targetRegion)
|
|
@ -1,6 +1,6 @@
|
|||
import typing
|
||||
from ..generic.Rules import add_rule
|
||||
from .Regions import connect_regions, v6areas
|
||||
from .Regions import v6areas
|
||||
|
||||
|
||||
def _has_trinket_range(state, player, start, end) -> bool:
|
||||
|
@ -10,34 +10,36 @@ def _has_trinket_range(state, player, start, end) -> bool:
|
|||
return True
|
||||
|
||||
|
||||
def set_rules(world, player, area_connections: typing.Dict[int, int], area_cost_map: typing.Dict[int, int]):
|
||||
def set_rules(multiworld, options, player, area_connections: typing.Dict[int, int], area_cost_map: typing.Dict[int, int]):
|
||||
areashuffle = list(range(len(v6areas)))
|
||||
if world.AreaRandomizer[player].value:
|
||||
world.random.shuffle(areashuffle)
|
||||
if options.area_rando:
|
||||
multiworld.random.shuffle(areashuffle)
|
||||
area_connections.update({(index + 1): (value + 1) for index, value in enumerate(areashuffle)})
|
||||
area_connections.update({0: 0})
|
||||
if world.AreaCostRandomizer[player].value:
|
||||
world.random.shuffle(areashuffle)
|
||||
if options.area_cost:
|
||||
multiworld.random.shuffle(areashuffle)
|
||||
area_cost_map.update({(index + 1): (value + 1) for index, value in enumerate(areashuffle)})
|
||||
area_cost_map.update({0: 0})
|
||||
|
||||
menu_region = multiworld.get_region("Menu", player)
|
||||
for i in range(1, 5):
|
||||
connect_regions(world, player, "Menu", v6areas[area_connections[i] - 1],
|
||||
lambda state, i=i: _has_trinket_range(state, player,
|
||||
world.DoorCost[player].value * (area_cost_map[i] - 1),
|
||||
world.DoorCost[player].value * area_cost_map[i]))
|
||||
target_region = multiworld.get_region(v6areas[area_connections[i] - 1], player)
|
||||
menu_region.connect(connecting_region=target_region,
|
||||
rule=lambda state, i=i: _has_trinket_range(state, player,
|
||||
options.door_cost * (area_cost_map[i] - 1),
|
||||
options.door_cost * area_cost_map[i]))
|
||||
|
||||
# Special Rule for V
|
||||
add_rule(world.get_location("V", player), lambda state: state.can_reach("Laboratory", 'Region', player) and
|
||||
add_rule(multiworld.get_location("V", player), lambda state: state.can_reach("Laboratory", 'Region', player) and
|
||||
state.can_reach("The Tower", 'Region', player) and
|
||||
state.can_reach("Space Station 2", 'Region', player) and
|
||||
state.can_reach("Warp Zone", 'Region', player))
|
||||
|
||||
# Special Rule for NPC Trinket
|
||||
add_rule(world.get_location("NPC Trinket", player),
|
||||
add_rule(multiworld.get_location("NPC Trinket", player),
|
||||
lambda state: state.can_reach("Laboratory", 'Region', player) or
|
||||
(state.can_reach("The Tower", 'Region', player) and
|
||||
state.can_reach("Space Station 2", 'Region', player) and
|
||||
state.can_reach("Warp Zone", 'Region', player)))
|
||||
|
||||
world.completion_condition[player] = lambda state: state.can_reach("V", 'Location', player)
|
||||
multiworld.completion_condition[player] = lambda state: state.can_reach("V", 'Location', player)
|
||||
|
|
|
@ -2,7 +2,7 @@ import typing
|
|||
import os, json
|
||||
from .Items import item_table, V6Item
|
||||
from .Locations import location_table, V6Location
|
||||
from .Options import v6_options
|
||||
from .Options import V6Options
|
||||
from .Rules import set_rules
|
||||
from .Regions import create_regions
|
||||
from BaseClasses import Item, ItemClassification, Tutorial
|
||||
|
@ -41,7 +41,7 @@ class V6World(World):
|
|||
|
||||
music_map: typing.Dict[int,int]
|
||||
|
||||
option_definitions = v6_options
|
||||
options_dataclass = V6Options
|
||||
|
||||
def create_regions(self):
|
||||
create_regions(self.multiworld, self.player)
|
||||
|
@ -49,7 +49,7 @@ class V6World(World):
|
|||
def set_rules(self):
|
||||
self.area_connections = {}
|
||||
self.area_cost_map = {}
|
||||
set_rules(self.multiworld, self.player, self.area_connections, self.area_cost_map)
|
||||
set_rules(self.multiworld, self.options, self.player, self.area_connections, self.area_cost_map)
|
||||
|
||||
def create_item(self, name: str) -> Item:
|
||||
return V6Item(name, ItemClassification.progression, item_table[name], self.player)
|
||||
|
@ -61,7 +61,7 @@ class V6World(World):
|
|||
def generate_basic(self):
|
||||
musiclist_o = [1,2,3,4,9,12]
|
||||
musiclist_s = musiclist_o.copy()
|
||||
if self.multiworld.MusicRandomizer[self.player].value:
|
||||
if self.options.music_rando:
|
||||
self.multiworld.random.shuffle(musiclist_s)
|
||||
self.music_map = dict(zip(musiclist_o, musiclist_s))
|
||||
|
||||
|
@ -69,10 +69,10 @@ class V6World(World):
|
|||
return {
|
||||
"MusicRando": self.music_map,
|
||||
"AreaRando": self.area_connections,
|
||||
"DoorCost": self.multiworld.DoorCost[self.player].value,
|
||||
"DoorCost": self.options.door_cost.value,
|
||||
"AreaCostRando": self.area_cost_map,
|
||||
"DeathLink": self.multiworld.death_link[self.player].value,
|
||||
"DeathLink_Amnesty": self.multiworld.DeathLinkAmnesty[self.player].value
|
||||
"DeathLink": self.options.death_link.value,
|
||||
"DeathLink_Amnesty": self.options.death_link_amnesty.value
|
||||
}
|
||||
|
||||
def generate_output(self, output_directory: str):
|
||||
|
|
Loading…
Reference in New Issue