Skip to content

Comments

Renju2#3

Open
Bu16a wants to merge 4 commits intomainfrom
Renju2
Open

Renju2#3
Bu16a wants to merge 4 commits intomainfrom
Renju2

Conversation

@Bu16a
Copy link
Owner

@Bu16a Bu16a commented Nov 2, 2024

Видны отличия от старой версии

Copy link
Collaborator

@12gerts 12gerts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да здравствует наследование! Код надо переиспользовать

bot_logic.py Outdated
return random.choice(available_moves)


def check_winner(grid_size: int, grid: List[List[Optional[str]]], row: int, col: int) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это старая типизация. С 3.11 не надо импортировать из typing

Suggested change
def check_winner(grid_size: int, grid: List[List[Optional[str]]], row: int, col: int) -> bool:
def check_winner(grid_size: int, grid: list[list[str | None]], row: int, col: int) -> bool:

bot_logic.py Outdated
return best_move

# 5. Если нет угроз и победных ходов, делаем случайный ход
available_moves: List[Tuple[int, int]] = [(x, y) for x in range(grid_size) for y in range(grid_size)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не понимаю, зачем вы складываете это в кортеж, потом распаковываете, а потом опять собираете в кортеж. Можно это просто будет сразу какая-то структура, с которой везде будете работать

bot_logic.py Outdated
return None


def bot_move(grid_size, grid, bot_color, player_color) -> Tuple[int, int]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нет аннотации

bot_logic.py Outdated

for dr, dc in _DIRECTIONS:
count: int = 1
for i in range(1, 5):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 в переменную

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и без i

button.py Outdated
is_transparent: bool, obj: Optional[str], text: str = '') -> None:
function: Callable, args=None,
color=(0, 0, 0), hover_color=(0, 0, 0), on_close=False,
is_transparent=False, obj=None, text='') -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем вы стерли типы?))

classic_game.py Outdated
Comment on lines 118 to 122
current_time = time.time()
elapsed = current_time - self._last_time
if elapsed >= 1: # Обновляем каждую секунду
self._total_time -= int(elapsed) # Уменьшаем общий таймер
self._player_time -= int(elapsed) # Уменьшаем таймер игрока
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Давайте datetime

from datetime import datetime
Suggested change
current_time = time.time()
elapsed = current_time - self._last_time
if elapsed >= 1: # Обновляем каждую секунду
self._total_time -= int(elapsed) # Уменьшаем общий таймер
self._player_time -= int(elapsed) # Уменьшаем таймер игрока
current_time = datetime.now()
elapsed = current_time - self._last_time
if elapsed >= 1: # Обновляем каждую секунду
self._total_time -= elapsed.seconds # Уменьшаем общий таймер
self._player_time -= elapsed.seconds # Уменьшаем таймер игрока

n_enemies.py Outdated
Comment on lines 44 to 45
winner = pygame.transform.scale(pygame.image.load("images/winner.png"), (290, 150))
self._robot: pygame.Surface = pygame.transform.scale(pygame.image.load("images/robot.png"), (290, 190))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вынесите (290, 150) и (290, 190) во что-нибудь

n_enemies.py Outdated
from window import Window


class NEnemiesMode:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Есть ощущение, что надо сделать интерфейс и базовый класс для этого и ClassicMode, чета слишком много общего кода

окна настроек. Изменения темы сохраняются в файл.
"""
themes: List[str] = ['grid0.jpg', 'grid1.jpg', 'grid2.jpg']
theme_file = Path('setting/theme.txt')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

чета какое-то бесполезное действие. вы не используете возможности pathlib и зачем-то приводите к пути на месте, так тут еще и обратно в строку конвертируете и вечно строкой везде прописываете

prev_theme: str = theme_file.read_text().strip()
theme_index: int = (themes.index(prev_theme) + 1) % len(themes)
theme_file.write_text(themes[theme_index])
theme_image_path = Path('images') / themes[theme_index]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

то же самое

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants