Skip to content

dots_v1#1

Open
alexthenugget wants to merge 3 commits into
mainfrom
dots_v1
Open

dots_v1#1
alexthenugget wants to merge 3 commits into
mainfrom
dots_v1

Conversation

@alexthenugget

Copy link
Copy Markdown
Owner

v1

@12gerts 12gerts left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  • Нет README
  • Нет аннотаций типов
  • Не настроен black и mypy
  • Нет прокоммита
  • Нет указания о используемых библиотеках
  • Нет тестов

Comment thread dots/dots_game.py Outdated

class DotsGame:
def __init__(self, root):
self.root = root

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

это все протектед

Comment thread dots/dots_game.py Outdated
Comment on lines +20 to +21
self.setup_ui()
self.create_grid()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

слишком тяжело для инита

Comment thread dots/dots_game.py Outdated
color = "darkred"
winning_score = red_score
else:
winner = "Ничья"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

в enum

Comment thread dots/dots_game.py Outdated
Comment on lines +81 to +84
if hasattr(self.game_logic, 'is_board_full') and self.game_logic.is_board_full():
message = f"Доска заполнена! Игра окончена! Победитель: {winner}" if winner != "Ничья" else "Доска заполнена! Игра окончена! Ничья!"
else:
message = f"Игра завершена досрочно! Победитель: {winner}" if winner != "Ничья" else "Игра завершена досрочно! Ничья!"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

вот это бы упростить можно. А еще можно в enum сохранять сразу Победитель: Красный игрок и не надо будет условие проверять, вы все равно нигде это больше не используете

Comment thread dots/dots_game.py Outdated
entry["score"]
))

def create_end_game_button(self):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

огромный метод, декомпозиция нужна

Comment thread dots/leaderboard.py Outdated


def load_leaderboard():
if not os.path.exists("leaderboard.txt"):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

используйте pathlib

Comment thread dots/leaderboard.py Outdated
leaderboard = []
for line in lines:
if line.strip():
parts = line.strip().split(",")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

так может лучше json вместо txt?

Comment thread dots/leaderboard.py Outdated
"name": parts[1],
"score": int(parts[2])
})
while len(leaderboard) < 3:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

опять магия

Comment thread dots/leaderboard.py Outdated


def update_leaderboard(new_name, new_score):
leaderboard = load_leaderboard()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Сделайте его моделькой какой-нибудь вместо словаря (BaseModel, dataclass, NamedTuple)

Comment thread dots/leaderboard.py Outdated

def update_leaderboard(new_name, new_score):
leaderboard = load_leaderboard()
if new_score > leaderboard[-1]["score"] or leaderboard[-1]["name"] == "None":

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

лучше конвертировать условие и сразу выйти

Comment thread .idea/.gitignore

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

.idea должна быть в gitignore

Comment thread README.md
@@ -1 +1,63 @@
# Dots_Game No newline at end of file
# 🎮 Точки - классическая стратегическая игра

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

как устанавливать? как запускать?

Comment thread dots/dots_game.py Outdated
RED_WIN = ("Красный игрок", "darkred")
DRAW = ("Ничья", "black")

def __init__(self, winner_text: str, color: str) -> None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

откуда в enum инит взялся???

Comment thread dots/dots_game.py Outdated
Comment on lines +19 to +21
BLUE_WIN = ("Синий игрок", "darkblue")
RED_WIN = ("Красный игрок", "darkred")
DRAW = ("Ничья", "black")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

вот это что-то странное, если честно.

Сделайте что- то одно и mapping

Comment thread dots/dots_game.py Outdated
Comment on lines +137 to +138
blue_score = self._game_logic.scores[1]
red_score = self._game_logic.scores[2]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

что-то как-то не особо красиво это

Comment thread dots/dots_game.py Outdated
)

if result != GameResult.DRAW:
winning_score = blue_score if result == GameResult.BLUE_WIN else red_score

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

тут тоже непонятно зачем условие, можно сразу хранить нужное

Comment thread dots/dots_game.py Outdated
Comment on lines +226 to +228
for i in range(start_x, end_x, CELL_SIZE):
self._canvas.create_line(i, start_y, i, end_y, tags="grid_line", fill="lightblue")
for i in range(start_y, end_y, CELL_SIZE):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i какие-то...

Comment thread dots/game_logic.py Outdated
Comment on lines +158 to +159
else:
pass

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

а в чем прикол?

Comment thread dots/dots_game.py Outdated
f"{'Доска заполнена' if board_full else 'Игра завершена досрочно'}! " f"Игра окончена! {result.winner_text}"
)

winning_score = blue_score if result == GameResult.BLUE_WIN else red_score

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

тут без условия, маппинг нужен

Comment thread dots/game_logic.py
Comment thread pyproject.toml
flake8 = "^7.2.0"
isort = "^6.0.1"
pre-commit = "^4.2.0"
pydantic = "^2.11.3"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

для чего он добавился, если он нигде не используется?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

pydantic добавила, потому что при запуске с poetry обнаружила, что он используется в leaderboard и нигде не указан как внешняя библиотека

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

А он сам не подтягивается?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

при запуске с poetry не пропускал, пока я не добавила явно в зависимости, поэтому решила оставить

Delete dots/leaderboard.txt

v2

v3

v4

v5

v6

v7

v8

v8
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