Esempio n. 1
0
    def test_pieces_amount(self):
        '''Tests whether all the 7 pieces are created'''

        colors = {'red': '#ff4d4d', 'orange': '#ffc966', 'yellow': '#ffff4d',
            'green': '#4dff4d', 'purple': '#be90d4', 'blue': '#4d4dff',
            'cyan': '#0cf0f0'}
        pieces = create_game_pieces(colors)

        self.assertEqual(len(pieces), 7)
Esempio n. 2
0
    def _prepare_for_game(self):
        '''Prepares to start the game'''

        canvas = self._background_canvas

        self._delete_welcome_widgets()
        self._score_label.configure(text='0')
        self._pieces = create_game_pieces(self._colors)
        self._show_next_piece()

        timer_label = ttk.Label(canvas, text='4', style='Timer.TLabel')
        timer_label.place(x=120, y=150)
        self._timer_label = timer_label
        self._set_timer()
Esempio n. 3
0
    def test_initiate_piece_position_row(self):
        '''Tests whether piece\'s row position is initiated'''

        colors = {'red': '#ff4d4d', 'orange': '#ffc966', 'yellow': '#ffff4d',
            'green': '#4dff4d', 'purple': '#be90d4', 'blue': '#4d4dff',
            'cyan': '#0cf0f0'}
        pieces = create_game_pieces(colors)
        piece = pieces[0]

        row = piece.get_current_state()[0][0]
        initiate_piece_location(piece)
        new_row = piece.get_current_state()[0][0]

        row_delta = new_row - row

        self.assertEqual(row_delta, -2)
Esempio n. 4
0
    def test_piece_drawn(self):
        '''Tests whether the piece is drawn on the grid'''

        colors = {'red': '#ff4d4d', 'orange': '#ffc966', 'yellow': '#ffff4d',
            'green': '#4dff4d', 'purple': '#be90d4', 'blue': '#4d4dff',
            'cyan': '#0cf0f0'}
        pieces = create_game_pieces(colors)
        piece = pieces[0]
        grid = create_play_grid()

        draw_piece(piece, grid)
        color = piece.get_color()
        shape = piece.get_current_state()
        tile = shape[0]
        background_color = str(grid[tile[0]][tile[1]].cget('background'))

        self.assertEqual(background_color, color)