sztuczna_inteligencja_2023_.../street.py

28 lines
1.1 KiB
Python
Raw Normal View History

2023-04-03 15:43:03 +02:00
from enum import Enum
from typing import Tuple
from gameContext import GameContext
2023-04-22 12:04:08 +02:00
from gridCellType import GridCellType
2023-04-03 15:43:03 +02:00
class StreetType (Enum):
VERTICAL = 0
2023-04-03 19:26:56 +02:00
HORIZONTAL = 1
2023-04-03 15:43:03 +02:00
class Street:
street_type: StreetType
start_cell: int
end_cell: int
row_or_column: int
2023-04-03 19:26:56 +02:00
def __init__(self, start_cell: int, end_cell: int, row_or_column: int, street_type: StreetType) -> None:
2023-04-03 15:43:03 +02:00
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:
2023-04-03 19:26:56 +02:00
for i in range(self.start_cell, self.end_cell + 1):
2023-04-03 15:43:03 +02:00
img_str: str = 'imgs/street_vertical.png' if self.street_type == StreetType.VERTICAL else 'imgs/street_horizontal.png'
2023-04-03 19:26:56 +02:00
cell: Tuple[int, int] = (self.row_or_column, i) if self.street_type == StreetType.VERTICAL else (i, self.row_or_column)
2023-04-03 15:43:03 +02:00
game_context.render_in_cell(cell, img_str)
2023-04-22 12:04:08 +02:00
game_context.grid[cell] = GridCellType.STREET_HORIZONTAL if self.street_type == StreetType.HORIZONTAL else GridCellType.STREET_VERTICAL