Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factorio: option groups #4293

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions worlds/factorio/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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},
Expand All @@ -421,7 +421,7 @@ def optional_min_lte_max(container, min_key, max_key):
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:
Expand All @@ -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
Expand Down Expand Up @@ -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
),
]
4 changes: 3 additions & 1 deletion worlds/factorio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
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, \
Expand Down Expand Up @@ -61,6 +62,7 @@ class FactorioWeb(WebWorld):
"setup/en",
["Berserker, Farrak Kilhn"]
)]
option_groups = option_groups


class FactorioItem(Item):
Expand Down
Loading