Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/ttt/application/game/common/ports/game_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,83 +7,83 @@

class GameViews(ABC):
@abstractmethod
async def render_game_view_with_locations(
async def game_view_with_locations(
self,
user_locations: Sequence[UserGameLocation],
game: Game,
/,
) -> None: ...

@abstractmethod
async def render_started_game_view_with_locations(
async def started_game_view_with_locations(
self,
user_locations: Sequence[UserGameLocation],
game: Game,
/,
) -> None: ...

@abstractmethod
async def render_no_game_view(
async def no_game_view(
self,
user_location: UserLocation,
/,
) -> None: ...

@abstractmethod
async def render_game_already_complteted_view(
async def game_already_complteted_view(
self,
user_location: UserLocation,
game: Game,
/,
) -> None: ...

@abstractmethod
async def render_not_current_user_view(
async def not_current_user_view(
self,
user_location: UserLocation,
game: Game,
/,
) -> None: ...

@abstractmethod
async def render_no_cell_view(
async def no_cell_view(
self,
user_location: UserLocation,
game: Game,
/,
) -> None: ...

@abstractmethod
async def render_already_filled_cell_error(
async def already_filled_cell_error(
self,
user_location: UserLocation,
game: Game,
/,
) -> None: ...

@abstractmethod
async def render_user_already_in_game_views(
async def user_already_in_game_views(
self,
locations: Sequence[UserLocation],
/,
) -> None: ...

@abstractmethod
async def render_waiting_for_game_view(
async def waiting_for_game_view(
self,
location: UserLocation,
/,
) -> None: ...

@abstractmethod
async def render_double_waiting_for_game_view(
async def double_waiting_for_game_view(
self,
location: UserLocation,
/,
) -> None: ...

@abstractmethod
async def render_waiting_for_ai_type_to_start_game_with_ai_view(
async def waiting_for_ai_type_to_start_game_with_ai_view(
self,
location: UserLocation,
/,
Expand Down
6 changes: 3 additions & 3 deletions src/ttt/application/game/game/cancel_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def __call__(self, location: UserLocation) -> None:
self.uuids.random_uuid(),
)
if game is None:
await self.game_views.render_no_game_view(location)
await self.game_views.no_game_view(location)
return

locations = tuple(
Expand All @@ -47,7 +47,7 @@ async def __call__(self, location: UserLocation) -> None:
game,
location,
)
await self.game_views.render_game_already_complteted_view(
await self.game_views.game_already_complteted_view(
location,
game,
)
Expand All @@ -56,7 +56,7 @@ async def __call__(self, location: UserLocation) -> None:
await self.log.game_cancelled(location, game)

await self.map_(tracking)
await self.game_views.render_game_view_with_locations(
await self.game_views.game_view_with_locations(
locations,
game,
)
14 changes: 7 additions & 7 deletions src/ttt/application/game/game/make_move_in_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async def __call__(
game = await self.games.game_with_game_location(location.user_id)

if game is None:
await self.game_views.render_no_game_view(location)
await self.game_views.no_game_view(location)
return

locations = tuple(
Expand Down Expand Up @@ -71,7 +71,7 @@ async def __call__(
location,
cell_number_int,
)
await self.game_views.render_game_already_complteted_view(
await self.game_views.game_already_complteted_view(
location,
game,
)
Expand All @@ -81,7 +81,7 @@ async def __call__(
location,
cell_number_int,
)
await self.game_views.render_not_current_user_view(
await self.game_views.not_current_user_view(
location,
game,
)
Expand All @@ -91,22 +91,22 @@ async def __call__(
location,
cell_number_int,
)
await self.game_views.render_no_cell_view(location, game)
await self.game_views.no_cell_view(location, game)
except AlreadyFilledCellError:
await self.log.already_filled_cell_to_make_move(
game,
location,
cell_number_int,
)
await self.game_views.render_already_filled_cell_error(
await self.game_views.already_filled_cell_error(
location,
game,
)
else:
await self.log.user_move_maked(location, game, user_move)

if user_move.next_move_ai_id is not None:
await self.game_views.render_game_view_with_locations(
await self.game_views.game_view_with_locations(
locations,
game,
)
Expand Down Expand Up @@ -137,7 +137,7 @@ async def __call__(
await self.log.game_completed(location, game)

await self.map_(tracking)
await self.game_views.render_game_view_with_locations(
await self.game_views.game_view_with_locations(
locations,
game,
)
18 changes: 8 additions & 10 deletions src/ttt/application/game/game/start_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ttt.application.game.common.ports.games import Games
from ttt.application.game.common.ports.waiting_locations import WaitingLocations
from ttt.application.game.game.ports.game_log import GameLog
from ttt.application.user.common.ports.user_views import UserViews
from ttt.application.user.common.ports.user_views import CommonUserViews
from ttt.application.user.common.ports.users import Users
from ttt.entities.core.game.game import UsersAlreadyInGameError, start_game
from ttt.entities.core.user.location import UserLocation
Expand All @@ -22,7 +22,7 @@ class StartGame:
uuids: UUIDs
emojis: Emojis
users: Users
user_views: UserViews
user_views: CommonUserViews
games: Games
game_views: GameViews
waiting_locations: WaitingLocations
Expand Down Expand Up @@ -55,11 +55,11 @@ async def __call__(self) -> None:
)

if user1 is None:
await self.user_views.render_user_is_not_registered_view(
await self.user_views.user_is_not_registered_view(
user1_location,
)
if user2 is None:
await self.user_views.render_user_is_not_registered_view(
await self.user_views.user_is_not_registered_view(
user2_location,
)
if user1 is None or user2 is None:
Expand Down Expand Up @@ -112,7 +112,7 @@ async def __call__(self) -> None:
await self.waiting_locations.push_many(
locations_of_users_not_in_game,
)
await self.game_views.render_user_already_in_game_views(
await self.game_views.user_already_in_game_views(
locations_of_users_in_game,
)
continue
Expand All @@ -125,9 +125,7 @@ async def __call__(self) -> None:
user1_location.game(game.id),
user2_location.game(game.id),
)
await (
self.game_views.render_started_game_view_with_locations(
game_locations,
game,
)
await self.game_views.started_game_view_with_locations(
game_locations,
game,
)
10 changes: 5 additions & 5 deletions src/ttt/application/game/game/wait_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ttt.application.game.common.ports.game_views import GameViews
from ttt.application.game.common.ports.waiting_locations import WaitingLocations
from ttt.application.game.game.ports.game_log import GameLog
from ttt.application.user.common.ports.user_views import UserViews
from ttt.application.user.common.ports.user_views import CommonUserViews
from ttt.application.user.common.ports.users import Users
from ttt.entities.core.user.location import UserLocation

Expand All @@ -13,7 +13,7 @@
class WaitGame:
users: Users
waiting_locations: WaitingLocations
user_views: UserViews
user_views: CommonUserViews
game_views: GameViews
transaction: Transaction
log: GameLog
Expand All @@ -23,7 +23,7 @@ async def __call__(self, location: UserLocation) -> None:
if not await self.users.contains_user_with_id(
location.user_id,
):
await self.user_views.render_user_is_not_registered_view(
await self.user_views.user_is_not_registered_view(
location,
)
return
Expand All @@ -32,9 +32,9 @@ async def __call__(self, location: UserLocation) -> None:

if push.was_location_dedublicated:
await self.log.double_waiting_for_game_start(location)
await self.game_views.render_double_waiting_for_game_view(
await self.game_views.double_waiting_for_game_view(
location,
)
else:
await self.log.waiting_for_game_start(location)
await self.game_views.render_waiting_for_game_view(location)
await self.game_views.waiting_for_game_view(location)
26 changes: 11 additions & 15 deletions src/ttt/application/game/game_with_ai/start_game_with_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ttt.application.game.common.ports.games import Games
from ttt.application.game.common.ports.waiting_locations import WaitingLocations
from ttt.application.game.game.ports.game_log import GameLog
from ttt.application.user.common.ports.user_views import UserViews
from ttt.application.user.common.ports.user_views import CommonUserViews
from ttt.application.user.common.ports.users import Users
from ttt.entities.core.game.ai import AiType
from ttt.entities.core.game.game import start_game_with_ai
Expand All @@ -26,7 +26,7 @@ class StartGameWithAi:
emojis: Emojis
randoms: Randoms
users: Users
user_views: UserViews
user_views: CommonUserViews
games: Games
game_views: GameViews
waiting_locations: WaitingLocations
Expand All @@ -46,7 +46,7 @@ async def __call__(self, location: UserLocation, ai_type: AiType) -> None:
user = await self.users.user_with_id(location.user_id)

if user is None:
await self.user_views.render_user_is_not_registered_view(
await self.user_views.user_is_not_registered_view(
location,
)
return
Expand All @@ -70,26 +70,22 @@ async def __call__(self, location: UserLocation, ai_type: AiType) -> None:
user,
location,
)
await self.game_views.render_user_already_in_game_views(
await self.game_views.user_already_in_game_views(
[location],
)
else:
await self.log.game_against_ai_started(started_game.game)

if started_game.next_move_ai_id is None:
await self.map_(tracking)
await (
self.game_views.render_started_game_view_with_locations(
[location.game(started_game.game.id)],
started_game.game,
)
await self.game_views.started_game_view_with_locations(
[location.game(started_game.game.id)],
started_game.game,
)
else:
await (
self.game_views.render_started_game_view_with_locations(
[location.game(started_game.game.id)],
started_game.game,
)
await self.game_views.started_game_view_with_locations(
[location.game(started_game.game.id)],
started_game.game,
)

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

await self.map_(tracking)
await self.game_views.render_game_view_with_locations(
await self.game_views.game_view_with_locations(
[location.game(started_game.game.id)],
started_game.game,
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ class WaitAiTypeToStartGameWithAi:
log: GameLog

async def __call__(self, location: UserLocation) -> None:
await (
self.game_views
.render_waiting_for_ai_type_to_start_game_with_ai_view(location)
await self.game_views.waiting_for_ai_type_to_start_game_with_ai_view(
location,
)
await self.log.user_intends_to_start_game_against_ai(location)
Loading