FF1: Switching Options System (#3302)
This commit is contained in:
parent
89a2a3c35b
commit
5fb1d0f98a
|
@ -1,6 +1,6 @@
|
||||||
from typing import Dict
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from Options import OptionDict
|
from Options import OptionDict, PerGameCommonOptions
|
||||||
|
|
||||||
|
|
||||||
class Locations(OptionDict):
|
class Locations(OptionDict):
|
||||||
|
@ -18,8 +18,8 @@ class Rules(OptionDict):
|
||||||
display_name = "rules"
|
display_name = "rules"
|
||||||
|
|
||||||
|
|
||||||
ff1_options: Dict[str, OptionDict] = {
|
@dataclass
|
||||||
"locations": Locations,
|
class FF1Options(PerGameCommonOptions):
|
||||||
"items": Items,
|
locations: Locations
|
||||||
"rules": Rules
|
items: Items
|
||||||
}
|
rules: Rules
|
||||||
|
|
|
@ -5,7 +5,7 @@ from typing import Dict
|
||||||
from BaseClasses import Item, Location, MultiWorld, Tutorial, ItemClassification
|
from BaseClasses import Item, Location, MultiWorld, Tutorial, ItemClassification
|
||||||
from .Items import ItemData, FF1Items, FF1_STARTER_ITEMS, FF1_PROGRESSION_LIST, FF1_BRIDGE
|
from .Items import ItemData, FF1Items, FF1_STARTER_ITEMS, FF1_PROGRESSION_LIST, FF1_BRIDGE
|
||||||
from .Locations import EventId, FF1Locations, generate_rule, CHAOS_TERMINATED_EVENT
|
from .Locations import EventId, FF1Locations, generate_rule, CHAOS_TERMINATED_EVENT
|
||||||
from .Options import ff1_options
|
from .Options import FF1Options
|
||||||
from ..AutoWorld import World, WebWorld
|
from ..AutoWorld import World, WebWorld
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,7 +34,8 @@ class FF1World(World):
|
||||||
Part puzzle and part speed-run, it breathes new life into one of the most influential games ever made.
|
Part puzzle and part speed-run, it breathes new life into one of the most influential games ever made.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
option_definitions = ff1_options
|
options: FF1Options
|
||||||
|
options_dataclass = FF1Options
|
||||||
settings: typing.ClassVar[FF1Settings]
|
settings: typing.ClassVar[FF1Settings]
|
||||||
settings_key = "ffr_options"
|
settings_key = "ffr_options"
|
||||||
game = "Final Fantasy"
|
game = "Final Fantasy"
|
||||||
|
@ -58,20 +59,20 @@ class FF1World(World):
|
||||||
def stage_assert_generate(cls, multiworld: MultiWorld) -> None:
|
def stage_assert_generate(cls, multiworld: MultiWorld) -> None:
|
||||||
# Fail generation if there are no items in the pool
|
# Fail generation if there are no items in the pool
|
||||||
for player in multiworld.get_game_players(cls.game):
|
for player in multiworld.get_game_players(cls.game):
|
||||||
options = get_options(multiworld, 'items', player)
|
items = multiworld.worlds[player].options.items.value
|
||||||
assert options,\
|
assert items, \
|
||||||
f"FFR settings submitted with no key items ({multiworld.get_player_name(player)}). Please ensure you " \
|
f"FFR settings submitted with no key items ({multiworld.get_player_name(player)}). Please ensure you " \
|
||||||
f"generated the settings using finalfantasyrandomizer.com AND enabled the AP flag"
|
f"generated the settings using finalfantasyrandomizer.com AND enabled the AP flag"
|
||||||
|
|
||||||
def create_regions(self):
|
def create_regions(self):
|
||||||
locations = get_options(self.multiworld, 'locations', self.player)
|
locations = self.options.locations.value
|
||||||
rules = get_options(self.multiworld, 'rules', self.player)
|
rules = self.options.rules.value
|
||||||
menu_region = self.ff1_locations.create_menu_region(self.player, locations, rules, self.multiworld)
|
menu_region = self.ff1_locations.create_menu_region(self.player, locations, rules, self.multiworld)
|
||||||
terminated_event = Location(self.player, CHAOS_TERMINATED_EVENT, EventId, menu_region)
|
terminated_event = Location(self.player, CHAOS_TERMINATED_EVENT, EventId, menu_region)
|
||||||
terminated_item = Item(CHAOS_TERMINATED_EVENT, ItemClassification.progression, EventId, self.player)
|
terminated_item = Item(CHAOS_TERMINATED_EVENT, ItemClassification.progression, EventId, self.player)
|
||||||
terminated_event.place_locked_item(terminated_item)
|
terminated_event.place_locked_item(terminated_item)
|
||||||
|
|
||||||
items = get_options(self.multiworld, 'items', self.player)
|
items = self.options.items.value
|
||||||
goal_rule = generate_rule([[name for name in items.keys() if name in FF1_PROGRESSION_LIST and name != "Shard"]],
|
goal_rule = generate_rule([[name for name in items.keys() if name in FF1_PROGRESSION_LIST and name != "Shard"]],
|
||||||
self.player)
|
self.player)
|
||||||
terminated_event.access_rule = goal_rule
|
terminated_event.access_rule = goal_rule
|
||||||
|
@ -93,7 +94,7 @@ class FF1World(World):
|
||||||
self.multiworld.completion_condition[self.player] = lambda state: state.has(CHAOS_TERMINATED_EVENT, self.player)
|
self.multiworld.completion_condition[self.player] = lambda state: state.has(CHAOS_TERMINATED_EVENT, self.player)
|
||||||
|
|
||||||
def create_items(self):
|
def create_items(self):
|
||||||
items = get_options(self.multiworld, 'items', self.player)
|
items = self.options.items.value
|
||||||
if FF1_BRIDGE in items.keys():
|
if FF1_BRIDGE in items.keys():
|
||||||
self._place_locked_item_in_sphere0(FF1_BRIDGE)
|
self._place_locked_item_in_sphere0(FF1_BRIDGE)
|
||||||
if items:
|
if items:
|
||||||
|
@ -109,7 +110,7 @@ class FF1World(World):
|
||||||
|
|
||||||
def _place_locked_item_in_sphere0(self, progression_item: str):
|
def _place_locked_item_in_sphere0(self, progression_item: str):
|
||||||
if progression_item:
|
if progression_item:
|
||||||
rules = get_options(self.multiworld, 'rules', self.player)
|
rules = self.options.rules.value
|
||||||
sphere_0_locations = [name for name, rules in rules.items()
|
sphere_0_locations = [name for name, rules in rules.items()
|
||||||
if rules and len(rules[0]) == 0 and name not in self.locked_locations]
|
if rules and len(rules[0]) == 0 and name not in self.locked_locations]
|
||||||
if sphere_0_locations:
|
if sphere_0_locations:
|
||||||
|
@ -126,7 +127,3 @@ class FF1World(World):
|
||||||
|
|
||||||
def get_filler_item_name(self) -> str:
|
def get_filler_item_name(self) -> str:
|
||||||
return self.multiworld.random.choice(["Heal", "Pure", "Soft", "Tent", "Cabin", "House"])
|
return self.multiworld.random.choice(["Heal", "Pure", "Soft", "Tent", "Cabin", "House"])
|
||||||
|
|
||||||
|
|
||||||
def get_options(world: MultiWorld, name: str, player: int):
|
|
||||||
return getattr(world, name, None)[player].value
|
|
||||||
|
|
Loading…
Reference in New Issue