diff --git a/field.py b/field.py index f3713a0..399238a 100644 --- a/field.py +++ b/field.py @@ -14,7 +14,6 @@ class Field(): else: self.state = [[' ' for cols in range(Field.WIDTH)] for rows in range(Field.HEIGHT)] - #self.rotate_90_degree_clckwise(self.state) self.cleared_rows = 1 def __str__(self): @@ -24,7 +23,8 @@ class Field(): '{:2d} |'.format(i) + ' '.join(row) + '|' for i, row in enumerate(self.state)]) + '\n' + BAR - def matrixflip(self, m, d): + @staticmethod + def matrixflip(m, d): tempm = m.copy() if d == 'h': for i in range(0, len(tempm), 1): @@ -33,14 +33,16 @@ class Field(): tempm.reverse() return (tempm) - def rotate_90_degree_anticlckwise(self, matrix): + @staticmethod + def rotate_90_degree_anticlckwise(matrix): new_matrix = [] for i in range(len(matrix[0]), 0, -1): new_matrix.append(list(map(lambda x: x[i - 1], matrix))) return new_matrix - def rotate_90_degree_clckwise(self, matrix): + @staticmethod + def rotate_90_degree_clckwise(matrix): new_matrix = [] for i in range(len(matrix[0])): li = list(map(lambda x: x[i], matrix)) @@ -58,9 +60,8 @@ class Field(): self.state[row] = [' ' for cols in range(Field.WIDTH)] def rotate_state(self): - self.state = self.rotate_90_degree_anticlckwise(self.state) - #self.state = self.matrixflip(self.state, 'v') - #print(self.state) + self.state = Field.rotate_90_degree_anticlckwise(self.state) + def get_line_count(self): return self.cleared_rows @@ -158,7 +159,7 @@ class Field(): def predict_gaps_in_next_rotation(self): tmp_state = copy(self.state) - tmp_state = self.rotate_90_degree_anticlckwise(tmp_state) + tmp_state = Field.rotate_90_degree_anticlckwise(tmp_state) for row in range(int(self.HEIGHT/2)): tmp_state[row] = [' ' for cols in range(Field.WIDTH)] return sum( diff --git a/litris.py b/litris.py index 0e09787..46d690e 100644 --- a/litris.py +++ b/litris.py @@ -100,8 +100,7 @@ class Litris(GameBase): def update_field_with_stored_edges(self): if self.move_mode == 4: - state_copy = copy(self.field_state_storage[1]) - state_copy = state_copy.rotate_90_degree_clckwise() + state_copy = Field.rotate_90_degree_clckwise(copy(self.field_state_storage[1])) for i in range(11,20,1): for e in range(0,2,1): self.field.state[i][e] = state_copy[i][e]