small fixes

This commit is contained in:
Adrien MALINGREY 2019-10-08 19:37:17 +02:00
parent a3dc434c88
commit 5ed15da4ed
2 changed files with 15 additions and 2 deletions

View File

@ -1,4 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""Tetris clone with arcade GUI library"""
import sys import sys
import random import random
@ -225,6 +228,7 @@ class MatrixSprites(MinoesSprites):
class TetrArcade(TetrisLogic, arcade.Window): class TetrArcade(TetrisLogic, arcade.Window):
"""Tetris clone with arcade GUI library"""
timer = Scheduler() timer = Scheduler()

View File

@ -27,6 +27,7 @@ CRYPT_KEY = 987943759387540938469837689379857347598347598379584857934579343
class AbstractScheduler: class AbstractScheduler:
"""Scheduler class to be implemented""" """Scheduler class to be implemented"""
def postpone(task, delay): def postpone(task, delay):
"""schedule callable task once after delay in second""" """schedule callable task once after delay in second"""
raise Warning("AbstractScheduler.postpone is not implemented.") raise Warning("AbstractScheduler.postpone is not implemented.")
@ -48,11 +49,13 @@ class AbstractPieceContainer:
class HoldQueue(AbstractPieceContainer): class HoldQueue(AbstractPieceContainer):
"""the storage place where players can Hold any falling Tetrimino for use later""" """the storage place where players can Hold any falling Tetrimino for use later"""
pass pass
class Matrix(list, AbstractPieceContainer): class Matrix(list, AbstractPieceContainer):
"""the rectangular arrangement of cells creating the active game area, usually 10 columns wide by 20 rows high.""" """the rectangular arrangement of cells creating the active game area, usually 10 columns wide by 20 rows high."""
def __init__(self, lines, collumns): def __init__(self, lines, collumns):
list.__init__(self) list.__init__(self)
AbstractPieceContainer.__init__(self) AbstractPieceContainer.__init__(self)
@ -88,6 +91,7 @@ class Matrix(list, AbstractPieceContainer):
class NextQueue(AbstractPieceContainer): class NextQueue(AbstractPieceContainer):
"""Displays the Next Tetrimino(s) to be placed (generated) just above the Matrix""" """Displays the Next Tetrimino(s) to be placed (generated) just above the Matrix"""
def __init__(self, nb_pieces): def __init__(self, nb_pieces):
super().__init__() super().__init__()
self.nb_pieces = nb_pieces self.nb_pieces = nb_pieces
@ -103,6 +107,7 @@ class NextQueue(AbstractPieceContainer):
class Stats: class Stats:
"""Game statistics""" """Game statistics"""
def _get_score(self): def _get_score(self):
return self._score return self._score
@ -225,7 +230,12 @@ class TetrisLogic:
self.on_generation_phase( self.on_generation_phase(
self.matrix, self.matrix.piece, self.matrix.ghost, self.next.pieces self.matrix, self.matrix.piece, self.matrix.ghost, self.next.pieces
) )
if self.matrix.space_to_move(
self.matrix.piece.coord, (mino.coord for mino in self.matrix.piece)
):
self.falling_phase() self.falling_phase()
else:
self.game_over()
def refresh_ghost(self): def refresh_ghost(self):
self.matrix.ghost.coord = self.matrix.piece.coord self.matrix.ghost.coord = self.matrix.piece.coord
@ -296,7 +306,6 @@ class TetrisLogic:
return False return False
def locks_down(self): def locks_down(self):
# self.timer.cancel(self.repeat_action)
self.timer.cancel(self.lock_phase) self.timer.cancel(self.lock_phase)
# Game over # Game over