Skip to content

Commit

Permalink
(bridge) new interface (but leaves TODO)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyangyi committed Dec 5, 2023
1 parent e6ccdbe commit f63a7ab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
3 changes: 0 additions & 3 deletions bridge/bridges/dovemere/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
the_bridge = ABridge(
id=0x01,
name="Test Bridge",
front=None,
back=None,
pillar=None,
intro_year_since_1920=0,
min_length=4,
max_length=32,
Expand Down
36 changes: 22 additions & 14 deletions bridge/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,26 @@ class ASingleTypeBridgeLayout:
flat: Tuple[SpritePair, SpritePair]
ramp: Tuple[SpritePair, SpritePair]

@staticmethod
def one_grid_layout(back, front, pillars, flat, ramp):
return ASingleTypeBridgeLayout((back,) * 6, (front,) * 6, (pillars,) * 6, flat, ramp)


@dataclass
class ABridgeLayout:
railX: ASingleTypeBridgeLayout
railY: ASingleTypeBridgeLayout
roadX: ASingleTypeBridgeLayout
roadY: ASingleTypeBridgeLayout
monoX: ASingleTypeBridgeLayout
monoY: ASingleTypeBridgeLayout
mlevX: ASingleTypeBridgeLayout
mlevY: ASingleTypeBridgeLayout
rail: ASingleTypeBridgeLayout
road: ASingleTypeBridgeLayout
mono: ASingleTypeBridgeLayout
mlev: ASingleTypeBridgeLayout

@staticmethod
def make_universal(single_layout):
return ABridgeLayout(
rail=single_layout,
road=single_layout,
mono=single_layout,
mlev=single_layout,
)


class ABridge(grf.SpriteGenerator):
Expand All @@ -36,9 +45,7 @@ def __init__(
*,
id,
name,
back,
front,
pillar,
layout: ABridgeLayout,
purchase_text=None,
description_rail=None,
description_road=None,
Expand All @@ -47,14 +54,15 @@ def __init__(
super().__init__()
self.id = id
self.name = name
self.back = back
self.front = front
self.pillar = pillar
self.layout = layout
self.purchase_text = purchase_text
self.description_rail = description_rail
self.description_road = description_road
self._props = props

# FIXME: supprt new layout abstraction
self._props["layout"] = layout

def get_sprites(self, g):
extra_props = {}
if self.purchase_text:
Expand Down

0 comments on commit f63a7ab

Please sign in to comment.