-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.py
27 lines (22 loc) · 798 Bytes
/
map.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
from ship import Ship
class Map:
fields: list[list['Map.MapCell']]
size: int
class MapCell: # класс, хронящий данные о карте
entity: Ship
around_entities: list[Ship]
parent_map: 'Map'
coordinates: tuple[int, int]
def __init__(self, map: 'Map', coordinates: tuple[int, int], ship: Ship = None):
self.entity = ship
self.around_entities = []
self.parent_map = map
self.coordinates = coordinates
def __init__(self, size: int = 10):
self.fields = []
self.size = size
for x in range(self.size):
tmp = []
for y in range(self.size):
tmp.append(Map.MapCell(self, (x, y)))
self.fields.append(tmp)