diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 8790457..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-.idea
-.idea/
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
deleted file mode 100644
index 3b00020..0000000
--- a/.idea/uiDesigner.xml
+++ /dev/null
@@ -1,125 +0,0 @@
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
-
-
-
-
diff --git a/README.md b/README.md
deleted file mode 100644
index c2224ae..0000000
--- a/README.md
+++ /dev/null
@@ -1,20 +0,0 @@
-Memory Puzzle
-============
-
-Memory Puzzle game developed using Pygame.
-
-(Adopted from the game written by Al Sweigart al@inventwithpython.com)
-
-Game Site
-=========
-
-http://uthcode.github.io/memorypuzzle/
-
-My aim for writing this game was write code which will live for a long time. The emphasis is modular code with excellent test coverage.
-
-Requirements
-============
-
- Python 2.7.6
- mock==1.0.1
- pygame==1.9.2pre
diff --git a/TODO b/TODO
deleted file mode 100644
index 44bd188..0000000
--- a/TODO
+++ /dev/null
@@ -1,16 +0,0 @@
-Desired Features
-================
-
-Version 1
----------
-* Write tests for the code and ensure coverage.
-* Package it.
-* github gh_pages.
-
-Version 2
----------
-* Make it object oriented if suitable.
-* A named tuple for box(x,y) will be better.
-* Reveal boards at random intervals.
-* Time Count and scores
-* Music
diff --git a/colors.py b/colors.py
deleted file mode 100644
index fc9718a..0000000
--- a/colors.py
+++ /dev/null
@@ -1,20 +0,0 @@
-"""Color values for MemoryPuzzle.
-
-These are the default colors used by the Memory Puzzle game.
-"""
-GRAY = (100, 100, 100)
-NAVYBLUE = (60, 60, 100)
-WHITE = (255, 255, 255)
-RED = (255, 0, 0)
-GREEN = (0, 255, 0)
-BLUE = (0, 0, 255)
-YELLOW = (255, 255, 0)
-ORANGE = (255, 128, 0)
-PURPLE = (255, 0, 255)
-CYAN = (0, 255, 255)
-IVORY = (255, 255, 240)
-
-BGCOLOR = GRAY
-LIGHTBGCOLOR = IVORY
-BOXCOLOR = IVORY
-HIGHLIGHTCOLOR = NAVYBLUE
diff --git a/constants.py b/constants.py
deleted file mode 100644
index 610cb87..0000000
--- a/constants.py
+++ /dev/null
@@ -1,64 +0,0 @@
-"""Constants used by the Memory Puzzle Game."""
-
-GAME_ROWS = 10
-GAME_COLS = 10
-
-EASY_GAME_ROWS = 4
-EASY_GAME_COLS = 5
-
-MEDIUM_GAME_ROWS = 6
-MEDIUM_GAME_COLS = 6
-
-HARD_GAME_ROWS = 7
-HARD_GAME_COLS = 10
-
-# size of box height and width in pixels
-BOXSIZE = 40
-QUARTER_BOXSIZE = int(BOXSIZE * 0.25)
-HALF_BOXSIZE = int(BOXSIZE * 0.5)
-
-# Frames per second, the general speed of the program.
-FPS = 20
-
-# size of gap between boxes in pixels
-GAPSIZE = 10
-
-# speed boxes sliding reveals and covers
-REVEALSPEED = 8
-
-# size of windows height in pixels
-WINDOWHEIGHT = 480
-
-# size of window's width in pixels
-WINDOWWIDTH = 640
-
-# welcome screen coordinates
-
-FONT_SIZE = 60
-
-LEVEL_BOX_WIDTH = WINDOWWIDTH / 2
-LEVEL_BOX_HEIGHT = WINDOWHEIGHT / 6
-LEVEL_BOX_LEFT = WINDOWWIDTH / 4
-LEVEL_BOX_TOP = WINDOWHEIGHT / 4
-
-EASY_RECT = ((LEVEL_BOX_LEFT, LEVEL_BOX_TOP),
- (LEVEL_BOX_WIDTH, LEVEL_BOX_HEIGHT))
-MEDIUM_RECT = ((LEVEL_BOX_LEFT, LEVEL_BOX_TOP + LEVEL_BOX_HEIGHT),
- (LEVEL_BOX_WIDTH, LEVEL_BOX_HEIGHT))
-HARD_RECT = ((LEVEL_BOX_LEFT, LEVEL_BOX_TOP + LEVEL_BOX_HEIGHT * 2),
- (LEVEL_BOX_WIDTH, LEVEL_BOX_HEIGHT))
-
-EASY_TEXT_POS = (LEVEL_BOX_LEFT + LEVEL_BOX_LEFT / 2,
- LEVEL_BOX_TOP + LEVEL_BOX_TOP / 4)
-MEDIUM_TEXT_POS = (LEVEL_BOX_LEFT + LEVEL_BOX_LEFT / 2,
- LEVEL_BOX_TOP + LEVEL_BOX_TOP / 4 + LEVEL_BOX_HEIGHT)
-HARD_TEXT_POS = (LEVEL_BOX_LEFT + LEVEL_BOX_LEFT / 2,
- LEVEL_BOX_TOP + LEVEL_BOX_TOP / 4 + LEVEL_BOX_HEIGHT * 2)
-
-# Game wait times
-
-GAME_END_WAIT = 2000
-
-GAME_WON_FLASH_WAIT = 300
-
-PIECE_CLOSE_WAIT = 1000
diff --git a/images/bkg.png b/images/bkg.png
new file mode 100644
index 0000000..d10e5ca
Binary files /dev/null and b/images/bkg.png differ
diff --git a/images/blacktocat.png b/images/blacktocat.png
new file mode 100644
index 0000000..9759d77
Binary files /dev/null and b/images/blacktocat.png differ
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..a26b338
--- /dev/null
+++ b/index.html
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+ Memorypuzzle by uthcode
+
+
+
+
+
+
+
Memorypuzzle
+
Memory Puzzle game developed using Pygame.
+
+
+
+
+
+
+
+ Memory puzzle is a simple memory puzzle game where you join two matching pieces and when all pieces are matched, you win. This is adopted from the game written by Al Sweigart al@inventwithpython.com .
+
+This version has 3 levels, Easy, Medium and Hard.
+
+
+ Game Opening
+
+
+
+
+ Easy Level
+
+
+
+
+ Medium Level
+
+
+
+
+ Hard Level
+
+
+
+
+ Game Source
+
+https://github.com/uthcode/memorypuzzle/
+
+Aim of this game was also to write modular reusable code, with the aim of longevity. The code has good test coverage too.
+
+
+ Author
+
+Senthil Kumaran senthil@uthcode.com
+
+
+
+
+
+
\ No newline at end of file
diff --git a/javascripts/main.js b/javascripts/main.js
new file mode 100644
index 0000000..d8135d3
--- /dev/null
+++ b/javascripts/main.js
@@ -0,0 +1 @@
+console.log('This would be the main JS file.');
diff --git a/memorypuzzle.py b/memorypuzzle.py
deleted file mode 100644
index 91dc4c5..0000000
--- a/memorypuzzle.py
+++ /dev/null
@@ -1,470 +0,0 @@
-"""Memory Puzzle Game.
-
-This is a small memory puzzle game, where blocks of similar images will be
-shown and you will be asked to guess, which boxes contained similar images.
-
-Adapted from the original game written by Al Sweigart al@inventwithpython.com
-
-@author: Senthil Kumaran
-"""
-import random
-import sys
-
-import pygame
-from pygame.constants import K_ESCAPE, KEYUP, MOUSEBUTTONUP, MOUSEMOTION, QUIT
-
-from colors import (
- BGCOLOR,
- BLUE,
- BOXCOLOR,
- CYAN,
- GREEN,
- HIGHLIGHTCOLOR,
- IVORY,
- LIGHTBGCOLOR,
- ORANGE,
- PURPLE,
- RED,
- YELLOW)
-from constants import (
- BOXSIZE,
- EASY_GAME_COLS,
- EASY_GAME_ROWS,
- EASY_RECT,
- EASY_TEXT_POS,
- FPS,
- FONT_SIZE,
- GAPSIZE,
- HARD_GAME_COLS,
- HARD_GAME_ROWS,
- HARD_RECT,
- HARD_TEXT_POS,
- MEDIUM_GAME_COLS,
- MEDIUM_GAME_ROWS,
- MEDIUM_RECT,
- MEDIUM_TEXT_POS,
- REVEALSPEED,
- WINDOWHEIGHT,
- WINDOWWIDTH, GAME_WON_FLASH_WAIT, GAME_END_WAIT, PIECE_CLOSE_WAIT,
- QUARTER_BOXSIZE, HALF_BOXSIZE)
-from shapes import (
- DIAMOND,
- DONUT,
- LINES,
- OVAL,
- SQUARE)
-
-
-ALLCOLORS = (RED, GREEN, BLUE, YELLOW, ORANGE, PURPLE, CYAN)
-ALLSHAPES = (DONUT, SQUARE, DIAMOND, LINES, OVAL)
-
-
-def left_top_coords_of_box(box, game_grid):
- """Top left coordinates of a box."""
-
- def get_xy_margins(grid):
- """Calculate the x, y margins of the grid."""
- game_rows, game_cols = grid
- return (int((WINDOWWIDTH - (game_cols * (BOXSIZE + GAPSIZE))) / 2),
- int((WINDOWHEIGHT - (game_rows * (BOXSIZE + GAPSIZE))) / 2))
-
- xmargin, ymargin = get_xy_margins(game_grid)
- x_value, y_value = box
- left = xmargin + x_value * (BOXSIZE + GAPSIZE)
- top = ymargin + y_value * (BOXSIZE + GAPSIZE)
- return left, top
-
-
-def draw_box_covers(display_surface, fps_clock, board, boxes, coverage,
- game_grid):
- """Draw boxes being covered/revealed.
-
- boxes is a list of two-item lists, which have the x & y spot of the box.
- """
- for box in boxes:
- left, top = left_top_coords_of_box(box, game_grid)
- pygame.draw.rect(
- display_surface,
- BGCOLOR,
- (left, top, BOXSIZE, BOXSIZE))
- shape, color = get_shape_and_color(board, box)
- draw_icon(display_surface, shape, color, box, game_grid)
- if coverage > 0: # only draw the cover if there is an coverage
- pygame.draw.rect(
- display_surface,
- BOXCOLOR,
- (left, top, coverage, BOXSIZE))
- pygame.display.update()
- fps_clock.tick(FPS)
-
-
-def draw_icon(display_surface, shape, color, box, game_grid):
- """Draw icon of the piece."""
- left, top = left_top_coords_of_box(box, game_grid)
-
- # Draw the shapes
- if shape == DONUT:
- pygame.draw.circle(
- display_surface,
- color,
- (left + HALF_BOXSIZE, top + HALF_BOXSIZE),
- HALF_BOXSIZE - 5)
- pygame.draw.circle(
- display_surface,
- BGCOLOR,
- (left + HALF_BOXSIZE, top + HALF_BOXSIZE),
- QUARTER_BOXSIZE - 5)
- elif shape == SQUARE:
- pygame.draw.rect(
- display_surface,
- color,
- (left + QUARTER_BOXSIZE,
- top + QUARTER_BOXSIZE,
- BOXSIZE - HALF_BOXSIZE,
- BOXSIZE - HALF_BOXSIZE))
- elif shape == DIAMOND:
- pygame.draw.polygon(
- display_surface,
- color,
- ((left + HALF_BOXSIZE, top),
- (left + BOXSIZE - 1, top + HALF_BOXSIZE),
- (left + HALF_BOXSIZE, top + BOXSIZE - 1),
- (left, top + HALF_BOXSIZE)))
- elif shape == LINES:
- for i in range(0, BOXSIZE, 4):
- pygame.draw.line(
- display_surface,
- color,
- (left, top + i),
- (left + i, top))
- pygame.draw.line(
- display_surface,
- color,
- (left + i, top + BOXSIZE - 1),
- (left + BOXSIZE - 1, top + i))
- elif shape == OVAL:
- pygame.draw.ellipse(
- display_surface,
- color,
- (left, top + QUARTER_BOXSIZE, BOXSIZE, HALF_BOXSIZE))
-
-
-def game_won(display_surface, board, game_grid):
- """Game is won by the place.
-
- Flash the background color celebrating the players win."""
- covered_boxes = generate_revealed_boxes_data(True, game_grid)
- flash_colors = [LIGHTBGCOLOR, BGCOLOR]
- for count in range(10):
- display_surface.fill(flash_colors[count % 2])
- draw_board(display_surface, board, covered_boxes, game_grid)
- pygame.display.update()
- pygame.time.wait(GAME_WON_FLASH_WAIT)
- pygame.time.wait(GAME_END_WAIT)
-
-
-def cover_boxes_animation(display_surface, fps_clock, board, boxes_to_cover,
- game_grid):
- """Do the box cover animation."""
- for coverage in range(0, BOXSIZE + REVEALSPEED, REVEALSPEED):
- draw_box_covers(
- display_surface,
- fps_clock,
- board,
- boxes_to_cover,
- coverage,
- game_grid)
-
-
-def get_shape_and_color(board, box):
- """Get the Shape and Color."""
- x_value, y_value = box
- return board[x_value][y_value][0], board[x_value][y_value][1]
-
-
-def reveal_boxes_animation(display_surface, fps_clock, board, boxes_to_reveal,
- game_grid):
- """Do the box reveal animation."""
- for coverage in range(BOXSIZE, -1, -REVEALSPEED):
- draw_box_covers(
- display_surface,
- fps_clock,
- board,
- boxes_to_reveal,
- coverage,
- game_grid)
-
-
-def draw_highlight_box(display_surface, box, game_grid):
- """Draw the highlight box."""
- left, top = left_top_coords_of_box(box, game_grid)
- pygame.draw.rect(
- display_surface,
- HIGHLIGHTCOLOR,
- (left - 5, top - 5, BOXSIZE + 10, BOXSIZE + 10),
- 4)
-
-
-def get_mouse_click():
- """Gets the mouse click position.
-
- Returns a tuple of if a mouse was clocked and the x, y coordinates."""
- mouse_clicked = False
- mouse_xpos = 0
- mouse_ypos = 0
- for event in pygame.event.get(): # event handling loop
- if (event.type == QUIT or
- (event.type == KEYUP and event.key == K_ESCAPE)):
- pygame.quit()
- sys.exit()
- elif event.type == MOUSEMOTION:
- mouse_xpos, mouse_ypos = event.pos
- elif event.type == MOUSEBUTTONUP:
- mouse_xpos, mouse_ypos = event.pos
- mouse_clicked = True
- return mouse_clicked, (mouse_xpos, mouse_ypos)
-
-
-def draw_board(display_surface, board, revealed, game_grid):
- """Draw the Board."""
- game_rows, game_cols = game_grid
- for x_value in range(game_cols):
- for y_value in range(game_rows):
- box = (x_value, y_value)
- left, top = left_top_coords_of_box(box, game_grid)
- if not revealed[x_value][y_value]:
- # Draw a covered Box
- pygame.draw.rect(
- display_surface,
- BOXCOLOR,
- (left, top, BOXSIZE, BOXSIZE),
- 3)
- else:
- shape, color = get_shape_and_color(board, box)
- draw_icon(
- display_surface,
- shape,
- color,
- box,
- game_grid)
-
-
-def generate_revealed_boxes_data(val, game_grid):
- """Generate Revealed Boxes Data."""
- game_rows, game_cols = game_grid
- revealed_boxes = [[val for _ in range(game_rows)] for _ in range(game_cols)]
- return revealed_boxes
-
-
-def start_game_animation(display_surface, fps_clock, board, game_grid):
- """Starts the Game opening animation.
-
- Randomly reveals the boxes 8 box at a time.
- """
- game_rows, game_cols = game_grid
-
- def split_into_groups_of(group_size, the_list):
- """Splits the list into the given group size."""
- result = []
- for cut in range(0, len(the_list), group_size):
- result.append(the_list[cut:cut + group_size])
- return result
-
- covered_boxes = generate_revealed_boxes_data(False, game_grid)
- boxes = [(x_value, y_value)
- for y_value in range(game_rows)
- for x_value in range(game_cols)]
- random.shuffle(boxes)
- box_groups = split_into_groups_of(8, boxes)
-
- draw_board(display_surface, board, covered_boxes, game_grid)
- for box_group in box_groups:
- reveal_boxes_animation(
- display_surface,
- fps_clock,
- board,
- box_group,
- game_grid)
- cover_boxes_animation(
- display_surface,
- fps_clock,
- board,
- box_group,
- game_grid)
-
-
-def get_game_level(display_surface, fps_clock):
- """Get the game level desired by the user."""
-
- def draw_welcome_screen():
- """Display the welcome and the three game levels."""
- font = pygame.font.Font(None, FONT_SIZE)
-
- easy_surf = font.render("Easy", True, IVORY)
- medium_surf = font.render("Medium", True, IVORY)
- hard_surf = font.render("Hard", True, IVORY)
- pygame.draw.rect(display_surface, CYAN, EASY_RECT, 3)
-
- display_surface.fill(CYAN, EASY_RECT)
- display_surface.blit(easy_surf, EASY_TEXT_POS)
-
- pygame.draw.rect(display_surface, ORANGE, MEDIUM_RECT, 3)
- display_surface.fill(ORANGE, MEDIUM_RECT)
- display_surface.blit(medium_surf, MEDIUM_TEXT_POS)
-
- pygame.draw.rect(display_surface, PURPLE, HARD_RECT, 3)
- display_surface.fill(PURPLE, HARD_RECT)
- display_surface.blit(hard_surf, HARD_TEXT_POS)
-
- while True:
- mouse_clicked, mouse_pointer = get_mouse_click()
- draw_welcome_screen()
-
- if mouse_clicked:
- display_surface.fill(BGCOLOR)
- if pygame.Rect(EASY_RECT).collidepoint(mouse_pointer):
- return EASY_GAME_ROWS, EASY_GAME_COLS
- elif pygame.Rect(MEDIUM_RECT).collidepoint(mouse_pointer):
- return MEDIUM_GAME_ROWS, MEDIUM_GAME_COLS
- elif pygame.Rect(HARD_RECT).collidepoint(mouse_pointer):
- return HARD_GAME_ROWS, HARD_GAME_COLS
-
- pygame.display.update()
- fps_clock.tick(FPS)
-
-
-def game_loop(display_surface, fps_clock):
- """Game loop encodes the logic of the game.
-
- During the game starts, prompts the player to choose the level and
- determines the game board size based on the level chosen. If two selections
- chosen by user are same, the boxes are left open, else they are closed.
- When all the chosen selections are open, the game is won by the user and
- the game is reset.
- """
-
- def player_has_won(revealed):
- """Game is won when all boxes are revealed."""
- return all([all(boxes) for boxes in revealed])
-
- def get_randomized_board(grid):
- """Get the Randomized Board.
-
- Gets the list of every possible shape in every possible color
- and then creates a board, a list of lists, with randomly placed icons.
- """
- game_rows, game_cols = grid
- icons = [(shape, color) for shape in ALLSHAPES for color in ALLCOLORS]
- random.shuffle(icons)
- num_icons_used = int(game_rows * game_cols / 2)
- icons = icons[:num_icons_used] * 2
- random.shuffle(icons)
-
- game_board = [[icons.pop(0) for _ in range(game_rows)]
- for _ in range(game_cols)]
- return game_board
-
- def get_box_under_mouse(pointer, grid):
- """Get the box at a pixel."""
- game_rows, game_cols = grid
- mouse_over = False
- for boxx in range(game_cols):
- for boxy in range(game_rows):
- left, top = left_top_coords_of_box((boxx, boxy), grid)
- box_rect = pygame.Rect(left, top, BOXSIZE, BOXSIZE)
- if box_rect.collidepoint(pointer):
- mouse_over = True
- return mouse_over, (boxx, boxy)
- return mouse_over, (None, None)
-
- def is_box_revealed(revealed, selected_box):
- """Returns the status of the box."""
- box_x, box_y = selected_box
- return revealed[box_x][box_y]
-
- def set_box_revealed(revealed, selected_box, status):
- """Sets the revealed status of the box."""
- box_x, box_y = selected_box
- revealed[box_x][box_y] = status
- return revealed
-
- game_started = False
- first_selection = None
-
- while True:
- display_surface.fill(BGCOLOR)
- if not game_started:
- game_grid = get_game_level(display_surface, fps_clock)
- board = get_randomized_board(game_grid)
- start_game_animation(display_surface, fps_clock, board, game_grid)
- revealed_boxes = generate_revealed_boxes_data(False, game_grid)
- game_started = True
- else:
- draw_board(display_surface, board, revealed_boxes, game_grid)
- mouse_clicked, mouse_pointer = get_mouse_click()
- mouse_over_box, box = get_box_under_mouse(mouse_pointer, game_grid)
- if mouse_over_box:
- if not is_box_revealed(revealed_boxes, box):
- draw_highlight_box(display_surface, box, game_grid)
- if not is_box_revealed(revealed_boxes, box) and mouse_clicked:
- reveal_boxes_animation(
- display_surface,
- fps_clock,
- board,
- [box],
- game_grid)
- revealed_boxes = set_box_revealed(revealed_boxes, box, True)
- if first_selection is None:
- first_selection = box
- else:
- first_piece = get_shape_and_color(
- board,
- first_selection)
- second_piece = get_shape_and_color(board, box)
- if first_piece != second_piece:
- pygame.time.wait(PIECE_CLOSE_WAIT)
- cover_boxes_animation(
- display_surface,
- fps_clock,
- board,
- [first_selection, box],
- game_grid)
- revealed_boxes = set_box_revealed(
- revealed_boxes,
- first_selection,
- False)
- revealed_boxes = set_box_revealed(
- revealed_boxes,
- box,
- False)
- elif player_has_won(revealed_boxes):
- game_won(display_surface, board, game_grid)
- game_started = False
- first_selection = None
-
- pygame.display.update()
- fps_clock.tick(FPS)
-
-
-def get_game_clock_display():
- """Initialize pygame and return clock and display.
-
- Return frames per second clock and Display Surface of the pygame.
- """
- pygame.init()
- pygame.display.set_caption("Memory Game")
- return (pygame.time.Clock(),
- pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT)))
-
-
-def main():
- """Memory puzzle game.
-
- Gets the clock and display surface and hands it over the game loop.
- """
- fps_clock, display_surface = get_game_clock_display()
- game_loop(display_surface, fps_clock)
-
-
-if __name__ == '__main__':
- main()
diff --git a/params.json b/params.json
new file mode 100644
index 0000000..d7c92bb
--- /dev/null
+++ b/params.json
@@ -0,0 +1 @@
+{"name":"Memorypuzzle","tagline":"Memory Puzzle game developed using Pygame.","body":"Memory puzzle is a simple memory puzzle game where you join two matching pieces and when all pieces are matched, you win. This is adopted from the game written by Al Sweigart .\r\n\r\nThis version has 3 levels, Easy, Medium and Hard.\r\n\r\n### Game Opening\r\n\r\n\r\n\r\n\r\n### Easy Level\r\n\r\n\r\n\r\n### Medium Level\r\n\r\n\r\n\r\n### Hard Level\r\n\r\n\r\n\r\n### Game Source\r\n\r\n`https://github.com/uthcode/memorypuzzle/`\r\n\r\nAim of this game was also to write modular reusable code, with the aim of longevity. The code has good test coverage too. \r\n\r\n### Author\r\n\r\nSenthil Kumaran ","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}
\ No newline at end of file
diff --git a/shapes.py b/shapes.py
deleted file mode 100644
index 4281176..0000000
--- a/shapes.py
+++ /dev/null
@@ -1,7 +0,0 @@
-"""Shapes used by the Memory Puzzle Game."""
-
-DIAMOND = 'diamond'
-DONUT = 'donut'
-LINES = 'lines'
-OVAL = 'oval'
-SQUARE = 'square'
diff --git a/stylesheets/pygment_trac.css b/stylesheets/pygment_trac.css
new file mode 100644
index 0000000..d1df6a2
--- /dev/null
+++ b/stylesheets/pygment_trac.css
@@ -0,0 +1,68 @@
+.highlight .c { color: #999988; font-style: italic } /* Comment */
+.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
+.highlight .k { font-weight: bold } /* Keyword */
+.highlight .o { font-weight: bold } /* Operator */
+.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */
+.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
+.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */
+.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
+.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
+.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */
+.highlight .ge { font-style: italic } /* Generic.Emph */
+.highlight .gr { color: #aa0000 } /* Generic.Error */
+.highlight .gh { color: #999999 } /* Generic.Heading */
+.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
+.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */
+.highlight .go { color: #888888 } /* Generic.Output */
+.highlight .gp { color: #555555 } /* Generic.Prompt */
+.highlight .gs { font-weight: bold } /* Generic.Strong */
+.highlight .gu { color: #800080; font-weight: bold; } /* Generic.Subheading */
+.highlight .gt { color: #aa0000 } /* Generic.Traceback */
+.highlight .kc { font-weight: bold } /* Keyword.Constant */
+.highlight .kd { font-weight: bold } /* Keyword.Declaration */
+.highlight .kn { font-weight: bold } /* Keyword.Namespace */
+.highlight .kp { font-weight: bold } /* Keyword.Pseudo */
+.highlight .kr { font-weight: bold } /* Keyword.Reserved */
+.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */
+.highlight .m { color: #009999 } /* Literal.Number */
+.highlight .s { color: #d14 } /* Literal.String */
+.highlight .na { color: #008080 } /* Name.Attribute */
+.highlight .nb { color: #0086B3 } /* Name.Builtin */
+.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */
+.highlight .no { color: #008080 } /* Name.Constant */
+.highlight .ni { color: #800080 } /* Name.Entity */
+.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */
+.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */
+.highlight .nn { color: #555555 } /* Name.Namespace */
+.highlight .nt { color: #CBDFFF } /* Name.Tag */
+.highlight .nv { color: #008080 } /* Name.Variable */
+.highlight .ow { font-weight: bold } /* Operator.Word */
+.highlight .w { color: #bbbbbb } /* Text.Whitespace */
+.highlight .mf { color: #009999 } /* Literal.Number.Float */
+.highlight .mh { color: #009999 } /* Literal.Number.Hex */
+.highlight .mi { color: #009999 } /* Literal.Number.Integer */
+.highlight .mo { color: #009999 } /* Literal.Number.Oct */
+.highlight .sb { color: #d14 } /* Literal.String.Backtick */
+.highlight .sc { color: #d14 } /* Literal.String.Char */
+.highlight .sd { color: #d14 } /* Literal.String.Doc */
+.highlight .s2 { color: #d14 } /* Literal.String.Double */
+.highlight .se { color: #d14 } /* Literal.String.Escape */
+.highlight .sh { color: #d14 } /* Literal.String.Heredoc */
+.highlight .si { color: #d14 } /* Literal.String.Interpol */
+.highlight .sx { color: #d14 } /* Literal.String.Other */
+.highlight .sr { color: #009926 } /* Literal.String.Regex */
+.highlight .s1 { color: #d14 } /* Literal.String.Single */
+.highlight .ss { color: #990073 } /* Literal.String.Symbol */
+.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */
+.highlight .vc { color: #008080 } /* Name.Variable.Class */
+.highlight .vg { color: #008080 } /* Name.Variable.Global */
+.highlight .vi { color: #008080 } /* Name.Variable.Instance */
+.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */
+
+.type-csharp .highlight .k { color: #0000FF }
+.type-csharp .highlight .kt { color: #0000FF }
+.type-csharp .highlight .nf { color: #000000; font-weight: normal }
+.type-csharp .highlight .nc { color: #2B91AF }
+.type-csharp .highlight .nn { color: #000000 }
+.type-csharp .highlight .s { color: #A31515 }
+.type-csharp .highlight .sc { color: #A31515 }
diff --git a/stylesheets/stylesheet.css b/stylesheets/stylesheet.css
new file mode 100644
index 0000000..a54a639
--- /dev/null
+++ b/stylesheets/stylesheet.css
@@ -0,0 +1,247 @@
+body {
+ margin: 0;
+ padding: 0;
+ background: #151515 url("../images/bkg.png") 0 0;
+ color: #eaeaea;
+ font: 16px;
+ line-height: 1.5;
+ font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace;
+}
+
+/* General & 'Reset' Stuff */
+
+.container {
+ width: 90%;
+ max-width: 600px;
+ margin: 0 auto;
+}
+
+section {
+ display: block;
+ margin: 0 0 20px 0;
+}
+
+h1, h2, h3, h4, h5, h6 {
+ margin: 0 0 20px;
+}
+
+li {
+ line-height: 1.4 ;
+}
+
+/* Header,
+ header - container
+ h1 - project name
+ h2 - project description
+*/
+
+header {
+ background: rgba(0, 0, 0, 0.1);
+ width: 100%;
+ border-bottom: 1px dashed #b5e853;
+ padding: 20px 0;
+ margin: 0 0 40px 0;
+}
+
+header h1 {
+ font-size: 30px;
+ line-height: 1.5;
+ margin: 0 0 0 -40px;
+ font-weight: bold;
+ font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace;
+ color: #b5e853;
+ text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1),
+ 0 0 5px rgba(181, 232, 83, 0.1),
+ 0 0 10px rgba(181, 232, 83, 0.1);
+ letter-spacing: -1px;
+ -webkit-font-smoothing: antialiased;
+}
+
+header h1:before {
+ content: "./ ";
+ font-size: 24px;
+}
+
+header h2 {
+ font-size: 18px;
+ font-weight: 300;
+ color: #666;
+}
+
+#downloads .btn {
+ display: inline-block;
+ text-align: center;
+ margin: 0;
+}
+
+/* Main Content
+*/
+
+#main_content {
+ width: 100%;
+ -webkit-font-smoothing: antialiased;
+}
+section img {
+ max-width: 100%
+}
+
+h1, h2, h3, h4, h5, h6 {
+ font-weight: normal;
+ font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace;
+ color: #b5e853;
+ letter-spacing: -0.03em;
+ text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1),
+ 0 0 5px rgba(181, 232, 83, 0.1),
+ 0 0 10px rgba(181, 232, 83, 0.1);
+}
+
+#main_content h1 {
+ font-size: 30px;
+}
+
+#main_content h2 {
+ font-size: 24px;
+}
+
+#main_content h3 {
+ font-size: 18px;
+}
+
+#main_content h4 {
+ font-size: 14px;
+}
+
+#main_content h5 {
+ font-size: 12px;
+ text-transform: uppercase;
+ margin: 0 0 5px 0;
+}
+
+#main_content h6 {
+ font-size: 12px;
+ text-transform: uppercase;
+ color: #999;
+ margin: 0 0 5px 0;
+}
+
+dt {
+ font-style: italic;
+ font-weight: bold;
+}
+
+ul li {
+ list-style: none;
+}
+
+ul li:before {
+ content: ">>";
+ font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace;
+ font-size: 13px;
+ color: #b5e853;
+ margin-left: -37px;
+ margin-right: 21px;
+ line-height: 16px;
+}
+
+blockquote {
+ color: #aaa;
+ padding-left: 10px;
+ border-left: 1px dotted #666;
+}
+
+pre {
+ background: rgba(0, 0, 0, 0.9);
+ border: 1px solid rgba(255, 255, 255, 0.15);
+ padding: 10px;
+ font-size: 14px;
+ color: #b5e853;
+ border-radius: 2px;
+ -moz-border-radius: 2px;
+ -webkit-border-radius: 2px;
+ text-wrap: normal;
+ overflow: auto;
+ overflow-y: hidden;
+}
+
+table {
+ width: 100%;
+ margin: 0 0 20px 0;
+}
+
+th {
+ text-align: left;
+ border-bottom: 1px dashed #b5e853;
+ padding: 5px 10px;
+}
+
+td {
+ padding: 5px 10px;
+}
+
+hr {
+ height: 0;
+ border: 0;
+ border-bottom: 1px dashed #b5e853;
+ color: #b5e853;
+}
+
+/* Buttons
+*/
+
+.btn {
+ display: inline-block;
+ background: -webkit-linear-gradient(top, rgba(40, 40, 40, 0.3), rgba(35, 35, 35, 0.3) 50%, rgba(10, 10, 10, 0.3) 50%, rgba(0, 0, 0, 0.3));
+ padding: 8px 18px;
+ border-radius: 50px;
+ border: 2px solid rgba(0, 0, 0, 0.7);
+ border-bottom: 2px solid rgba(0, 0, 0, 0.7);
+ border-top: 2px solid rgba(0, 0, 0, 1);
+ color: rgba(255, 255, 255, 0.8);
+ font-family: Helvetica, Arial, sans-serif;
+ font-weight: bold;
+ font-size: 13px;
+ text-decoration: none;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.75);
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
+}
+
+.btn:hover {
+ background: -webkit-linear-gradient(top, rgba(40, 40, 40, 0.6), rgba(35, 35, 35, 0.6) 50%, rgba(10, 10, 10, 0.8) 50%, rgba(0, 0, 0, 0.8));
+}
+
+.btn .icon {
+ display: inline-block;
+ width: 16px;
+ height: 16px;
+ margin: 1px 8px 0 0;
+ float: left;
+}
+
+.btn-github .icon {
+ opacity: 0.6;
+ background: url("../images/blacktocat.png") 0 0 no-repeat;
+}
+
+/* Links
+ a, a:hover, a:visited
+*/
+
+a {
+ color: #63c0f5;
+ text-shadow: 0 0 5px rgba(104, 182, 255, 0.5);
+}
+
+/* Clearfix */
+
+.cf:before, .cf:after {
+ content:"";
+ display:table;
+}
+
+.cf:after {
+ clear:both;
+}
+
+.cf {
+ zoom:1;
+}
\ No newline at end of file
diff --git a/test_memorypuzzle.py b/test_memorypuzzle.py
deleted file mode 100644
index b373216..0000000
--- a/test_memorypuzzle.py
+++ /dev/null
@@ -1,411 +0,0 @@
-import sys
-import unittest
-
-import mock
-from pygame.constants import QUIT, MOUSEBUTTONUP
-import pygame
-from mock import MagicMock
-
-import memorypuzzle
-from colors import (
- BGCOLOR,
- BLUE,
- BOXCOLOR,
- CYAN,
- GRAY,
- GREEN,
- HIGHLIGHTCOLOR,
- IVORY,
- LIGHTBGCOLOR,
- NAVYBLUE,
- ORANGE,
- PURPLE,
- RED,
- WHITE,
- YELLOW)
-from constants import (
- BOXSIZE,
- EASY_GAME_COLS,
- EASY_GAME_ROWS,
- FPS,
- GAME_COLS,
- GAME_ROWS,
- GAPSIZE,
- HARD_GAME_COLS,
- HARD_GAME_ROWS,
- MEDIUM_GAME_COLS,
- MEDIUM_GAME_ROWS,
- REVEALSPEED,
- WINDOWHEIGHT,
- WINDOWWIDTH, HALF_BOXSIZE, QUARTER_BOXSIZE, GAME_WON_FLASH_WAIT,
- GAME_END_WAIT, EASY_RECT)
-from shapes import (
- DIAMOND,
- DONUT,
- LINES,
- OVAL,
- SQUARE)
-from memorypuzzle import ALLCOLORS, ALLSHAPES
-
-
-TEST_BOARD = [
- [(LINES, ORANGE), (DIAMOND, ORANGE), (SQUARE, RED), (SQUARE, RED)],
- [(DIAMOND, CYAN), (SQUARE, PURPLE), (DIAMOND, ORANGE), (LINES, CYAN)],
- [(LINES, CYAN), (LINES, YELLOW), (SQUARE, PURPLE), (LINES, ORANGE)],
- [(DONUT, GREEN), (DONUT, CYAN), (DONUT, RED), (DONUT, CYAN)],
- [(DONUT, GREEN), (DIAMOND, CYAN), (LINES, YELLOW), (DONUT, RED)]]
-
-TEST_BOX = (0, 0)
-TEST_GRID = (EASY_GAME_ROWS, EASY_GAME_COLS)
-LEFT_TOP_COORDS_OF_TEST_BOX = (195, 140)
-
-
-class TestGame(unittest.TestCase):
- def test_constants(self):
- self.assertTrue(GAME_ROWS > 0)
- self.assertTrue(GAME_COLS > 0)
- self.assertTrue(BOXSIZE > 0)
- self.assertTrue(FPS > 0)
- self.assertTrue(GAPSIZE > 0)
- self.assertTrue(REVEALSPEED > 0)
- self.assertTrue(WINDOWHEIGHT > 0)
- self.assertTrue(WINDOWWIDTH > 0)
-
- def test_even_pairs(self):
- self.assertEqual(GAME_COLS * GAME_ROWS % 2, 0,
- "Board needs to have even number of boxes"
- "for pairs of matches.")
-
- def test_color_shape_ratio(self):
- self.assertTrue(
- len(ALLCOLORS) * len(ALLSHAPES) * 4 >= GAME_COLS * GAME_ROWS,
- "Board is too big for the number of shapes/colors defined.")
-
- def test_color_values(self):
- colors = [
- BGCOLOR,
- BLUE,
- BOXCOLOR,
- CYAN,
- GRAY,
- GREEN,
- HIGHLIGHTCOLOR,
- IVORY,
- LIGHTBGCOLOR,
- NAVYBLUE,
- ORANGE,
- PURPLE,
- RED,
- WHITE,
- YELLOW]
- for color in colors:
- self.assertTrue(isinstance(color, tuple))
- self.assertEqual(3, len(color))
- self.assertTrue(
- 0 <= color[0] <= 255 and
- 0 <= color[1] <= 255 and
- 0 <= color[2] <= 255)
-
- def test_all_constants(self):
- constants = [
- BOXSIZE,
- EASY_GAME_COLS,
- EASY_GAME_ROWS,
- FPS,
- GAME_COLS,
- GAME_ROWS,
- GAPSIZE,
- HARD_GAME_COLS,
- HARD_GAME_ROWS,
- MEDIUM_GAME_COLS,
- MEDIUM_GAME_ROWS,
- REVEALSPEED,
- WINDOWHEIGHT,
- WINDOWWIDTH]
- for constant in constants:
- self.assertTrue(constant > 0)
-
- def test_shapes(self):
- shapes = [
- DIAMOND,
- DONUT,
- LINES,
- OVAL,
- SQUARE]
- for shape in shapes:
- self.assertTrue(isinstance(shape, str))
- self.assertTrue(shape in ALLSHAPES, "%s not in ALLCOLORS" % shape)
-
- def test_get_game_clock_display(self):
- pygame.init = MagicMock()
- pygame.display = MagicMock()
- pygame.time = MagicMock()
- memorypuzzle.get_game_clock_display()
- pygame.init.assert_called_once_with()
- pygame.display.set_caption.assert_called_once_with("Memory Game")
- pygame.time.Clock.assert_called_once_with()
- pygame.display.set_mode.assert_called_once_with(
- (WINDOWWIDTH, WINDOWHEIGHT))
-
- def test_left_top_coords_of_box(self):
- left, top = memorypuzzle.left_top_coords_of_box(TEST_BOX, TEST_GRID)
- self.assertEquals(
- (left, top),
- LEFT_TOP_COORDS_OF_TEST_BOX,
- "Coordinates Differ From the calculated expected Value.")
-
- @mock.patch("memorypuzzle.draw_icon", MagicMock())
- def test_draw_box_covers(self):
- pygame.draw = MagicMock()
- pygame.display = MagicMock()
- display_surface = MagicMock()
- fps_clock = MagicMock()
- left, top = LEFT_TOP_COORDS_OF_TEST_BOX
- memorypuzzle.draw_box_covers(
- display_surface,
- fps_clock,
- TEST_BOARD,
- [TEST_BOX],
- 10,
- TEST_GRID)
-
- expected_draw_rect = [
- mock.call(display_surface, BGCOLOR, (left, top, BOXSIZE, BOXSIZE)),
- mock.call(display_surface, BOXCOLOR, (left, top, 10, BOXSIZE))
- ]
- self.assertEqual(expected_draw_rect,
- pygame.draw.rect.call_args_list)
- memorypuzzle.draw_icon.assert_called_once_with(
- display_surface,
- LINES,
- ORANGE,
- TEST_BOX,
- TEST_GRID)
- pygame.display.update.assert_called_once_with()
- fps_clock.tick.assert_called_once_with(FPS)
-
- def test_draw_icon(self):
- pygame.draw = MagicMock()
- display_surface = MagicMock()
- left, top = LEFT_TOP_COORDS_OF_TEST_BOX
- memorypuzzle.draw_icon(display_surface, DONUT, RED, TEST_BOX, TEST_GRID)
- expected = [
- mock.call(
- display_surface,
- RED,
- (left + HALF_BOXSIZE, top + HALF_BOXSIZE),
- HALF_BOXSIZE - 5),
- mock.call(
- display_surface,
- BGCOLOR,
- (left + HALF_BOXSIZE, top + HALF_BOXSIZE),
- QUARTER_BOXSIZE - 5)
- ]
- self.assertTrue(pygame.draw.circle.call_args_list, expected)
-
- @mock.patch('memorypuzzle.draw_board', MagicMock())
- def test_game_won(self):
- display_surface = MagicMock()
- pygame.time = MagicMock()
- pygame.display = MagicMock()
- covered_boxes = memorypuzzle.generate_revealed_boxes_data(
- True,
- TEST_GRID)
- display_update_expected = [mock.call() for _ in range(10)]
- flash_colors = [LIGHTBGCOLOR, BGCOLOR]
- display_surface_fill_expected = [
- mock.call(flash_colors[count % 2]) for count in range(10)]
- time_wait_expected = [mock.call(GAME_WON_FLASH_WAIT) for _ in range(10)]
- time_wait_expected.append(mock.call(GAME_END_WAIT))
- draw_board_called = [
- mock.call(display_surface, TEST_BOARD, covered_boxes, TEST_GRID)
- for _ in range(10)]
- memorypuzzle.game_won(display_surface, TEST_BOARD, TEST_GRID)
- self.assertEqual(
- pygame.display.update.call_args_list,
- display_update_expected)
- self.assertEqual(display_surface.fill.call_args_list,
- display_surface_fill_expected)
- self.assertEqual(pygame.time.wait.call_args_list,
- time_wait_expected)
- self.assertEqual(
- memorypuzzle.draw_board.call_args_list,
- draw_board_called)
-
- @mock.patch('memorypuzzle.draw_box_covers', MagicMock())
- def test_cover_boxes_animation(self):
- display_surface = MagicMock()
- fps_clock = MagicMock()
- expected_box_covers = [
- mock.call(
- display_surface,
- fps_clock,
- TEST_BOARD,
- [TEST_BOX],
- coverage,
- TEST_GRID)
- for coverage in range(0, BOXSIZE + REVEALSPEED, REVEALSPEED)]
-
- memorypuzzle.cover_boxes_animation(
- display_surface,
- fps_clock,
- TEST_BOARD,
- [TEST_BOX],
- TEST_GRID)
- self.assertEquals(
- memorypuzzle.draw_box_covers.call_args_list,
- expected_box_covers)
-
- def test_get_shape_and_color(self):
- self.assertEqual(
- (LINES, ORANGE),
- memorypuzzle.get_shape_and_color(TEST_BOARD, TEST_BOX))
-
- @mock.patch("memorypuzzle.draw_box_covers", MagicMock())
- def test_reveal_boxes_animation(self):
- display_surface = MagicMock()
- fps_clock = MagicMock()
- expected_draw_box_covers = [
- mock.call(
- display_surface,
- fps_clock,
- TEST_BOARD,
- [TEST_BOX],
- coverage,
- TEST_GRID)
- for coverage in range(BOXSIZE, -1, -REVEALSPEED)]
- memorypuzzle.reveal_boxes_animation(
- display_surface,
- fps_clock,
- TEST_BOARD,
- [TEST_BOX],
- TEST_GRID)
- self.assertEqual(
- expected_draw_box_covers,
- memorypuzzle.draw_box_covers.call_args_list)
-
- def test_draw_highlight_box(self):
- display_surface = MagicMock()
- left, top = LEFT_TOP_COORDS_OF_TEST_BOX
- pygame.draw = MagicMock()
- memorypuzzle.draw_highlight_box(display_surface, TEST_BOX, TEST_GRID)
- pygame.draw.rect.assert_called_once_with(
- display_surface,
- HIGHLIGHTCOLOR,
- (left - 5, top - 5, BOXSIZE + 10, BOXSIZE + 10),
- 4)
-
- def test_get_mouse_click(self):
- pygame.event = MagicMock()
- pygame.quit = MagicMock()
- sys.exit = MagicMock()
- pygame.event.type = QUIT
- pygame.event.get.return_value = [pygame.event]
- memorypuzzle.get_mouse_click()
- pygame.quit.assert_called_once_with()
- sys.exit.assert_called_once_with()
-
- pygame.event.type = MOUSEBUTTONUP
- pygame.event.pos = (100, 100)
- pygame.event.get.return_value = [pygame.event]
- self.assertEqual(
- (True, (100, 100)),
- memorypuzzle.get_mouse_click())
-
- @mock.patch("memorypuzzle.draw_icon", MagicMock())
- def test_draw_board(self):
- display_surface = MagicMock()
- pygame.draw = MagicMock()
- rows, cols = TEST_GRID
- revealed_boxes = memorypuzzle.generate_revealed_boxes_data(
- False,
- TEST_GRID)
- expected_pygame_draw = [
- mock.call(
- display_surface,
- BOXCOLOR,
- (mock.ANY, mock.ANY, BOXSIZE, BOXSIZE),
- 3)
- for _ in range(rows * cols)]
- memorypuzzle.draw_board(
- display_surface,
- TEST_BOARD,
- revealed_boxes,
- TEST_GRID)
- self.assertEqual(expected_pygame_draw, pygame.draw.rect.call_args_list)
- revealed_boxes[0][0] = True
- expected_pygame_draw.pop(0)
- pygame.draw.rect.reset_mock()
- expected_draw_icon = [
- mock.call(display_surface, LINES, ORANGE, TEST_BOX, TEST_GRID)]
- memorypuzzle.draw_board(
- display_surface,
- TEST_BOARD,
- revealed_boxes,
- TEST_GRID)
- self.assertEqual(
- len(expected_pygame_draw),
- len(pygame.draw.rect.call_args_list))
- self.assertEqual(
- expected_draw_icon,
- memorypuzzle.draw_icon.call_args_list)
-
- def test_generate_revealed_boxes_data(self):
- table = memorypuzzle.generate_revealed_boxes_data(True, TEST_GRID)
- self.assertTrue(all(all(rows) for rows in table))
-
- @mock.patch("memorypuzzle.draw_board", MagicMock())
- @mock.patch("memorypuzzle.reveal_boxes_animation", MagicMock())
- @mock.patch("memorypuzzle.cover_boxes_animation", MagicMock())
- def test_start_game_animation(self):
- display_surface = MagicMock()
- fps_clock = MagicMock()
- covered_boxes = memorypuzzle.generate_revealed_boxes_data(
- False,
- TEST_GRID)
- expected_revealed_boxes_animation = [
- mock.call(display_surface, fps_clock, TEST_BOARD, mock.ANY,
- TEST_GRID)
- for _ in range(3)]
- expected_cover_boxes_animation = [
- mock.call(display_surface, fps_clock, TEST_BOARD, mock.ANY,
- TEST_GRID)
- for _ in range(3)]
- memorypuzzle.start_game_animation(
- display_surface,
- fps_clock,
- TEST_BOARD,
- TEST_GRID)
- self.assertEqual(
- [mock.call(display_surface, TEST_BOARD, covered_boxes, TEST_GRID)],
- memorypuzzle.draw_board.call_args_list)
- self.assertEqual(
- expected_revealed_boxes_animation,
- memorypuzzle.reveal_boxes_animation.call_args_list)
- self.assertEqual(
- expected_cover_boxes_animation,
- memorypuzzle.cover_boxes_animation.call_args_list)
-
- @mock.patch("memorypuzzle.get_mouse_click", MagicMock())
- def test_game_level(self):
- display_surface = MagicMock()
- fps_clock = MagicMock()
- pygame.Rect = MagicMock()
- pygame.font = MagicMock()
- memorypuzzle.get_mouse_click.return_value = (True, mock.ANY)
- pygame.Rect(EASY_RECT).collidepoint.return_value = True
- self.assertEqual(
- (EASY_GAME_ROWS, EASY_GAME_COLS),
- memorypuzzle.get_game_level(display_surface, fps_clock))
- memorypuzzle.get_mouse_click.assert_called_once_with()
-
- @mock.patch("memorypuzzle.game_loop", MagicMock())
- @mock.patch(
- "memorypuzzle.get_game_clock_display",
- MagicMock(return_value=(mock.ANY, mock.ANY)))
- def test_main(self):
- memorypuzzle.main()
- fps, clock = memorypuzzle.get_game_clock_display()
- memorypuzzle.game_loop.assert_called_with(fps, clock)
-
-