mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
The Witness: Change Regions, Areas and Connections from Dict[str, Any] to dataclasses&NamedTuples (#4415)
* Change Regions, Areas and Connections to dataclasses/NamedTuples * Move to new file * we do a little renaming * Purge the 'lambda' naming in favor of 'rule' or 'WitnessRule' * missed one * unnecessary change * omega oops * NOOOOOOOO * Merge error * mypy thing
This commit is contained in:
33
worlds/witness/data/definition_classes.py
Normal file
33
worlds/witness/data/definition_classes.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from dataclasses import dataclass, field
|
||||
from typing import FrozenSet, List, NamedTuple
|
||||
|
||||
# A WitnessRule is just an or-chain of and-conditions.
|
||||
# It represents the set of all options that could fulfill this requirement.
|
||||
# E.g. if something requires "Dots or (Shapers and Stars)", it'd be represented as: {{"Dots"}, {"Shapers, "Stars"}}
|
||||
# {} is an unusable requirement.
|
||||
# {{}} is an always usable requirement.
|
||||
WitnessRule = FrozenSet[FrozenSet[str]]
|
||||
|
||||
|
||||
@dataclass
|
||||
class AreaDefinition:
|
||||
name: str
|
||||
regions: List[str] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass
|
||||
class RegionDefinition:
|
||||
name: str
|
||||
short_name: str
|
||||
area: AreaDefinition
|
||||
logical_entities: List[str] = field(default_factory=list)
|
||||
physical_entities: List[str] = field(default_factory=list)
|
||||
|
||||
|
||||
class ConnectionDefinition(NamedTuple):
|
||||
target_region: str
|
||||
traversal_rule: WitnessRule
|
||||
|
||||
@property
|
||||
def can_be_traversed(self) -> bool:
|
||||
return bool(self.traversal_rule)
|
Reference in New Issue
Block a user