Convert the generator.Configuration class to a dataclass
This commit is contained in:
parent
0b577ad5ea
commit
25aa5506c8
1 changed files with 6 additions and 5 deletions
|
@ -7,6 +7,7 @@ import random
|
||||||
import tcod
|
import tcod
|
||||||
from .geometry import Direction, Point, Rect, Size
|
from .geometry import Direction, Point, Rect, Size
|
||||||
from .tile import Empty, Floor, Wall
|
from .tile import Empty, Floor, Wall
|
||||||
|
from dataclasses import dataclass
|
||||||
from typing import Iterator, List, Optional
|
from typing import Iterator, List, Optional
|
||||||
|
|
||||||
LOG = logging.getLogger('map')
|
LOG = logging.getLogger('map')
|
||||||
|
@ -52,14 +53,14 @@ class MapGenerator:
|
||||||
class RoomsAndCorridorsGenerator(MapGenerator):
|
class RoomsAndCorridorsGenerator(MapGenerator):
|
||||||
'''Generate a rooms-and-corridors style map with BSP.'''
|
'''Generate a rooms-and-corridors style map with BSP.'''
|
||||||
|
|
||||||
|
@dataclass
|
||||||
class Configuration:
|
class Configuration:
|
||||||
def __init__(self, min_room_size: Size, max_room_size: Size):
|
minimum_room_size: Size
|
||||||
self.minimum_room_size = min_room_size
|
maximum_room_size: Size
|
||||||
self.maximum_room_size = max_room_size
|
|
||||||
|
|
||||||
DefaultConfiguration = Configuration(
|
DefaultConfiguration = Configuration(
|
||||||
min_room_size=Size(5, 5),
|
minimum_room_size=Size(5, 5),
|
||||||
max_room_size=Size(15, 15),
|
maximum_room_size=Size(15, 15),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, *, size: Size, config: Optional[Configuration] = None):
|
def __init__(self, *, size: Size, config: Optional[Configuration] = None):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue