diff --git a/src/game/screens/game.py b/src/game/screens/game.py index 8e27485..518d002 100644 --- a/src/game/screens/game.py +++ b/src/game/screens/game.py @@ -36,10 +36,18 @@ class Game(BaseScreen): self._start_background_music() def draw(self) -> None: - """Update the display.""" + """ + Raises: + NotImplementedError: Not implemented yet. + """ + raise NotImplementedError def update(self) -> None: - pass + """ + Raises: + NotImplementedError: Not implemented yet. + """ + raise NotImplementedError def run(self) -> None: """Run a single iteration of the game loop.""" diff --git a/src/game/screens/main.py b/src/game/screens/main.py index cf7b622..a2fe10a 100644 --- a/src/game/screens/main.py +++ b/src/game/screens/main.py @@ -103,7 +103,11 @@ class Main(BaseScreen, SceenElement, TextScreen): self.display_surface.fill(CONFIG.colors.bg) def _draw_border(self) -> None: - """Draw a border (not implemented).""" + """ + Raises: + NotImplementedError: Not implemented yet. + """ + raise NotImplementedError def _initialize_surface(self) -> None: """Initialize the display surface.""" @@ -114,7 +118,11 @@ class Main(BaseScreen, SceenElement, TextScreen): self.rect = self.display_surface.get_rect(topright=(0, 0)) def _update_display_surface(self) -> None: - """Update display surface (not implemented).""" + """ + Raises: + NotImplementedError: Not implemented yet. + """ + raise NotImplementedError def _initialize_increment_height(self) -> None: """Initialize the increment height for positioning text elements/buttons.""" diff --git a/src/game/screens/preview.py b/src/game/screens/preview.py index a0cdb2b..3a761dc 100644 --- a/src/game/screens/preview.py +++ b/src/game/screens/preview.py @@ -50,13 +50,7 @@ class Preview(BaseScreen, SceenElement): ) def _draw_figure(self) -> None: - """ - Draw a single upcoming figure on the preview surface. - - Args: - figure (Figure): The upcoming figure to draw. - idx (int): Index of the figure in the list. - """ + """Draw a single upcoming figure on the preview surface.""" figure_surface = self.next_figure.value.image x = self.surface.get_width() / 2 y = self.surface.get_height() / 2 diff --git a/src/game/screens/score.py b/src/game/screens/score.py index 9f6bf06..9042e4e 100644 --- a/src/game/screens/score.py +++ b/src/game/screens/score.py @@ -67,9 +67,9 @@ class Score(BaseScreen, SceenElement, TextScreen): Update the score information. Args: - lines (int): Number of lines cleared. - score (int): Current game score. - level (int): Current game level. + lines: Number of lines cleared. + score: Current game score. + level: Current game level. """ if score > self.highscore: diff --git a/src/utils/config.py b/src/utils/config.py index c95b2fa..20c3874 100644 --- a/src/utils/config.py +++ b/src/utils/config.py @@ -14,6 +14,27 @@ PADDING = 20 @define class Game: + """ + Attributes: + columns: The number of columns. + rows: The number of rows. + line_width: The width of the lines. + border_radius: The radius of the border. + padding: The padding. + cell: The size of a cell. + size: The size of the game. + pos: The position of the game. + offset: The offset of the game. + initial_speed: The initial speed of the game. + movment_delay: The delay of the movment. + rotation_delay: The delay of the rotation. + drop_delay: The delay of the drop. + score: The score. + highscore: The path to the highscore file. + fps: The FPS. + + """ + columns: int = 10 rows: int = 20 line_width: int = 1 @@ -34,6 +55,14 @@ class Game: @define class SideBar: + """ + Attributes: + padding: The padding. + size: The size of the sidebar. + score: The size of the score. + preview: The size of the preview. + """ + padding: int = PADDING size: Size = Size(200, Game().size.height) score: Size = Size(size.width, size.height - size.width - padding) @@ -42,17 +71,36 @@ class SideBar: @define class Font: + """ + Attributes: + family: The font family. + size: The font size. + """ + family: Path = BASE_PATH / "assets" / "fonts" / "ChakraPetch" / "Regular.ttf" size: int = 32 @define class Button: + """ + Attributes: + size: The size of the button. + """ + size: Size = Size(200, 50) @define class Window: + """ + Attributes: + title: The title of the window. + padding: The padding. + size: The size of the window. + button: The button. + """ + title: str = "Tetris" padding: int = PADDING size: Size = Size( @@ -64,12 +112,28 @@ class Window: @define class Music: + """ + Attributes: + background: The background music. + landing: The landing music. + """ + background: Path = BASE_PATH / "assets" / "music" / "background.mp3" landing: Path = BASE_PATH / "assets" / "music" / "landing.wav" @define class Config: + """ + Attributes: + game: The game. + sidebar: The sidebar. + window: The window. + font: The font. + music: The music. + colors: The colors. + """ + game: Game = Game() sidebar: SideBar = SideBar() window: Window = Window() diff --git a/src/utils/enum.py b/src/utils/enum.py index cdaac2c..577a027 100644 --- a/src/utils/enum.py +++ b/src/utils/enum.py @@ -2,6 +2,16 @@ from enum import Enum, auto class Direction(Enum): + """ + Enum for direction of movement. + + Attributes: + LEFT: Left direction + RIGHT: Right direction + DOWN: Down direction + UP: Up direction + """ + LEFT = -1 RIGHT = 1 DOWN = 1 @@ -9,11 +19,28 @@ class Direction(Enum): class Rotation(Enum): + """ + Enum for rotation of movement. + + Attributes: + CLOCKWISE: Clockwise rotation + COUNTER_CLOCKWISE: Counter clockwise rotation + """ + CLOCKWISE = 90 COUNTER_CLOCKWISE = -90 class GameMode(Enum): + """ + Enum for game mode. + + Attributes: + PLAYER: Player mode + AI_PLAYING: AI playing mode + AI_TRAINING: AI training mode + """ + PLAYER = auto() AI_PLAYING = auto() AI_TRAINING = auto() diff --git a/src/utils/figure.py b/src/utils/figure.py index 578d180..c4029fd 100644 --- a/src/utils/figure.py +++ b/src/utils/figure.py @@ -10,6 +10,13 @@ from .path import BASE_PATH class FigureConfig(NamedTuple): + """ + Attributes: + shape: The shape of the figure. + color: The color of the figure. + image: The image of the figure. + """ + shape: list[Vec2] color: str image: pygame.Surface @@ -23,6 +30,17 @@ def _load_image(filename: str) -> pygame.Surface: class Figure(Enum): + """ + Attributes: + I: The I figure. + O: The O figure. + T: The T figure. + S: The S figure. + Z: The Z figure. + J: The J figure. + L: The L figure. + """ + I = FigureConfig( [ Vec2(0, 0), diff --git a/src/utils/settings.py b/src/utils/settings.py index 1b065c0..b59b9f2 100644 --- a/src/utils/settings.py +++ b/src/utils/settings.py @@ -8,6 +8,13 @@ from .path import BASE_PATH def save_settings(settings: dict[str, Any], file_path: Path) -> None: + """ + Save the settings to a TOML file. + + Args: + settings: The settings to save. + file_path: The path to the TOML file. + """ with open(file_path, "w") as file: toml.dump(settings, file) diff --git a/src/utils/tuples.py b/src/utils/tuples.py index 9cdacf0..27e6e0a 100644 --- a/src/utils/tuples.py +++ b/src/utils/tuples.py @@ -2,6 +2,14 @@ from typing import NamedTuple, Union class Size(NamedTuple): + """ + A size object. + + Attributes: + width: The width of the object. + height: The height of the object. + """ + width: int | float height: int | float