-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored main branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,10 +11,20 @@ def square_start(self, hieght: int, width: int) -> [[int, int]]: | |
| fourth_x = second_x * 3 | ||
| first_y = hieght / 3 | ||
| second_y = first_y * 2 | ||
| squares = [[first_x, 0], [second_x, 0], [third_x, 0], [fourth_x, 0], | ||
| [first_x, first_y], [second_x, first_y], [third_x, first_y], [fourth_x, first_y], | ||
| [first_x, second_y], [second_x, second_y], [third_x, second_y], [fourth_x, second_y]] | ||
| return squares | ||
| return [ | ||
| [first_x, 0], | ||
| [second_x, 0], | ||
| [third_x, 0], | ||
| [fourth_x, 0], | ||
| [first_x, first_y], | ||
| [second_x, first_y], | ||
| [third_x, first_y], | ||
| [fourth_x, first_y], | ||
| [first_x, second_y], | ||
| [second_x, second_y], | ||
| [third_x, second_y], | ||
| [fourth_x, second_y], | ||
| ] | ||
|
|
||
| def fullsquares(self, hieght: int, width: int) -> {int: pygame.Rect}: | ||
| numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] | ||
|
|
@@ -28,13 +38,16 @@ def fullsquares(self, hieght: int, width: int) -> {int: pygame.Rect}: | |
| return fullsquares | ||
|
|
||
| def prompts(self) -> {str: str}: | ||
| prompts = { | ||
| "Pencil": "Click On the square where you saw the yellow Pencil.", | ||
| "Mountain": "Click On the square where you saw the Tall White Mountain.", | ||
| "Numbers": "Click On the square where you saw the Numbers surronded by the red circles.", | ||
| "Letters": "Click On the square where you saw the the letters in the yellow box." | ||
| return { | ||
| "Pencil": | ||
| "Click On the square where you saw the yellow Pencil.", | ||
| "Mountain": | ||
| "Click On the square where you saw the Tall White Mountain.", | ||
| "Numbers": | ||
| "Click On the square where you saw the Numbers surronded by the red circles.", | ||
| "Letters": | ||
| "Click On the square where you saw the the letters in the yellow box.", | ||
| } | ||
| return prompts | ||
|
Comment on lines
-31
to
-37
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def images(self) -> {str: pygame.surface}: | ||
| images = {"Pencil": pygame.image.load("../assets/pencil.jpg"), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,17 +64,13 @@ def draw_random_image(self, random_image_choice: str = "Mountain", sleeptime: in | |
| del self.Images[invimage] | ||
| self.correct_square = self.squares.index(random_square) | ||
| self.correct_square += 1 | ||
|
|
||
| prompt = self.prompts[random_image_choice] | ||
|
|
||
| return prompt | ||
|
|
||
| return self.prompts[random_image_choice] | ||
|
Comment on lines
-67
to
+68
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def drawscreen(self, difficulty: int = 5, sleeptimer: int = 1) -> pygame.display: | ||
|
|
||
| prompt = "" | ||
| current_difficulty = 0 | ||
| amount_of_guesses = 1 | ||
|
|
||
|
Comment on lines
-76
to
-77
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| while current_difficulty != difficulty: | ||
| event = pygame.event.poll() | ||
| if event.type == pygame.QUIT: | ||
|
|
@@ -87,8 +83,8 @@ def drawscreen(self, difficulty: int = 5, sleeptimer: int = 1) -> pygame.display | |
| self.drawlines() | ||
| prompt = self.draw_random_image(sleeptime=sleeptimer) | ||
| current_difficulty += 1 | ||
| if self.correct_square == None: | ||
|
|
||
| if self.correct_square is None: | ||
| print("Game Bug Image did not show up.") | ||
| print("Restarting...") | ||
| self.screen.fill((0, 0, 0)) | ||
|
|
@@ -98,7 +94,9 @@ def drawscreen(self, difficulty: int = 5, sleeptimer: int = 1) -> pygame.display | |
| self.drawscreen(difficulty, sleeptimer) | ||
| else: | ||
| print(prompt) | ||
|
|
||
|
|
||
| amount_of_guesses = 1 | ||
|
|
||
| while True: | ||
| event = pygame.event.poll() | ||
| self.screen.fill((0, 0, 0)) | ||
|
|
@@ -109,18 +107,17 @@ def drawscreen(self, difficulty: int = 5, sleeptimer: int = 1) -> pygame.display | |
| if event.type == pygame.K_ESCAPE: | ||
| pygame.quit() | ||
| sys.exit() | ||
| if event.type == pygame.MOUSEBUTTONUP: | ||
|
|
||
| if (event.type == pygame.MOUSEBUTTONUP | ||
| and event.button == 1): | ||
| correct_rect = self.fullsquares[self.correct_square] | ||
| if event.button == 1: | ||
| if correct_rect.collidepoint(event.pos): | ||
| print("guess : " + str(amount_of_guesses)) | ||
| print("Correct!") | ||
| print("You got it right in " + str(amount_of_guesses) + " guess/ess") | ||
| sys.exit() | ||
|
|
||
| else: | ||
| print("guess : " + str(amount_of_guesses)) | ||
| amount_of_guesses += 1 | ||
| print("That is not the correct square") | ||
| if correct_rect.collidepoint(event.pos): | ||
| print("guess : " + str(amount_of_guesses)) | ||
| print("Correct!") | ||
| print("You got it right in " + str(amount_of_guesses) + " guess/ess") | ||
| sys.exit() | ||
|
|
||
| else: | ||
| print("guess : " + str(amount_of_guesses)) | ||
| amount_of_guesses += 1 | ||
| print("That is not the correct square") | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
MemoryGameData.square_startrefactored with the following changes:inline-immediately-returned-variable)