added async stone detection thread
This commit is contained in:
9
field.py
9
field.py
@@ -13,6 +13,7 @@ class Field():
|
||||
else:
|
||||
self.state = [[' ' for cols in range(Field.WIDTH)]
|
||||
for rows in range(Field.HEIGHT)]
|
||||
self.cleared_rows = 0
|
||||
|
||||
def __str__(self):
|
||||
BAR = ' ' + '-' * (Field.WIDTH * 2 + 1) + '\n ' + \
|
||||
@@ -21,6 +22,13 @@ class Field():
|
||||
'{:2d} |'.format(i) + ' '.join(row) + '|'
|
||||
for i, row in enumerate(self.state)]) + '\n' + BAR
|
||||
|
||||
|
||||
def rotate_state(self):
|
||||
self.state = list(zip(*self.state[::-1]))
|
||||
|
||||
def get_line_count(self):
|
||||
return self.cleared_rows
|
||||
|
||||
def _test_tetromino(self, tetromino, row, column):
|
||||
"""
|
||||
Tests to see if a tetromino can be placed at the specified row and
|
||||
@@ -80,6 +88,7 @@ class Field():
|
||||
self.state = list(filter(lambda row: row.count(' ') != 0, self.state))
|
||||
while len(self.state) < Field.HEIGHT:
|
||||
self.state.insert(0, [' ' for col in range(Field.WIDTH)])
|
||||
self.cleared_rows = self.cleared_rows + 1
|
||||
|
||||
def copy(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user