Example #1
0
        public async Task <Game> Load(Guid id, User user, ClientInfo clientInfo)
        {
            var gameId   = new GameId(id);
            var concepts = await conceptsRepository.GetConceptsFromGame(gameId);

            var deck     = DeckFactory.Create(concepts);
            var gameInfo = await gameRepository.GetGameInfo(gameId);

            var avaliableTeams = await gameRepository.GetTeams(gameId, deck);

            var game = new Game(
                gameId,
                GetRoundContext(gameInfo.TotalRounds, gameInfo.CurrentRound),
                deck,
                GetTeams(avaliableTeams, gameInfo.CurrentTeam),
                gameInfo.Owner,
                gameInfo.CreationDate
                );

            gameRepository.AddLoadedLog(game.Id, user, clientInfo);
            await unitOfWork.CompleteAsync();

            return(game);
        }