-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRender.py
35 lines (30 loc) · 1.28 KB
/
Render.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from colorama import init, Fore
from SimulationEntity import Grass, Herbivore, Predator, Tree, Rock
init(autoreset=True)
class Render:
"""
Класс визуализации карты
"""
def __init__(self, simulation_map):
self.map = simulation_map
def render(self):
"""Метод отрисовки карты по __objects_by_coordinates"""
print("- " * self.map.width)
for row in range(self.map.height):
for column in range(self.map.width):
entity = self.map.get_object((row, column))
if entity is None:
print('*', end=' ')
else:
if isinstance(entity, Grass):
print(Fore.GREEN + entity.marking, end=' ')
if isinstance(entity, Herbivore):
print(Fore.CYAN + entity.marking, end=' ')
if isinstance(entity, Predator):
print(Fore.RED + entity.marking, end=' ')
if isinstance(entity, Tree):
print(Fore.YELLOW + entity.marking, end=' ')
if isinstance(entity, Rock):
print(entity.marking, end=' ')
print()
print("- " * self.map.width)