28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
from enum import Enum
|
|
from typing import Tuple
|
|
from gameContext import GameContext
|
|
from gridCellType import GridCellType
|
|
|
|
class StreetType (Enum):
|
|
VERTICAL = 0
|
|
HORIZONTAL = 1
|
|
|
|
class Street:
|
|
street_type: StreetType
|
|
start_cell: int
|
|
end_cell: int
|
|
row_or_column: int
|
|
|
|
def __init__(self, start_cell: int, end_cell: int, row_or_column: int, street_type: StreetType) -> None:
|
|
self.start_cell = start_cell
|
|
self.end_cell = end_cell
|
|
self.street_type = street_type
|
|
self.row_or_column = row_or_column
|
|
|
|
def render(self, game_context: GameContext) -> None:
|
|
for i in range(self.start_cell, self.end_cell + 1):
|
|
img_str: str = 'imgs/street_vertical.png' if self.street_type == StreetType.VERTICAL else 'imgs/street_horizontal.png'
|
|
cell: Tuple[int, int] = (self.row_or_column, i) if self.street_type == StreetType.VERTICAL else (i, self.row_or_column)
|
|
game_context.render_in_cell(cell, img_str)
|
|
game_context.grid[cell] = GridCellType.STREET_HORIZONTAL if self.street_type == StreetType.HORIZONTAL else GridCellType.STREET_VERTICAL
|