44
55from ttt .application .common .ports .map import Map
66from ttt .application .common .ports .randoms import Randoms
7- from ttt .application .common .ports .transaction import SerializableTransaction
7+ from ttt .application .common .ports .transaction import (
8+ NotSerializableTransaction ,
9+ )
810from ttt .application .common .ports .uuids import UUIDs
911from ttt .application .game .game .ports .game_ai_gateway import GameAiGateway
1012from ttt .application .game .game .ports .game_dao import GameDao
1113from ttt .application .game .game .ports .game_log import GameLog
1214from ttt .application .game .game .ports .game_views import GameViews
1315from ttt .application .game .game .ports .games import Games
16+ from ttt .application .user .common .ports .user_locks import UserLocks
1417from ttt .application .user .common .ports .users import Users
1518from ttt .entities .core .game .game import (
1619 AlreadyCompletedGameError ,
@@ -28,17 +31,15 @@ class MakeAiMoveInGame:
2831 uuids : UUIDs
2932 randoms : Randoms
3033 ai_gateway : GameAiGateway
31- transaction : SerializableTransaction
34+ transaction : NotSerializableTransaction
3235 log : GameLog
3336 dao : GameDao
37+ locks : UserLocks
3438
35- async def __call__ (self , game_id : UUID , ai_id : UUID ) -> None :
36- """
37- :raises ttt.application.common.errors.serialization_error.SerializationError:
38- """ # noqa: E501
39-
39+ async def __call__ (self , user_id : int , game_id : UUID , ai_id : UUID ) -> None :
4040 async with self .transaction :
41- game = await self .games .game_with_id (game_id )
41+ await self .locks .lock_user_by_id (user_id )
42+ game = await self .games .not_locked_game_with_id (game_id )
4243
4344 if game is None :
4445 await self .log .no_game_to_make_ai_move (game_id )
0 commit comments