Skip to content

Commit 1a8d09e

Browse files
committed
ref(application): remove dtos (#9)
1 parent e103c20 commit 1a8d09e

File tree

18 files changed

+176
-278
lines changed

18 files changed

+176
-278
lines changed

src/ttt/application/common/dto/__init__.py

Whitespace-only changes.

src/ttt/application/common/dto/player_message.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/ttt/application/common/ports/player_message_sending.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/ttt/application/game/dto/__init__.py

Whitespace-only changes.

src/ttt/application/game/dto/game_message.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/ttt/application/game/ports/game_message_sending.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/ttt/application/game/ports/game_views.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,18 @@ async def render_no_cell_view(
4646
async def render_already_filled_cell_error(
4747
self, player_location: PlayerLocation, game: Game, /,
4848
) -> None: ...
49+
50+
@abstractmethod
51+
async def render_player_already_in_game_views(
52+
self, locations: Sequence[PlayerLocation],
53+
) -> None: ...
54+
55+
@abstractmethod
56+
async def render_waiting_for_game_view(
57+
self, location: PlayerLocation,
58+
) -> None: ...
59+
60+
@abstractmethod
61+
async def render_double_waiting_for_game_view(
62+
self, location: PlayerLocation,
63+
) -> None: ...

src/ttt/application/game/start_game.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
from ttt.application.common.ports.players import Players
77
from ttt.application.common.ports.transaction import Transaction
88
from ttt.application.common.ports.uuids import UUIDs
9-
from ttt.application.game.dto.game_message import PlayerAlreadyInGameMessage
10-
from ttt.application.game.ports.game_message_sending import GameMessageSending
119
from ttt.application.game.ports.game_views import GameViews
1210
from ttt.application.game.ports.games import Games
1311
from ttt.application.game.ports.waiting_locations import WaitingLocations
@@ -24,7 +22,6 @@ class StartGame:
2422
players: Players
2523
games: Games
2624
game_views: GameViews
27-
game_message_sending: GameMessageSending
2825
waiting_locations: WaitingLocations
2926
transaction: Transaction
3027

@@ -75,10 +72,9 @@ async def __call__(self) -> None:
7572
await self.waiting_locations.push_many(
7673
locations_of_players_not_in_game,
7774
)
78-
await self.game_message_sending.send_messages(tuple(
79-
PlayerAlreadyInGameMessage(location)
80-
for location in locations_of_players_in_game
81-
))
75+
await self.game_views.render_player_already_in_game_views(
76+
locations_of_players_in_game,
77+
)
8278
continue
8379

8480
else:
Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,36 @@
11
from dataclasses import dataclass
22

3-
from ttt.application.common.dto.player_message import (
4-
PlayerIsNotRegisteredMessage,
5-
)
6-
from ttt.application.common.ports.player_message_sending import (
7-
PlayerMessageSending,
8-
)
93
from ttt.application.common.ports.players import Players
104
from ttt.application.common.ports.transaction import Transaction
11-
from ttt.application.game.dto.game_message import (
12-
DoubleWaitingForGameMessage,
13-
WaitingForGameMessage,
14-
)
15-
from ttt.application.game.ports.game_message_sending import GameMessageSending
5+
from ttt.application.game.ports.game_views import GameViews
166
from ttt.application.game.ports.waiting_locations import WaitingLocations
7+
from ttt.application.player.ports.player_views import PlayerViews
178
from ttt.entities.core.player.location import PlayerLocation
189

1910

2011
@dataclass(frozen=True, unsafe_hash=False)
2112
class WaitGame:
2213
players: Players
2314
waiting_locations: WaitingLocations
24-
player_message_sending: PlayerMessageSending
25-
game_message_sending: GameMessageSending
15+
player_views: PlayerViews
16+
game_views: GameViews
2617
transaction: Transaction
2718

2819
async def __call__(self, location: PlayerLocation) -> None:
2920
async with self.transaction:
3021
if not await self.players.contains_player_with_id(
3122
location.player_id,
3223
):
33-
await self.player_message_sending.send_message(
34-
PlayerIsNotRegisteredMessage(location),
24+
await self.player_views.render_player_is_not_registered_view(
25+
location,
3526
)
3627
return
3728

3829
push = await self.waiting_locations.push(location)
3930

4031
if push.was_location_dedublicated:
41-
await self.game_message_sending.send_message(
42-
DoubleWaitingForGameMessage(location),
32+
await self.game_views.render_double_waiting_for_game_view(
33+
location,
4334
)
4435
else:
45-
await self.game_message_sending.send_message(
46-
WaitingForGameMessage(location),
47-
)
36+
await self.game_views.render_waiting_for_game_view(location)
Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
from abc import ABC, abstractmethod
22

3+
from ttt.entities.core.player.location import PlayerLocation
4+
5+
6+
class PlayerViews(ABC):
7+
@abstractmethod
8+
async def render_view_of_player_with_id(self, player_id: int, /) -> None:
9+
...
10+
11+
@abstractmethod
12+
async def render_player_is_not_registered_view(
13+
self, location: PlayerLocation, /,
14+
) -> None: ...
15+
16+
@abstractmethod
17+
async def render_player_already_registered_view(
18+
self, location: PlayerLocation, /,
19+
) -> None: ...
320

4-
class PlayerViews[PlayerWithIDViewT](ABC):
521
@abstractmethod
6-
async def view_of_player_with_id(
7-
self, player_id: int, /,
8-
) -> PlayerWithIDViewT: ...
22+
async def render_player_registered_view(
23+
self, location: PlayerLocation, /,
24+
) -> None: ...

0 commit comments

Comments
 (0)