-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCell.py
54 lines (40 loc) · 1.21 KB
/
Cell.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import random
import itertools
from typing import Type, TypeVar
from pygame import Surface
TCell = TypeVar('TCell', bound='Cell')
class Cell:
def __init__(self: TCell, column: int, row: int, value: int = 0) -> None:
self._column: int = column
self._row: int = row
self._value: int = value
self._visible: bool = False
@property
def column(self: TCell):
return self._column
@column.setter
def column(self: TCell, column: int):
self._column = column
@property
def row(self: TCell):
return self._row
@row.setter
def row(self: TCell, row: int):
self._row = row
@property
def value(self: TCell):
return self._value
@value.setter
def value(self, value: int):
self._value = value
@property
def visible(self: TCell):
return self._visible
@visible.setter
def visible(self: TCell, visible: bool):
self._visible = visible
def get_coords(self: TCell, coords: tuple[int, int], torus: bool) -> tuple[int, int]:
if torus:
return self.column+coords[0], self.row+coords[1]
else:
return abs(self.column+coords[0]), abs(self.row+coords[1])