From 0c28898b8cc2fadfad160f0e279ce6efd54283fa Mon Sep 17 00:00:00 2001 From: En Yi Date: Fri, 20 Jul 2018 14:24:27 +0800 Subject: [PATCH] PEP8 check, mostly --- .gitignore | 1 + gameplay/Sudoku_Solver.py | 3 ++- gameplay/sudoku_gameplay.py | 5 ++--- general/extras.py | 3 ++- general/highscore.py | 3 ++- graphic_components/buttons.py | 2 +- graphic_components/menu_graphics.py | 3 +-- graphic_components/sudoku_graphics.py | 3 ++- 8 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index d309cbc..b699e4a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ demos/ .idea/ */__pycache__/* *.pyc +*/highscore.txt diff --git a/gameplay/Sudoku_Solver.py b/gameplay/Sudoku_Solver.py index 6bb4eec..f3eefa5 100644 --- a/gameplay/Sudoku_Solver.py +++ b/gameplay/Sudoku_Solver.py @@ -1,8 +1,9 @@ -# TODO: Rewrite this to use array instead? """ Module to solve any Sudoku Board Credits for Solver : http://norvig.com/sudoku.html """ + + def cross(array1, array2): """Cross product of elements in A and elements in B.""" return [a+b for a in array1 for b in array2] diff --git a/gameplay/sudoku_gameplay.py b/gameplay/sudoku_gameplay.py index 65fa3c2..d2c0140 100644 --- a/gameplay/sudoku_gameplay.py +++ b/gameplay/sudoku_gameplay.py @@ -1,6 +1,5 @@ -import os import numpy as np -from . import Sudoku_Generator as sdk_gen +from . import Sudoku_Generator as SdkGen EMPTY = 0 VALID = 1 @@ -131,7 +130,7 @@ class SudokuSystem: def generate_random_board(self, difficulty): self.clear_grid() - self.number_grid[:] = sdk_gen.generate_sudoku_puzzle(difficulty) + self.number_grid[:] = SdkGen.generate_sudoku_puzzle(difficulty) row, col = np.where(self.number_grid == 0) for r, c in zip(row, col): diff --git a/general/extras.py b/general/extras.py index ba95dcf..336191c 100644 --- a/general/extras.py +++ b/general/extras.py @@ -1,5 +1,6 @@ def bound_value(lower, val, higher): return min(max(val, lower), higher) + def print_rect_info(rect): - print(rect.x(), rect.y(), rect.width(), rect.height()) \ No newline at end of file + print(rect.x(), rect.y(), rect.width(), rect.height()) diff --git a/general/highscore.py b/general/highscore.py index 6057cbc..d213505 100644 --- a/general/highscore.py +++ b/general/highscore.py @@ -14,6 +14,7 @@ def generate_highscore_file(file): if not i == 4: f.write('\n---\n') + def read_highscore_file(file): with open(file, 'r') as f: file_data = f.read() @@ -62,4 +63,4 @@ if __name__ == "__main__": #score = read_highscore_file("./highscore.txt") #replace_placing(score, DIFFICULTIES[2], 'abcv', 12345) #write_highscore_file("./new_highscore.txt", score) - generate_highscore_file("./highscore.txt") \ No newline at end of file + generate_highscore_file("./highscore.txt") diff --git a/graphic_components/buttons.py b/graphic_components/buttons.py index 1f9f656..0521053 100644 --- a/graphic_components/buttons.py +++ b/graphic_components/buttons.py @@ -15,7 +15,7 @@ from general import extras RANDOMCHAR = "~!@#$%^&*()_+`-=[]\{}|;:'<>,./?\"" -class animBox(QGraphicsObject): +class AnimBox(QGraphicsObject): # Prepare the signal hoverEnter = pyqtSignal() hoverExit = pyqtSignal() diff --git a/graphic_components/menu_graphics.py b/graphic_components/menu_graphics.py index a9a4b28..0dcee05 100644 --- a/graphic_components/menu_graphics.py +++ b/graphic_components/menu_graphics.py @@ -158,7 +158,7 @@ class DifficultyMenu(QGraphicsWidget): self.width = self.btn_width for i in range(5): - btn = buttons.animBox(0, (self.btn_height + 10) * i, + btn = buttons.AnimBox(0, (self.btn_height + 10) * i, self.btn_width, self.btn_height, DIFFICULTIES[i], parent=self) btn.buttonClicked.connect(self.clicked_on) self.diff_buttons.append(btn) @@ -199,7 +199,6 @@ class HighScoreDisplayer(QGraphicsObject): self.scoreboard_widget.setVisible(False) self.setAcceptHoverEvents(True) - #self.show_board(True) self.selected = False def set_disabled(self, state): diff --git a/graphic_components/sudoku_graphics.py b/graphic_components/sudoku_graphics.py index 009d8be..d5948dc 100644 --- a/graphic_components/sudoku_graphics.py +++ b/graphic_components/sudoku_graphics.py @@ -221,6 +221,7 @@ class SudokuGrid(BaseSudokuItem): self.update() + class NumberRing(BaseSudokuItem): # TODO: Add functions to animated the ring appearing # TODO: Adjust the positioning of each element @@ -239,7 +240,7 @@ class NumberRing(BaseSudokuItem): cell_string = 'X' else: cell_string = str(i) - btn = buttons.animBox(0, 0, self.cell_width, + btn = buttons.AnimBox(0, 0, self.cell_width, self.cell_height, cell_string, parent=self) self.cell_buttons.append(btn)