From 38301b06888e2690ababaf059b711fa4bd3138de Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Mon, 15 Jan 2024 07:00:16 +0200 Subject: [PATCH] refactor(game): use attrs --- src/utils/figure.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/utils/figure.py b/src/utils/figure.py index 66b7ad1..c504d63 100644 --- a/src/utils/figure.py +++ b/src/utils/figure.py @@ -1,15 +1,16 @@ import random from enum import Enum -from typing import NamedTuple import pygame +from attrs import define from pygame import Vector2 as Vec2 from .config import CONFIG from .path import BASE_PATH -class FigureParams(NamedTuple): +@define +class FigureParams: """ Attributes: shape: The shape of the figure. @@ -41,7 +42,7 @@ class Figure(Enum): L: The L figure. """ - I = FigureParams( + I = FigureParams( # type: ignore [ Vec2(0, 0), Vec2(0, -1), @@ -51,7 +52,7 @@ class Figure(Enum): CONFIG.colors.cyan, "I.png", ) - O = FigureParams( + O = FigureParams( # type: ignore [ Vec2(0, 0), Vec2(0, -1), @@ -61,7 +62,7 @@ class Figure(Enum): CONFIG.colors.yellow, "O.png", ) - T = FigureParams( + T = FigureParams( # type: ignore [ Vec2(0, 0), Vec2(-1, 0), @@ -72,7 +73,7 @@ class Figure(Enum): "T.png", ) - S = FigureParams( + S = FigureParams( # type: ignore [ Vec2(0, 0), Vec2(-1, 0), @@ -82,7 +83,7 @@ class Figure(Enum): CONFIG.colors.green, "S.png", ) - Z = FigureParams( + Z = FigureParams( # type: ignore [ Vec2(0, 0), Vec2(1, 0), @@ -92,7 +93,7 @@ class Figure(Enum): CONFIG.colors.red, "Z.png", ) - J = FigureParams( + J = FigureParams( # type: ignore [ Vec2(0, 0), Vec2(0, -1), @@ -102,7 +103,7 @@ class Figure(Enum): CONFIG.colors.blue, "J.png", ) - L = FigureParams( + L = FigureParams( # type: ignore [ Vec2(0, 0), Vec2(0, -1),