Skip to content

Commit 8f3e2af

Browse files
authored
Merge pull request #25 from emptybutton/split-view-ports
Split view ports
2 parents 67f854f + d6afd36 commit 8f3e2af

26 files changed

+362
-260
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,83 +7,83 @@
77

88
class GameViews(ABC):
99
@abstractmethod
10-
async def render_game_view_with_locations(
10+
async def game_view_with_locations(
1111
self,
1212
user_locations: Sequence[UserGameLocation],
1313
game: Game,
1414
/,
1515
) -> None: ...
1616

1717
@abstractmethod
18-
async def render_started_game_view_with_locations(
18+
async def started_game_view_with_locations(
1919
self,
2020
user_locations: Sequence[UserGameLocation],
2121
game: Game,
2222
/,
2323
) -> None: ...
2424

2525
@abstractmethod
26-
async def render_no_game_view(
26+
async def no_game_view(
2727
self,
2828
user_location: UserLocation,
2929
/,
3030
) -> None: ...
3131

3232
@abstractmethod
33-
async def render_game_already_complteted_view(
33+
async def game_already_complteted_view(
3434
self,
3535
user_location: UserLocation,
3636
game: Game,
3737
/,
3838
) -> None: ...
3939

4040
@abstractmethod
41-
async def render_not_current_user_view(
41+
async def not_current_user_view(
4242
self,
4343
user_location: UserLocation,
4444
game: Game,
4545
/,
4646
) -> None: ...
4747

4848
@abstractmethod
49-
async def render_no_cell_view(
49+
async def no_cell_view(
5050
self,
5151
user_location: UserLocation,
5252
game: Game,
5353
/,
5454
) -> None: ...
5555

5656
@abstractmethod
57-
async def render_already_filled_cell_error(
57+
async def already_filled_cell_error(
5858
self,
5959
user_location: UserLocation,
6060
game: Game,
6161
/,
6262
) -> None: ...
6363

6464
@abstractmethod
65-
async def render_user_already_in_game_views(
65+
async def user_already_in_game_views(
6666
self,
6767
locations: Sequence[UserLocation],
6868
/,
6969
) -> None: ...
7070

7171
@abstractmethod
72-
async def render_waiting_for_game_view(
72+
async def waiting_for_game_view(
7373
self,
7474
location: UserLocation,
7575
/,
7676
) -> None: ...
7777

7878
@abstractmethod
79-
async def render_double_waiting_for_game_view(
79+
async def double_waiting_for_game_view(
8080
self,
8181
location: UserLocation,
8282
/,
8383
) -> None: ...
8484

8585
@abstractmethod
86-
async def render_waiting_for_ai_type_to_start_game_with_ai_view(
86+
async def waiting_for_ai_type_to_start_game_with_ai_view(
8787
self,
8888
location: UserLocation,
8989
/,

src/ttt/application/game/game/cancel_game.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async def __call__(self, location: UserLocation) -> None:
3030
self.uuids.random_uuid(),
3131
)
3232
if game is None:
33-
await self.game_views.render_no_game_view(location)
33+
await self.game_views.no_game_view(location)
3434
return
3535

3636
locations = tuple(
@@ -47,7 +47,7 @@ async def __call__(self, location: UserLocation) -> None:
4747
game,
4848
location,
4949
)
50-
await self.game_views.render_game_already_complteted_view(
50+
await self.game_views.game_already_complteted_view(
5151
location,
5252
game,
5353
)
@@ -56,7 +56,7 @@ async def __call__(self, location: UserLocation) -> None:
5656
await self.log.game_cancelled(location, game)
5757

5858
await self.map_(tracking)
59-
await self.game_views.render_game_view_with_locations(
59+
await self.game_views.game_view_with_locations(
6060
locations,
6161
game,
6262
)

src/ttt/application/game/game/make_move_in_game.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async def __call__(
4343
game = await self.games.game_with_game_location(location.user_id)
4444

4545
if game is None:
46-
await self.game_views.render_no_game_view(location)
46+
await self.game_views.no_game_view(location)
4747
return
4848

4949
locations = tuple(
@@ -71,7 +71,7 @@ async def __call__(
7171
location,
7272
cell_number_int,
7373
)
74-
await self.game_views.render_game_already_complteted_view(
74+
await self.game_views.game_already_complteted_view(
7575
location,
7676
game,
7777
)
@@ -81,7 +81,7 @@ async def __call__(
8181
location,
8282
cell_number_int,
8383
)
84-
await self.game_views.render_not_current_user_view(
84+
await self.game_views.not_current_user_view(
8585
location,
8686
game,
8787
)
@@ -91,22 +91,22 @@ async def __call__(
9191
location,
9292
cell_number_int,
9393
)
94-
await self.game_views.render_no_cell_view(location, game)
94+
await self.game_views.no_cell_view(location, game)
9595
except AlreadyFilledCellError:
9696
await self.log.already_filled_cell_to_make_move(
9797
game,
9898
location,
9999
cell_number_int,
100100
)
101-
await self.game_views.render_already_filled_cell_error(
101+
await self.game_views.already_filled_cell_error(
102102
location,
103103
game,
104104
)
105105
else:
106106
await self.log.user_move_maked(location, game, user_move)
107107

108108
if user_move.next_move_ai_id is not None:
109-
await self.game_views.render_game_view_with_locations(
109+
await self.game_views.game_view_with_locations(
110110
locations,
111111
game,
112112
)
@@ -137,7 +137,7 @@ async def __call__(
137137
await self.log.game_completed(location, game)
138138

139139
await self.map_(tracking)
140-
await self.game_views.render_game_view_with_locations(
140+
await self.game_views.game_view_with_locations(
141141
locations,
142142
game,
143143
)

src/ttt/application/game/game/start_game.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ttt.application.game.common.ports.games import Games
1010
from ttt.application.game.common.ports.waiting_locations import WaitingLocations
1111
from ttt.application.game.game.ports.game_log import GameLog
12-
from ttt.application.user.common.ports.user_views import UserViews
12+
from ttt.application.user.common.ports.user_views import CommonUserViews
1313
from ttt.application.user.common.ports.users import Users
1414
from ttt.entities.core.game.game import UsersAlreadyInGameError, start_game
1515
from ttt.entities.core.user.location import UserLocation
@@ -22,7 +22,7 @@ class StartGame:
2222
uuids: UUIDs
2323
emojis: Emojis
2424
users: Users
25-
user_views: UserViews
25+
user_views: CommonUserViews
2626
games: Games
2727
game_views: GameViews
2828
waiting_locations: WaitingLocations
@@ -55,11 +55,11 @@ async def __call__(self) -> None:
5555
)
5656

5757
if user1 is None:
58-
await self.user_views.render_user_is_not_registered_view(
58+
await self.user_views.user_is_not_registered_view(
5959
user1_location,
6060
)
6161
if user2 is None:
62-
await self.user_views.render_user_is_not_registered_view(
62+
await self.user_views.user_is_not_registered_view(
6363
user2_location,
6464
)
6565
if user1 is None or user2 is None:
@@ -112,7 +112,7 @@ async def __call__(self) -> None:
112112
await self.waiting_locations.push_many(
113113
locations_of_users_not_in_game,
114114
)
115-
await self.game_views.render_user_already_in_game_views(
115+
await self.game_views.user_already_in_game_views(
116116
locations_of_users_in_game,
117117
)
118118
continue
@@ -125,9 +125,7 @@ async def __call__(self) -> None:
125125
user1_location.game(game.id),
126126
user2_location.game(game.id),
127127
)
128-
await (
129-
self.game_views.render_started_game_view_with_locations(
130-
game_locations,
131-
game,
132-
)
128+
await self.game_views.started_game_view_with_locations(
129+
game_locations,
130+
game,
133131
)

src/ttt/application/game/game/wait_game.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from ttt.application.game.common.ports.game_views import GameViews
55
from ttt.application.game.common.ports.waiting_locations import WaitingLocations
66
from ttt.application.game.game.ports.game_log import GameLog
7-
from ttt.application.user.common.ports.user_views import UserViews
7+
from ttt.application.user.common.ports.user_views import CommonUserViews
88
from ttt.application.user.common.ports.users import Users
99
from ttt.entities.core.user.location import UserLocation
1010

@@ -13,7 +13,7 @@
1313
class WaitGame:
1414
users: Users
1515
waiting_locations: WaitingLocations
16-
user_views: UserViews
16+
user_views: CommonUserViews
1717
game_views: GameViews
1818
transaction: Transaction
1919
log: GameLog
@@ -23,7 +23,7 @@ async def __call__(self, location: UserLocation) -> None:
2323
if not await self.users.contains_user_with_id(
2424
location.user_id,
2525
):
26-
await self.user_views.render_user_is_not_registered_view(
26+
await self.user_views.user_is_not_registered_view(
2727
location,
2828
)
2929
return
@@ -32,9 +32,9 @@ async def __call__(self, location: UserLocation) -> None:
3232

3333
if push.was_location_dedublicated:
3434
await self.log.double_waiting_for_game_start(location)
35-
await self.game_views.render_double_waiting_for_game_view(
35+
await self.game_views.double_waiting_for_game_view(
3636
location,
3737
)
3838
else:
3939
await self.log.waiting_for_game_start(location)
40-
await self.game_views.render_waiting_for_game_view(location)
40+
await self.game_views.waiting_for_game_view(location)

src/ttt/application/game/game_with_ai/start_game_with_ai.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from ttt.application.game.common.ports.games import Games
1111
from ttt.application.game.common.ports.waiting_locations import WaitingLocations
1212
from ttt.application.game.game.ports.game_log import GameLog
13-
from ttt.application.user.common.ports.user_views import UserViews
13+
from ttt.application.user.common.ports.user_views import CommonUserViews
1414
from ttt.application.user.common.ports.users import Users
1515
from ttt.entities.core.game.ai import AiType
1616
from ttt.entities.core.game.game import start_game_with_ai
@@ -26,7 +26,7 @@ class StartGameWithAi:
2626
emojis: Emojis
2727
randoms: Randoms
2828
users: Users
29-
user_views: UserViews
29+
user_views: CommonUserViews
3030
games: Games
3131
game_views: GameViews
3232
waiting_locations: WaitingLocations
@@ -46,7 +46,7 @@ async def __call__(self, location: UserLocation, ai_type: AiType) -> None:
4646
user = await self.users.user_with_id(location.user_id)
4747

4848
if user is None:
49-
await self.user_views.render_user_is_not_registered_view(
49+
await self.user_views.user_is_not_registered_view(
5050
location,
5151
)
5252
return
@@ -70,26 +70,22 @@ async def __call__(self, location: UserLocation, ai_type: AiType) -> None:
7070
user,
7171
location,
7272
)
73-
await self.game_views.render_user_already_in_game_views(
73+
await self.game_views.user_already_in_game_views(
7474
[location],
7575
)
7676
else:
7777
await self.log.game_against_ai_started(started_game.game)
7878

7979
if started_game.next_move_ai_id is None:
8080
await self.map_(tracking)
81-
await (
82-
self.game_views.render_started_game_view_with_locations(
83-
[location.game(started_game.game.id)],
84-
started_game.game,
85-
)
81+
await self.game_views.started_game_view_with_locations(
82+
[location.game(started_game.game.id)],
83+
started_game.game,
8684
)
8785
else:
88-
await (
89-
self.game_views.render_started_game_view_with_locations(
90-
[location.game(started_game.game.id)],
91-
started_game.game,
92-
)
86+
await self.game_views.started_game_view_with_locations(
87+
[location.game(started_game.game.id)],
88+
started_game.game,
9389
)
9490

9591
game_result_id = await self.uuids.random_uuid()
@@ -114,7 +110,7 @@ async def __call__(self, location: UserLocation, ai_type: AiType) -> None:
114110
)
115111

116112
await self.map_(tracking)
117-
await self.game_views.render_game_view_with_locations(
113+
await self.game_views.game_view_with_locations(
118114
[location.game(started_game.game.id)],
119115
started_game.game,
120116
)

src/ttt/application/game/game_with_ai/wait_ai_type_to_start_game_with_ai.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ class WaitAiTypeToStartGameWithAi:
1111
log: GameLog
1212

1313
async def __call__(self, location: UserLocation) -> None:
14-
await (
15-
self.game_views
16-
.render_waiting_for_ai_type_to_start_game_with_ai_view(location)
14+
await self.game_views.waiting_for_ai_type_to_start_game_with_ai_view(
15+
location,
1716
)
1817
await self.log.user_intends_to_start_game_against_ai(location)

0 commit comments

Comments
 (0)