Factorio: option groups (#4293)

This commit is contained in:
Fabian Dill 2024-11-30 04:08:17 +01:00 committed by GitHub
parent a537d8eb65
commit 0705f6e6c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 6 deletions

View File

@ -6,7 +6,7 @@ import typing
from schema import Schema, Optional, And, Or
from Options import Choice, OptionDict, OptionSet, DefaultOnToggle, Range, DeathLink, Toggle, \
StartInventoryPool, PerGameCommonOptions
StartInventoryPool, PerGameCommonOptions, OptionGroup
# schema helpers
FloatRange = lambda low, high: And(Or(int, float), lambda f: low <= f <= high)
@ -293,7 +293,7 @@ class FactorioWorldGen(OptionDict):
with in-depth documentation at https://lua-api.factorio.com/latest/Concepts.html#MapGenSettings"""
display_name = "World Generation"
# FIXME: do we want default be a rando-optimized default or in-game DS?
value: typing.Dict[str, typing.Dict[str, typing.Any]]
value: dict[str, dict[str, typing.Any]]
default = {
"autoplace_controls": {
# terrain
@ -402,7 +402,7 @@ class FactorioWorldGen(OptionDict):
}
})
def __init__(self, value: typing.Dict[str, typing.Any]):
def __init__(self, value: dict[str, typing.Any]):
advanced = {"pollution", "enemy_evolution", "enemy_expansion"}
self.value = {
"basic": {k: v for k, v in value.items() if k not in advanced},
@ -421,7 +421,7 @@ class FactorioWorldGen(OptionDict):
optional_min_lte_max(enemy_expansion, "min_expansion_cooldown", "max_expansion_cooldown")
@classmethod
def from_any(cls, data: typing.Dict[str, typing.Any]) -> FactorioWorldGen:
def from_any(cls, data: dict[str, typing.Any]) -> FactorioWorldGen:
if type(data) == dict:
return cls(data)
else:
@ -435,7 +435,7 @@ class ImportedBlueprint(DefaultOnToggle):
class EnergyLink(Toggle):
"""Allow sending energy to other worlds. 25% of the energy is lost in the transfer."""
display_name = "EnergyLink"
display_name = "Energy Link"
@dataclass
@ -473,3 +473,34 @@ class FactorioOptions(PerGameCommonOptions):
death_link: DeathLink
energy_link: EnergyLink
start_inventory_from_pool: StartInventoryPool
option_groups: list[OptionGroup] = [
OptionGroup(
"Technologies",
[
TechTreeLayout,
Progressive,
MinTechCost,
MaxTechCost,
TechCostDistribution,
TechCostMix,
RampingTechCosts,
TechTreeInformation,
]
),
OptionGroup(
"Traps",
[
AttackTrapCount,
EvolutionTrapCount,
EvolutionTrapIncrease,
TeleportTrapCount,
GrenadeTrapCount,
ClusterGrenadeTrapCount,
ArtilleryTrapCount,
AtomicRocketTrapCount,
],
start_collapsed=True
),
]

View File

@ -12,7 +12,8 @@ from worlds.LauncherComponents import Component, components, Type, launch_subpro
from worlds.generic import Rules
from .Locations import location_pools, location_table
from .Mod import generate_mod
from .Options import FactorioOptions, MaxSciencePack, Silo, Satellite, TechTreeInformation, Goal, TechCostDistribution
from .Options import (FactorioOptions, MaxSciencePack, Silo, Satellite, TechTreeInformation, Goal,
TechCostDistribution, option_groups)
from .Shapes import get_shapes
from .Technologies import base_tech_table, recipe_sources, base_technology_table, \
all_product_sources, required_technologies, get_rocket_requirements, \
@ -61,6 +62,7 @@ class FactorioWeb(WebWorld):
"setup/en",
["Berserker, Farrak Kilhn"]
)]
option_groups = option_groups
class FactorioItem(Item):