예제 #1
0
 def test_remove_end(self):
     field_remove = Field(COLORS, 3, 3, [[
         (220, 20, 60), (220, 20, 60), (0, 0, 205)
     ], [(220, 20, 60), (255, 140, 0),
         (0, 0, 205)], [(220, 20, 60), (0, 0, 205), (255, 140, 0)]])
     field_remove.remove((2, 0))
     new_field = '  (0, 0, 205)\n' \
                 ' (255, 140, 0) (0, 0, 205)\n' \
                 ' (0, 0, 205) (255, 140, 0)\n'
     self.assertEqual(new_field, field_remove.__str__())
예제 #2
0
파일: game.py 프로젝트: superanya/cubes
    def __init__(self, colors, size):
        super().__init__()

        self.size = size
        self.width, self.height, self.colors = \
            self.init_field_size(colors, self.size)
        self.game_over = False
        self.object = Field(self.colors, self.width, self.height)
        self.total_score = 0
        self.isWaitingAfterLine = False
        self.table_of_records_file = "texts/best_results.txt"
        self.init_ui()
        self.information_about_colors = self.set_information_about_colors()
        self.table_of_records = self.set_table_of_records()
        self.best_results = {}
예제 #3
0
파일: game.py 프로젝트: superanya/cubes
 def new_game(self):
     self.total_score = 0
     self.object = Field(self.colors, self.width, self.height)
     self.information_about_colors = self.set_information_about_colors()
예제 #4
0
 def test_is_exit(self):
     field = Field(COLORS, 1, 1, [[(220, 20, 60)], [(0, 0, 205)]])
     self.assertTrue(field.is_exit())
예제 #5
0
import unittest
import sys
from menu import Color
from field_attributes.field import Field

COLORS = [color for color in Color]
COLORS_VALUES = [color.value for color in Color]
field = '(220, 20, 60) (220, 20, 60) (0, 0, 205)\n' \
        '(220, 20, 60) (255, 140, 0) (0, 0, 205)\n' \
        '(220, 20, 60) (0, 0, 205) (255, 140, 0)\n'

FIELD = Field(
    COLORS, 3, 3,
    [[(220, 20, 60), (220, 20, 60),
      (0, 0, 205)], [(220, 20, 60), (255, 140, 0),
                     (0, 0, 205)], [(220, 20, 60), (0, 0, 205),
                                    (255, 140, 0)]])
TEST = Field(COLORS, 3, 3)


class TestField(unittest.TestCase):
    def test_generate_random_field(self):
        for i in range(TEST.width):
            for j in range(TEST.height):
                self.assertTrue(
                    TEST.blocks2coordinates[(i, j)][0].color in COLORS_VALUES)

    def test_make_field(self):
        self.assertEqual(field, FIELD.__str__())

    def test_set_block2coordinates(self):