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