|
28 | 28 | PlayerLoss, |
29 | 29 | PlayerWin, |
30 | 30 | ) |
31 | | -from ttt.entities.core.user.location import UserGameLocation |
32 | 31 | from ttt.entities.core.user.user import ( |
33 | 32 | User, |
34 | 33 | UserAlreadyInGameError, |
@@ -111,7 +110,7 @@ class Game: |
111 | 110 |
|
112 | 111 | def __post_init__(self) -> None: |
113 | 112 | assert_( |
114 | | - not all(isinstance(player, Ai) for player in self._players()), |
| 113 | + not all(isinstance(player, Ai) for player in self.players()), |
115 | 114 | else_=OnlyAiGameError, |
116 | 115 | ) |
117 | 116 |
|
@@ -141,7 +140,7 @@ def is_against_user(self) -> bool: |
141 | 140 | return not self.is_against_ai() |
142 | 141 |
|
143 | 142 | def user(self, user_id: int) -> User | None: |
144 | | - for user in self._users(): |
| 143 | + for user in self.users(): |
145 | 144 | if user.id == user_id: |
146 | 145 | return user |
147 | 146 |
|
@@ -195,10 +194,10 @@ def make_user_move( # noqa: C901 |
195 | 194 | if not isinstance(current_player, User): |
196 | 195 | raise TypeError |
197 | 196 |
|
198 | | - not_current_player = not_none(self._not_current_player()) |
| 197 | + not_current_player = not_none(self.not_current_player()) |
199 | 198 |
|
200 | 199 | assert_( |
201 | | - user_id in {user.id for user in self._users()}, |
| 200 | + user_id in {user.id for user in self.users()}, |
202 | 201 | else_=NotPlayerError(), |
203 | 202 | ) |
204 | 203 | assert_(current_player.id == user_id, else_=NotCurrentPlayerError()) |
@@ -296,7 +295,7 @@ def make_ai_move( |
296 | 295 | if not isinstance(current_player, Ai): |
297 | 296 | raise NotAiCurrentMoveError |
298 | 297 |
|
299 | | - not_current_player = self._not_current_player() |
| 298 | + not_current_player = self.not_current_player() |
300 | 299 | if not isinstance(not_current_player, User): |
301 | 300 | raise TypeError |
302 | 301 |
|
@@ -384,9 +383,6 @@ def is_player_move_expected(self, player_id: int | UUID) -> bool: |
384 | 383 | case _: |
385 | 384 | raise ValueError(self.state, player_id) |
386 | 385 |
|
387 | | - def locations(self) -> tuple[UserGameLocation, ...]: |
388 | | - return tuple(not_none(user.game_location) for user in self._users()) |
389 | | - |
390 | 386 | def _make_random_ai_move( |
391 | 387 | self, |
392 | 388 | current_player: Ai, |
@@ -459,15 +455,15 @@ def _current_player(self) -> Player | None: |
459 | 455 | case GameState.completed: |
460 | 456 | return None |
461 | 457 |
|
462 | | - def _players(self) -> tuple[Player, ...]: |
| 458 | + def players(self) -> tuple[Player, ...]: |
463 | 459 | return self.player1, self.player2 |
464 | 460 |
|
465 | | - def _users(self) -> tuple[User, ...]: |
| 461 | + def users(self) -> tuple[User, ...]: |
466 | 462 | return tuple( |
467 | | - player for player in self._players() if isinstance(player, User) |
| 463 | + player for player in self.players() if isinstance(player, User) |
468 | 464 | ) |
469 | 465 |
|
470 | | - def _not_current_player(self) -> Player | None: |
| 466 | + def not_current_player(self) -> Player | None: |
471 | 467 | match self.state: |
472 | 468 | case GameState.wait_player1: |
473 | 469 | return self.player2 |
|
0 commit comments