add render method in city class

This commit is contained in:
Pawel Felcyn 2023-04-03 15:49:28 +02:00
parent ba49049cc3
commit b8280a3854
1 changed files with 13 additions and 19 deletions

32
city.py
View File

@ -1,17 +1,19 @@
from typing import List, Tuple
from typing import List
from garbageCan import GarbageCan
from street import Street
from gameContext import GameContext
class Node:
garbageCan: GarbageCan
id: int
def __init__(self, id: int, can: GarbageCan) -> None:
self.id = id
self.id
self.can = can
class City:
nodes: List[Node]
streets: List[Tuple[int, int]]
streets: List[Street]
def __init__(self) -> None:
self.nodes = []
@ -20,20 +22,12 @@ class City:
def add_node(self, node: Node) -> None:
self.nodes.append(node)
def add_street(self, street: Tuple[int, int]) -> None:
firstFound: bool = False
secondFound: bool = False
def add_street(self, street: Street) -> None:
self.streets.append(street)
for node in self.nodes:
if firstFound and secondFound:
break
if node.id == street.__getitem__(0):
firstFound = True
continue
if node.id == street.__getitem__(1):
secondFound = True
if not firstFound or not secondFound:
return
self.streets.append(street)
def render_city(self, game_context: GameContext) -> None:
self._render_streets(game_context)
def _render_streets(self, game_context: GameContext) -> None:
for street in self.streets:
street.render(game_context)